diff --git a/AUTHORS b/AUTHORS index 2c74450..7556783d7 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -626,6 +626,7 @@ Jari Karppanen <jkarp@amazon.com> Jason Gronn <jasontopia03@gmail.com> Javayhu <javayhu@gmail.com> +Jay Kapadia <jaykapadia389@gmail.com> Jay Oster <jay@kodewerx.org> Jay Soffian <jaysoffian@gmail.com> Jay Yang <sjyang1126@gmail.com>
diff --git a/DEPS b/DEPS index 48594338..be315bc 100644 --- a/DEPS +++ b/DEPS
@@ -280,11 +280,11 @@ # 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': '65d7bff9d16aaec9c731c16cccfbca8303e60992', + 'skia_revision': 'fe8bac8f2251b50ce93a62d044495d36713bbbef', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '8d90bc07afaf3d2a0b8fabb44ebc6dcec67e02ad', + 'v8_revision': '4551bf13781091625662a39f2b02b3b9ebe1c42b', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. @@ -300,7 +300,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling BoringSSL # and whatever else without interference from each other. - 'boringssl_revision': '822902749a5956bba09c7e9e451104e8a74f02c5', + 'boringssl_revision': '04c19925b088e8b884080ee6bd3d771d40e3c3a9', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Fuchsia sdk # and whatever else without interference from each other. @@ -328,7 +328,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling freetype # and whatever else without interference from each other. - 'freetype_revision': '10b3b14da2a60151dd9242364ad7a375d0d7590a', + 'freetype_revision': '64f8b7fbd029a8715e01ba58de5119666be56811', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling freetype # and whatever else without interference from each other. @@ -372,7 +372,7 @@ # 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': '586fb9db396c599ab5549f869429f886c724a827', + 'devtools_frontend_revision': '97928d6f6cccc7bd47fb2afe0d3ddeed9cc9ef2a', # 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. @@ -500,7 +500,7 @@ # If you change this, also update the libc++ revision in # //buildtools/deps_revisions.gni. - 'libcxx_revision': 'b4511937e4e55617e26ba3912e0dc169443e0c00', + 'libcxx_revision': '80194f087251d7ad235ffbf4c602786208bdb863', # GN CIPD package version. 'gn_version': 'git_revision:c97a86a72105f3328a540f5a5ab17d11989ab7dd', @@ -1304,12 +1304,12 @@ 'src/clank': { 'url': Var('chrome_git') + '/clank/internal/apps.git' + '@' + - '4d4cf09821c697212343fc07e330cf0438982470', + '9538b5ce9a3291d7c7ad7bd04a9e31d15812fe28', 'condition': 'checkout_android and checkout_src_internal', }, 'src/docs/website': { - 'url': Var('chromium_git') + '/website.git' + '@' + '35124dbd52018ec09acadfbf61b18d5ca4d4b067', + 'url': Var('chromium_git') + '/website.git' + '@' + 'adc61787dec31973d464788e4ea78d99320b7474', }, 'src/ios/third_party/earl_grey2/src': { @@ -2075,7 +2075,7 @@ Var('chromium_git') + '/external/libaddressinput.git' + '@' + 'e8712e415627f22d0b00ebee8db99547077f39bd', 'src/third_party/libaom/source/libaom': - Var('aomedia_git') + '/aom.git' + '@' + 'f74eae54f3beb6850c0a468091f4d0291b2d563c', + Var('aomedia_git') + '/aom.git' + '@' + '433be28b4f4f899f533991e2d2829dde0ab68406', 'src/third_party/libavif/src': Var('chromium_git') + '/external/github.com/AOMediaCodec/libavif.git' + '@' + Var('libavif_revision'), @@ -2301,7 +2301,7 @@ Var('pdfium_git') + '/pdfium.git' + '@' + Var('pdfium_revision'), 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + 'fe572aaa214487007138ea9a546692771bd6e25b', + Var('android_git') + '/platform/external/perfetto.git' + '@' + '16c0f5bc196947725c1f24ef519c0bdc47b6222f', 'src/base/tracing/test/data': { 'bucket': 'perfetto', @@ -4497,7 +4497,7 @@ 'src/ios_internal': { 'url': Var('chrome_git') + '/chrome/ios_internal.git' + '@' + - '61022675d8772a34fc6bcc1c3b60908fc0ee6623', + '318acc714eeb02ac2fd443810f5143f4830ca6a4', 'condition': 'checkout_ios and checkout_src_internal', },
diff --git a/android_webview/test/data/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt b/android_webview/test/data/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt index 8b316e4..2c92351e 100644 --- a/android_webview/test/data/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt +++ b/android_webview/test/data/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -3524,6 +3524,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -3553,6 +3554,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority @@ -4614,6 +4616,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -4643,6 +4646,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority
diff --git a/android_webview/test/data/web_tests/webexposed/global-interface-listing-expected.txt b/android_webview/test/data/web_tests/webexposed/global-interface-listing-expected.txt index e0a67c62..b2e3cf4 100644 --- a/android_webview/test/data/web_tests/webexposed/global-interface-listing-expected.txt +++ b/android_webview/test/data/web_tests/webexposed/global-interface-listing-expected.txt
@@ -3522,6 +3522,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -3551,6 +3552,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority @@ -4612,6 +4614,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -4641,6 +4644,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority
diff --git a/ash/components/kcer/kcer_nss/kcer_nss_fuzzer.cc b/ash/components/kcer/kcer_nss/kcer_nss_fuzzer.cc index 3efc1a3..33d0837 100644 --- a/ash/components/kcer/kcer_nss/kcer_nss_fuzzer.cc +++ b/ash/components/kcer/kcer_nss/kcer_nss_fuzzer.cc
@@ -424,7 +424,7 @@ cert_builder_->SetCaIssuersAndOCSPUrls(ca_issuers_urls, ocsp_urls); } if (GetBool()) { - std::vector<GURL> urls; + std::vector<std::string> urls; while (GetBool()) { urls.emplace_back(GetString()); }
diff --git a/ash/public/cpp/holding_space/holding_space_item_unittest.cc b/ash/public/cpp/holding_space/holding_space_item_unittest.cc index 3c2e51e..7f8c3f88 100644 --- a/ash/public/cpp/holding_space/holding_space_item_unittest.cc +++ b/ash/public/cpp/holding_space/holding_space_item_unittest.cc
@@ -20,7 +20,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" namespace ash { @@ -146,7 +146,8 @@ // It should be possible to update commands to a new value. std::vector<HoldingSpaceItem::InProgressCommand> in_progress_commands; in_progress_commands.push_back(HoldingSpaceItem::InProgressCommand( - HoldingSpaceCommandId::kCancelItem, /*label_id=*/-1, &gfx::kNoneIcon, + HoldingSpaceCommandId::kCancelItem, /*label_id=*/-1, + &gfx::VectorIcon::EmptyIcon(), /*handler=*/base::DoNothing())); EXPECT_TRUE(holding_space_item->SetInProgressCommands(in_progress_commands)); EXPECT_EQ(holding_space_item->in_progress_commands(), in_progress_commands);
diff --git a/ash/public/cpp/holding_space/holding_space_model_unittest.cc b/ash/public/cpp/holding_space/holding_space_model_unittest.cc index b4129de..06504c5 100644 --- a/ash/public/cpp/holding_space/holding_space_model_unittest.cc +++ b/ash/public/cpp/holding_space/holding_space_model_unittest.cc
@@ -27,7 +27,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" #include "ui/color/color_id.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" namespace ash { namespace { @@ -41,7 +41,7 @@ HoldingSpaceItem::InProgressCommand CreateInProgressCommand( HoldingSpaceCommandId command_id) { return HoldingSpaceItem::InProgressCommand(command_id, /*label_id=*/-1, - &gfx::kNoneIcon, + &gfx::VectorIcon::EmptyIcon(), /*handler=*/base::DoNothing()); }
diff --git a/ash/public/cpp/system/toast_data.h b/ash/public/cpp/system/toast_data.h index 087d1df..6192ca80 100644 --- a/ash/public/cpp/system/toast_data.h +++ b/ash/public/cpp/system/toast_data.h
@@ -13,7 +13,7 @@ #include "base/functional/callback_helpers.h" #include "base/memory/raw_ptr_exclusion.h" #include "base/time/time.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" namespace ash { @@ -75,8 +75,10 @@ std::u16string button_text; // RAW_PTR_EXCLUSION: Never allocated by PartitionAlloc (always points to a // global), so there is no benefit to using a raw_ptr, only cost. - RAW_PTR_EXCLUSION const gfx::VectorIcon* button_icon = &gfx::kNoneIcon; - RAW_PTR_EXCLUSION const gfx::VectorIcon* leading_icon = &gfx::kNoneIcon; + RAW_PTR_EXCLUSION const gfx::VectorIcon* button_icon = + &gfx::VectorIcon::EmptyIcon(); + RAW_PTR_EXCLUSION const gfx::VectorIcon* leading_icon = + &gfx::VectorIcon::EmptyIcon(); base::OnceClosure expired_callback; base::TimeTicks time_created; base::TimeTicks time_start_showing;
diff --git a/ash/public/cpp/system_notification_builder.h b/ash/public/cpp/system_notification_builder.h index 20165c4fe5..ef92f3970 100644 --- a/ash/public/cpp/system_notification_builder.h +++ b/ash/public/cpp/system_notification_builder.h
@@ -13,6 +13,7 @@ #include "ash/public/cpp/ash_public_export.h" #include "base/memory/raw_ptr.h" #include "base/memory/scoped_refptr.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notification_types.h" #include "ui/message_center/public/cpp/notifier_id.h" @@ -232,7 +233,7 @@ scoped_refptr<message_center::NotificationDelegate> delegate); // Set the small image shown in the notification. - // Default: kNoneIcon + // Default: VectorIcon::EmptyIcon() SystemNotificationBuilder& SetSmallImage(const gfx::VectorIcon& small_image); // Set additional optional fields. @@ -279,7 +280,7 @@ std::optional<message_center::NotifierId> notifier_id_; NotificationCatalogName catalog_name_ = NotificationCatalogName::kNone; scoped_refptr<message_center::NotificationDelegate> delegate_ = nullptr; - raw_ptr<const gfx::VectorIcon> small_image_ = &gfx::kNoneIcon; + raw_ptr<const gfx::VectorIcon> small_image_ = &gfx::VectorIcon::EmptyIcon(); message_center::RichNotificationData optional_fields_; message_center::SystemNotificationWarningLevel warning_level_ = message_center::SystemNotificationWarningLevel::NORMAL;
diff --git a/ash/public/cpp/system_notification_builder_unittest.cc b/ash/public/cpp/system_notification_builder_unittest.cc index 582955f1..d0ba0b9 100644 --- a/ash/public/cpp/system_notification_builder_unittest.cc +++ b/ash/public/cpp/system_notification_builder_unittest.cc
@@ -7,6 +7,7 @@ #include "base/functional/callback_helpers.h" #include "components/vector_icons/vector_icons.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/vector_icon_types.h" namespace ash { @@ -24,7 +25,7 @@ EXPECT_EQ(notification.display_source(), u""); EXPECT_FALSE(notification.origin_url().is_valid()); EXPECT_EQ(notification.delegate(), nullptr); - EXPECT_EQ(¬ification.vector_small_image(), &gfx::kNoneIcon); + EXPECT_EQ(¬ification.vector_small_image(), &gfx::VectorIcon::EmptyIcon()); EXPECT_EQ(notification.rich_notification_data().progress, 0); EXPECT_EQ(notification.system_notification_warning_level(), message_center::SystemNotificationWarningLevel::NORMAL);
diff --git a/ash/public/cpp/test/test_nearby_share_delegate.cc b/ash/public/cpp/test/test_nearby_share_delegate.cc index a7086fe0..a7b9b2c 100644 --- a/ash/public/cpp/test/test_nearby_share_delegate.cc +++ b/ash/public/cpp/test/test_nearby_share_delegate.cc
@@ -10,10 +10,6 @@ namespace ash { -namespace { -const gfx::VectorIcon kEmptyIcon; -} // namespace - TestNearbyShareDelegate::TestNearbyShareDelegate() = default; TestNearbyShareDelegate::~TestNearbyShareDelegate() = default; @@ -53,7 +49,7 @@ void TestNearbyShareDelegate::ShowNearbyShareSettings() const {} const gfx::VectorIcon& TestNearbyShareDelegate::GetIcon(bool on_icon) const { - return kEmptyIcon; + return gfx::VectorIcon::EmptyIcon(); } std::u16string TestNearbyShareDelegate::GetPlaceholderFeatureName() const {
diff --git a/ash/quick_pair/COMMON_METADATA b/ash/quick_pair/COMMON_METADATA index 73525f6..07fd5b6 100644 --- a/ash/quick_pair/COMMON_METADATA +++ b/ash/quick_pair/COMMON_METADATA
@@ -1,4 +1,4 @@ buganizer { component_id: 1133283 } -team_email: "chromeos-cross-device-eng@google.com " +team_email: "chromeos-cross-device-eng@google.com"
diff --git a/ash/scalable_iph/scalable_iph_pixeltest.cc b/ash/scalable_iph/scalable_iph_pixeltest.cc index ab3e4f43..11750e5 100644 --- a/ash/scalable_iph/scalable_iph_pixeltest.cc +++ b/ash/scalable_iph/scalable_iph_pixeltest.cc
@@ -9,7 +9,7 @@ #include "ash/test/pixel/ash_pixel_test_init_params.h" #include "base/test/scoped_feature_list.h" #include "chromeos/constants/chromeos_features.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notifier_id.h" @@ -66,7 +66,7 @@ u"NotificationTitle", /*message=*/u"", u"NotificationSourceName", GURL(), message_center::NotifierId(), message_center::RichNotificationData(), - /*delegate=*/nullptr, gfx::kNoneIcon, + /*delegate=*/nullptr, gfx::VectorIcon::EmptyIcon(), message_center::SystemNotificationWarningLevel::NORMAL); message_center::MessageCenter* message_center =
diff --git a/ash/style/counter_expand_button.cc b/ash/style/counter_expand_button.cc index 69cf4c7e..b715bb9 100644 --- a/ash/style/counter_expand_button.cc +++ b/ash/style/counter_expand_button.cc
@@ -20,6 +20,7 @@ #include "ui/compositor/animation_throughput_reporter.h" #include "ui/compositor/layer.h" #include "ui/gfx/animation/tween.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/animation/animation_builder.h" #include "ui/views/controls/highlight_path_generator.h"
diff --git a/ash/system/audio/labeled_slider_view.cc b/ash/system/audio/labeled_slider_view.cc index 44a2764..7b57464 100644 --- a/ash/system/audio/labeled_slider_view.cc +++ b/ash/system/audio/labeled_slider_view.cc
@@ -24,6 +24,7 @@ #include "ui/compositor/layer.h" #include "ui/gfx/geometry/rounded_corners_f.h" #include "ui/gfx/geometry/rrect_f.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/controls/focus_ring.h" #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/controls/label.h" @@ -132,7 +133,8 @@ // Creates and formats the device name view. device_name_view_ = detailed_view->AddScrollListCheckableItem( - this, gfx::kNoneIcon, GetAudioDeviceName(device), device.active); + this, gfx::VectorIcon::EmptyIcon(), GetAudioDeviceName(device), + device.active); ConfigureDeviceNameView(device); // Puts `unified_slider_view_` beneath `device_name_view_`.
diff --git a/ash/system/bluetooth/bluetooth_device_list_controller_impl.cc b/ash/system/bluetooth/bluetooth_device_list_controller_impl.cc index e67f3db4..4ef64f3b 100644 --- a/ash/system/bluetooth/bluetooth_device_list_controller_impl.cc +++ b/ash/system/bluetooth/bluetooth_device_list_controller_impl.cc
@@ -9,7 +9,7 @@ #include "ash/system/bluetooth/bluetooth_device_list_item_view.h" #include "base/check.h" #include "base/memory/raw_ptr.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/view.h" namespace ash { @@ -132,7 +132,7 @@ size_t index) { if (!sub_header) { sub_header = bluetooth_detailed_view_->AddDeviceListSubHeader( - gfx::kNoneIcon, text_id); + gfx::VectorIcon::EmptyIcon(), text_id); } bluetooth_detailed_view_->device_list()->ReorderChildView(sub_header, index); return sub_header;
diff --git a/ash/system/holding_space/holding_space_tray_unittest.cc b/ash/system/holding_space/holding_space_tray_unittest.cc index b6ee414..f2556fa 100644 --- a/ash/system/holding_space/holding_space_tray_unittest.cc +++ b/ash/system/holding_space/holding_space_tray_unittest.cc
@@ -72,6 +72,7 @@ #include "ui/gfx/geometry/transform_util.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/skia_util.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/background.h" #include "ui/views/controls/image_view.h" @@ -104,7 +105,7 @@ int label_id, HoldingSpaceItem::InProgressCommand::Handler handler = base::DoNothing()) { return HoldingSpaceItem::InProgressCommand( - command_id, label_id, &gfx::kNoneIcon, std::move(handler)); + command_id, label_id, &gfx::VectorIcon::EmptyIcon(), std::move(handler)); } // A wrapper around `views::View::GetVisible()` with a null check for `view`.
diff --git a/ash/system/hotspot/hotspot_notifier.cc b/ash/system/hotspot/hotspot_notifier.cc index d9e214c..8173a43 100644 --- a/ash/system/hotspot/hotspot_notifier.cc +++ b/ash/system/hotspot/hotspot_notifier.cc
@@ -12,6 +12,7 @@ #include "ash/strings/grit/ash_strings.h" #include "base/strings/utf_string_conversions.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/message_center_constants.h" @@ -288,7 +289,7 @@ const bool use_hotspot_icon, scoped_refptr<message_center::NotificationDelegate> delegate) { const gfx::VectorIcon& icon = - use_hotspot_icon ? kHotspotOnIcon : gfx::kNoneIcon; + use_hotspot_icon ? kHotspotOnIcon : gfx::VectorIcon::EmptyIcon(); std::unique_ptr<message_center::Notification> notification = ash::CreateSystemNotificationPtr( message_center::NOTIFICATION_TYPE_SIMPLE, notification_id, title_id,
diff --git a/ash/system/network/managed_sim_lock_notifier.cc b/ash/system/network/managed_sim_lock_notifier.cc index 5cc179ee..0e53fd2 100644 --- a/ash/system/network/managed_sim_lock_notifier.cc +++ b/ash/system/network/managed_sim_lock_notifier.cc
@@ -18,6 +18,7 @@ #include "components/onc/onc_constants.h" #include "components/session_manager/session_manager_types.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/message_center_constants.h" @@ -194,7 +195,7 @@ message_center::RichNotificationData(), base::MakeRefCounted<message_center::ThunkNotificationDelegate>( weak_ptr_factory_.GetWeakPtr()), - /*small_image=*/gfx::VectorIcon(), + /*small_image=*/gfx::VectorIcon::EmptyIcon(), message_center::SystemNotificationWarningLevel::WARNING); notification->set_host_view_element_id( kCellularManagedSimLockNotificationElementId);
diff --git a/ash/system/notification_center/notification_grouping_controller_unittest.cc b/ash/system/notification_center/notification_grouping_controller_unittest.cc index c7d5f7e8..1907b41f 100644 --- a/ash/system/notification_center/notification_grouping_controller_unittest.cc +++ b/ash/system/notification_center/notification_grouping_controller_unittest.cc
@@ -389,7 +389,7 @@ auto* message_center = MessageCenter::Get(); std::string id0, id1, id2; const GURL url(u"http://test-url.com/"); - const auto icon = gfx::VectorIcon(); + const auto& icon = gfx::VectorIcon::EmptyIcon(); const auto small_image = gfx::Image(); const std::u16string display_source0 = u"test_display_source0";
diff --git a/ash/system/notification_center/stacked_notification_bar.cc b/ash/system/notification_center/stacked_notification_bar.cc index f47320d..d24f9387 100644 --- a/ash/system/notification_center/stacked_notification_bar.cc +++ b/ash/system/notification_center/stacked_notification_bar.cc
@@ -25,6 +25,7 @@ #include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/layer_animator.h" #include "ui/gfx/interpolated_transform.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/message_center/message_center.h" #include "ui/message_center/vector_icons.h" #include "ui/views/accessibility/view_accessibility.h"
diff --git a/ash/system/notification_center/views/notifier_settings_view.cc b/ash/system/notification_center/views/notifier_settings_view.cc index 360106c4..a5cb71c 100644 --- a/ash/system/notification_center/views/notifier_settings_view.cc +++ b/ash/system/notification_center/views/notifier_settings_view.cc
@@ -46,6 +46,7 @@ #include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/image/image.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/skia_paint_util.h" #include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/message_center_constants.h"
diff --git a/ash/system/palette/palette_tool.cc b/ash/system/palette/palette_tool.cc index 15a5266f..af45190f 100644 --- a/ash/system/palette/palette_tool.cc +++ b/ash/system/palette/palette_tool.cc
@@ -15,7 +15,7 @@ #include "ash/system/palette/tools/laser_pointer_mode.h" #include "ash/system/palette/tools/magnifier_mode.h" #include "ash/system/palette/tools/marker_mode.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" namespace ash { @@ -43,7 +43,7 @@ } const gfx::VectorIcon& PaletteTool::GetActiveTrayIcon() const { - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } } // namespace ash
diff --git a/ash/system/toast/system_toast_view.h b/ash/system/toast/system_toast_view.h index d0ce70e..8db17a2f 100644 --- a/ash/system/toast/system_toast_view.h +++ b/ash/system/toast/system_toast_view.h
@@ -9,7 +9,7 @@ #include "base/memory/raw_ptr.h" #include "ui/base/interaction/element_identifier.h" #include "ui/base/metadata/metadata_header_macros.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/layout/flex_layout_view.h" namespace views { @@ -38,12 +38,13 @@ kIconButton, }; - SystemToastView(const std::u16string& text, - ButtonType button_type = ButtonType::kNone, - const std::u16string& button_text = std::u16string(), - const gfx::VectorIcon* button_icon = &gfx::kNoneIcon, - base::RepeatingClosure button_callback = base::DoNothing(), - const gfx::VectorIcon* leading_icon = &gfx::kNoneIcon); + SystemToastView( + const std::u16string& text, + ButtonType button_type = ButtonType::kNone, + const std::u16string& button_text = std::u16string(), + const gfx::VectorIcon* button_icon = &gfx::VectorIcon::EmptyIcon(), + base::RepeatingClosure button_callback = base::DoNothing(), + const gfx::VectorIcon* leading_icon = &gfx::VectorIcon::EmptyIcon()); SystemToastView(const SystemToastView&) = delete; SystemToastView& operator=(const SystemToastView&) = delete; ~SystemToastView() override;
diff --git a/ash/system/toast/system_toast_view_pixeltest.cc b/ash/system/toast/system_toast_view_pixeltest.cc index a283a10b..4151950 100644 --- a/ash/system/toast/system_toast_view_pixeltest.cc +++ b/ash/system/toast/system_toast_view_pixeltest.cc
@@ -12,7 +12,7 @@ #include "ash/test/pixel/ash_pixel_test_init_params.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" #include "ui/gfx/geometry/rect.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/background.h" #include "ui/views/layout/flex_layout_view.h" #include "ui/views/view.h" @@ -77,7 +77,8 @@ GetContentsView()->AddChildView(std::make_unique<SystemToastView>( /*text=*/kTestText, SystemToastView::ButtonType::kNone, /*button_text=*/std::u16string(), - /*button_icon=*/&gfx::kNoneIcon, /*button_callback=*/base::DoNothing(), + /*button_icon=*/&gfx::VectorIcon::EmptyIcon(), + /*button_callback=*/base::DoNothing(), /*leading_icon=*/kTestIcon)); EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen( @@ -106,7 +107,8 @@ GetContentsView()->AddChildView(std::make_unique<SystemToastView>( /*text=*/kTestText, SystemToastView::ButtonType::kTextButton, /*button_text=*/kTestButtonText, - /*button_icon=*/&gfx::kNoneIcon, /*button_callback=*/base::DoNothing(), + /*button_icon=*/&gfx::VectorIcon::EmptyIcon(), + /*button_callback=*/base::DoNothing(), /*leading_icon=*/kTestIcon)); EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen( @@ -125,7 +127,8 @@ GetContentsView()->AddChildView(std::make_unique<SystemToastView>( /*text=*/kTestLongText, SystemToastView::ButtonType::kNone, /*button_text=*/std::u16string(), - /*button_icon=*/&gfx::kNoneIcon, /*button_callback=*/base::DoNothing(), + /*button_icon=*/&gfx::VectorIcon::EmptyIcon(), + /*button_callback=*/base::DoNothing(), /*leading_icon=*/kTestIcon)); EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen( @@ -145,7 +148,8 @@ GetContentsView()->AddChildView(std::make_unique<SystemToastView>( /*text=*/kTestLongText, SystemToastView::ButtonType::kTextButton, /*button_text=*/kTestButtonText, - /*button_icon=*/&gfx::kNoneIcon, /*button_callback=*/base::DoNothing(), + /*button_icon=*/&gfx::VectorIcon::EmptyIcon(), + /*button_callback=*/base::DoNothing(), /*leading_icon=*/kTestIcon)); EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
diff --git a/ash/system/toast/system_toast_view_unittest.cc b/ash/system/toast/system_toast_view_unittest.cc index 995dbea..905524c1 100644 --- a/ash/system/toast/system_toast_view_unittest.cc +++ b/ash/system/toast/system_toast_view_unittest.cc
@@ -14,7 +14,7 @@ #include "ash/style/icon_button.h" #include "ash/test/ash_test_base.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" @@ -73,7 +73,7 @@ widget->SetContentsView(std::make_unique<SystemToastView>( /*text=*/kTestText, SystemToastView::ButtonType::kNone, /*button_text=*/std::u16string(), - /*button_icon=*/&gfx::kNoneIcon, + /*button_icon=*/&gfx::VectorIcon::EmptyIcon(), /*button_callback=*/base::DoNothing(), /*leading_icon=*/kTestIcon)); // Test that the appropriate toast elements were created.
diff --git a/ash/system/unified/notification_counter_view.cc b/ash/system/unified/notification_counter_view.cc index b7dd1df1..12267a561 100644 --- a/ash/system/unified/notification_counter_view.cc +++ b/ash/system/unified/notification_counter_view.cc
@@ -26,6 +26,7 @@ #include "ui/gfx/canvas.h" #include "ui/gfx/font_list.h" #include "ui/gfx/image/canvas_image_source.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/message_center/message_center.h" #include "ui/views/border.h" #include "ui/views/controls/image_view.h"
diff --git a/ash/system/unified/notification_icons_controller_unittest.cc b/ash/system/unified/notification_icons_controller_unittest.cc index a84a58c..919beb35 100644 --- a/ash/system/unified/notification_icons_controller_unittest.cc +++ b/ash/system/unified/notification_icons_controller_unittest.cc
@@ -18,6 +18,7 @@ #include "ash/system/unified/notification_counter_view.h" #include "ash/test/ash_test_base.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/notification.h" #include "ui/views/accessibility/view_accessibility.h" @@ -56,8 +57,8 @@ message_center::NotifierId( message_center::NotifierType::SYSTEM_COMPONENT, notifier_id, NotificationCatalogName::kTestCatalogName), - rich_notification_data, nullptr /* delegate */, gfx::VectorIcon(), - warning_level)); + rich_notification_data, nullptr /* delegate */, + gfx::VectorIcon::EmptyIcon(), warning_level)); notification_id_++; return id;
diff --git a/ash/system/video_conference/bubble/set_value_effects_view.cc b/ash/system/video_conference/bubble/set_value_effects_view.cc index 9b9e6d9..c148332 100644 --- a/ash/system/video_conference/bubble/set_value_effects_view.cc +++ b/ash/system/video_conference/bubble/set_value_effects_view.cc
@@ -22,6 +22,7 @@ #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/controls/animated_image_view.h" #include "ui/views/controls/image_view.h"
diff --git a/ash/user_education/user_education_util_unittest.cc b/ash/user_education/user_education_util_unittest.cc index eb50876..c598caf 100644 --- a/ash/user_education/user_education_util_unittest.cc +++ b/ash/user_education/user_education_util_unittest.cc
@@ -23,7 +23,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/interaction/element_tracker.h" #include "ui/base/mojom/ui_base_types.mojom-shared.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/metadata/view_factory.h" #include "ui/views/view.h" #include "ui/views/view_class_properties.h" @@ -79,9 +79,10 @@ // `GetHelpBubbleBodyIcon()` can be used to retrieve help bubble body icon from // extended properties. TEST_F(UserEducationUtilTest, CreateExtendedPropertiesWithBodyIcon) { - EXPECT_EQ( - &GetHelpBubbleBodyIcon(CreateExtendedProperties(gfx::kNoneIcon))->get(), - &gfx::kNoneIcon); + EXPECT_EQ(&GetHelpBubbleBodyIcon( + CreateExtendedProperties(gfx::VectorIcon::EmptyIcon())) + ->get(), + &gfx::VectorIcon::EmptyIcon()); // It is permissible to query help bubble body icon even when absent. EXPECT_EQ(GetHelpBubbleBodyIcon(HelpBubbleParams::ExtendedProperties()),
diff --git a/ash/user_education/views/help_bubble_view_ash.cc b/ash/user_education/views/help_bubble_view_ash.cc index 12955f00..d7ac6c5 100644 --- a/ash/user_education/views/help_bubble_view_ash.cc +++ b/ash/user_education/views/help_bubble_view_ash.cc
@@ -48,7 +48,6 @@ #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/geometry/rounded_corners_f.h" #include "ui/gfx/geometry/skia_conversions.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/text_constants.h" #include "ui/gfx/text_utils.h" #include "ui/gfx/vector_icon_types.h" @@ -386,7 +385,7 @@ // Add the body icon (optional). constexpr int kBodyIconSize = 20; constexpr int kBodyIconBackgroundSize = 24; - if (body_icon && (body_icon != &gfx::kNoneIcon)) { + if (body_icon && (body_icon != &gfx::VectorIcon::EmptyIcon())) { icon_view_ = top_text_container->AddChildViewAt( views::Builder<views::ImageView>() .SetAccessibleName(params.body_icon_alt_text)
diff --git a/ash/user_education/views/help_bubble_view_ash_unittest.cc b/ash/user_education/views/help_bubble_view_ash_unittest.cc index d78c05a..56734d0 100644 --- a/ash/user_education/views/help_bubble_view_ash_unittest.cc +++ b/ash/user_education/views/help_bubble_view_ash_unittest.cc
@@ -22,7 +22,7 @@ #include "ui/color/color_provider.h" #include "ui/events/base_event_utils.h" #include "ui/events/event.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/controls/image_view.h" @@ -120,12 +120,12 @@ HelpBubbleViewAshBodyIconTest, ::testing::Combine( /*body_icon_from_params=*/::testing::Values( - std::make_optional(std::cref(gfx::kNoneIcon)), + std::make_optional(std::cref(gfx::VectorIcon::EmptyIcon())), std::make_optional(std::cref(vector_icons::kCelebrationIcon)), std::make_optional(std::cref(vector_icons::kHelpIcon)), std::nullopt), /*body_icon_from_extended_properties=*/::testing::Values( - std::make_optional(std::cref(gfx::kNoneIcon)), + std::make_optional(std::cref(gfx::VectorIcon::EmptyIcon())), std::make_optional(std::cref(vector_icons::kCelebrationIcon)), std::make_optional(std::cref(vector_icons::kHelpIcon)), std::nullopt))); @@ -160,7 +160,7 @@ // Cache `expected_body_icon` based on order of precedence. const gfx::VectorIcon& expected_body_icon = body_icon_from_extended_properties().value_or( - body_icon_from_params().value_or(gfx::kNoneIcon)); + body_icon_from_params().value_or(gfx::VectorIcon::EmptyIcon())); // Confirm body icon exists iff expected and is configured as expected. EXPECT_THAT( @@ -168,7 +168,7 @@ ->GetUniqueViewAs<views::ImageView>( HelpBubbleViewAsh::kBodyIconIdForTesting, views::ElementTrackerViews::GetContextForView(help_bubble_view)), - Conditional(&expected_body_icon != &gfx::kNoneIcon, + Conditional(&expected_body_icon != &gfx::VectorIcon::EmptyIcon(), Property(&views::ImageView::GetImageModel, Eq(ui::ImageModel::FromVectorIcon( expected_body_icon,
diff --git a/ash/user_education/welcome_tour/welcome_tour_controller.cc b/ash/user_education/welcome_tour/welcome_tour_controller.cc index 08426c85..c0439d7f 100644 --- a/ash/user_education/welcome_tour/welcome_tour_controller.cc +++ b/ash/user_education/welcome_tour/welcome_tour_controller.cc
@@ -56,7 +56,7 @@ #include "ui/display/screen.h" #include "ui/display/tablet_state.h" #include "ui/events/base_event_utils.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/interaction/element_tracker_views.h" #include "ui/views/view.h" @@ -78,7 +78,7 @@ user_education_util::CreateExtendedProperties( ui::mojom::ModalType::kSystem), user_education_util::CreateExtendedProperties( - /*body_icon=*/gfx::kNoneIcon)); + /*body_icon=*/gfx::VectorIcon::EmptyIcon())); } user_education::HelpBubbleParams::ExtendedProperties
diff --git a/ash/user_education/welcome_tour/welcome_tour_controller_unittest.cc b/ash/user_education/welcome_tour/welcome_tour_controller_unittest.cc index c2f85a4..1278466 100644 --- a/ash/user_education/welcome_tour/welcome_tour_controller_unittest.cc +++ b/ash/user_education/welcome_tour/welcome_tour_controller_unittest.cc
@@ -61,6 +61,7 @@ #include "ui/display/display.h" #include "ui/display/screen.h" #include "ui/events/types/event_type.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notification_delegate.h" @@ -168,7 +169,8 @@ arg.next_button_callback().is_null() != has_next_button && util::GetHelpBubbleModalType(ext_props) == ui::mojom::ModalType::kSystem && - &util::GetHelpBubbleBodyIcon(ext_props)->get() == &gfx::kNoneIcon; + &util::GetHelpBubbleBodyIcon(ext_props)->get() == + &gfx::VectorIcon::EmptyIcon(); } MATCHER_P7(BubbleStep, @@ -189,7 +191,8 @@ arg.body_text_id() == body_text_id && arg.arrow() == arrow && Matches(body_text_matcher)(util::GetHelpBubbleBodyText(ext_props)) && arg.next_button_callback().is_null() != has_next_button && - &util::GetHelpBubbleBodyIcon(ext_props)->get() == &gfx::kNoneIcon && + &util::GetHelpBubbleBodyIcon(ext_props)->get() == + &gfx::VectorIcon::EmptyIcon() && util::GetHelpBubbleModalType(ext_props) == ui::mojom::ModalType::kSystem; } @@ -215,7 +218,8 @@ arg.body_text_id() == body_text_id && arg.arrow() == arrow && Matches(body_text_matcher)(util::GetHelpBubbleBodyText(ext_props)) && arg.next_button_callback().is_null() != has_next_button && - &util::GetHelpBubbleBodyIcon(ext_props)->get() == &gfx::kNoneIcon && + &util::GetHelpBubbleBodyIcon(ext_props)->get() == + &gfx::VectorIcon::EmptyIcon() && util::GetHelpBubbleModalType(ext_props) == ui::mojom::ModalType::kSystem; }
diff --git a/ash/wm/splitview/split_view_setup_view.cc b/ash/wm/splitview/split_view_setup_view.cc index 782b069..b562559 100644 --- a/ash/wm/splitview/split_view_setup_view.cc +++ b/ash/wm/splitview/split_view_setup_view.cc
@@ -15,6 +15,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/compositor/layer.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/highlight_border.h" @@ -100,9 +101,9 @@ SystemToastView::ButtonType::kTextButton, /*button_text=*/ l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_FASTER_SPLITSCREEN_TOAST_SKIP), - /*button_icon=*/&gfx::kNoneIcon, + /*button_icon=*/&gfx::VectorIcon::EmptyIcon(), /*button_callback=*/std::move(skip_callback), - /*leading_icon=*/&gfx::kNoneIcon)); + /*leading_icon=*/&gfx::VectorIcon::EmptyIcon())); auto* dismiss_button = toast->button(); dismiss_button->SetTooltipText(l10n_util::GetStringUTF16( IDS_ASH_OVERVIEW_FASTER_SPLITSCREEN_TOAST_DISMISS_WINDOW_SUGGESTIONS));
diff --git a/ash/wm/window_mini_view.cc b/ash/wm/window_mini_view.cc index 1693744f..7e0e5e8 100644 --- a/ash/wm/window_mini_view.cc +++ b/ash/wm/window_mini_view.cc
@@ -134,8 +134,6 @@ // Always put the backdrop view under other children. backdrop_view_ = AddChildViewAt(std::make_unique<views::View>(), 0); backdrop_view_->SetPaintToLayer(ui::LAYER_SOLID_COLOR); - backdrop_view_->SetBackground( - views::CreateThemedSolidBackground(cros_tokens::kCrosSysScrim)); ui::Layer* layer = backdrop_view_->layer(); @@ -187,6 +185,15 @@ OnRoundedCornersSet(); } +void WindowMiniView::OnThemeChanged() { + View::OnThemeChanged(); + + if (backdrop_view_) { + backdrop_view_->layer()->SetColor( + GetColorProvider()->GetColor(cros_tokens::kCrosSysScrim)); + } +} + bool WindowMiniView::Contains(aura::Window* window) const { return source_window_ == window; }
diff --git a/ash/wm/window_mini_view.h b/ash/wm/window_mini_view.h index da21bd06..27877f0 100644 --- a/ash/wm/window_mini_view.h +++ b/ash/wm/window_mini_view.h
@@ -134,6 +134,9 @@ // `header_view_rounded_corners_` and `preview_view_rounded_corners_`. void ResetRoundedCorners(); + // views::View: + void OnThemeChanged() override; + // WindowMiniViewBase: bool Contains(aura::Window* window) const override; aura::Window* GetWindowAtPoint(const gfx::Point& screen_point) const override;
diff --git a/base/android/java/src/org/chromium/base/FeatureList.java b/base/android/java/src/org/chromium/base/FeatureList.java index c68271b..11334ea 100644 --- a/base/android/java/src/org/chromium/base/FeatureList.java +++ b/base/android/java/src/org/chromium/base/FeatureList.java
@@ -62,8 +62,9 @@ addFieldTrialParamOverride(param.getFeatureName(), param.getName(), testValue); } + @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) @Nullable - Boolean getFeatureFlagOverride(String featureName) { + public Boolean getFeatureFlagOverride(String featureName) { return mFeatureFlags.get(featureName); } @@ -205,43 +206,28 @@ } /** - * Override feature flags for testing. Convenience method for #setTestValues() without params. + * Adds overrides to feature flags and field trial parameters in addition to existing ones. * - * <p>If |testFeatures| is null, resets all feature flag and param test overrides (including - * ones added by @EnableFeatures, @DisableFeatures and @CommandLineFlags). - * - * <p>TODO(crbug.com/386813115): Migrate usages to #setTestFeature or #setTestValues to delete - * this method. + * <p>An alias for #mergeTestValues(testValues, replace=true). */ @VisibleForTesting - public static void setTestFeatures(@Nullable Map<String, Boolean> testFeatures) { - if (testFeatures == null) { - setTestValues(null); - } else { - TestValues testValues = new TestValues(); - testValues.setFeatureFlagsOverride(testFeatures); - setTestValues(testValues); - } + public static void setTestValues(TestValues testValues) { + assert testValues != null; + mergeTestValues(testValues, /* replace= */ true); } /** - * Adds overrides to feature flags and field trial parameters in addition to existing ones. + * Rarely necessary. Remove all Java overrides to feature flags and field trial parameters. * - * <p>If |testFeatures| is null, resets all feature flag and param test overrides (including - * ones added by @EnableFeatures, @DisableFeatures and @CommandLineFlags). + * <p>You don't need to call this on tearDown() or at the end of a test. ResettersForTesting + * already resets test values. * - * <p>Otherwise, it's an alias for #mergeTestValues(testValues, replace=true). - * - * <p>TODO(crbug.com/386813115): Create resetTestValues() to remove all test values and make - * this param @NotNull. + * <p>@Features annotations and @CommandLineFlags --enable/disable-features are affected by + * this. */ @VisibleForTesting - public static void setTestValues(@Nullable TestValues testValues) { - if (testValues == null) { - overwriteTestValues(null); - } else { - mergeTestValues(testValues, /* replace= */ true); - } + public static void removeAllTestOverrides() { + overwriteTestValues(null); } private static void overwriteTestValues(@Nullable TestValues testValues) {
diff --git a/base/android/java/src/org/chromium/base/FeatureMap.java b/base/android/java/src/org/chromium/base/FeatureMap.java index dd87b86..d1afa783 100644 --- a/base/android/java/src/org/chromium/base/FeatureMap.java +++ b/base/android/java/src/org/chromium/base/FeatureMap.java
@@ -44,8 +44,9 @@ * to be marked as active. * * <p>Should be called only after native is loaded. If {@link FeatureList#isInitialized()} - * returns true, this method is safe to call. In tests, this will return any values set through - * {@link FeatureList#setTestFeatures(Map)}, even before native is loaded. + * returns true, this method is safe to call. In tests, this will return any values set + * through @Enable/@DisableFeatures annotations or {@link + * FeatureList#setTestValues(FeatureList.TestValues)}, even before native is loaded. * * @param featureName The name of the feature to query. * @return Whether the feature is enabled or not.
diff --git a/base/android/junit/src/org/chromium/base/MutableFlagWithSafeDefaultUnitTest.java b/base/android/junit/src/org/chromium/base/MutableFlagWithSafeDefaultUnitTest.java index b372902..90ab680 100644 --- a/base/android/junit/src/org/chromium/base/MutableFlagWithSafeDefaultUnitTest.java +++ b/base/android/junit/src/org/chromium/base/MutableFlagWithSafeDefaultUnitTest.java
@@ -42,7 +42,7 @@ FEATURE_MAP.mutableFlagWithSafeDefault(FEATURE_B, true); // Values from ChromeFeatureList should be used from now on. - FeatureList.setTestFeatures(A_ON_B_OFF); + FeatureList.setTestValues(A_ON_B_OFF); // Verify that {@link MutableFlagWithSafeDefault} returns native values. BaseFlagTestRule.assertIsEnabledMatches(A_ON_B_OFF, featureA, featureB); @@ -70,7 +70,7 @@ BaseFlagTestRule.assertIsEnabledMatches(A_OFF_B_ON, featureA, featureB); // Values from ChromeFeatureList should be used from now on. - FeatureList.setTestFeatures(A_ON_B_OFF); + FeatureList.setTestValues(A_ON_B_OFF); // Verify that {@link MutableFlagWithSafeDefault} returns native values. BaseFlagTestRule.assertIsEnabledMatches(A_ON_B_OFF, featureA, featureB);
diff --git a/base/android/junit/src/org/chromium/base/PostNativeFlagUnitTest.java b/base/android/junit/src/org/chromium/base/PostNativeFlagUnitTest.java index ccdcad4..5c86787e 100644 --- a/base/android/junit/src/org/chromium/base/PostNativeFlagUnitTest.java +++ b/base/android/junit/src/org/chromium/base/PostNativeFlagUnitTest.java
@@ -44,7 +44,7 @@ PostNativeFlag featureB = new PostNativeFlag(BaseFlagTestRule.FEATURE_MAP, FEATURE_B); // Values from ChromeFeatureList should be used from now on. - FeatureList.setTestFeatures(A_OFF_B_ON); + FeatureList.setTestValues(A_OFF_B_ON); // Assert {@link MutableFlagWithSafeDefault} uses the values from {@link ChromeFeatureList}. assertIsEnabledMatches(A_OFF_B_ON, featureA, featureB);
diff --git a/base/profiler/frame_pointer_unwinder.cc b/base/profiler/frame_pointer_unwinder.cc index 73c8228..08853da 100644 --- a/base/profiler/frame_pointer_unwinder.cc +++ b/base/profiler/frame_pointer_unwinder.cc
@@ -51,8 +51,10 @@ namespace base { FramePointerUnwinder::FramePointerUnwinder( - CanUnwindFromDelegate can_unwind_from_delegate) - : can_unwind_from_delegate_(can_unwind_from_delegate) {} + CanUnwindFromDelegate can_unwind_from_delegate, + bool is_system_unwinder) + : can_unwind_from_delegate_(can_unwind_from_delegate), + is_system_unwinder_(is_system_unwinder) {} FramePointerUnwinder::~FramePointerUnwinder() = default; @@ -108,7 +110,8 @@ // If `next_frame` is 0, we've hit the root and `retaddr` isn't useful. // Bail without recording the frame. if (next_frame == 0) { - return UnwindResult::kCompleted; + return is_system_unwinder_ ? UnwindResult::kCompleted + : UnwindResult::kUnrecognizedFrame; } const ModuleCache::Module* module = module_cache()->GetModuleForAddress(retaddr);
diff --git a/base/profiler/frame_pointer_unwinder.h b/base/profiler/frame_pointer_unwinder.h index 1aafc6f..df4f362d 100644 --- a/base/profiler/frame_pointer_unwinder.h +++ b/base/profiler/frame_pointer_unwinder.h
@@ -22,6 +22,7 @@ // * iOS, ARM64 and X86_64, // * macOS // * ChromeOS X86_64 and ARM64 +// * Android ARM64 (Chrome module) class BASE_EXPORT #if BUILDFLAG(IS_APPLE) API_AVAILABLE(ios(12)) @@ -32,7 +33,8 @@ RepeatingCallback<bool(const Frame& current_frame)>; FramePointerUnwinder( - CanUnwindFromDelegate can_unwind_from_delegate = CanUnwindFromDelegate()); + CanUnwindFromDelegate can_unwind_from_delegate = CanUnwindFromDelegate(), + bool is_system_unwinder = true); ~FramePointerUnwinder() override; FramePointerUnwinder(const FramePointerUnwinder&) = delete; @@ -47,6 +49,7 @@ private: CanUnwindFromDelegate can_unwind_from_delegate_; + const bool is_system_unwinder_; }; } // namespace base
diff --git a/base/strings/to_string.h b/base/strings/to_string.h index dacae95c..96e61da 100644 --- a/base/strings/to_string.h +++ b/base/strings/to_string.h
@@ -6,6 +6,7 @@ #define BASE_STRINGS_TO_STRING_H_ #include <concepts> +#include <iomanip> #include <ios> #include <memory> #include <sstream> @@ -134,6 +135,7 @@ template <typename... Ts> std::string ToString(const Ts&... values) { std::ostringstream ss; + ss.setf(std::ios_base::boolalpha); // Stringify bools as "true"/"false". (..., internal::ToStringHelper<std::remove_cvref_t<decltype(values)>>::Stringify( values, ss));
diff --git a/base/strings/to_string_unittest.cc b/base/strings/to_string_unittest.cc index b3bd8e3..83d2362 100644 --- a/base/strings/to_string_unittest.cc +++ b/base/strings/to_string_unittest.cc
@@ -41,6 +41,7 @@ // Types with built-in <<. EXPECT_EQ(ToString("foo"), "foo"); EXPECT_EQ(ToString(123), "123"); + EXPECT_EQ(ToString(true), "true"); // bools should become words, not numbers. } enum class StreamableTestEnum { kGreeting, kLocation };
diff --git a/base/task/task_features.cc b/base/task/task_features.cc index 7938f29..75ca91d 100644 --- a/base/task/task_features.cc +++ b/base/task/task_features.cc
@@ -26,10 +26,6 @@ "UseUtilityThreadGroup", base::FEATURE_DISABLED_BY_DEFAULT); -BASE_FEATURE(kDelayFirstWorkerWake, - "DelayFirstWorkerWake", - base::FEATURE_ENABLED_BY_DEFAULT); - BASE_FEATURE(kAddTaskLeewayFeature, "AddTaskLeeway", base::FEATURE_ENABLED_BY_DEFAULT);
diff --git a/base/task/task_features.h b/base/task/task_features.h index 476011f..a33f8d9 100644 --- a/base/task/task_features.h +++ b/base/task/task_features.h
@@ -21,11 +21,6 @@ // running USER_VISIBLE tasks. BASE_EXPORT BASE_DECLARE_FEATURE(kUseUtilityThreadGroup); -// This feature controls whether ThreadPool WorkerThreads should hold off waking -// up to purge PartitionAlloc within the first minute of their lifetime. See -// base::internal::GetSleepDurationBeforePurge. -BASE_EXPORT BASE_DECLARE_FEATURE(kDelayFirstWorkerWake); - // Under this feature, a non-zero leeway is added to delayed tasks. Along with // DelayPolicy, this affects the time at which a delayed task runs. BASE_EXPORT BASE_DECLARE_FEATURE(kAddTaskLeewayFeature);
diff --git a/base/task/thread_pool/worker_thread.cc b/base/task/thread_pool/worker_thread.cc index 5db4eb2..c949a05 100644 --- a/base/task/thread_pool/worker_thread.cc +++ b/base/task/thread_pool/worker_thread.cc
@@ -14,10 +14,8 @@ #include "base/check_op.h" #include "base/compiler_specific.h" #include "base/debug/alias.h" -#include "base/feature_list.h" #include "base/functional/callback_helpers.h" #include "base/synchronization/waitable_event.h" -#include "base/task/task_features.h" #include "base/task/thread_pool/environment_config.h" #include "base/task/thread_pool/worker_thread_observer.h" #include "base/threading/hang_watcher.h" @@ -99,20 +97,11 @@ // PA_CONFIG(THREAD_CACHE_SUPPORTED) } -bool WorkerThread::Delegate::IsDelayFirstWorkerSleepEnabled() { - static bool state = FeatureList::IsEnabled(kDelayFirstWorkerWake); - return state; -} - #if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \ PA_CONFIG(THREAD_CACHE_SUPPORTED) TimeDelta WorkerThread::Delegate::GetSleepDurationBeforePurge(TimeTicks now) { base::TimeDelta sleep_duration_before_purge = kPurgeThreadCacheIdleDelay; - if (!IsDelayFirstWorkerSleepEnabled()) { - return sleep_duration_before_purge; - } - // Use the first time a worker goes to sleep in this process as an // approximation of the process creation time. static const TimeTicks first_sleep_time = now; @@ -175,20 +164,6 @@ WorkerThreadObserver* worker_thread_observer) { CheckedLock::AssertNoLockHeldOnCurrentThread(); - // Prime kDelayFirstWorkerWake's feature state right away on thread creation - // instead of looking it up for the first time later on thread as this avoids - // a data race in tests that may ~FeatureList while the first worker thread - // is still initializing (the first WorkerThread will be started on the main - // thread as part of ThreadPoolImpl::Start() so doing it then avoids this - // race), crbug.com/1344573. - // Note 1: the feature state is always available at this point as - // ThreadPoolInstance::Start() contractually happens-after FeatureList - // initialization. - // Note 2: This is done on Start instead of in the constructor as construction - // happens under a ThreadGroup lock which precludes calling into - // FeatureList (as that can also use a lock). - delegate()->IsDelayFirstWorkerSleepEnabled(); - CheckedAutoLock auto_lock(thread_lock_); DCHECK(thread_handle_.is_null());
diff --git a/base/task/thread_pool/worker_thread.h b/base/task/thread_pool/worker_thread.h index cd04aea..1b187ed 100644 --- a/base/task/thread_pool/worker_thread.h +++ b/base/task/thread_pool/worker_thread.h
@@ -107,7 +107,6 @@ protected: friend WorkerThread; - static bool IsDelayFirstWorkerSleepEnabled(); // Called in WaitForWork() to hide the worker's synchronization // mechanism. Returns |true| if signaled, and |false| if the call timed out.
diff --git a/base/test/android/junit/src/org/chromium/base/test/util/BaseFlagTestRule.java b/base/test/android/junit/src/org/chromium/base/test/util/BaseFlagTestRule.java index 4db3a25..d7dfce5 100644 --- a/base/test/android/junit/src/org/chromium/base/test/util/BaseFlagTestRule.java +++ b/base/test/android/junit/src/org/chromium/base/test/util/BaseFlagTestRule.java
@@ -10,12 +10,11 @@ import org.junit.runner.Description; import org.junit.runners.model.Statement; +import org.chromium.base.FeatureList; import org.chromium.base.FeatureMap; import org.chromium.base.FeatureParam; import org.chromium.base.Flag; -import java.util.Map; - /** Test rule for testing subclasses of {@link Flag}. */ public class BaseFlagTestRule implements TestRule { @Override @@ -33,14 +32,21 @@ public static final String FEATURE_A = "FeatureA"; public static final String FEATURE_B = "FeatureB"; - public static final Map<String, Boolean> A_OFF_B_ON = - Map.of(FEATURE_A, false, FEATURE_B, true); - public static final Map<String, Boolean> A_OFF_B_OFF = - Map.of(FEATURE_A, false, FEATURE_B, false); - public static final Map<String, Boolean> A_ON_B_OFF = - Map.of(FEATURE_A, true, FEATURE_B, false); - public static final Map<String, Boolean> A_ON_B_ON = - Map.of(FEATURE_A, true, FEATURE_B, true); + public static final FeatureList.TestValues A_OFF_B_ON = new FeatureList.TestValues(); + public static final FeatureList.TestValues A_OFF_B_OFF = new FeatureList.TestValues(); + public static final FeatureList.TestValues A_ON_B_OFF = new FeatureList.TestValues(); + public static final FeatureList.TestValues A_ON_B_ON = new FeatureList.TestValues(); + + static { + A_OFF_B_ON.addFeatureFlagOverride(FEATURE_A, false); + A_OFF_B_ON.addFeatureFlagOverride(FEATURE_B, true); + A_OFF_B_OFF.addFeatureFlagOverride(FEATURE_A, false); + A_OFF_B_OFF.addFeatureFlagOverride(FEATURE_B, false); + A_ON_B_OFF.addFeatureFlagOverride(FEATURE_A, true); + A_ON_B_OFF.addFeatureFlagOverride(FEATURE_B, false); + A_ON_B_ON.addFeatureFlagOverride(FEATURE_A, true); + A_ON_B_ON.addFeatureFlagOverride(FEATURE_B, true); + } /** A stub FeatureMap instance to create flags on. */ public static final FeatureMap FEATURE_MAP = @@ -55,8 +61,8 @@ }; public static void assertIsEnabledMatches( - Map<String, Boolean> state, Flag feature1, Flag feature2) { - assertEquals(state.get(FEATURE_A), feature1.isEnabled()); - assertEquals(state.get(FEATURE_B), feature2.isEnabled()); + FeatureList.TestValues state, Flag feature1, Flag feature2) { + assertEquals(state.getFeatureFlagOverride(FEATURE_A), feature1.isEnabled()); + assertEquals(state.getFeatureFlagOverride(FEATURE_B), feature2.isEnabled()); } }
diff --git a/base/timer/wall_clock_timer.cc b/base/timer/wall_clock_timer.cc index 90847b8..98f2732 100644 --- a/base/timer/wall_clock_timer.cc +++ b/base/timer/wall_clock_timer.cc
@@ -6,71 +6,72 @@ #include <utility> +#include "base/functional/callback.h" +#include "base/location.h" +#include "base/memory/raw_ptr.h" #include "base/power_monitor/power_monitor.h" +#include "base/sequence_checker.h" #include "base/time/clock.h" #include "base/time/default_clock.h" -#include "base/time/default_tick_clock.h" -#include "base/time/tick_clock.h" +#include "base/time/time.h" +#include "base/timer/timer.h" namespace base { -WallClockTimer::WallClockTimer() = default; +WallClockTimer::WallClockTimer() : WallClockTimer(nullptr, nullptr) {} + WallClockTimer::WallClockTimer(const Clock* clock, const TickClock* tick_clock) - : timer_(tick_clock), clock_(clock ? clock : DefaultClock::GetInstance()) {} + : timer_(tick_clock), clock_(clock ? clock : DefaultClock::GetInstance()) { + DETACH_FROM_SEQUENCE(sequence_checker_); +} WallClockTimer::~WallClockTimer() { - RemoveObserver(); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + PowerMonitor::GetInstance()->RemovePowerSuspendObserver(this); } void WallClockTimer::Start(const Location& posted_from, Time desired_run_time, OnceClosure user_task) { - user_task_ = std::move(user_task); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(user_task); posted_from_ = posted_from; desired_run_time_ = desired_run_time; - AddObserver(); - timer_.Start(posted_from_, desired_run_time_ - Now(), this, - &WallClockTimer::RunUserTask); + if (!user_task_) { + PowerMonitor::GetInstance()->AddPowerSuspendObserver(this); + } + user_task_ = std::move(user_task); + OnResume(); } void WallClockTimer::Stop() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); timer_.Stop(); user_task_.Reset(); - RemoveObserver(); + PowerMonitor::GetInstance()->RemovePowerSuspendObserver(this); + DETACH_FROM_SEQUENCE(sequence_checker_); } bool WallClockTimer::IsRunning() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); return timer_.IsRunning(); } void WallClockTimer::OnResume() { - // This will actually restart timer with smaller delay - timer_.Start(posted_from_, desired_run_time_ - Now(), this, + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + timer_.Start(posted_from_, desired_run_time_ - clock_->Now(), this, &WallClockTimer::RunUserTask); } -void WallClockTimer::AddObserver() { - if (!observer_added_) { - PowerMonitor::GetInstance()->AddPowerSuspendObserver(this); - observer_added_ = true; - } -} - -void WallClockTimer::RemoveObserver() { - if (observer_added_) { - PowerMonitor::GetInstance()->RemovePowerSuspendObserver(this); - observer_added_ = false; - } -} - void WallClockTimer::RunUserTask() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(user_task_); - RemoveObserver(); - std::exchange(user_task_, {}).Run(); -} - -Time WallClockTimer::Now() const { - return clock_->Now(); + PowerMonitor::GetInstance()->RemovePowerSuspendObserver(this); + // Detach the sequence checker before running the task, just in case someone + // sets a new task (= new sequence) while executing the task. + auto task = std::move(user_task_); + DETACH_FROM_SEQUENCE(sequence_checker_); + std::move(task).Run(); } } // namespace base
diff --git a/base/timer/wall_clock_timer.h b/base/timer/wall_clock_timer.h index eabfe95f..65561ac6 100644 --- a/base/timer/wall_clock_timer.h +++ b/base/timer/wall_clock_timer.h
@@ -11,30 +11,32 @@ #include "base/location.h" #include "base/memory/raw_ptr.h" #include "base/power_monitor/power_observer.h" -#include "base/time/default_clock.h" +#include "base/sequence_checker.h" #include "base/time/time.h" #include "base/timer/timer.h" namespace base { + class Clock; class TickClock; -// WallClockTimer is based on OneShotTimer and provides a simple timer API -// which is mostly similar to OneShotTimer's API. The main difference is that -// WallClockTimer is using Time (which is system-dependent) to schedule task. -// WallClockTimer calls you back once scheduled time has come. +// `WallClockTimer` is based on `OneShotTimer` and provides a similar API. +// Where `OneShotTimer` uses `TimeTicks`, however, `WallClockTimer` uses `Time`. +// On some platforms, `TimeTicks` freezes during suspend; `Time` does not. +// `WallClockTimer` recomputes the desired delay after resuming from suspend, so +// on these platforms, suspends will "delay" `OneShotTimer` but not +// `WallClockTimer`. // -// Comparison with OneShotTimer: WallClockTimer runs |user_task_| after |delay_| -// expires according to usual time, while OneShotTimer runs |user_task_| after -// |delay_| expires according to TimeTicks which may freeze on some platforms -// when power suspends (desktop falls asleep). On platforms where TimeTicks -// don't freeze, the WallClockTimer has the same behavior as OneShotTimer. +// This does not attempt to observe and accommodate other `Time` changes, e.g. +// `Time` moving backwards in response to a DST change. `WallClockTimer` will +// only notice such changes if the system is subsequently suspended (which will +// cause a recalculation on resume that will coincidentally take them into +// account). // -// The API is not thread safe. All methods must be called from the same -// sequence (not necessarily the construction sequence), except for the -// destructor. -// - The destructor may be called from any sequence when the timer is not -// running and there is no scheduled task active. +// After construction, the timer will become bound to the first sequence any +// method is called on. All subsequent calls must happen on that sequence until +// the task runs or is canceled via `Stop()`, after which the timer may be +// destroyed or restarted on another sequence. class BASE_EXPORT WallClockTimer : public PowerSuspendObserver { public: // Constructs a timer. Start() must be called later to start the timer. @@ -46,7 +48,6 @@ WallClockTimer(const Clock* clock, const TickClock* tick_clock); WallClockTimer(const WallClockTimer&) = delete; WallClockTimer& operator=(const WallClockTimer&) = delete; - ~WallClockTimer() override; // Starts the timer to run at the given |desired_run_time|. If the timer is @@ -67,43 +68,37 @@ BindOnce(method, Unretained(receiver))); } - // Stops the timer. It is a no-op if the timer is not running. + // Stops the timer. No-op if the timer is not running. void Stop(); - // Returns true if the timer is running. + // Returns whether the timer is running. bool IsRunning() const; // PowerSuspendObserver: void OnResume() override; - Time desired_run_time() const { return desired_run_time_; } + Time desired_run_time() const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + return desired_run_time_; + } private: - void AddObserver(); - - void RemoveObserver(); - - // Actually run scheduled task void RunUserTask(); - // Returns the current time count. - Time Now() const; - - bool observer_added_ = false; + SEQUENCE_CHECKER(sequence_checker_); // Location in user code. - Location posted_from_; + Location posted_from_ GUARDED_BY_CONTEXT(sequence_checker_); // The desired run time of |user_task_|. - Time desired_run_time_; + Time desired_run_time_ GUARDED_BY_CONTEXT(sequence_checker_); - OnceClosure user_task_; + OnceClosure user_task_ GUARDED_BY_CONTEXT(sequence_checker_); - // Timer which should notify to run task in the period while system awake OneShotTimer timer_; // The clock used to calculate the run time for scheduled tasks. - const raw_ptr<const Clock> clock_ = DefaultClock::GetInstance(); + const raw_ptr<const Clock> clock_; }; } // namespace base
diff --git a/base/types/strong_alias.h b/base/types/strong_alias.h index 4a8d8e1..1ff8e35 100644 --- a/base/types/strong_alias.h +++ b/base/types/strong_alias.h
@@ -113,19 +113,6 @@ friend bool operator==(const StrongAlias& lhs, const StrongAlias& rhs) = default; - // Hasher to use in std::unordered_map, std::unordered_set, etc. - // - // Example usage: - // using MyType = base::StrongAlias<...>; - // using MySet = std::unordered_set<MyType, typename MyType::Hasher>; - struct Hasher { - using argument_type = StrongAlias; - using result_type = std::size_t; - result_type operator()(const argument_type& id) const { - return std::hash<UnderlyingType>()(id.value()); - } - }; - // If UnderlyingType can be serialised into trace, its alias is also // serialisable. template <class U = UnderlyingType>
diff --git a/base/types/strong_alias_unittest.cc b/base/types/strong_alias_unittest.cc index 760306bf..cbbfb24 100644 --- a/base/types/strong_alias_unittest.cc +++ b/base/types/strong_alias_unittest.cc
@@ -295,7 +295,7 @@ TYPED_TEST(StrongAliasTest, CanBeKeysInStdUnorderedMap) { using FooAlias = StrongAlias<class FooTag, TypeParam>; - std::unordered_map<FooAlias, std::string, typename FooAlias::Hasher> map; + std::unordered_map<FooAlias, std::string> map; FooAlias k1(GetExampleValue<TypeParam>(0)); FooAlias k2(GetExampleValue<TypeParam>(1));
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 33a232ed..8810926 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn
@@ -1823,9 +1823,6 @@ # Note we apply the actual lint flags in config("compiler"). All warnings # are suppressed in third-party crates. rustflags = [ "-Dwarnings" ] - - # TODO(https://crbug.com/326247202): Fix unused imports and remove this flag. - rustflags += [ "-Aunused-imports" ] } # default_warnings ------------------------------------------------------------
diff --git a/buildtools/deps_revisions.gni b/buildtools/deps_revisions.gni index e8c41876..1986be1 100644 --- a/buildtools/deps_revisions.gni +++ b/buildtools/deps_revisions.gni
@@ -5,5 +5,5 @@ declare_args() { # Used to cause full rebuilds on libc++ rolls. This should be kept in sync # with the libcxx_revision var in //DEPS. - libcxx_revision = "b4511937e4e55617e26ba3912e0dc169443e0c00" + libcxx_revision = "80194f087251d7ad235ffbf4c602786208bdb863" }
diff --git a/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/sheet_component/AccessorySheetRenderTest.java b/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/sheet_component/AccessorySheetRenderTest.java index 3bb1215b..1da99a3b 100644 --- a/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/sheet_component/AccessorySheetRenderTest.java +++ b/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/sheet_component/AccessorySheetRenderTest.java
@@ -35,7 +35,6 @@ import org.mockito.junit.MockitoRule; import org.chromium.base.Callback; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.BaseActivityTestRule; import org.chromium.base.test.params.ParameterAnnotations; @@ -76,9 +75,7 @@ import org.chromium.ui.test.util.ViewUtils; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * These tests render screenshots of various accessory sheets and compare them to a gold standard. @@ -116,10 +113,6 @@ @Mock private PersonalDataManager mPersonalDataManager; public AccessorySheetRenderTest(boolean nightModeEnabled, boolean useRtlLayout) { - Map<String, Boolean> featureMap = new HashMap<>(); - featureMap.put(ChromeFeatureList.AUTOFILL_ENABLE_NEW_CARD_ART_AND_NETWORK_IMAGES, false); - FeatureList.setTestFeatures(featureMap); - setRtlForTesting(useRtlLayout); NightModeTestUtils.setUpNightModeForBlankUiTestActivity(nightModeEnabled); mRenderTestRule.setNightModeEnabled(nightModeEnabled);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/base/SplitChromeApplication.java b/chrome/android/java/src/org/chromium/chrome/browser/base/SplitChromeApplication.java index 6e66774..2e5aa583 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/base/SplitChromeApplication.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/base/SplitChromeApplication.java
@@ -79,7 +79,7 @@ private Context createContextForSplitNoWait(String name) { synchronized (sSplitLock) { - boolean shouldRecordHistogram = sCachedSplits.contains(name); + boolean shouldRecordHistogram = !sCachedSplits.contains(name); try { long startTime = SystemClock.uptimeMillis(); Context context = super.createContextForSplit(name);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUi.java b/chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUi.java index 39fc6a4..7510e61 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUi.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUi.java
@@ -161,29 +161,33 @@ // Request notification permission if needed. ContextualNotificationPermissionRequester.getInstance().requestPermissionIfNeeded(); - DownloadInfo info = DownloadInfo.fromOfflineItem(item, visuals); - switch (item.state) { - case OfflineItemState.IN_PROGRESS: - mUi.notifyDownloadProgress(info, item.creationTimeMs, item.allowMetered); - break; - case OfflineItemState.COMPLETE: - mUi.notifyDownloadSuccessful(info, -1L, false, item.isOpenable); - break; - case OfflineItemState.INTERRUPTED: - mUi.notifyDownloadInterrupted( - info, !LegacyHelpers.isLegacyDownload(item.id), item.pendingState); - break; - case OfflineItemState.PAUSED: - mUi.notifyDownloadPaused(info); - break; - case OfflineItemState.FAILED: - mUi.notifyDownloadFailed(info); - break; - case OfflineItemState.PENDING: - mUi.notifyDownloadPaused(info); - break; - default: - assert false : "Unexpected OfflineItem state."; + try { + DownloadInfo info = DownloadInfo.fromOfflineItem(item, visuals); + switch (item.state) { + case OfflineItemState.IN_PROGRESS: + mUi.notifyDownloadProgress(info, item.creationTimeMs, item.allowMetered); + break; + case OfflineItemState.COMPLETE: + mUi.notifyDownloadSuccessful(info, -1L, false, item.isOpenable); + break; + case OfflineItemState.INTERRUPTED: + mUi.notifyDownloadInterrupted( + info, !LegacyHelpers.isLegacyDownload(item.id), item.pendingState); + break; + case OfflineItemState.PAUSED: + mUi.notifyDownloadPaused(info); + break; + case OfflineItemState.FAILED: + mUi.notifyDownloadFailed(info); + break; + case OfflineItemState.PENDING: + mUi.notifyDownloadPaused(info); + break; + default: + assert false : "Unexpected OfflineItem state."; + } + } catch (IllegalStateException e) { + mUi.notifyDownloadCanceled(item.id); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java index 6a83fde..62c90c5 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java
@@ -33,7 +33,6 @@ import org.chromium.chrome.browser.back_press.SecondaryActivityBackPressUma.SecondaryActivity; import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.feature_engagement.TrackerFactory; -import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.metrics.UmaUtils; import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; import org.chromium.chrome.browser.profiles.Profile; @@ -432,10 +431,7 @@ private void onNativeDependenciesFullyInitialized() { mNativeInitializationPromise.fulfill(null); - if (ChromeFeatureList.isEnabled( - ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS)) { - mPager.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT); - } + mPager.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT); onInternalStateChanged(); }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuRenderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuRenderTest.java index af0083a..98a469e 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuRenderTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/ContextMenuRenderTest.java
@@ -21,7 +21,6 @@ import org.junit.Test; import org.junit.runner.RunWith; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.BaseActivityTestRule; import org.chromium.base.test.params.ParameterAnnotations; @@ -124,7 +123,6 @@ NightModeTestUtils.tearDownNightModeForBlankUiTestActivity(); mListItems.clear(); }); - FeatureList.setTestValues(null); } @Test
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLocationDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLocationDialogTest.java index 74813fb5..b23599b 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLocationDialogTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/dialogs/DownloadLocationDialogTest.java
@@ -28,10 +28,10 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.BaseActivityTestRule; import org.chromium.base.test.util.CommandLineFlags; +import org.chromium.base.test.util.Features.DisableFeatures; import org.chromium.chrome.R; import org.chromium.chrome.browser.download.DirectoryOption; import org.chromium.chrome.browser.download.DownloadDialogBridge; @@ -54,12 +54,11 @@ import org.chromium.ui.test.util.BlankUiTestActivity; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; /** Test focus on verifying UI elements in the download location dialog. */ @RunWith(ChromeJUnit4ClassRunner.class) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) +@DisableFeatures(ChromeFeatureList.SMART_SUGGESTION_FOR_LARGE_DOWNLOADS) public class DownloadLocationDialogTest { private static final long TOTAL_BYTES = 1024L; private static final String SUGGESTED_PATH = "download.png"; @@ -102,9 +101,6 @@ return new ModalDialogManager( mAppModalPresenter, ModalDialogManager.ModalDialogType.APP); }); - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.SMART_SUGGESTION_FOR_LARGE_DOWNLOADS, false); - FeatureList.setTestFeatures(features); setDownloadPromptStatus(DownloadPromptStatus.SHOW_INITIAL); ThreadUtils.runOnUiThreadBlocking(
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationHandlerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationHandlerTest.java index 0a5a5cc..ef7a7bc3 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationHandlerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationHandlerTest.java
@@ -24,7 +24,6 @@ import org.chromium.base.ActivityState; import org.chromium.base.ApplicationStatus; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.util.Batch; import org.chromium.base.test.util.CommandLineFlags; @@ -65,7 +64,6 @@ import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.UiAndroidFeatures; -import java.util.Map; import java.util.concurrent.TimeoutException; /** Tests {@link NavigationHandler} navigating back/forward using overscroll history navigation. */ @@ -490,16 +488,16 @@ @Test @SmallTest + @DisableFeatures(ChromeFeatureList.BACK_FORWARD_TRANSITIONS) public void testLeftEdgeSwipeClosesTabLaunchedFromLink() { - FeatureList.setTestFeatures(Map.of(ChromeFeatureList.BACK_FORWARD_TRANSITIONS, false)); testLeftEdgeSwipeClosesTabLaunchedFromLinkInternal(); } @Test @SmallTest + @EnableFeatures(ChromeFeatureList.BACK_FORWARD_TRANSITIONS) @DisabledTest(message = "crbug.com/1426201") public void testLeftEdgeSwipeClosesTabLaunchedFromLink_withBackForwardTransition() { - FeatureList.setTestFeatures(Map.of(ChromeFeatureList.BACK_FORWARD_TRANSITIONS, true)); testLeftEdgeSwipeClosesTabLaunchedFromLinkInternal(); }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationTransitionsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationTransitionsTest.java index fa9490e..31bbbe4 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationTransitionsTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/gesturenav/NavigationTransitionsTest.java
@@ -462,6 +462,7 @@ */ @Test @MediumTest + @DisabledTest(message = "crbug.com/385189006") public void startBackNavWithTopControlHidden() throws Throwable { if (mTestNavigationMode == NAVIGATION_MODE_GESTURAL && VERSION.SDK_INT < VERSION_CODES.UPSIDE_DOWN_CAKE) return;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/reengagement/ReengagementNotificationControllerIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/reengagement/ReengagementNotificationControllerIntegrationTest.java index 9172285..679ac31 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/reengagement/ReengagementNotificationControllerIntegrationTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/reengagement/ReengagementNotificationControllerIntegrationTest.java
@@ -33,12 +33,13 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CriteriaHelper; import org.chromium.base.test.util.DisabledTest; +import org.chromium.base.test.util.Features.DisableFeatures; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.base.test.util.UrlUtils; import org.chromium.chrome.browser.DefaultBrowserInfo2; import org.chromium.chrome.browser.app.reengagement.ReengagementActivity; @@ -60,12 +61,13 @@ import org.chromium.components.feature_engagement.Tracker; import org.chromium.content_public.common.ContentUrlConstants; -import java.util.HashMap; -import java.util.Map; - /** Integration tests for {@link ReengagementNotificationController}. */ @RunWith(ChromeJUnit4ClassRunner.class) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) +@EnableFeatures(ChromeFeatureList.REENGAGEMENT_NOTIFICATION) +// TODO(crbug.com/40142646): Remove these overrides when FeatureList#isInitialized() works +// as expected with test values +@DisableFeatures(ChromeFeatureList.VOICE_SEARCH_AUDIO_CAPTURE_POLICY) public class ReengagementNotificationControllerIntegrationTest { @Rule public ChromeTabbedActivityTestRule mTabbedActivityTestRule = @@ -81,7 +83,6 @@ @Before public void setUp() throws Exception { reset(mTracker); - setReengagementNotificationEnabled(true); TrackerFactory.setTrackerForTests(mTracker); closeReengagementNotifications(); } @@ -229,9 +230,9 @@ @Test @SmallTest + @DisableFeatures(ChromeFeatureList.REENGAGEMENT_NOTIFICATION) @DisabledTest(message = "crbug.com/1112519 - Disabled while safety guard is in place.") public void testEngagementTrackedWhenDisabled() { - setReengagementNotificationEnabled(false); mTabbedActivityTestRule.startMainActivityFromLauncher(); verify(mTracker, times(1)).notifyEvent(EventConstants.STARTED_FROM_MAIN_INTENT); } @@ -246,8 +247,8 @@ @Test @MediumTest + @DisableFeatures(ChromeFeatureList.REENGAGEMENT_NOTIFICATION) public void testEngagementNotificationNotSentDueToDisabled() { - setReengagementNotificationEnabled(false); DefaultBrowserInfo2.setDefaultInfoForTests( createDefaultInfo(/* passesPrecondition= */ true)); mCustomTabActivityTestRule.startCustomTabActivityWithIntent( @@ -379,13 +380,4 @@ browserCount, /* systemCount= */ 0); } - - private static void setReengagementNotificationEnabled(boolean enabled) { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.REENGAGEMENT_NOTIFICATION, enabled); - // TODO(crbug.com/40142646): Remove these overrides when FeatureList#isInitialized() works - // as expected with test values. - features.put(ChromeFeatureList.VOICE_SEARCH_AUDIO_CAPTURE_POLICY, false); - FeatureList.setTestFeatures(features); - } }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegateUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegateUnitTest.java index ee6c0fe..996f38c 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegateUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegateUnitTest.java
@@ -21,10 +21,10 @@ import org.mockito.MockitoAnnotations; import org.chromium.base.ContextUtils; -import org.chromium.base.FeatureList; import org.chromium.base.supplier.ObservableSupplierImpl; import org.chromium.base.supplier.Supplier; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.Features.DisableFeatures; import org.chromium.chrome.R; import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.bookmarks.BookmarkModel; @@ -42,11 +42,14 @@ import org.chromium.url.GURL; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; /** Unit tests for {@link CustomTabAppMenuPropertiesDelegate}. */ @RunWith(BaseRobolectricTestRunner.class) +@DisableFeatures({ + ChromeFeatureList.READALOUD_IN_OVERFLOW_MENU_IN_CCT, + ContentFeatureList.ANDROID_OPEN_PDF_INLINE, + ChromeFeatureList.ANDROID_OPEN_PDF_INLINE_BACKPORT +}) public class CustomTabAppMenuPropertiesDelegateUnitTest { @Mock private ActivityTabProvider mActivityTabProvider; @Mock private Tab mTab; @@ -70,11 +73,6 @@ when(mActivityTabProvider.get()).thenReturn(mTab); when(mTab.getUrl()).thenReturn(new GURL("https://google.com")); when(mTab.isNativePage()).thenReturn(false); - Map<String, Boolean> featureMap = new HashMap<>(); - featureMap.put(ChromeFeatureList.READALOUD_IN_OVERFLOW_MENU_IN_CCT, false); - featureMap.put(ContentFeatureList.ANDROID_OPEN_PDF_INLINE, false); - featureMap.put(ChromeFeatureList.ANDROID_OPEN_PDF_INLINE_BACKPORT, false); - FeatureList.setTestFeatures(featureMap); } private Menu createMenu(Context context, int menuResourceId) {
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/RealtimeEngagementSignalObserverUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/RealtimeEngagementSignalObserverUnitTest.java index ff715ec7..9ff93e2 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/RealtimeEngagementSignalObserverUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/customtabs/content/RealtimeEngagementSignalObserverUnitTest.java
@@ -41,7 +41,6 @@ import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowSystemClock; -import org.chromium.base.FeatureList; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.cc.mojom.RootScrollOffsetUpdateFrequency; import org.chromium.chrome.browser.customtabs.content.RealtimeEngagementSignalObserver.ScrollState; @@ -98,7 +97,6 @@ @After public void tearDown() { RealtimeEngagementSignalObserver.ScrollState.setInstanceForTesting(null); - FeatureList.setTestValues(null); } @Test
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/feed/FeedActionDelegateImplTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/feed/FeedActionDelegateImplTest.java index 5e2afa0e..f292870 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/feed/FeedActionDelegateImplTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/feed/FeedActionDelegateImplTest.java
@@ -15,8 +15,6 @@ import android.app.Activity; import android.content.Intent; -import com.google.common.collect.ImmutableMap; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -26,8 +24,9 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.chromium.base.FeatureList; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.Features.DisableFeatures; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.chrome.browser.app.feed.FeedActionDelegateImpl; import org.chromium.chrome.browser.bookmarks.BookmarkModel; import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge; @@ -101,27 +100,24 @@ } @Test + @EnableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND) public void testShowSyncConsentActivity_shownWhenFlagEnabled() { - FeatureList.setTestFeatures( - ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, true)); mFeedActionDelegateImpl.showSyncConsentActivity(SigninAccessPoint.NTP_FEED_TOP_PROMO); verify(mMockSyncConsentActivityLauncher) .launchActivityIfAllowed(any(), eq(SigninAccessPoint.NTP_FEED_TOP_PROMO)); } @Test + @DisableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND) public void testShowSyncConsentActivity_dontShowWhenFlagDisabled() { - FeatureList.setTestFeatures( - ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, false)); mFeedActionDelegateImpl.showSyncConsentActivity(SigninAccessPoint.NTP_FEED_TOP_PROMO); verify(mMockSyncConsentActivityLauncher, never()) .launchActivityIfAllowed(any(), eq(SigninAccessPoint.NTP_FEED_TOP_PROMO)); } @Test + @EnableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND) public void testStartSigninFlow_shownWhenFlagEnabled() { - FeatureList.setTestFeatures( - ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, true)); when(mMockSigninAndHistorySyncActivityLauncher.createBottomSheetSigninIntentOrShowError( any(), any(), any(), eq(SigninAccessPoint.NTP_FEED_TOP_PROMO))) .thenReturn(mSigninIntent); @@ -146,9 +142,8 @@ } @Test + @DisableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND) public void testStartSigninFlow_dontShowWhenFlagDisabled() { - FeatureList.setTestFeatures( - ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, false)); mFeedActionDelegateImpl.startSigninFlow(SigninAccessPoint.NTP_FEED_TOP_PROMO); verify(mMockSigninAndHistorySyncActivityLauncher, never()) .createBottomSheetSigninIntentOrShowError( @@ -156,9 +151,8 @@ } @Test + @EnableFeatures(ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS) public void testShowSigninInterstitial_replaceSyncPromosWithSignInPromosEnabled() { - FeatureList.setTestFeatures( - ImmutableMap.of(ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS, true)); when(mMockSigninAndHistorySyncActivityLauncher.createBottomSheetSigninIntentOrShowError( any(), any(), any(), eq(SigninAccessPoint.NTP_FEED_CARD_MENU_PROMO))) .thenReturn(mSigninIntent); @@ -183,8 +177,8 @@ } @Test + @EnableFeatures(ChromeFeatureList.CORMORANT) public void testOpenWebFeed_enabledWhenCormorantFlagEnabled() { - FeatureList.setTestFeatures(ImmutableMap.of(ChromeFeatureList.CORMORANT, true)); String webFeedName = "SomeFeedName"; mFeedActionDelegateImpl.openWebFeed(webFeedName, SingleWebFeedEntryPoint.OTHER); @@ -197,9 +191,9 @@ } @Test + @DisableFeatures(ChromeFeatureList.CORMORANT) public void testOpenWebFeed_disabledWhenCormorantFlagDisabled() { when(mWebFeedBridgeJniMock.isCormorantEnabledForLocale()).thenReturn(false); - FeatureList.setTestFeatures(ImmutableMap.of(ChromeFeatureList.CORMORANT, false)); mFeedActionDelegateImpl.openWebFeed("SomeFeedName", SingleWebFeedEntryPoint.OTHER); verify(mActivity, never()).startActivity(any()); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/omaha/OmahaBaseTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/omaha/OmahaBaseTest.java index 9fbf9df..1ceb0a81 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/omaha/OmahaBaseTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/omaha/OmahaBaseTest.java
@@ -18,7 +18,6 @@ import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.FakeTimeTestRule; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Batch; @@ -199,7 +198,6 @@ @After public void tearDown() { - FeatureList.setTestValues(null); OmahaBase.setIsDisabledForTesting(true); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/tab/RequestDesktopUtilsUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/tab/RequestDesktopUtilsUnitTest.java index c61f55c1..f58bc9b 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/tab/RequestDesktopUtilsUnitTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/tab/RequestDesktopUtilsUnitTest.java
@@ -42,7 +42,6 @@ import org.robolectric.shadows.ShadowPackageManager; import org.chromium.base.ContextUtils; -import org.chromium.base.FeatureList; import org.chromium.base.FeatureList.TestValues; import org.chromium.base.ResettersForTesting; import org.chromium.base.SysUtils; @@ -289,7 +288,6 @@ @After public void tearDown() { - FeatureList.setTestValues(null); ShadowDisplayAndroid.setDisplayAndroid(null); if (mSharedPreferencesManager != null) { mSharedPreferencesManager.removeKey(
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 8a3568c..f71ee00 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -3298,6 +3298,7 @@ "//components/browsing_data/content/android:jni_headers", "//components/cbor", "//components/cdm/browser", + "//components/collaboration/public:conversion_utils", "//components/commerce/core:commerce_subscription_db_content_proto", "//components/commerce/core:feature_list", "//components/commerce/core:heuristics_provider", @@ -8941,9 +8942,6 @@ deps += [ "//services/resource_coordinator/public/mojom:mojom_js" ] } - if (is_android) { - deps += [ "//chrome/browser/resources/offline_pages:build_ts" ] - } if (is_chromeos_ash) { deps += [ "//chrome/browser/resources/chromeos/account_manager:css_wrapper_files",
diff --git a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.cc b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.cc index 87c77f2..206bb148 100644 --- a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.cc +++ b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.cc
@@ -277,8 +277,13 @@ const std::string& source_language, const std::string& target_language, bool is_final, - const std::string& result) { - std::string formatted_result = result; + const captions::TranslateEvent& result) { + // TODO(384019306) Maybe report metrics on failure? + if (!result.has_value()) { + return; + } + + std::string formatted_result = result.value(); // Don't cache the translation if the source language is an ideographic // language but the target language is not to avoid translate // sentence by sentence because the Cloud Translation API does not properly @@ -288,7 +293,7 @@ if (is_final) { translation_cache_.Clear(); } else { - translation_cache_.InsertIntoCache(original_transcription, result, + translation_cache_.InsertIntoCache(original_transcription, result.value(), source_language, target_language); } } else { @@ -303,9 +308,9 @@ } } - LiveCaptionController* live_caption_controller = GetLiveCaptionController(); auto text = base::StrCat({cached_translation, formatted_result}); + LiveCaptionController* live_caption_controller = GetLiveCaptionController(); stop_transcriptions_ = !live_caption_controller->DispatchTranscription( context_.get(), media::SpeechRecognitionResult( GetTextForDispatch(text, is_final), is_final));
diff --git a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.h b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.h index 55c9d157..e3b78b7c 100644 --- a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.h +++ b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.h
@@ -82,7 +82,7 @@ const std::string& source_language, const std::string& target_language, bool is_final, - const std::string& result); + const captions::TranslateEvent& result); // Returns the WebContents if it exists. If it does not exist, sets the // RenderFrameHost reference to nullptr and returns nullptr.
diff --git a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.cc b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.cc index 2a516c9a..6ac438c 100644 --- a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.cc +++ b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.cc
@@ -18,6 +18,7 @@ #include "components/live_caption/live_caption_controller.h" #include "components/live_caption/live_translate_controller.h" #include "components/live_caption/pref_names.h" +#include "components/live_caption/translation_util.h" #include "components/prefs/pref_service.h" #include "components/sync_preferences/pref_service_syncable.h" #include "content/public/browser/render_frame_host.h" @@ -58,9 +59,9 @@ const std::string& result, std::string source_language, std::string target_language, - OnTranslateEventCallback callback) { + TranslateEventCallback callback) { translation_requests_.push_back(result); - std::move(callback).Run(result); + std::move(callback).Run(TranslateEvent(result)); } std::vector<std::string> MockLiveTranslateController::GetTranslationRequests() {
diff --git a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.h b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.h index 9c1fae96..d3fc4eb 100644 --- a/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.h +++ b/chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.h
@@ -5,12 +5,11 @@ #ifndef CHROME_BROWSER_ACCESSIBILITY_LIVE_CAPTION_LIVE_CAPTION_SPEECH_RECOGNITION_HOST_BROWSERTEST_H_ #define CHROME_BROWSER_ACCESSIBILITY_LIVE_CAPTION_LIVE_CAPTION_SPEECH_RECOGNITION_HOST_BROWSERTEST_H_ -#include "chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.h" - #include <string> #include <vector> #include "chrome/browser/accessibility/live_caption/live_caption_controller_factory.h" +#include "chrome/browser/accessibility/live_caption/live_caption_speech_recognition_host.h" #include "chrome/browser/accessibility/live_caption/live_caption_test_util.h" #include "chrome/browser/accessibility/live_translate_controller_factory.h" #include "chrome/browser/profiles/profile.h" @@ -21,6 +20,7 @@ #include "components/live_caption/live_caption_controller.h" #include "components/live_caption/live_translate_controller.h" #include "components/live_caption/pref_names.h" +#include "components/live_caption/translation_util.h" #include "components/prefs/pref_service.h" #include "components/sync_preferences/pref_service_syncable.h" #include "content/public/browser/render_frame_host.h" @@ -60,7 +60,7 @@ void GetTranslation(const std::string& result, std::string source_language, std::string target_language, - OnTranslateEventCallback callback) override; + TranslateEventCallback callback) override; // Returns a collection of strings passed into `GetTranslation()`. std::vector<std::string> GetTranslationRequests();
diff --git a/chrome/browser/android/partner_browser_customizations.cc b/chrome/browser/android/partner_browser_customizations.cc index 2cb3d369..06670af2 100644 --- a/chrome/browser/android/partner_browser_customizations.cc +++ b/chrome/browser/android/partner_browser_customizations.cc
@@ -9,7 +9,6 @@ // Must come after all headers that specialize FromJniType() / ToJniType(). #include "chrome/browser/partnercustomizations/jni_headers/PartnerBrowserCustomizations_jni.h" -namespace chrome { namespace android { bool PartnerBrowserCustomizations::IsIncognitoDisabled() { @@ -18,4 +17,3 @@ } } // namespace android -} // namespace chrome
diff --git a/chrome/browser/android/partner_browser_customizations.h b/chrome/browser/android/partner_browser_customizations.h index 7d8d9be..b9e8c1af 100644 --- a/chrome/browser/android/partner_browser_customizations.h +++ b/chrome/browser/android/partner_browser_customizations.h
@@ -5,7 +5,6 @@ #ifndef CHROME_BROWSER_ANDROID_PARTNER_BROWSER_CUSTOMIZATIONS_H_ #define CHROME_BROWSER_ANDROID_PARTNER_BROWSER_CUSTOMIZATIONS_H_ -namespace chrome { namespace android { class PartnerBrowserCustomizations { @@ -20,6 +19,5 @@ }; } // namespace android -} // namespace chrome #endif // CHROME_BROWSER_ANDROID_PARTNER_BROWSER_CUSTOMIZATIONS_H_
diff --git a/chrome/browser/apps/app_service/publisher_host.cc b/chrome/browser/apps/app_service/publisher_host.cc index 1ac91f23..e420385 100644 --- a/chrome/browser/apps/app_service/publisher_host.cc +++ b/chrome/browser/apps/app_service/publisher_host.cc
@@ -15,6 +15,7 @@ #include "chrome/browser/apps/app_service/publishers/extension_apps_chromeos.h" #include "chrome/browser/apps/app_service/publishers/plugin_vm_apps.h" #include "chrome/browser/ash/guest_os/guest_os_registry_service_factory.h" +#include "chrome/browser/profiles/profile.h" #include "chromeos/ash/components/browser_context_helper/browser_context_helper.h" #include "components/user_manager/user.h" #endif
diff --git a/chrome/browser/apps/link_capturing/web_app_link_capturing_delegate.cc b/chrome/browser/apps/link_capturing/web_app_link_capturing_delegate.cc index ce6f26d8..0fcc6d4 100644 --- a/chrome/browser/apps/link_capturing/web_app_link_capturing_delegate.cc +++ b/chrome/browser/apps/link_capturing/web_app_link_capturing_delegate.cc
@@ -8,10 +8,12 @@ #include "base/functional/bind.h" #include "base/memory/values_equivalent.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/web_applications/web_app_command_scheduler.h" #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_tab_helper.h" +#include "chrome/browser/web_applications/web_app_ui_manager.h" #include "chrome/browser/web_applications/web_app_utils.h" #include "components/webapps/common/web_app_id.h" #include "content/public/browser/navigation_handle.h"
diff --git a/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.cc b/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.cc index 098d9de..4ba2161 100644 --- a/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.cc +++ b/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.cc
@@ -318,8 +318,13 @@ const std::string& source_language, const std::string& target_language, bool is_final, - const std::string& result) { - std::string formatted_result = result; + const ::captions::TranslateEvent& event) { + // TODO(384019306) Maybe record dispatcher error metric? + if (!event.has_value()) { + return; + } + + std::string formatted_result = event.value(); // Don't cache the translation if the source language is an ideographic // language but the target language is not. This avoids translate // sentence by sentence because the Cloud Translation API does not properly @@ -329,7 +334,7 @@ if (is_final) { translation_cache_.Clear(); } else { - translation_cache_.InsertIntoCache(original_transcription, result, + translation_cache_.InsertIntoCache(original_transcription, event.value(), source_language, target_language); } } else { @@ -345,7 +350,11 @@ } auto text = base::StrCat({cached_translation, formatted_result}); + AttemptDispatch(text, is_final); +} +void SystemLiveCaptionService::AttemptDispatch(const std::string& text, + bool is_final) { if (!controller_->DispatchTranscription( &context_, media::SpeechRecognitionResult(text, is_final))) { StopRecognizing();
diff --git a/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.h b/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.h index 848aa4d..41c08184 100644 --- a/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.h +++ b/chrome/browser/ash/accessibility/live_caption/system_live_caption_service.h
@@ -114,7 +114,9 @@ const std::string& source_language, const std::string& target_language, bool is_final, - const std::string& result); + const ::captions::TranslateEvent& result); + + void AttemptDispatch(const std::string& text, bool is_final); // Binds to the correct observer list based on `source_` void BindToBrowserInterface();
diff --git a/chrome/browser/ash/app_list/app_context_menu.cc b/chrome/browser/ash/app_list/app_context_menu.cc index 47c5c4b..863316a 100644 --- a/chrome/browser/ash/app_list/app_context_menu.cc +++ b/chrome/browser/ash/app_list/app_context_menu.cc
@@ -21,7 +21,6 @@ #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" #include "ui/color/color_id.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" #include "ui/views/vector_icons.h" @@ -136,14 +135,14 @@ return views::kNewIncognitoWindowIcon; case ash::INSTALL: // Deprecated. - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); case ash::SETTINGS: return vector_icons::kSettingsIcon; case ash::USE_LAUNCH_TYPE_REGULAR: case ash::USE_LAUNCH_TYPE_WINDOW: case ash::USE_LAUNCH_TYPE_TABBED_WINDOW: // Check items use the default icon. - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); case ash::DEPRECATED_USE_LAUNCH_TYPE_PINNED: case ash::DEPRECATED_USE_LAUNCH_TYPE_FULLSCREEN: NOTREACHED();
diff --git a/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.cc b/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.cc index 7b218df..b567c74 100644 --- a/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.cc +++ b/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.cc
@@ -19,6 +19,7 @@ #include "chrome/browser/web_applications/web_app_registrar.h" #include "components/account_id/account_id.h" #include "components/webapps/common/web_app_id.h" +#include "services/network/public/cpp/shared_url_loader_factory.h" namespace ash {
diff --git a/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.h b/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.h index 73fd0fb5..bfef875 100644 --- a/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.h +++ b/chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_launcher.h
@@ -11,7 +11,6 @@ #include "base/memory/raw_ref.h" #include "base/memory/weak_ptr.h" #include "base/values.h" -#include "chrome/browser/ash/app_mode/isolated_web_app/kiosk_iwa_data.h" #include "chrome/browser/ash/app_mode/kiosk_app_launcher.h" #include "chrome/browser/ash/app_mode/kiosk_web_app_launcher_base.h" #include "chrome/browser/profiles/profile.h" @@ -20,6 +19,7 @@ #include "components/webapps/common/web_app_id.h" namespace ash { +class KioskIwaData; // TODO(crbug.com/374730382): Add unit tests. class KioskIwaLauncher : public KioskWebAppLauncherBase {
diff --git a/chrome/browser/ash/boca/babelorca/BUILD.gn b/chrome/browser/ash/boca/babelorca/BUILD.gn index 7e6ed74..150fc19 100644 --- a/chrome/browser/ash/boca/babelorca/BUILD.gn +++ b/chrome/browser/ash/boca/babelorca/BUILD.gn
@@ -25,5 +25,6 @@ "//components/live_caption", "//components/live_caption:constants", "//components/live_caption:live_translate", + "//components/live_caption:utils", ] }
diff --git a/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.cc b/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.cc index 0c33f6d..a230fd22 100644 --- a/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.cc +++ b/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.cc
@@ -8,6 +8,7 @@ #include <string> #include "components/live_caption/translation_dispatcher.h" +#include "components/live_caption/translation_util.h" namespace ash { @@ -22,7 +23,7 @@ const std::string& result, const std::string& source_language, const std::string& target_language, - captions::OnTranslateEventCallback callback) { + captions::TranslateEventCallback callback) { translation_dispatcher_->GetTranslation(result, source_language, target_language, std::move(callback)); }
diff --git a/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.h b/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.h index 0df229be..a0b916b5 100644 --- a/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.h +++ b/chrome/browser/ash/boca/babelorca/babel_orca_translation_dispatcher_impl.h
@@ -10,6 +10,7 @@ #include "chromeos/ash/components/boca/babelorca/babel_orca_translation_dispatcher.h" #include "components/live_caption/translation_dispatcher.h" +#include "components/live_caption/translation_util.h" namespace ash { @@ -30,7 +31,7 @@ void GetTranslation(const std::string& result, const std::string& source_language, const std::string& target_language, - ::captions::OnTranslateEventCallback callback) override; + ::captions::TranslateEventCallback callback) override; private: const std::unique_ptr<::captions::TranslationDispatcher>
diff --git a/chrome/browser/ash/child_accounts/on_device_controls/app_controls_notifier.cc b/chrome/browser/ash/child_accounts/on_device_controls/app_controls_notifier.cc index 822c7527..d10314e 100644 --- a/chrome/browser/ash/child_accounts/on_device_controls/app_controls_notifier.cc +++ b/chrome/browser/ash/child_accounts/on_device_controls/app_controls_notifier.cc
@@ -116,7 +116,7 @@ base::MakeRefCounted<message_center::HandleNotificationClickDelegate>( base::BindRepeating(&AppControlsNotifier::HandleClick, weak_ptr_factory_.GetWeakPtr())), - /*small_image=*/gfx::VectorIcon(), + /*small_image=*/gfx::VectorIcon::EmptyIcon(), message_center::SystemNotificationWarningLevel::NORMAL); NotificationDisplayServiceFactory::GetForProfile(profile_)->Display(
diff --git a/chrome/browser/ash/crostini/crostini_upgrade_available_notification.cc b/chrome/browser/ash/crostini/crostini_upgrade_available_notification.cc index d0f0759..24ce9d138 100644 --- a/chrome/browser/ash/crostini/crostini_upgrade_available_notification.cc +++ b/chrome/browser/ash/crostini/crostini_upgrade_available_notification.cc
@@ -22,6 +22,7 @@ #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" +#include "ui/gfx/paint_vector_icon.h" namespace crostini {
diff --git a/chrome/browser/ash/file_manager/virtual_tasks/DEPS b/chrome/browser/ash/file_manager/virtual_tasks/DEPS index d270ec7c..ba93114 100644 --- a/chrome/browser/ash/file_manager/virtual_tasks/DEPS +++ b/chrome/browser/ash/file_manager/virtual_tasks/DEPS
@@ -24,6 +24,7 @@ "+chrome/browser/web_applications/isolated_web_apps", "+chrome/browser/web_applications/test", "+chrome/browser/web_applications/web_app_provider.h", + "+chrome/browser/web_applications/web_app_ui_manager.h", "+chrome/browser/web_applications/web_app_utils.h", "+chrome/common/chrome_features.h", "+chrome/test/base",
diff --git a/chrome/browser/ash/file_manager/virtual_tasks/install_isolated_web_app_virtual_task.cc b/chrome/browser/ash/file_manager/virtual_tasks/install_isolated_web_app_virtual_task.cc index 0b879be2..1e4ef09 100644 --- a/chrome/browser/ash/file_manager/virtual_tasks/install_isolated_web_app_virtual_task.cc +++ b/chrome/browser/ash/file_manager/virtual_tasks/install_isolated_web_app_virtual_task.cc
@@ -17,6 +17,7 @@ #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_features.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager.h" #include "chrome/browser/web_applications/web_app_provider.h" +#include "chrome/browser/web_applications/web_app_ui_manager.h" #include "chrome/browser/web_applications/web_app_utils.h" #include "components/services/app_service/public/cpp/intent_util.h" #include "content/public/browser/isolated_web_apps_policy.h"
diff --git a/chrome/browser/ash/login/signin/authentication_flow_auto_reload_manager.cc b/chrome/browser/ash/login/signin/authentication_flow_auto_reload_manager.cc index 10fe9df..089ce7c1 100644 --- a/chrome/browser/ash/login/signin/authentication_flow_auto_reload_manager.cc +++ b/chrome/browser/ash/login/signin/authentication_flow_auto_reload_manager.cc
@@ -6,6 +6,7 @@ #include <functional> +#include "base/time/clock.h" #include "chrome/browser/ash/login/login_constants.h" #include "chrome/browser/ash/login/login_pref_names.h" #include "chrome/browser/browser_process.h"
diff --git a/chrome/browser/ash/login/signin/offline_signin_limiter_unittest.cc b/chrome/browser/ash/login/signin/offline_signin_limiter_unittest.cc index 56aa79c7..c21bf7de 100644 --- a/chrome/browser/ash/login/signin/offline_signin_limiter_unittest.cc +++ b/chrome/browser/ash/login/signin/offline_signin_limiter_unittest.cc
@@ -10,6 +10,7 @@ #include "base/memory/raw_ptr.h" #include "base/test/power_monitor_test.h" #include "base/test/task_environment.h" +#include "base/time/clock.h" #include "base/time/time.h" #include "base/timer/wall_clock_timer.h" #include "chrome/browser/ash/login/login_constants.h"
diff --git a/chrome/browser/ash/notifications/gnubby_notification.cc b/chrome/browser/ash/notifications/gnubby_notification.cc index b3e6ce3..0692ff7 100644 --- a/chrome/browser/ash/notifications/gnubby_notification.cc +++ b/chrome/browser/ash/notifications/gnubby_notification.cc
@@ -14,6 +14,7 @@ #include "chrome/grit/generated_resources.h" #include "chromeos/ash/components/dbus/gnubby/gnubby_client.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notification_delegate.h" @@ -54,7 +55,7 @@ new message_center::HandleNotificationClickDelegate( base::BindRepeating(&GnubbyNotification::DismissNotification, weak_ptr_factory_.GetWeakPtr())), - gfx::VectorIcon(), colorType); + gfx::VectorIcon::EmptyIcon(), colorType); } void GnubbyNotification::ShowNotification() {
diff --git a/chrome/browser/ash/policy/core/browser_policy_connector_ash.cc b/chrome/browser/ash/policy/core/browser_policy_connector_ash.cc index fc69ad73..842b6a9b 100644 --- a/chrome/browser/ash/policy/core/browser_policy_connector_ash.cc +++ b/chrome/browser/ash/policy/core/browser_policy_connector_ash.cc
@@ -28,6 +28,7 @@ #include "base/task/sequenced_task_runner.h" #include "base/task/single_thread_task_runner.h" #include "base/task/thread_pool.h" +#include "base/time/default_clock.h" #include "chrome/browser/ash/cert_provisioning/cert_provisioning_common.h" #include "chrome/browser/ash/notifications/adb_sideloading_policy_change_notification.h" #include "chrome/browser/ash/policy/core/device_cloud_policy_store_ash.h"
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_reboot_job_test_util.h b/chrome/browser/ash/policy/remote_commands/device_command_reboot_job_test_util.h index 232cb0d..d5f6ffa 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_reboot_job_test_util.h +++ b/chrome/browser/ash/policy/remote_commands/device_command_reboot_job_test_util.h
@@ -8,6 +8,7 @@ #include <memory> #include "base/test/task_environment.h" +#include "base/time/clock.h" #include "base/time/time.h" #include "chrome/browser/ash/policy/remote_commands/device_command_reboot_job.h" #include "chrome/browser/ash/policy/scheduled_task_handler/test/fake_reboot_notifications_scheduler.h"
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_reset_euicc_job.cc b/chrome/browser/ash/policy/remote_commands/device_command_reset_euicc_job.cc index e291b0170..1c4d2fbb 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_reset_euicc_job.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_reset_euicc_job.cc
@@ -120,7 +120,7 @@ message_center::RichNotificationData(), base::MakeRefCounted<message_center::HandleNotificationClickDelegate>( base::DoNothingAs<void()>()), - /*small_image=*/gfx::VectorIcon(), + /*small_image=*/gfx::VectorIcon::EmptyIcon(), message_center::SystemNotificationWarningLevel::NORMAL); SystemNotificationHelper::GetInstance()->Display(notification); }
diff --git a/chrome/browser/ash/scalable_iph/scalable_iph_delegate_impl.cc b/chrome/browser/ash/scalable_iph/scalable_iph_delegate_impl.cc index 005f448..66217555 100644 --- a/chrome/browser/ash/scalable_iph/scalable_iph_delegate_impl.cc +++ b/chrome/browser/ash/scalable_iph/scalable_iph_delegate_impl.cc
@@ -60,7 +60,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia_operations.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notification_delegate.h" #include "url/gurl.h" @@ -501,7 +501,7 @@ notification_image_id.value()); } - const gfx::VectorIcon* icon = &gfx::kNoneIcon; + const gfx::VectorIcon* icon = &gfx::VectorIcon::EmptyIcon(); if (params.icon == ScalableIphDelegate::NotificationIcon::kRedeem) { icon = &chromeos::kRedeemIcon; }
diff --git a/chrome/browser/ash/shimless_rma/chrome_shimless_rma_delegate_unittest.cc b/chrome/browser/ash/shimless_rma/chrome_shimless_rma_delegate_unittest.cc index 621a095..e7373adf 100644 --- a/chrome/browser/ash/shimless_rma/chrome_shimless_rma_delegate_unittest.cc +++ b/chrome/browser/ash/shimless_rma/chrome_shimless_rma_delegate_unittest.cc
@@ -8,6 +8,7 @@ #include "ash/constants/ash_features.h" #include "base/files/file_path.h" +#include "base/functional/bind.h" #include "base/logging.h" #include "base/path_service.h" #include "base/run_loop.h" @@ -22,6 +23,7 @@ #include "chrome/browser/extensions/extension_service_test_base.h" #include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_storage_location.h" #include "chrome/browser/web_applications/web_app.h"
diff --git a/chrome/browser/ash/system/automatic_reboot_manager.cc b/chrome/browser/ash/system/automatic_reboot_manager.cc index f5838aa6..5a4a94c7 100644 --- a/chrome/browser/ash/system/automatic_reboot_manager.cc +++ b/chrome/browser/ash/system/automatic_reboot_manager.cc
@@ -31,6 +31,7 @@ #include "base/task/sequenced_task_runner.h" #include "base/task/thread_pool.h" #include "base/threading/scoped_blocking_call.h" +#include "base/time/clock.h" #include "base/time/tick_clock.h" #include "base/time/time.h" #include "base/timer/wall_clock_timer.h"
diff --git a/chrome/browser/ash/tpm/tpm_firmware_update_notification.cc b/chrome/browser/ash/tpm/tpm_firmware_update_notification.cc index 0e2574213..0f702a9 100644 --- a/chrome/browser/ash/tpm/tpm_firmware_update_notification.cc +++ b/chrome/browser/ash/tpm/tpm_firmware_update_notification.cc
@@ -23,6 +23,7 @@ #include "components/prefs/pref_service.h" #include "ui/base/l10n/l10n_util.h" #include "ui/chromeos/devicetype_utils.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/public/cpp/notification.h" namespace ash { @@ -87,7 +88,8 @@ NotificationCatalogName::kTPMFirmwareUpdate), message_center::RichNotificationData(), base::MakeRefCounted<TPMFirmwareUpdateNotificationDelegate>(profile), - gfx::kNoneIcon, message_center::SystemNotificationWarningLevel::WARNING); + gfx::VectorIcon::EmptyIcon(), + message_center::SystemNotificationWarningLevel::WARNING); NotificationDisplayServiceFactory::GetForProfile(profile)->Display( NotificationHandler::Type::TRANSIENT, notification,
diff --git a/chrome/browser/ash/u2f/u2f_notification.cc b/chrome/browser/ash/u2f/u2f_notification.cc index 76bb0de..ef7d3c5 100644 --- a/chrome/browser/ash/u2f/u2f_notification.cc +++ b/chrome/browser/ash/u2f/u2f_notification.cc
@@ -26,6 +26,7 @@ #include "components/strings/grit/components_strings.h" #include "third_party/cros_system_api/dbus/debugd/dbus-constants.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/public/cpp/notification.h" namespace ash { @@ -114,7 +115,8 @@ base::MakeRefCounted<message_center::HandleNotificationClickDelegate>( base::BindRepeating(&U2FNotification::OnNotificationClick, weak_factory_.GetWeakPtr())), - gfx::kNoneIcon, message_center::SystemNotificationWarningLevel::WARNING); + gfx::VectorIcon::EmptyIcon(), + message_center::SystemNotificationWarningLevel::WARNING); notification.SetSystemPriority(); notification.set_pinned(false);
diff --git a/chrome/browser/ash/usb/cros_usb_detector.cc b/chrome/browser/ash/usb/cros_usb_detector.cc index 1f15143..8e768bf8 100644 --- a/chrome/browser/ash/usb/cros_usb_detector.cc +++ b/chrome/browser/ash/usb/cros_usb_detector.cc
@@ -50,6 +50,7 @@ #include "services/device/public/mojom/usb_enumeration_options.mojom.h" #include "ui/base/l10n/l10n_util.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" +#include "ui/gfx/paint_vector_icon.h" namespace ash {
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index cf02df4..5d02943 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd
@@ -195,10 +195,6 @@ </if> <if expr="is_android"> <include name="IDR_DEV_UI_LOADER_ERROR_HTML" file="resources/dev_ui/dev_ui_loader_error.html" type="BINDATA" /> - <include name="IDR_OFFLINE_INTERNALS_HTML" file="resources\offline_pages\offline_internals.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> - <include name="IDR_OFFLINE_INTERNALS_CSS" file="resources\offline_pages\offline_internals.css" type="BINDATA" /> - <include name="IDR_OFFLINE_INTERNALS_JS" file="${root_gen_dir}\chrome\browser\resources\offline_pages\tsc\offline_internals.js" use_base_dir="false" type="BINDATA" /> - <include name="IDR_OFFLINE_INTERNALS_BROWSER_PROXY_JS" file="${root_gen_dir}\chrome\browser\resources\offline_pages\tsc\offline_internals_browser_proxy.js" use_base_dir="false" type="BINDATA" /> </if> <if expr="enable_hangout_services_extension"> @@ -212,10 +208,6 @@ <include name="IDR_DESK_API_MANIFEST" file="resources\chromeos\desk_api\manifest.json" type="BINDATA" /> </if> - <include name="IDR_INSPECT_CSS" file="resources\inspect\inspect.css" flattenhtml="true" type="BINDATA" /> - <include name="IDR_INSPECT_HTML" file="resources\inspect\inspect.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> - <include name="IDR_INSPECT_JS" file="resources\inspect\inspect.js" type="BINDATA" /> - <include name="IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST" file="resources\network_speech_synthesis\manifest.json" type="BINDATA" /> <include name="IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST_MV3" file="resources\network_speech_synthesis\mv3\manifest.json" type="BINDATA" /> <include name="IDR_READING_MODE_GDOCS_HELPER_MANIFEST" file="resources\reading_mode_gdocs_helper\manifest.json" type="BINDATA" />
diff --git a/chrome/browser/browsing_topics/browsing_topics_service_browsertest.cc b/chrome/browser/browsing_topics/browsing_topics_service_browsertest.cc index 675adb3..8bf2116 100644 --- a/chrome/browser/browsing_topics/browsing_topics_service_browsertest.cc +++ b/chrome/browser/browsing_topics/browsing_topics_service_browsertest.cc
@@ -21,7 +21,6 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" -#include "components/browsing_topics/browsing_topics_service.h" #include "components/browsing_topics/browsing_topics_service_impl.h" #include "components/browsing_topics/epoch_topics.h" #include "components/browsing_topics/test_util.h" @@ -623,6 +622,105 @@ base::CallbackListSubscription subscription_; }; +class BrowsingTopicsSubresourceRequestTest + : public BrowsingTopicsBrowserTest, + public ::testing::WithParamInterface<bool> { + public: + // If true, test the fetch option. If false, test the img attribute. + bool TestFetch() { return GetParam(); } + + std::string GetRelativePath() { + if (TestFetch()) { + return "/browsing_topics/page_with_custom_topics_header.html"; + } + + return "/browsing_topics/topics-writable-pixel.png"; + } + + std::string GetRedirectRelativePath() { + if (TestFetch()) { + return "/browsing_topics/page_with_custom_topics_header2.html"; + } + + return "/browsing_topics/topics-writable-pixel2.png"; + } + + bool ExecJsWithBrowsingTopicsTrue(GURL url) { + if (TestFetch()) { + return ExecJs( + web_contents()->GetPrimaryMainFrame(), + content::JsReplace("fetch($1, {browsingTopics: true})", url)); + } + + return ExecJs(web_contents()->GetPrimaryMainFrame(), + content::JsReplace(R"( + let img = document.createElement('img'); + img.src = $1; + img.browsingTopics = true; + img.decode() + .then(() => { + document.body.appendChild(img); + }) + )", + url.spec())); + } + + bool ExecJSWithBrowsingTopicsFalse(GURL url) { + if (TestFetch()) { + return ExecJs( + web_contents()->GetPrimaryMainFrame(), + content::JsReplace("fetch($1, {browsingTopics: false})", url)); + } + + return ExecJs(web_contents()->GetPrimaryMainFrame(), + content::JsReplace(R"( + let img = document.createElement('img'); + img.src = $1; + img.browsingTopics = false; + img.decode() + .then(() => { + document.body.appendChild(img); + }) + )", + url.spec())); + } + + bool ExecJsWithMissingBrowsingTopicsAttribute(GURL url) { + if (TestFetch()) { + return ExecJs(web_contents()->GetPrimaryMainFrame(), + content::JsReplace("fetch($1)", url)); + } + + return ExecJs(web_contents()->GetPrimaryMainFrame(), + content::JsReplace(R"( + let img = document.createElement('img'); + img.src = $1; + img.decode() + .then(() => { + document.body.appendChild(img); + }) + )", + url.spec())); + } + + int GetBrowsingTopicsApiActionType(bool observe) { + if (TestFetch()) { + if (observe) { + return 3; // kObserveViaFetchLikeApi + } + return 2; // kGetViaFetchLikeApi; + } + if (observe) { + return 7; // kObserveViaImgAttributeApi + } + return 6; // kGetViaImgAttributeApi + } +}; + +INSTANTIATE_TEST_SUITE_P(All, + BrowsingTopicsSubresourceRequestTest, + ::testing::Bool()); + IN_PROC_BROWSER_TEST_F(BrowsingTopicsBrowserTest, HasBrowsingTopicsService) { EXPECT_TRUE(browsing_topics_service()); } @@ -1163,24 +1261,19 @@ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), new_url)); } -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchSameOrigin_TopicsEligible_SendTopics_HasNoObserveResponse) { +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + SameOrigin_TopicsEligible_SendTopics_HasNoObserveResponse) { GURL main_frame_url = https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); - GURL fetch_url = https_server_.GetURL( - "a.test", "/browsing_topics/page_with_custom_topics_header.html"); + GURL resource_url = https_server_.GetURL("a.test", GetRelativePath()); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); - + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_TRUE(topics_header_value); EXPECT_EQ(*topics_header_value, kExpectedHeaderValueForSiteA); @@ -1191,23 +1284,22 @@ EXPECT_EQ(api_usage_contexts.size(), 1u); } -IN_PROC_BROWSER_TEST_F(BrowsingTopicsBrowserTest, FetchWithoutTopicsFlagSet) { +IN_PROC_BROWSER_TEST_P(BrowsingTopicsSubresourceRequestTest, + WithoutTopicsFlagSet) { GURL main_frame_url = https_server_.GetURL("b.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); - GURL fetch_url = https_server_.GetURL( - "b.test", "/browsing_topics/page_with_custom_topics_header.html"); + GURL resource_url = https_server_.GetURL("b.test", GetRelativePath()); { - // Invoke fetch() without the `browsingTopics` flag. This request isn't - // eligible for topics. - EXPECT_TRUE(ExecJs(web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1)", fetch_url))); + // Invoke fetch() or img without the `browsingTopics` flag. This request + // isn't eligible for topics. + + EXPECT_TRUE(ExecJsWithMissingBrowsingTopicsAttribute(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); // Expect no topics header as the request did not specify // {browsingTopics: true}. @@ -1215,15 +1307,12 @@ } { - // Invoke fetch() with the `browsingTopics` flag set to false. This request - // isn't eligible for topics. - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: false})", fetch_url))); + // Invoke fetch() or img with the `browsingTopics` flag set to false. This + // request isn't eligible for topics. + EXPECT_TRUE(ExecJSWithBrowsingTopicsFalse(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); // Expect no topics header as the request did not specify // {browsingTopics: true}. @@ -1231,25 +1320,21 @@ } } -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchSameOrigin_TopicsEligible_SendNoTopic_HasNoObserveResponse) { +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + SameOrigin_TopicsEligible_SendNoTopic_HasNoObserveResponse) { base::HistogramTester histogram_tester; GURL main_frame_url = https_server_.GetURL("b.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); - GURL fetch_url = https_server_.GetURL( - "b.test", "/browsing_topics/page_with_custom_topics_header.html"); + GURL resource_url = https_server_.GetURL("b.test", GetRelativePath()); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); // Expect an empty header value as "b.test" did not observe the candidate // topics. @@ -1262,14 +1347,15 @@ content::GetBrowsingTopicsApiUsage(browsing_topics_site_data_manager()); EXPECT_EQ(api_usage_contexts.size(), 1u); - histogram_tester.ExpectUniqueSample(kBrowsingTopicsApiActionTypeHistogramId, - 2 /*kGetViaFetchLikeApi*/, - /*expected_bucket_count=*/1); + histogram_tester.ExpectUniqueSample( + kBrowsingTopicsApiActionTypeHistogramId, + GetBrowsingTopicsApiActionType(/*observe=*/false), + /*expected_bucket_count=*/1); } -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchSameOrigin_TopicsEligible_SendNoTopic_HasObserveResponse) { +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + SameOrigin_TopicsEligible_SendNoTopic_HasObserveResponse) { base::HistogramTester histogram_tester; GURL main_frame_url = @@ -1282,15 +1368,11 @@ "Observe-Browsing-Topics: ?1")); replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "")); - GURL fetch_url = https_server_.GetURL( - "b.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "b.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); // A new observation should have been recorded in addition to the pre-existing // one, as the response had the `Observe-Browsing-Topics: ?1` header and the @@ -1310,17 +1392,19 @@ // Expect a "get" event and an "observe" event respectively. histogram_tester.ExpectTotalCount(kBrowsingTopicsApiActionTypeHistogramId, /*expected_count=*/2); - histogram_tester.ExpectBucketCount(kBrowsingTopicsApiActionTypeHistogramId, - 2 /*kGetViaFetchLikeApi*/, - /*expected_count=*/1); - histogram_tester.ExpectBucketCount(kBrowsingTopicsApiActionTypeHistogramId, - 3 /*kObserveViaFetchLikeApi*/, - /*expected_count=*/1); + histogram_tester.ExpectBucketCount( + kBrowsingTopicsApiActionTypeHistogramId, + GetBrowsingTopicsApiActionType(/*observe=*/false), + /*expected_count=*/1); + histogram_tester.ExpectBucketCount( + kBrowsingTopicsApiActionTypeHistogramId, + GetBrowsingTopicsApiActionType(/*observe=*/true), + /*expected_count=*/1); } -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchSameOrigin_TopicsNotEligibleDueToUserSettings_HasObserveResponse) { +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + SameOrigin_TopicsNotEligibleDueToUserSettings_HasObserveResponse) { GURL main_frame_url = https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); @@ -1331,22 +1415,17 @@ "Observe-Browsing-Topics: ?1")); replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "")); - GURL fetch_url = https_server_.GetURL( - "a.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "a.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); CookieSettingsFactory::GetForProfile(browser()->profile()) - ->SetCookieSetting(fetch_url, CONTENT_SETTING_BLOCK); + ->SetCookieSetting(resource_url, CONTENT_SETTING_BLOCK); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); // When the request is ineligible for topics due to user settings, an empty // list of topics will be sent in the header. @@ -1360,9 +1439,9 @@ EXPECT_EQ(api_usage_contexts.size(), 1u); } -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchCrossOrigin_TopicsEligible_SendTopics_HasObserveResponse) { +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + CrossOrigin_TopicsEligible_SendTopics_HasObserveResponse) { GURL main_frame_url = https_server_.GetURL("b.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); @@ -1373,19 +1452,14 @@ "Observe-Browsing-Topics: ?1")); replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "")); - GURL fetch_url = https_server_.GetURL( - "a.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "a.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_TRUE(topics_header_value); EXPECT_EQ(*topics_header_value, kExpectedHeaderValueForSiteB); @@ -1406,28 +1480,31 @@ EXPECT_EQ(api_usage_contexts[1].hashed_context_domain, HashedDomain(1)); } -// On an insecure site (i.e. URL with http scheme), test fetch request with -// the `browsingTopics` set to true. Expect it to throw an exception. -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchCrossOrigin_TopicsNotEligibleDueToInsecureInitiatorContext) { +// On an insecure site (i.e. URL with http scheme), test a fetch or image +// request with the `browsingTopics` set to true. Expect it to throw an +// exception. +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + CrossOrigin_TopicsNotEligibleDueToInsecureInitiatorContext) { GURL main_frame_url = embedded_test_server()->GetURL( "b.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); - GURL fetch_url = - https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); + GURL resource_url = https_server_.GetURL("a.test", GetRelativePath()); - content::EvalJsResult result = EvalJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url)); - - EXPECT_THAT(result.error, - testing::HasSubstr("browsingTopics: Topics operations are only " - "available in secure contexts.")); + if (TestFetch()) { + content::EvalJsResult result = EvalJs( + web_contents()->GetPrimaryMainFrame(), + content::JsReplace("fetch($1, {browsingTopics: true})", resource_url)); + EXPECT_THAT(result.error, + testing::HasSubstr("browsingTopics: Topics operations are only " + "available in secure contexts.")); + } else { + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); + } std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath("/browsing_topics/empty_page.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); // Expect no topics header as the request was not eligible for topics due to // insecure initiator context. @@ -1436,9 +1513,9 @@ // Only allow topics from origin c.test, and test fetch requests to b.test and // c.test to verify that only c.test gets them. -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchCrossOrigin_TopicsNotEligibleDueToPermissionsPolicyAgainstRequestOrigin) { +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + CrossOrigin_TopicsNotEligibleDueToPermissionsPolicyAgainstRequestOrigin) { base::StringPairs allowed_origin_replacement; allowed_origin_replacement.emplace_back( "{{ALLOWED_ORIGIN}}", https_server_.GetOrigin("c.test").Serialize()); @@ -1454,15 +1531,12 @@ { base::HistogramTester histogram_tester; - GURL fetch_url = - https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); + GURL resource_url = https_server_.GetURL("a.test", GetRelativePath()); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath("/browsing_topics/empty_page.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); // No topics header was sent, as the permissions policy denied it. EXPECT_FALSE(topics_header_value); @@ -1477,31 +1551,29 @@ { base::HistogramTester histogram_tester; - GURL fetch_url = - https_server_.GetURL("c.test", "/browsing_topics/empty_page.html"); + GURL resource_url = https_server_.GetURL("c.test", GetRelativePath()); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath("/browsing_topics/empty_page.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_TRUE(topics_header_value); - histogram_tester.ExpectUniqueSample(kBrowsingTopicsApiActionTypeHistogramId, - 2 /*kGetViaFetchLikeApi*/, - /*expected_bucket_count=*/1); + histogram_tester.ExpectUniqueSample( + kBrowsingTopicsApiActionTypeHistogramId, + GetBrowsingTopicsApiActionType(/*observe=*/false), + /*expected_bucket_count=*/1); } } -// On site b.test, test fetch request to a.test that gets redirected to c.test. -// The topics header should be calculated for them individually (i.e. given that -// only a.test has observed the candidate topics for site b.test, the request to -// a.test should have a non-empty topics header, while the redirected request to -// c.test should have an empty topics header.) -IN_PROC_BROWSER_TEST_F(BrowsingTopicsBrowserTest, - FetchCrossOriginWithRedirect) { +// On site b.test, test a fetch or image request to a.test that gets redirected +// to c.test. The topics header should be calculated for them individually (i.e. +// given that only a.test has observed the candidate topics for site b.test, the +// request to a.test should have a non-empty topics header, while the redirected +// request to c.test should have an empty topics header.) +IN_PROC_BROWSER_TEST_P(BrowsingTopicsSubresourceRequestTest, + CrossOriginWithRedirect) { base::HistogramTester histogram_tester; GURL main_frame_url = @@ -1517,9 +1589,7 @@ GURL redirect_url = https_server_.GetURL( "c.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header2.html", - redirect_replacement)); + GetRedirectRelativePath(), redirect_replacement)); base::StringPairs replacement; replacement.emplace_back( @@ -1529,27 +1599,21 @@ replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "Location: " + redirect_url.spec())); - GURL fetch_url = https_server_.GetURL( - "a.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "a.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); { std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_TRUE(topics_header_value); EXPECT_EQ(*topics_header_value, kExpectedHeaderValueForSiteB); } { std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header2.html"); + GetTopicsHeaderForRequestPath(GetRedirectRelativePath()); EXPECT_TRUE(topics_header_value); // An empty topics header value was sent, because "c.test" did not observe @@ -1580,22 +1644,24 @@ // and the redirect respectively. histogram_tester.ExpectTotalCount(kBrowsingTopicsApiActionTypeHistogramId, /*expected_count=*/4); - histogram_tester.ExpectBucketCount(kBrowsingTopicsApiActionTypeHistogramId, - 2 /*kGetViaFetchLikeApi*/, - /*expected_count=*/2); - histogram_tester.ExpectBucketCount(kBrowsingTopicsApiActionTypeHistogramId, - 3 /*kObserveViaFetchLikeApi*/, - /*expected_count=*/2); + histogram_tester.ExpectBucketCount( + kBrowsingTopicsApiActionTypeHistogramId, + GetBrowsingTopicsApiActionType(/*observe=*/false), + /*expected_count=*/2); + histogram_tester.ExpectBucketCount( + kBrowsingTopicsApiActionTypeHistogramId, + GetBrowsingTopicsApiActionType(/*observe=*/true), + /*expected_count=*/2); } -// On site b.test, test fetch request to a.test that gets redirected to c.test. -// The topics header eligibility should be checked for them individually (i.e. -// given that the declared policy on the page only allows origin c.test, the -// request to a.test should not have the topics header, while the redirected -// request to c.test should have the topics header.) -IN_PROC_BROWSER_TEST_F( - BrowsingTopicsBrowserTest, - FetchCrossOriginWithRedirect_InitialRequestTopicsNotEligibleDueToPermissionsPolicy) { +// On site b.test, test a fetch or image request to a.test that gets redirected +// to c.test. The topics header eligibility should be checked for them +// individually (i.e. given that the declared policy on the page only allows +// origin c.test, the request to a.test should not have the topics header, while +// the redirected request to c.test should have the topics header.) +IN_PROC_BROWSER_TEST_P( + BrowsingTopicsSubresourceRequestTest, + CrossOriginWithRedirect_InitialRequestTopicsNotEligibleDueToPermissionsPolicy) { base::StringPairs allowed_origin_replacement; allowed_origin_replacement.emplace_back( "{{ALLOWED_ORIGIN}}", https_server_.GetOrigin("c.test").Serialize()); @@ -1616,9 +1682,7 @@ GURL redirect_url = https_server_.GetURL( "c.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header2.html", - redirect_replacement)); + GetRedirectRelativePath(), redirect_replacement)); base::StringPairs replacement; replacement.emplace_back( @@ -1628,28 +1692,22 @@ replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "Location: " + redirect_url.spec())); - GURL fetch_url = https_server_.GetURL( - "a.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "a.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); { std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); // No topics header was sent, as the permissions policy denied it. EXPECT_FALSE(topics_header_value); } { std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header2.html"); + GetTopicsHeaderForRequestPath(GetRedirectRelativePath()); EXPECT_TRUE(topics_header_value); // An empty topics header value was sent, as "c.test" did not observe the @@ -1739,6 +1797,71 @@ } } +IN_PROC_BROWSER_TEST_F(BrowsingTopicsBrowserTest, UseCounter_Img) { + base::HistogramTester histogram_tester; + + GURL main_frame_url = + https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); + + GURL img_url = https_server_.GetURL( + "a.test", "/browsing_topics/topics-writable-pixel.png"); + + { + ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); + + // Request an image with `browsingTopics` set to false. Expect no + // `kTopicsAPIImg` use counter. + EXPECT_TRUE(ExecJs(web_contents()->GetPrimaryMainFrame(), + content::JsReplace(R"( + let img = document.createElement('img'); + img.src = $1; + img.browsingTopics = false; + img.decode() + .then(() => { + document.body.appendChild(img); + }) + )", + img_url.spec()))); + + // Navigate away to flush use counters. + ASSERT_TRUE( + ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL))); + + histogram_tester.ExpectBucketCount("Blink.UseCounter.Features", + blink::mojom::WebFeature::kTopicsAPIImg, + 0); + } + + { + ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); + + // Request an img with `browsingTopics` set to true. Expect one + // `kTopicsAPIImg` use counter. + EXPECT_TRUE(ExecJs(web_contents()->GetPrimaryMainFrame(), + content::JsReplace(R"( + let img = document.createElement('img'); + img.src = $1; + img.browsingTopics = true; + img.decode() + .then(() => { + document.body.appendChild(img); + }) + )", + img_url.spec()))); + + // Navigate away to flush use counters. + ASSERT_TRUE( + ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL))); + + histogram_tester.ExpectBucketCount("Blink.UseCounter.Features", + blink::mojom::WebFeature::kTopicsAPIImg, + 1); + histogram_tester.ExpectBucketCount("Blink.UseCounter.Features", + blink::mojom::WebFeature::kTopicsAPIAll, + 1); + } +} + // For a page that contains a static <iframe> with a "browsingtopics" // attribute, the iframe navigation request should be eligible for topics. IN_PROC_BROWSER_TEST_F(BrowsingTopicsBrowserTest, @@ -2463,6 +2586,24 @@ ~AttestationBrowsingTopicsBrowserTest() override = default; }; +class AttestationSubresourceRequestTest + : public BrowsingTopicsSubresourceRequestTest { + public: + void SetUpOnMainThread() override { + // This test suite tests Privacy Sandbox Attestations related behaviors, + // turn off the setting that makes all APIs considered attested. + BrowsingTopicsBrowserTest::SetUpOnMainThread(); + privacy_sandbox::PrivacySandboxAttestations::GetInstance() + ->SetAllPrivacySandboxAttestedForTesting(false); + } + + ~AttestationSubresourceRequestTest() override = default; +}; + +INSTANTIATE_TEST_SUITE_P(All, + AttestationSubresourceRequestTest, + ::testing::Bool()); + // Site a.test is attested for Topics, so it should receive a valid response. IN_PROC_BROWSER_TEST_F(AttestationBrowsingTopicsBrowserTest, AttestedSiteCanGetBrowsingTopicsViaDocumentAPI) { @@ -2542,8 +2683,8 @@ EXPECT_FALSE(console_observer.messages().empty()); } -IN_PROC_BROWSER_TEST_F(AttestationBrowsingTopicsBrowserTest, - FetchSameOrigin_TopicsEligible_SendTopics_SiteAttested) { +IN_PROC_BROWSER_TEST_P(AttestationSubresourceRequestTest, + SameOrigin_TopicsEligible_SendTopics_SiteAttested) { privacy_sandbox::PrivacySandboxAttestationsMap map; map.insert_or_assign( net::SchemefulSite(GURL("https://a.test")), @@ -2559,16 +2700,12 @@ https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); - GURL fetch_url = https_server_.GetURL( - "a.test", "/browsing_topics/page_with_custom_topics_header.html"); + GURL resource_url = https_server_.GetURL("a.test", GetRelativePath()); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_TRUE(topics_header_value); EXPECT_EQ(*topics_header_value, kExpectedHeaderValueForSiteA); @@ -2576,8 +2713,8 @@ EXPECT_TRUE(console_observer.messages().empty()); } -IN_PROC_BROWSER_TEST_F(AttestationBrowsingTopicsBrowserTest, - FetchSameOrigin_TopicsEligible_SiteNotAttested) { +IN_PROC_BROWSER_TEST_P(AttestationSubresourceRequestTest, + SameOrigin_TopicsEligible_SiteNotAttested) { privacy_sandbox::PrivacySandboxAttestationsMap map; map.insert_or_assign( net::SchemefulSite(GURL("https://b.test")), @@ -2593,16 +2730,12 @@ https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); - GURL fetch_url = https_server_.GetURL( - "a.test", "/browsing_topics/page_with_custom_topics_header.html"); + GURL resource_url = https_server_.GetURL("a.test", GetRelativePath()); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_EQ(topics_header_value, kExpectedHeaderValueForEmptyTopics); @@ -2610,9 +2743,8 @@ EXPECT_FALSE(console_observer.messages().empty()); } -IN_PROC_BROWSER_TEST_F( - AttestationBrowsingTopicsBrowserTest, - FetchSameOrigin_TopicsEligible_SiteAttested_MismatchedMap) { +IN_PROC_BROWSER_TEST_P(AttestationSubresourceRequestTest, + SameOrigin_TopicsEligible_SiteAttested_MismatchedMap) { privacy_sandbox::PrivacySandboxAttestationsMap map; map.insert_or_assign(net::SchemefulSite(GURL("https://a.test")), privacy_sandbox::PrivacySandboxAttestationsGatedAPISet{ @@ -2628,16 +2760,12 @@ https_server_.GetURL("a.test", "/browsing_topics/empty_page.html"); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_frame_url)); - GURL fetch_url = https_server_.GetURL( - "a.test", "/browsing_topics/page_with_custom_topics_header.html"); + GURL resource_url = https_server_.GetURL("a.test", GetRelativePath()); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_EQ(topics_header_value, kExpectedHeaderValueForEmptyTopics); @@ -2647,9 +2775,9 @@ // Site a.test is attested, so when an x-origin request is made to it from // site b.test, a.test should still include a topics header. -IN_PROC_BROWSER_TEST_F( - AttestationBrowsingTopicsBrowserTest, - FetchCrossOrigin_TopicsEligible_SendTopics_HasObserveResponse_SiteAttested) { +IN_PROC_BROWSER_TEST_P( + AttestationSubresourceRequestTest, + CrossOrigin_TopicsEligible_SendTopics_HasObserveResponse_SiteAttested) { privacy_sandbox::PrivacySandboxAttestationsMap map; map.insert_or_assign( net::SchemefulSite(GURL("https://a.test")), @@ -2671,19 +2799,14 @@ "Observe-Browsing-Topics: ?1")); replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "")); - GURL fetch_url = https_server_.GetURL( - "a.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "a.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_TRUE(topics_header_value); EXPECT_EQ(*topics_header_value, kExpectedHeaderValueForSiteB); @@ -2708,8 +2831,8 @@ // Site a.test is not attested, so this should not generate a Topics header in a // x-origin fetch to site a.test. -IN_PROC_BROWSER_TEST_F(AttestationBrowsingTopicsBrowserTest, - FetchCrossOrigin_TopicsEligible_SiteNotAttested) { +IN_PROC_BROWSER_TEST_P(AttestationSubresourceRequestTest, + CrossOrigin_TopicsEligible_SiteNotAttested) { privacy_sandbox::PrivacySandboxAttestationsMap map; map.insert_or_assign( net::SchemefulSite(GURL("https://b.test")), @@ -2731,19 +2854,14 @@ "Observe-Browsing-Topics: ?1")); replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "")); - GURL fetch_url = https_server_.GetURL( - "a.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "a.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_EQ(topics_header_value, kExpectedHeaderValueForEmptyTopics); @@ -2757,11 +2875,11 @@ EXPECT_FALSE(console_observer.messages().empty()); } -// Site a.test is attested, but not for Topics, so the fetch request to a.test -// should not get a header. -IN_PROC_BROWSER_TEST_F( - AttestationBrowsingTopicsBrowserTest, - FetchCrossOrigin_TopicsEligible_SiteNotAttested_MismatchedMap) { +// Site a.test is attested, but not for Topics, so the fetch/img request to +// a.test should not get a header. +IN_PROC_BROWSER_TEST_P( + AttestationSubresourceRequestTest, + CrossOrigin_TopicsEligible_SiteNotAttested_MismatchedMap) { privacy_sandbox::PrivacySandboxAttestationsMap map; map.insert_or_assign(net::SchemefulSite(GURL("https://a.test")), privacy_sandbox::PrivacySandboxAttestationsGatedAPISet{ @@ -2783,19 +2901,14 @@ "Observe-Browsing-Topics: ?1")); replacement.emplace_back(std::make_pair("{{REDIRECT_HEADER}}", "")); - GURL fetch_url = https_server_.GetURL( - "a.test", net::test_server::GetFilePathWithReplacements( - "/browsing_topics/" - "page_with_custom_topics_header.html", - replacement)); + GURL resource_url = https_server_.GetURL( + "a.test", net::test_server::GetFilePathWithReplacements(GetRelativePath(), + replacement)); - EXPECT_TRUE(ExecJs( - web_contents()->GetPrimaryMainFrame(), - content::JsReplace("fetch($1, {browsingTopics: true})", fetch_url))); + EXPECT_TRUE(ExecJsWithBrowsingTopicsTrue(resource_url)); std::optional<std::string> topics_header_value = - GetTopicsHeaderForRequestPath( - "/browsing_topics/page_with_custom_topics_header.html"); + GetTopicsHeaderForRequestPath(GetRelativePath()); EXPECT_EQ(topics_header_value, kExpectedHeaderValueForEmptyTopics);
diff --git a/chrome/browser/chromeos/policy/dlp/clipboard_bubble.cc b/chrome/browser/chromeos/policy/dlp/clipboard_bubble.cc index 8cd5e64..a18b578 100644 --- a/chrome/browser/chromeos/policy/dlp/clipboard_bubble.cc +++ b/chrome/browser/chromeos/policy/dlp/clipboard_bubble.cc
@@ -19,20 +19,9 @@ #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/link.h" #include "ui/views/controls/styled_label.h" - -#if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/public/cpp/new_window_delegate.h" #include "ash/public/cpp/style/color_provider.h" #include "ui/chromeos/styles/cros_tokens_color_mappings.h" -#endif // BUILDFLAG(IS_CHROMEOS_ASH) - -#if BUILDFLAG(IS_CHROMEOS_LACROS) -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/ui/browser_navigator.h" -#include "chrome/browser/ui/browser_navigator_params.h" -#include "ui/chromeos/styles/cros_styles.h" -#include "ui/native_theme/native_theme_aura.h" -#endif // BUILDFLAG(IS_CHROMEOS_LACROS) namespace policy { @@ -81,15 +70,6 @@ // The spacing between the buttons. constexpr int kButtonsSpacing = 8; -#if BUILDFLAG(IS_CHROMEOS_LACROS) -// TODO(crbug.com/1311180) Replace color retrieval with more long term solution. -SkColor RetrieveColor(cros_styles::ColorName name) { - return cros_styles::ResolveColor( - name, ui::NativeTheme::GetInstanceForNativeUi()->ShouldUseDarkColors(), - /*use_debug_colors=*/false); -} -#endif // BUILDFLAG(IS_CHROMEOS_LACROS) - class BubbleButton : public views::LabelButton { METADATA_HEADER(BubbleButton, views::LabelButton) @@ -102,17 +82,8 @@ const gfx::FontList font_list = GetFontList(); label()->SetFontList(font_list); -#if BUILDFLAG(IS_CHROMEOS_ASH) const SkColor text_color = ash::ColorProvider::Get()->GetContentLayerColor( ash::ColorProvider::ContentLayerType::kButtonLabelColorBlue); -#elif BUILDFLAG(IS_CHROMEOS_LACROS) - // TODO(crbug.com/1311180) Replace color retrieval with more long term - // solution. - const SkColor text_color = - ui::NativeTheme::GetInstanceForNativeUi()->ShouldUseDarkColors() - ? gfx::kGoogleBlue300 - : gfx::kGoogleBlue600; -#endif // BUILDFLAG(IS_CHROMEOS_ASH) SetTextColor(ButtonState::STATE_NORMAL, text_color); SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_CENTER); SetSize({gfx::GetStringWidth(button_label, font_list) + 2 * kButtonPadding, @@ -132,22 +103,10 @@ }; void OnLearnMoreLinkClicked() { -#if BUILDFLAG(IS_CHROMEOS_ASH) ash::NewWindowDelegate::GetPrimary()->OpenUrl( GURL(dlp::kDlpLearnMoreUrl), ash::NewWindowDelegate::OpenUrlFrom::kUserInteraction, ash::NewWindowDelegate::Disposition::kNewForegroundTab); -#elif BUILDFLAG(IS_CHROMEOS_LACROS) - // The dlp policy applies to the main profile, so use the main profile for - // opening the page. - NavigateParams navigate_params( - ProfileManager::GetPrimaryUserProfile(), GURL(dlp::kDlpLearnMoreUrl), - ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | - ui::PAGE_TRANSITION_FROM_API)); - navigate_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; - navigate_params.window_action = NavigateParams::SHOW_WINDOW; - Navigate(&navigate_params); -#endif // BUILDFLAG(IS_CHROMEOS_ASH) } } // namespace @@ -158,26 +117,15 @@ ClipboardBubbleView::ClipboardBubbleView(const std::u16string& text) { SetPaintToLayer(ui::LAYER_SOLID_COLOR); -#if BUILDFLAG(IS_CHROMEOS_LACROS) - // TODO(crbug.com/1311180) Replace color retrieval with more long term - // solution. - layer()->SetColor(RetrieveColor(cros_styles::ColorName::kBgColor)); - layer()->SetBackgroundBlur(kBubbleBlurRadius); -#endif // BUILDFLAG(IS_CHROMEOS_LACROS) + layer()->SetBackgroundBlur(kBubbleBlurRadius); layer()->SetRoundedCornerRadius(kCornerRadii); // Add the managed icon. -#if BUILDFLAG(IS_CHROMEOS_ASH) ash::ColorProvider* color_provider = ash::ColorProvider::Get(); const SkColor icon_color = color_provider->GetContentLayerColor( ash::ColorProvider::ContentLayerType::kIconColorPrimary); -#elif BUILDFLAG(IS_CHROMEOS_LACROS) - // TODO(crbug.com/1311180) Replace color retrieval with more long term - // solution. - const SkColor icon_color = - RetrieveColor(cros_styles::ColorName::kIconColorPrimary); -#endif // BUILDFLAG(IS_CHROMEOS_ASH) + managed_icon_ = AddChildView(std::make_unique<views::ImageView>()); managed_icon_->SetPaintToLayer(); managed_icon_->layer()->SetFillsBoundsOpaquely(false); @@ -204,15 +152,8 @@ // Set the styling of the main text. // TODO(crbug.com/1150741): Handle RTL. views::StyledLabel::RangeStyleInfo message_style; -#if BUILDFLAG(IS_CHROMEOS_ASH) message_style.override_color = color_provider->GetContentLayerColor( ash::ColorProvider::ContentLayerType::kTextColorPrimary); -#elif BUILDFLAG(IS_CHROMEOS_LACROS) - // TODO(crbug.com/1311180) Replace color retrieval with more long term - // solution. - message_style.override_color = - RetrieveColor(cros_styles::ColorName::kTextColorPrimary); -#endif // BUILDFLAG(IS_CHROMEOS_ASH) label_->SetText(full_text); label_->AddStyleRange(gfx::Range(0, main_message_length), message_style); @@ -221,17 +162,8 @@ views::StyledLabel::RangeStyleInfo link_style = views::StyledLabel::RangeStyleInfo::CreateForLink( base::BindRepeating(&OnLearnMoreLinkClicked)); -#if BUILDFLAG(IS_CHROMEOS_ASH) link_style.override_color = color_provider->GetContentLayerColor( ash::ColorProvider::ContentLayerType::kTextColorURL); -#elif BUILDFLAG(IS_CHROMEOS_LACROS) - // TODO(crbug.com/1311180) Replace color retrieval with more long term - // solution. - link_style.override_color = - ui::NativeTheme::GetInstanceForNativeUi()->ShouldUseDarkColors() - ? gfx::kGoogleBlue300 - : gfx::kGoogleBlue600; -#endif // BUILDFLAG(IS_CHROMEOS_ASH) label_->AddStyleRange(gfx::Range(main_message_length, full_text.size()), link_style); @@ -258,12 +190,10 @@ void ClipboardBubbleView::OnThemeChanged() { views::View::OnThemeChanged(); -#if BUILDFLAG(IS_CHROMEOS_ASH) const SkColor background_color = GetColorProvider()->GetColor(cros_tokens::kCrosSysSystemBaseElevated); layer()->SetColor(background_color); label_->SetDisplayedOnBackgroundColor(background_color); -#endif // BUILDFLAG(IS_CHROMEOS_ASH) } void ClipboardBubbleView::UpdateBorderSize(const gfx::Size& size) {
diff --git a/chrome/browser/collaboration/BUILD.gn b/chrome/browser/collaboration/BUILD.gn index 12de5be..ff441f5 100644 --- a/chrome/browser/collaboration/BUILD.gn +++ b/chrome/browser/collaboration/BUILD.gn
@@ -62,6 +62,7 @@ "//third_party/hamcrest:hamcrest_core_java", "//third_party/hamcrest:hamcrest_library_java", "//third_party/junit:junit", + "//url:url_java", ] }
diff --git a/chrome/browser/collaboration/android/collaboration_controller_delegate_android.cc b/chrome/browser/collaboration/android/collaboration_controller_delegate_android.cc index 7b2a708..fcbd712 100644 --- a/chrome/browser/collaboration/android/collaboration_controller_delegate_android.cc +++ b/chrome/browser/collaboration/android/collaboration_controller_delegate_android.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/collaboration/android/collaboration_controller_delegate_android.h" #include "base/android/jni_string.h" +#include "components/collaboration/public/android/conversion_utils.h" #include "components/data_sharing/public/android/conversion_utils.h" // Must come after all headers that specialize FromJniType() / ToJniType(). @@ -17,45 +18,43 @@ namespace collaboration { -namespace { - -jlong GetCallbackPointer(ResultCallback result) { - std::unique_ptr<ResultCallback> wrapped_callback = - std::make_unique<ResultCallback>(std::move(result)); - CHECK(wrapped_callback.get()); - jlong j_native_ptr = reinterpret_cast<jlong>(wrapped_callback.get()); - wrapped_callback.release(); - - return j_native_ptr; -} - -} // namespace - static void JNI_CollaborationControllerDelegateImpl_RunResultCallback( JNIEnv* env, jint joutcome, jlong callback) { - std::unique_ptr<ResultCallback> callback_ptr( - reinterpret_cast<ResultCallback*>(callback)); + std::unique_ptr<ResultCallback> callback_ptr = + conversion::GetNativeResultCallbackFromJava(callback); CollaborationControllerDelegate::Outcome outcome = static_cast<CollaborationControllerDelegate::Outcome>(joutcome); std::move(*callback_ptr).Run(outcome); } +static jlong JNI_CollaborationControllerDelegateImpl_CreateNativeObject( + JNIEnv* env, + const base::android::JavaParamRef<jobject>& j_object) { + std::unique_ptr<CollaborationControllerDelegate> delegate_unique_ptr = + std::make_unique<CollaborationControllerDelegateAndroid>(j_object); + + return conversion::GetJavaDelegateUniquePtr(std::move(delegate_unique_ptr)); +} + CollaborationControllerDelegateAndroid::CollaborationControllerDelegateAndroid( - ScopedJavaGlobalRef<jobject> java_obj) { - DCHECK(java_obj); - java_obj_.Reset(java_obj); + const base::android::JavaParamRef<jobject>& j_object) { + DCHECK(j_object); + java_obj_.Reset(base::android::ScopedJavaGlobalRef<jobject>(j_object)); } CollaborationControllerDelegateAndroid:: - ~CollaborationControllerDelegateAndroid() = default; + ~CollaborationControllerDelegateAndroid() { + JNIEnv* env = base::android::AttachCurrentThread(); + Java_CollaborationControllerDelegateImpl_clearNativePtr(env, java_obj_); +} void CollaborationControllerDelegateAndroid::PrepareFlowUI( ResultCallback result) { JNIEnv* env = base::android::AttachCurrentThread(); Java_CollaborationControllerDelegateImpl_prepareFlowUI( - env, java_obj_, GetCallbackPointer(std::move(result))); + env, java_obj_, conversion::GetJavaResultCallbackPtr(std::move(result))); } void CollaborationControllerDelegateAndroid::ShowError(const ErrorInfo& error, @@ -63,20 +62,20 @@ JNIEnv* env = base::android::AttachCurrentThread(); Java_CollaborationControllerDelegateImpl_showError( env, java_obj_, static_cast<int>(error.type), - GetCallbackPointer(std::move(result))); + conversion::GetJavaResultCallbackPtr(std::move(result))); } void CollaborationControllerDelegateAndroid::Cancel(ResultCallback result) { JNIEnv* env = base::android::AttachCurrentThread(); Java_CollaborationControllerDelegateImpl_cancel( - env, java_obj_, GetCallbackPointer(std::move(result))); + env, java_obj_, conversion::GetJavaResultCallbackPtr(std::move(result))); } void CollaborationControllerDelegateAndroid::ShowAuthenticationUi( ResultCallback result) { JNIEnv* env = base::android::AttachCurrentThread(); Java_CollaborationControllerDelegateImpl_showAuthenticationUi( - env, java_obj_, GetCallbackPointer(std::move(result))); + env, java_obj_, conversion::GetJavaResultCallbackPtr(std::move(result))); } void CollaborationControllerDelegateAndroid::NotifySignInAndSyncStatusChange() { @@ -95,7 +94,7 @@ data_sharing::conversion::CreateJavaGroupToken(env, token), data_sharing::conversion::CreateJavaSharedTabGroupPreview( env, preview_data.shared_tab_group_preview.value()), - GetCallbackPointer(std::move(result))); + conversion::GetJavaResultCallbackPtr(std::move(result))); } void CollaborationControllerDelegateAndroid::ShowShareDialog( @@ -103,7 +102,15 @@ ResultCallback result) { JNIEnv* env = base::android::AttachCurrentThread(); Java_CollaborationControllerDelegateImpl_showShareDialog( - env, java_obj_, GetCallbackPointer(std::move(result))); + env, java_obj_, conversion::GetJavaResultCallbackPtr(std::move(result))); +} + +void CollaborationControllerDelegateAndroid::ShowManageDialog( + const tab_groups::EitherGroupID& either_id, + ResultCallback result) { + JNIEnv* env = base::android::AttachCurrentThread(); + Java_CollaborationControllerDelegateImpl_showManageDialog( + env, java_obj_, conversion::GetJavaResultCallbackPtr(std::move(result))); } void CollaborationControllerDelegateAndroid::PromoteTabGroup( @@ -113,7 +120,7 @@ Java_CollaborationControllerDelegateImpl_promoteTabGroup( env, java_obj_, base::android::ConvertUTF8ToJavaString(env, group_id.value()), - GetCallbackPointer(std::move(result))); + conversion::GetJavaResultCallbackPtr(std::move(result))); } void CollaborationControllerDelegateAndroid::PromoteCurrentScreen() {
diff --git a/chrome/browser/collaboration/android/collaboration_controller_delegate_android.h b/chrome/browser/collaboration/android/collaboration_controller_delegate_android.h index 483b839..162eb990 100644 --- a/chrome/browser/collaboration/android/collaboration_controller_delegate_android.h +++ b/chrome/browser/collaboration/android/collaboration_controller_delegate_android.h
@@ -8,7 +8,6 @@ #include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" #include "base/supports_user_data.h" -#include "chrome/browser/profiles/profile.h" #include "components/collaboration/public/collaboration_controller_delegate.h" namespace collaboration { @@ -18,7 +17,7 @@ : public CollaborationControllerDelegate { public: explicit CollaborationControllerDelegateAndroid( - base::android::ScopedJavaGlobalRef<jobject> java_obj); + const base::android::JavaParamRef<jobject>& j_object); ~CollaborationControllerDelegateAndroid() override; // CollaborationControllerDelegate. @@ -32,6 +31,8 @@ ResultCallback result) override; void ShowShareDialog(const tab_groups::EitherGroupID& either_id, ResultCallback result) override; + void ShowManageDialog(const tab_groups::EitherGroupID& either_id, + ResultCallback result) override; void PromoteTabGroup(const data_sharing::GroupId& group_id, ResultCallback result) override; void PromoteCurrentScreen() override;
diff --git a/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationControllerDelegateImpl.java b/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationControllerDelegateImpl.java index 285b42d9..b8401fef 100644 --- a/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationControllerDelegateImpl.java +++ b/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationControllerDelegateImpl.java
@@ -17,6 +17,17 @@ /** An interface to manage collaboration flow UI screens. */ @JNINamespace("collaboration") public class CollaborationControllerDelegateImpl implements CollaborationControllerDelegate { + private long mNativePtr; + + CollaborationControllerDelegateImpl() { + mNativePtr = CollaborationControllerDelegateImplJni.get().createNativeObject(this); + } + + @Override + public long getNativePtr() { + return mNativePtr; + } + /** * Prepare and wait for the UI to be ready to be shown. * @@ -91,6 +102,17 @@ } /** + * Show the manage dialog screen. + * + * @param resultCallback The callback to notify the outcome of the UI screen. + */ + @CalledByNative + void showManageDialog(long resultCallback) { + CollaborationControllerDelegateImplJni.get() + .runResultCallback(Outcome.FAILURE, resultCallback); + } + + /** * Open and show the local tab group. * * @param collaborationId The collaboration id of the tab group to promote. @@ -106,8 +128,15 @@ @CalledByNative void promoteCurrentScreen() {} + @CalledByNative + private void clearNativePtr() { + mNativePtr = 0; + } + @NativeMethods interface Natives { void runResultCallback(int joutcome, long resultCallback); + + long createNativeObject(CollaborationControllerDelegateImpl jdelegate); } }
diff --git a/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationServiceFactoryTest.java b/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationServiceFactoryTest.java index f3358ee3..5b563397 100644 --- a/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationServiceFactoryTest.java +++ b/chrome/browser/collaboration/android/java/src/org/chromium/chrome/browser/collaboration/CollaborationServiceFactoryTest.java
@@ -25,6 +25,7 @@ import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.profiles.ProfileManager; import org.chromium.chrome.test.ChromeTabbedActivityTestRule; +import org.chromium.components.collaboration.CollaborationControllerDelegate; import org.chromium.components.collaboration.CollaborationService; import org.chromium.components.collaboration.CollaborationStatus; import org.chromium.components.collaboration.ServiceStatus; @@ -32,6 +33,7 @@ import org.chromium.components.collaboration.SyncStatus; import org.chromium.components.data_sharing.GroupData; import org.chromium.components.data_sharing.member_role.MemberRole; +import org.chromium.url.GURL; import java.util.concurrent.TimeoutException; @@ -53,6 +55,13 @@ } @Override + public void startJoinFlow(CollaborationControllerDelegate delegate, GURL url) {} + + @Override + public void startShareOrManageFlow( + CollaborationControllerDelegate delegate, String syncId) {} + + @Override public ServiceStatus getServiceStatus() { return new ServiceStatus( SigninStatus.NOT_SIGNED_IN,
diff --git a/chrome/browser/commerce/price_change/android/junit/src/org/chromium/chrome/browser/price_change/PriceChangeModuleMediatorUnitTest.java b/chrome/browser/commerce/price_change/android/junit/src/org/chromium/chrome/browser/price_change/PriceChangeModuleMediatorUnitTest.java index 7bbb4b9..a0d632e 100644 --- a/chrome/browser/commerce/price_change/android/junit/src/org/chromium/chrome/browser/price_change/PriceChangeModuleMediatorUnitTest.java +++ b/chrome/browser/commerce/price_change/android/junit/src/org/chromium/chrome/browser/price_change/PriceChangeModuleMediatorUnitTest.java
@@ -40,9 +40,9 @@ import org.chromium.base.Callback; import org.chromium.base.ContextUtils; -import org.chromium.base.FeatureList; import org.chromium.base.shared_preferences.SharedPreferencesManager; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.chrome.R; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.magic_stack.ModuleDelegate; @@ -70,10 +70,8 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; /** Test relating to {@link PriceChangeModuleMediator} */ @@ -81,6 +79,7 @@ @Config( manifest = Config.NONE, shadows = {ShadowAppCompatResources.class}) +@EnableFeatures(ChromeFeatureList.PRICE_CHANGE_MODULE) public class PriceChangeModuleMediatorUnitTest { @Rule public MockitoRule mMockitoRule = MockitoJUnit.rule(); @@ -137,10 +136,6 @@ mSharedPreferenceManager = ChromeSharedPreferences.getInstance(); mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size); PriceTrackingFeatures.setPriceAnnotationsEnabledForTesting(true); - - Map<String, Boolean> featureOverride = new HashMap<>(); - featureOverride.put(ChromeFeatureList.PRICE_CHANGE_MODULE, true); - FeatureList.setTestFeatures(featureOverride); } @After
diff --git a/chrome/browser/controlled_frame/controlled_frame_wpt_browsertest.cc b/chrome/browser/controlled_frame/controlled_frame_wpt_browsertest.cc index 975a39c..724115a 100644 --- a/chrome/browser/controlled_frame/controlled_frame_wpt_browsertest.cc +++ b/chrome/browser/controlled_frame/controlled_frame_wpt_browsertest.cc
@@ -27,8 +27,8 @@ namespace { -// TODO(b/386380410): Re-enable event_handlers.window.js and -// webrequest_event_handlers.window.js once they no longer timeout. +// TODO(crbug.com/386380410): Re-enable event_handlers.window.js, once it no +// longer times out. const auto kTestFiles = testing::Values("add_content_scripts.window.js", "camera.window.js", "client_hints_user_agent.window.js", @@ -36,7 +36,8 @@ "new_window.window.js", "no_callback.window.js", "scheme.window.js", - "user_agent_override.window.js"); + "user_agent_override.window.js", + "webrequest_event_handlers.window.js"); constexpr char kTestDirectory[] = "chrome/test/data/controlled_frame"; constexpr char kTestHarnessPath[] =
diff --git a/chrome/browser/data_sharing/BUILD.gn b/chrome/browser/data_sharing/BUILD.gn index 02088be1..e08aac91 100644 --- a/chrome/browser/data_sharing/BUILD.gn +++ b/chrome/browser/data_sharing/BUILD.gn
@@ -68,8 +68,8 @@ sources = [ "android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingMetrics.java", "android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabGroupUtils.java", - "android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabManager.java", "android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabGroupsDelegate.java", + "android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabManager.java", "android/java/src/org/chromium/chrome/browser/data_sharing/RecentActivityActionHandlerImpl.java", "android/java/src/org/chromium/chrome/browser/data_sharing/TabGridDialogShareBottomSheetContent.java", ] @@ -354,6 +354,7 @@ deps = [ ":recent_activity_java", "//base:base_java", + "//base:base_java_test_support", "//base:base_junit_test_support", "//chrome/browser/tab:java", "//chrome/test/android:chrome_java_unit_test_support",
diff --git a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListMediatorUnitTest.java b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListMediatorUnitTest.java index 0f9d6cd7..79e8aba 100644 --- a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListMediatorUnitTest.java +++ b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListMediatorUnitTest.java
@@ -32,6 +32,7 @@ import org.chromium.base.Callback; import org.chromium.base.TimeUtils; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.DisabledTest; import org.chromium.chrome.browser.data_sharing.ui.recent_activity.RecentActivityListCoordinator.AvatarProvider; import org.chromium.chrome.browser.data_sharing.ui.recent_activity.RecentActivityListCoordinator.FaviconProvider; import org.chromium.components.collaboration.messaging.ActivityLogItem; @@ -129,6 +130,7 @@ } @Test + @DisabledTest(message = "https://crbug.com/382626225") public void testTwoItemsTitleAndDescription() { // Expected title: "You changed a tab". ActivityLogItem logItem1 = createLog1(CollaborationEvent.TAB_UPDATED); @@ -279,6 +281,7 @@ } @Test + @DisabledTest(message = "https://crbug.com/382626225") public void testGetTitleResStringForAllEventTypes() { // Create one item for each type of collaboration event and add to the backend. int[] events = {
diff --git a/chrome/browser/devtools/protocol/pwa_handler.cc b/chrome/browser/devtools/protocol/pwa_handler.cc index 5843290..5922dc0 100644 --- a/chrome/browser/devtools/protocol/pwa_handler.cc +++ b/chrome/browser/devtools/protocol/pwa_handler.cc
@@ -24,6 +24,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/web_applications/locks/app_lock.h" +#include "chrome/browser/web_applications/os_integration/os_integration_manager.h" #include "chrome/browser/web_applications/os_integration/web_app_file_handler_manager.h" #include "chrome/browser/web_applications/proto/web_app_install_state.pb.h" #include "chrome/browser/web_applications/proto/web_app_os_integration_state.pb.h" @@ -33,6 +34,7 @@ #include "chrome/browser/web_applications/web_app_install_params.h" #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_registrar.h" +#include "chrome/browser/web_applications/web_app_ui_manager.h" #include "chrome/common/url_constants.h" #include "components/webapps/browser/install_result_code.h" #include "components/webapps/browser/installable/installable_metrics.h"
diff --git a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProvider.java b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProvider.java index 793adcedb..a0bb024 100644 --- a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProvider.java +++ b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProvider.java
@@ -5,38 +5,19 @@ package org.chromium.chrome.browser.educational_tip; import androidx.annotation.DrawableRes; -import androidx.annotation.IntDef; import org.chromium.chrome.browser.hub.PaneId; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - /** The interface for a card which is shown in the educational tip module. */ public interface EducationalTipCardProvider { // A callback to open the provided pane Id of the Hub layout. + // TODO(https://crbug.com/382803396): Check if this is related to the crash that occurs when + // clicking the tab group sync card; if not, delete it. @FunctionalInterface interface ShowHubPaneCallback { void onClick(@PaneId int paneId); } - /** Card types that are shown in the educational tip module on the magic stack. */ - @IntDef({ - EducationalTipCardType.DEFAULT_BROWSER_PROMO, - EducationalTipCardType.TAB_GROUP, - EducationalTipCardType.TAB_GROUP_SYNC, - EducationalTipCardType.QUICK_DELETE, - EducationalTipCardType.NUM_ENTRIES, - }) - @Retention(RetentionPolicy.SOURCE) - @interface EducationalTipCardType { - int DEFAULT_BROWSER_PROMO = 0; - int TAB_GROUP = 1; - int TAB_GROUP_SYNC = 2; - int QUICK_DELETE = 3; - int NUM_ENTRIES = 4; - } - /** Gets the title of the card. */ String getCardTitle();
diff --git a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderFactory.java b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderFactory.java index dd5c609..bad63e83 100644 --- a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderFactory.java +++ b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderFactory.java
@@ -7,11 +7,11 @@ import androidx.annotation.NonNull; import org.chromium.base.CallbackController; -import org.chromium.chrome.browser.educational_tip.EducationalTipCardProvider.EducationalTipCardType; import org.chromium.chrome.browser.educational_tip.cards.DefaultBrowserPromoCoordinator; import org.chromium.chrome.browser.educational_tip.cards.QuickDeletePromoCoordinator; import org.chromium.chrome.browser.educational_tip.cards.TabGroupPromoCoordinator; import org.chromium.chrome.browser.educational_tip.cards.TabGroupSyncPromoCoordinator; +import org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType; /** A factory interface for building a EducationalTipCardProvider instance. */ public class EducationalTipCardProviderFactory { @@ -19,20 +19,20 @@ * @return An instance of EducationalTipCardProvider. */ static EducationalTipCardProvider createInstance( - @EducationalTipCardType int cardType, + @ModuleType int moduleType, @NonNull Runnable onModuleClickedCallback, @NonNull CallbackController callbackController, @NonNull EducationTipModuleActionDelegate actionDelegate) { - switch (cardType) { - case EducationalTipCardType.DEFAULT_BROWSER_PROMO: + switch (moduleType) { + case ModuleType.DEFAULT_BROWSER_PROMO: return new DefaultBrowserPromoCoordinator(onModuleClickedCallback, actionDelegate); - case EducationalTipCardType.TAB_GROUP: + case ModuleType.TAB_GROUP: return new TabGroupPromoCoordinator( onModuleClickedCallback, callbackController, actionDelegate); - case EducationalTipCardType.TAB_GROUP_SYNC: + case ModuleType.TAB_GROUP_SYNC: return new TabGroupSyncPromoCoordinator( onModuleClickedCallback, callbackController, actionDelegate); - case EducationalTipCardType.QUICK_DELETE: + case ModuleType.QUICK_DELETE: return new QuickDeletePromoCoordinator( onModuleClickedCallback, callbackController, actionDelegate); default:
diff --git a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandler.java b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandler.java index 66bb9e2..a1ba2d7 100644 --- a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandler.java +++ b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandler.java
@@ -8,7 +8,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; -import org.chromium.chrome.browser.educational_tip.EducationalTipCardProvider.EducationalTipCardType; +import org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.tab_group_sync.TabGroupSyncFeatures; import org.chromium.chrome.browser.tab_group_sync.TabGroupSyncServiceFactory; @@ -28,13 +28,13 @@ /** Creates an instance of InputContext. */ @VisibleForTesting static InputContext createInputContext( - @EducationalTipCardType int cardType, + @ModuleType int moduleType, EducationTipModuleActionDelegate actionDelegate, @NonNull Profile profile, Tracker tracker) { InputContext inputContext = new InputContext(); - switch (cardType) { - case EducationalTipCardType.DEFAULT_BROWSER_PROMO: + switch (moduleType) { + case ModuleType.DEFAULT_BROWSER_PROMO: inputContext.addEntry( "should_show_non_role_manager_default_browser_promo", ProcessedValue.fromFloat( @@ -44,7 +44,7 @@ ProcessedValue.fromFloat( hasDefaultBrowserPromoShownInOtherSurface(tracker))); return inputContext; - case EducationalTipCardType.TAB_GROUP: + case ModuleType.TAB_GROUP: inputContext.addEntry( "tab_group_exists", ProcessedValue.fromFloat(tabGroupExists(actionDelegate))); @@ -52,12 +52,12 @@ "number_of_tabs", ProcessedValue.fromFloat(getCurrentTabCount(actionDelegate))); return inputContext; - case EducationalTipCardType.TAB_GROUP_SYNC: + case ModuleType.TAB_GROUP_SYNC: inputContext.addEntry( "synced_tab_group_exists", ProcessedValue.fromFloat(syncedTabGroupExists(profile))); return inputContext; - case EducationalTipCardType.QUICK_DELETE: + case ModuleType.QUICK_DELETE: return inputContext; default: assert false : "Card type not supported!";
diff --git a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilder.java b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilder.java index fa5a81f..0b27eb278 100644 --- a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilder.java +++ b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilder.java
@@ -84,11 +84,10 @@ @Override public InputContext createInputContext() { - int cardType = EducationalTipModuleUtils.getCardType(mModuleType); Profile profile = getRegularProfile(mActionDelegate.getProfileSupplier()); Tracker tracker = TrackerFactory.getTrackerForProfile(profile); return EducationalTipCardProviderSignalHandler.createInputContext( - cardType, mActionDelegate, profile, tracker); + mModuleType, mActionDelegate, profile, tracker); } /** Gets the regular profile if exists. */
diff --git a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediator.java b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediator.java index 82936e0..60feb47 100644 --- a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediator.java +++ b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediator.java
@@ -5,11 +5,8 @@ package org.chromium.chrome.browser.educational_tip; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.VisibleForTesting; import org.chromium.base.CallbackController; -import org.chromium.chrome.browser.educational_tip.EducationalTipCardProvider.EducationalTipCardType; import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.magic_stack.ModuleDelegate; import org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType; @@ -24,8 +21,7 @@ public class EducationalTipModuleMediator { private final EducationTipModuleActionDelegate mActionDelegate; private final Profile mProfile; - private final @ModuleType int mModuleType; - private final @EducationalTipCardType int mCardType; + private @ModuleType int mModuleType; private final PropertyModel mModel; private final ModuleDelegate mModuleDelegate; private final CallbackController mCallbackController; @@ -41,7 +37,6 @@ EducationTipModuleActionDelegate actionDelegate, @NonNull Profile profile) { mModuleType = moduleType; - mCardType = EducationalTipModuleUtils.getCardType(mModuleType); mModel = model; mModuleDelegate = moduleDelegate; mActionDelegate = actionDelegate; @@ -54,39 +49,14 @@ /** Show the educational tip module. */ void showModule() { - showModuleWithCardInfo(mCardType); - } - - /** Called when the educational tip module is visible to users on the magic stack. */ - void onViewCreated() { - if (mCardType == EducationalTipCardType.DEFAULT_BROWSER_PROMO) { - boolean shouldDisplay = - mTracker.shouldTriggerHelpUi( - FeatureConstants.DEFAULT_BROWSER_PROMO_MAGIC_STACK); - if (shouldDisplay) { - DefaultBrowserPromoUtils defaultBrowserPromoUtils = - DefaultBrowserPromoUtils.getInstance(); - defaultBrowserPromoUtils.removeListener(mDefaultBrowserPromoTriggerStateListener); - defaultBrowserPromoUtils.notifyDefaultBrowserPromoVisible(); - } - } - } - - @VisibleForTesting - void showModuleWithCardInfo(@Nullable Integer cardType) { - if (cardType == null) { - mModuleDelegate.onDataFetchFailed(mModuleType); - return; - } - - if (cardType == EducationalTipCardType.DEFAULT_BROWSER_PROMO) { + if (mModuleType == ModuleType.DEFAULT_BROWSER_PROMO) { DefaultBrowserPromoUtils.getInstance() .addListener(mDefaultBrowserPromoTriggerStateListener); } mEducationalTipCardProvider = EducationalTipCardProviderFactory.createInstance( - cardType, this::onCardClicked, mCallbackController, mActionDelegate); + mModuleType, this::onCardClicked, mCallbackController, mActionDelegate); mModel.set( EducationalTipModuleProperties.MODULE_CONTENT_TITLE_STRING, @@ -106,6 +76,21 @@ mModuleDelegate.onDataReady(mModuleType, mModel); } + /** Called when the educational tip module is visible to users on the magic stack. */ + void onViewCreated() { + if (mModuleType == ModuleType.DEFAULT_BROWSER_PROMO) { + boolean shouldDisplay = + mTracker.shouldTriggerHelpUi( + FeatureConstants.DEFAULT_BROWSER_PROMO_MAGIC_STACK); + if (shouldDisplay) { + DefaultBrowserPromoUtils defaultBrowserPromoUtils = + DefaultBrowserPromoUtils.getInstance(); + defaultBrowserPromoUtils.removeListener(mDefaultBrowserPromoTriggerStateListener); + defaultBrowserPromoUtils.notifyDefaultBrowserPromoVisible(); + } + } + } + @ModuleType int getModuleType() { return mModuleType; @@ -146,4 +131,8 @@ DefaultBrowserPromoTriggerStateListener getDefaultBrowserPromoTriggerStateListenerForTesting() { return mDefaultBrowserPromoTriggerStateListener; } + + void setModuleTypeForTesting(@ModuleType int moduleType) { + mModuleType = moduleType; + } }
diff --git a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleUtils.java b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleUtils.java index b54fb97..5cf8e594 100644 --- a/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleUtils.java +++ b/chrome/browser/educational_tip/java/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleUtils.java
@@ -4,7 +4,6 @@ package org.chromium.chrome.browser.educational_tip; -import org.chromium.chrome.browser.educational_tip.EducationalTipCardProvider.EducationalTipCardType; import org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType; import java.util.HashSet; @@ -16,26 +15,9 @@ public static HashSet<Integer> getModuleTypes() { HashSet<Integer> modules = new HashSet<>(); modules.add(ModuleType.DEFAULT_BROWSER_PROMO); - modules.add(ModuleType.TAB_GROUPS); + modules.add(ModuleType.TAB_GROUP); modules.add(ModuleType.TAB_GROUP_SYNC); modules.add(ModuleType.QUICK_DELETE); return modules; } - - /** Returns the card type based on module type. */ - @EducationalTipCardType - static Integer getCardType(@ModuleType int moduleType) { - switch (moduleType) { - case ModuleType.DEFAULT_BROWSER_PROMO: - return EducationalTipCardType.DEFAULT_BROWSER_PROMO; - case ModuleType.TAB_GROUPS: - return EducationalTipCardType.TAB_GROUP; - case ModuleType.TAB_GROUP_SYNC: - return EducationalTipCardType.TAB_GROUP_SYNC; - case ModuleType.QUICK_DELETE: - return EducationalTipCardType.QUICK_DELETE; - default: - return null; - } - } }
diff --git a/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandlerUnitTest.java b/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandlerUnitTest.java index f3953318..8f57b519 100644 --- a/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandlerUnitTest.java +++ b/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipCardProviderSignalHandlerUnitTest.java
@@ -24,9 +24,9 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Features.EnableFeatures; -import org.chromium.chrome.browser.educational_tip.EducationalTipCardProvider.EducationalTipCardType; import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.flags.ChromeFeatureList; +import org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.tab_group_sync.TabGroupSyncFeatures; import org.chromium.chrome.browser.tab_group_sync.TabGroupSyncFeaturesJni; @@ -90,10 +90,7 @@ InputContext inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.DEFAULT_BROWSER_PROMO, - mActionDelegate, - mProfile, - mTracker); + ModuleType.DEFAULT_BROWSER_PROMO, mActionDelegate, mProfile, mTracker); assertEquals(2, inputContext.getSizeForTesting()); // Test signal "should_show_non_role_manager_default_browser_promo". @@ -101,10 +98,7 @@ .thenReturn(true); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.DEFAULT_BROWSER_PROMO, - mActionDelegate, - mProfile, - mTracker); + ModuleType.DEFAULT_BROWSER_PROMO, mActionDelegate, mProfile, mTracker); assertEquals( 1, inputContext.getEntryForTesting( @@ -116,10 +110,7 @@ .thenReturn(false); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.DEFAULT_BROWSER_PROMO, - mActionDelegate, - mProfile, - mTracker); + ModuleType.DEFAULT_BROWSER_PROMO, mActionDelegate, mProfile, mTracker); assertEquals( 0, inputContext.getEntryForTesting( @@ -132,10 +123,7 @@ .thenReturn(true); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.DEFAULT_BROWSER_PROMO, - mActionDelegate, - mProfile, - mTracker); + ModuleType.DEFAULT_BROWSER_PROMO, mActionDelegate, mProfile, mTracker); assertEquals( 0, inputContext.getEntryForTesting("has_default_browser_promo_shown_in_other_surface") @@ -146,10 +134,7 @@ .thenReturn(false); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.DEFAULT_BROWSER_PROMO, - mActionDelegate, - mProfile, - mTracker); + ModuleType.DEFAULT_BROWSER_PROMO, mActionDelegate, mProfile, mTracker); assertEquals( 1, inputContext.getEntryForTesting("has_default_browser_promo_shown_in_other_surface") @@ -165,7 +150,7 @@ InputContext inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP, mActionDelegate, mProfile, mTracker); assertEquals(2, inputContext.getSizeForTesting()); // Test signal "tab_group_exists". @@ -173,14 +158,14 @@ when(mIncognitoFilter.getTabGroupCount()).thenReturn(0); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP, mActionDelegate, mProfile, mTracker); assertEquals(0, inputContext.getEntryForTesting("tab_group_exists").floatValue, 0.01); when(mNormalFilter.getTabGroupCount()).thenReturn(5); when(mIncognitoFilter.getTabGroupCount()).thenReturn(6); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP, mActionDelegate, mProfile, mTracker); assertEquals(1, inputContext.getEntryForTesting("tab_group_exists").floatValue, 0.01); // Test signal "number_of_tabs". @@ -188,28 +173,28 @@ when(mIncognitoModel.getCount()).thenReturn(0); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP, mActionDelegate, mProfile, mTracker); assertEquals(0, inputContext.getEntryForTesting("number_of_tabs").floatValue, 0.01); when(mNormalModel.getCount()).thenReturn(5); when(mIncognitoModel.getCount()).thenReturn(0); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP, mActionDelegate, mProfile, mTracker); assertEquals(5, inputContext.getEntryForTesting("number_of_tabs").floatValue, 0.01); when(mNormalModel.getCount()).thenReturn(0); when(mIncognitoModel.getCount()).thenReturn(10); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP, mActionDelegate, mProfile, mTracker); assertEquals(10, inputContext.getEntryForTesting("number_of_tabs").floatValue, 0.01); when(mNormalModel.getCount()).thenReturn(10); when(mIncognitoModel.getCount()).thenReturn(10); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP, mActionDelegate, mProfile, mTracker); assertEquals(20, inputContext.getEntryForTesting("number_of_tabs").floatValue, 0.01); } @@ -222,7 +207,7 @@ InputContext inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); assertEquals(1, inputContext.getSizeForTesting()); // Test signal "synced_tab_group_exists". @@ -230,14 +215,14 @@ when(mMockTabGroupSyncService.getAllGroupIds()).thenReturn(new String[] {SYNC_ID}); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); assertEquals( 1, inputContext.getEntryForTesting("synced_tab_group_exists").floatValue, 0.01); when(mMockTabGroupSyncService.getAllGroupIds()).thenReturn(new String[] {}); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); assertEquals( 0, inputContext.getEntryForTesting("synced_tab_group_exists").floatValue, 0.01); @@ -245,7 +230,7 @@ when(mMockTabGroupSyncService.getAllGroupIds()).thenReturn(new String[] {SYNC_ID}); inputContext = EducationalTipCardProviderSignalHandler.createInputContext( - EducationalTipCardType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); + ModuleType.TAB_GROUP_SYNC, mActionDelegate, mProfile, mTracker); assertEquals( 0, inputContext.getEntryForTesting("synced_tab_group_exists").floatValue, 0.01); }
diff --git a/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilderUnitTest.java b/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilderUnitTest.java index 76d86dd..7218819 100644 --- a/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilderUnitTest.java +++ b/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleBuilderUnitTest.java
@@ -137,7 +137,7 @@ assertNull(inputContextForTest.getEntryForTesting("number_of_tabs")); EducationalTipModuleBuilder moduleBuilderForTabGroupPromo = - new EducationalTipModuleBuilder(ModuleType.TAB_GROUPS, mActionDelegate); + new EducationalTipModuleBuilder(ModuleType.TAB_GROUP, mActionDelegate); inputContextForTest = moduleBuilderForTabGroupPromo.createInputContext(); assertNull( inputContextForTest.getEntryForTesting(
diff --git a/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediatorUnitTest.java b/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediatorUnitTest.java index 84e5d27..9f7468f 100644 --- a/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediatorUnitTest.java +++ b/chrome/browser/educational_tip/junit/src/org/chromium/chrome/browser/educational_tip/EducationalTipModuleMediatorUnitTest.java
@@ -6,7 +6,6 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -26,10 +25,8 @@ import org.mockito.junit.MockitoRule; import org.robolectric.annotation.Config; -import org.chromium.base.FeatureList; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Features.EnableFeatures; -import org.chromium.chrome.browser.educational_tip.EducationalTipCardProvider.EducationalTipCardType; import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.magic_stack.ModuleDelegate; @@ -61,63 +58,61 @@ private ArgumentCaptor<DefaultBrowserPromoTriggerStateListener> mDefaultBrowserPromoTriggerStateListener; - private FeatureList.TestValues mParamsTestValues; private Context mContext; - private @ModuleType int mExpectedModuleType; + private @ModuleType int mDefaultModuleTypeForTesting; private EducationalTipModuleMediator mEducationalTipModuleMediator; @Before public void setUp() { - mParamsTestValues = new FeatureList.TestValues(); mContext = ApplicationProvider.getApplicationContext(); when(mActionDelegate.getContext()).thenReturn(mContext); when(mProfile.getOriginalProfile()).thenReturn(mProfile); - mExpectedModuleType = ModuleType.DEFAULT_BROWSER_PROMO; + mDefaultModuleTypeForTesting = ModuleType.DEFAULT_BROWSER_PROMO; TrackerFactory.setTrackerForTests(mTracker); DefaultBrowserPromoUtils.setInstanceForTesting(mMockDefaultBrowserPromoUtils); mEducationalTipModuleMediator = new EducationalTipModuleMediator( - mExpectedModuleType, mModel, mModuleDelegate, mActionDelegate, mProfile); + mDefaultModuleTypeForTesting, + mModel, + mModuleDelegate, + mActionDelegate, + mProfile); } @Test @SmallTest @EnableFeatures({ChromeFeatureList.EDUCATIONAL_TIP_MODULE}) - public void testShowModuleWithCardInfo() { + public void testShowModule() { assertTrue(ChromeFeatureList.sEducationalTipModule.isEnabled()); // Test showing default browser promo card. - testShowModuleWithCardInfoImpl( - EducationalTipCardType.DEFAULT_BROWSER_PROMO, + testShowModuleImpl( + ModuleType.DEFAULT_BROWSER_PROMO, R.string.educational_tip_default_browser_title, R.string.educational_tip_default_browser_description, - R.drawable.default_browser_promo_logo, - /* timesOfCall= */ 1); + R.drawable.default_browser_promo_logo); // Test showing tab group promo card. - testShowModuleWithCardInfoImpl( - EducationalTipCardType.TAB_GROUP, + testShowModuleImpl( + ModuleType.TAB_GROUP, R.string.educational_tip_tab_group_title, R.string.educational_tip_tab_group_description, - R.drawable.tab_group_promo_logo, - /* timesOfCall= */ 2); + R.drawable.tab_group_promo_logo); // Test showing tab group sync promo card. - testShowModuleWithCardInfoImpl( - EducationalTipCardType.TAB_GROUP_SYNC, + testShowModuleImpl( + ModuleType.TAB_GROUP_SYNC, R.string.educational_tip_tab_group_sync_title, R.string.educational_tip_tab_group_sync_description, - R.drawable.tab_group_sync_promo_logo, - /* timesOfCall= */ 3); + R.drawable.tab_group_sync_promo_logo); // Test showing quick delete promo card. - testShowModuleWithCardInfoImpl( - EducationalTipCardType.QUICK_DELETE, + testShowModuleImpl( + ModuleType.QUICK_DELETE, R.string.educational_tip_quick_delete_title, R.string.educational_tip_quick_delete_description, - R.drawable.quick_delete_promo_logo, - /* timesOfCall= */ 4); + R.drawable.quick_delete_promo_logo); } @Test @@ -137,8 +132,8 @@ when(mTracker.shouldTriggerHelpUi(FeatureConstants.DEFAULT_BROWSER_PROMO_MAGIC_STACK)) .thenReturn(true); - mEducationalTipModuleMediator.showModuleWithCardInfo( - EducationalTipCardType.DEFAULT_BROWSER_PROMO); + mEducationalTipModuleMediator.setModuleTypeForTesting(ModuleType.DEFAULT_BROWSER_PROMO); + mEducationalTipModuleMediator.showModule(); mEducationalTipModuleMediator.onViewCreated(); verify(mMockDefaultBrowserPromoUtils) .removeListener( @@ -148,9 +143,15 @@ mEducationalTipModuleMediator = new EducationalTipModuleMediator( - ModuleType.TAB_GROUPS, mModel, mModuleDelegate, mActionDelegate, mProfile); - mEducationalTipModuleMediator.showModuleWithCardInfo(EducationalTipCardType.TAB_GROUP); + ModuleType.TAB_GROUP, mModel, mModuleDelegate, mActionDelegate, mProfile); + mEducationalTipModuleMediator.setModuleTypeForTesting(ModuleType.TAB_GROUP); + mEducationalTipModuleMediator.showModule(); mEducationalTipModuleMediator.onViewCreated(); + verify(mMockDefaultBrowserPromoUtils, never()) + .removeListener( + mEducationalTipModuleMediator + .getDefaultBrowserPromoTriggerStateListenerForTesting()); + verify(mMockDefaultBrowserPromoUtils).notifyDefaultBrowserPromoVisible(); } @Test @@ -158,24 +159,21 @@ @EnableFeatures({ChromeFeatureList.EDUCATIONAL_TIP_MODULE}) public void testRemoveModule() { assertTrue(ChromeFeatureList.sEducationalTipModule.isEnabled()); - mEducationalTipModuleMediator.showModuleWithCardInfo( - EducationalTipCardType.DEFAULT_BROWSER_PROMO); + mEducationalTipModuleMediator.setModuleTypeForTesting(ModuleType.DEFAULT_BROWSER_PROMO); + mEducationalTipModuleMediator.showModule(); verify(mMockDefaultBrowserPromoUtils) .addListener(mDefaultBrowserPromoTriggerStateListener.capture()); mDefaultBrowserPromoTriggerStateListener.getValue().onDefaultBrowserPromoTriggered(); - verify(mModuleDelegate).removeModule(mExpectedModuleType); + verify(mModuleDelegate).removeModule(mDefaultModuleTypeForTesting); verify(mMockDefaultBrowserPromoUtils) .removeListener(mDefaultBrowserPromoTriggerStateListener.capture()); } - private void testShowModuleWithCardInfoImpl( - @EducationalTipCardType int cardType, - int titleId, - int descriptionId, - int imageResource, - int timesOfCall) { - mEducationalTipModuleMediator.showModuleWithCardInfo(cardType); + private void testShowModuleImpl( + @ModuleType int moduleType, int titleId, int descriptionId, int imageResource) { + mEducationalTipModuleMediator.setModuleTypeForTesting(moduleType); + mEducationalTipModuleMediator.showModule(); verify(mModel) .set( @@ -186,7 +184,7 @@ EducationalTipModuleProperties.MODULE_CONTENT_DESCRIPTION_STRING, mContext.getString(descriptionId)); verify(mModel).set(EducationalTipModuleProperties.MODULE_CONTENT_IMAGE, imageResource); - verify(mModuleDelegate, times(timesOfCall)).onDataReady(mExpectedModuleType, mModel); - verify(mModuleDelegate, never()).onDataFetchFailed(mExpectedModuleType); + verify(mModuleDelegate).onDataReady(moduleType, mModel); + verify(mModuleDelegate, never()).onDataFetchFailed(moduleType); } }
diff --git a/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc b/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc index 2a04248..7f92ea30 100644 --- a/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc +++ b/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
@@ -34,6 +34,7 @@ #include "chrome/browser/ui/tab_helpers.h" #include "chrome/browser/ui/web_applications/web_app_dialog_utils.h" #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" +#include "chrome/browser/web_applications/commands/fetch_installability_for_chrome_management.h" #include "chrome/browser/web_applications/extension_status_utils.h" #include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h" #include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc index 2438e2c..a588df8f 100644 --- a/chrome/browser/extensions/api/tabs/tabs_test.cc +++ b/chrome/browser/extensions/api/tabs/tabs_test.cc
@@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - #include <limits.h> #include <stddef.h> #include <stdint.h> @@ -53,6 +52,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h" #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h"
diff --git a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedFeaturesTest.java b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedFeaturesTest.java index 63e6182..0f557ad 100644 --- a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedFeaturesTest.java +++ b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedFeaturesTest.java
@@ -12,7 +12,6 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; -import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -66,11 +65,6 @@ FeatureList.setTestValues(mParamsTestValues); } - @After - public void tearDown() { - FeatureList.setTestValues(null); - } - @Test public void testAlwaysResetByDefault() { assertEquals(StreamTabId.FOR_YOU, FeedFeatures.getFeedTabIdToRestore(mProfile));
diff --git a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedStreamTest.java b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedStreamTest.java index 4623fdf..4cf6167 100644 --- a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedStreamTest.java +++ b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedStreamTest.java
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.when; import android.app.Activity; -import android.util.ArrayMap; import android.util.TypedValue; import android.widget.FrameLayout; @@ -49,9 +48,10 @@ import org.robolectric.shadows.ShadowLog; import org.chromium.base.Callback; -import org.chromium.base.FeatureList; import org.chromium.base.supplier.Supplier; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.Features.DisableFeatures; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.base.test.util.HistogramWatcher; import org.chromium.chrome.browser.feed.v2.FeedUserActionType; import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge; @@ -82,15 +82,15 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** Unit tests for {@link FeedStream}. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE) // TODO(crbug.com/40182398): Rewrite using paused loop. See crbug for details. @LooperMode(LooperMode.Mode.LEGACY) +@EnableFeatures(ChromeFeatureList.FEED_LOADING_PLACEHOLDER) +@DisableFeatures(ChromeFeatureList.FEED_CONTAINMENT) public class FeedStreamTest { private static final int LOAD_MORE_TRIGGER_LOOKAHEAD = 5; private static final int LOAD_MORE_TRIGGER_SCROLL_DISTANCE_DP = 100; @@ -151,13 +151,6 @@ } } - private void setFeatureOverrides(boolean feedLoadingPlaceholderOn) { - Map<String, Boolean> overrides = new ArrayMap<>(); - overrides.put(ChromeFeatureList.FEED_LOADING_PLACEHOLDER, feedLoadingPlaceholderOn); - overrides.put(ChromeFeatureList.FEED_CONTAINMENT, false); - FeatureList.setTestFeatures(overrides); - } - private static HistogramWatcher expectFeedRecordForLoadMoreTrigger( @StreamKind int streamKind, int itemCount, int numCardsRemaining) { return HistogramWatcher.newBuilder() @@ -206,8 +199,6 @@ when(mRenderer.getListLayoutHelper()).thenReturn(mLayoutManager); when(mRenderer.getAdapter()).thenReturn(mAdapter); - setFeatureOverrides(/* feedLoadingPlaceholderOn= */ true); - // Print logs to stdout. ShadowLog.stream = System.out; } @@ -1151,8 +1142,8 @@ @Test @SmallTest + @DisableFeatures(ChromeFeatureList.FEED_LOADING_PLACEHOLDER) public void testShowSpinner_PlaceholderDisabled() { - setFeatureOverrides(/* feedLoadingPlaceholderOn= */ false); createHeaderContent(1); bindToView(); FeedUiProto.StreamUpdate update = @@ -1196,10 +1187,8 @@ @Test @SmallTest + @DisableFeatures(ChromeFeatureList.WEB_FEED_SORT) public void testUnreadContentObserver_notNullWebFeed_sortOff() { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.WEB_FEED_SORT, false); - FeatureList.setTestFeatures(features); FeedStream stream = new FeedStream( mActivity, @@ -1215,15 +1204,12 @@ /* SingleWebFeedHelper= */ null, new FeedSurfaceRendererBridgeFactory()); assertNotNull(stream.getUnreadContentObserverForTest()); - FeatureList.setTestFeatures(null); } @Test @SmallTest + @EnableFeatures(ChromeFeatureList.WEB_FEED_SORT) public void testUnreadContentObserver_notNullWebFeed_sortOn() { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.WEB_FEED_SORT, true); - FeatureList.setTestFeatures(features); FeedStream stream = new FeedStream( mActivity, @@ -1239,15 +1225,12 @@ /* SingleWebFeedHelper= */ null, new FeedSurfaceRendererBridgeFactory()); assertNotNull(stream.getUnreadContentObserverForTest()); - FeatureList.setTestFeatures(null); } @Test @SmallTest + @DisableFeatures(ChromeFeatureList.WEB_FEED_SORT) public void testSupportsOptions_InterestFeed_sortOff() { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.WEB_FEED_SORT, false); - FeatureList.setTestFeatures(features); FeedStream stream = new FeedStream( mActivity, @@ -1267,10 +1250,8 @@ @Test @SmallTest + @EnableFeatures(ChromeFeatureList.WEB_FEED_SORT) public void testSupportsOptions_InterestFeed_sortOn() { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.WEB_FEED_SORT, true); - FeatureList.setTestFeatures(features); FeedStream stream = new FeedStream( mActivity, @@ -1290,10 +1271,8 @@ @Test @SmallTest + @DisableFeatures(ChromeFeatureList.WEB_FEED_SORT) public void testSupportsOptions_WebFeed_sortOff() { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.WEB_FEED_SORT, false); - FeatureList.setTestFeatures(features); FeedStream stream = new FeedStream( mActivity, @@ -1313,10 +1292,8 @@ @Test @SmallTest + @EnableFeatures(ChromeFeatureList.WEB_FEED_SORT) public void testSupportsOptions_WebFeed_sortOn() { - Map<String, Boolean> features = new HashMap<>(); - features.put(ChromeFeatureList.WEB_FEED_SORT, true); - FeatureList.setTestFeatures(features); FeedStream stream = new FeedStream( mActivity,
diff --git a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/SingleWebFeedStreamTest.java b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/SingleWebFeedStreamTest.java index 2850341..0c3980d 100644 --- a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/SingleWebFeedStreamTest.java +++ b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/SingleWebFeedStreamTest.java
@@ -16,7 +16,6 @@ import static org.mockito.Mockito.when; import android.app.Activity; -import android.util.ArrayMap; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; @@ -36,9 +35,9 @@ import org.robolectric.shadows.ShadowLog; import org.chromium.base.Callback; -import org.chromium.base.FeatureList; import org.chromium.base.supplier.Supplier; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.chrome.browser.feed.v2.FeedUserActionType; import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge; import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge.FollowResults; @@ -67,13 +66,13 @@ import org.chromium.url.JUnitTestGURLs; import java.nio.charset.StandardCharsets; -import java.util.Map; /** Unit tests for {@link FeedStream}. */ @RunWith(BaseRobolectricTestRunner.class) @Config(manifest = Config.NONE) // TODO(crbug.com/40182398): Rewrite using paused loop. See crbug for details. @LooperMode(LooperMode.Mode.LEGACY) +@EnableFeatures(ChromeFeatureList.FEED_LOADING_PLACEHOLDER) public class SingleWebFeedStreamTest { private static final int LOAD_MORE_TRIGGER_LOOKAHEAD = 5; private static final int LOAD_MORE_TRIGGER_SCROLL_DISTANCE_DP = 100; @@ -129,12 +128,6 @@ } } - private void setFeatureOverrides(boolean feedLoadingPlaceholderOn) { - Map<String, Boolean> overrides = new ArrayMap<>(); - overrides.put(ChromeFeatureList.FEED_LOADING_PLACEHOLDER, feedLoadingPlaceholderOn); - FeatureList.setTestFeatures(overrides); - } - @Before public void setUp() { MockitoAnnotations.initMocks(this); @@ -174,8 +167,6 @@ when(mRenderer.getListLayoutHelper()).thenReturn(mLayoutManager); when(mRenderer.getAdapter()).thenReturn(mAdapter); - setFeatureOverrides(/* feedLoadingPlaceholderOn= */ true); - // Print logs to stdout. ShadowLog.stream = System.out; }
diff --git a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/webfeed/WebFeedFollowIntroViewTest.java b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/webfeed/WebFeedFollowIntroViewTest.java index 1eacbe3..459ac290 100644 --- a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/webfeed/WebFeedFollowIntroViewTest.java +++ b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/webfeed/WebFeedFollowIntroViewTest.java
@@ -33,8 +33,6 @@ import org.chromium.components.user_prefs.UserPrefs; import org.chromium.components.user_prefs.UserPrefsJni; -import java.util.HashMap; - /** Test for the WebFeedFollowIntroView class. */ @RunWith(BaseRobolectricTestRunner.class) public final class WebFeedFollowIntroViewTest { @@ -58,9 +56,6 @@ mMenuButtonAnchorView = new View(mActivity); TrackerFactory.setTrackerForTests(mTracker); - // This empty setTestFeatures call below is needed to enable the field trial param calls. - FeatureList.setTestFeatures(new HashMap<String, Boolean>()); - // Build the class under test. Runnable noOp = CallbackUtils.emptyRunnable(); mWebFeedFollowIntroView =
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListInstrumentationTest.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListInstrumentationTest.java index 632a5ff..3cfde9819 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListInstrumentationTest.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListInstrumentationTest.java
@@ -7,8 +7,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import android.util.ArrayMap; - import androidx.test.filters.MediumTest; import org.junit.Before; @@ -24,8 +22,6 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeTabbedActivityTestRule; -import java.util.Map; - /** Tests the behavior of {@link ChromeFeatureList} in instrumentation tests. */ @RunWith(ChromeJUnit4ClassRunner.class) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @@ -57,15 +53,13 @@ @Test @MediumTest - public void testSetTestFeatures() { - Map<String, Boolean> overrides = new ArrayMap<>(); - overrides.put(ChromeFeatureList.TEST_DEFAULT_DISABLED, true); - overrides.put(ChromeFeatureList.TEST_DEFAULT_ENABLED, false); - FeatureList.setTestFeatures(overrides); + public void testSetTestValues() { + FeatureList.TestValues overrides = new FeatureList.TestValues(); + overrides.addFeatureFlagOverride(ChromeFeatureList.TEST_DEFAULT_DISABLED, true); + overrides.addFeatureFlagOverride(ChromeFeatureList.TEST_DEFAULT_ENABLED, false); + FeatureList.setTestValues(overrides); assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_DISABLED)); assertFalse(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_ENABLED)); - - FeatureList.setTestFeatures(null); } }
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListUnitTest.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListUnitTest.java index bbb0e87..6778fc7e 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListUnitTest.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureListUnitTest.java
@@ -60,21 +60,21 @@ /** * In unit tests, flags may have their value specified by calling {@link - * FeatureList#setTestFeatures(java.util.Map)}. + * FeatureList#setTestFeature(String, boolean)}. */ @Test - @EnableFeatures(ChromeFeatureList.TEST_DEFAULT_DISABLED) - public void testSetTestFeaturesEnabled_returnsEnabled() { + public void testSetTestFeatureEnabled_returnsEnabled() { + FeatureList.setTestFeature(ChromeFeatureList.TEST_DEFAULT_DISABLED, true); assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_DISABLED)); } /** * In unit tests, flags may have their value specified by calling {@link - * FeatureList#setTestFeatures(java.util.Map)}. + * FeatureList#setTestFeature(String, boolean)}. */ @Test - @DisableFeatures(ChromeFeatureList.TEST_DEFAULT_ENABLED) public void testSetTestFeaturesDisabled_returnsDisabled() { + FeatureList.setTestFeature(ChromeFeatureList.TEST_DEFAULT_ENABLED, false); assertFalse(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_ENABLED)); }
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/FieldTrialsInstrumentationTest.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/FieldTrialsInstrumentationTest.java index 8062aa8..de0fd41 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/FieldTrialsInstrumentationTest.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/FieldTrialsInstrumentationTest.java
@@ -63,7 +63,7 @@ public void testNative_EnableWithParams() { // @Param overrides as Java level, but should also override at native level. Remove the // override at Java level to check the override at native level. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); mActivityTestRule.startMainActivityOnBlankPage(); Assert.assertEquals("b1", ChromeFeatureList.getFieldTrialParamByFeature(FEATURE_1, "a1")); @@ -85,7 +85,7 @@ // @CommandLine overrides as Java level, but should also override at native level. Remove // the override at Java level to check the override at native level. mActivityTestRule.startMainActivityOnBlankPage(); - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); Assert.assertEquals("b1", ChromeFeatureList.getFieldTrialParamByFeature(FEATURE_1, "a1")); Assert.assertEquals("b2", ChromeFeatureList.getFieldTrialParamByFeature(FEATURE_1, "a2")); @@ -110,7 +110,7 @@ // @CommandLine overrides as Java level, but should also override at native level. Remove // the override at Java level to check the override at native level. mActivityTestRule.startMainActivityOnBlankPage(); - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); Assert.assertEquals( "%:/.,",
diff --git a/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesConfigSettings.java b/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesConfigSettings.java index 6deb531..e8da87f 100644 --- a/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesConfigSettings.java +++ b/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesConfigSettings.java
@@ -10,7 +10,7 @@ import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.QUICK_DELETE; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.SAFETY_HUB; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.SINGLE_TAB; -import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_GROUPS; +import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_GROUP; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_GROUP_SYNC; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_RESUMPTION; @@ -91,7 +91,7 @@ case SAFETY_HUB: return resources.getString(R.string.safety_hub_magic_stack_module_name); case DEFAULT_BROWSER_PROMO: - case TAB_GROUPS: + case TAB_GROUP: case TAB_GROUP_SYNC: case QUICK_DELETE: // All tips use the same name.
diff --git a/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesMetricsUtils.java b/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesMetricsUtils.java index 943726c9..324ee70 100644 --- a/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesMetricsUtils.java +++ b/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/HomeModulesMetricsUtils.java
@@ -11,7 +11,7 @@ import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.QUICK_DELETE; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.SAFETY_HUB; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.SINGLE_TAB; -import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_GROUPS; +import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_GROUP; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_GROUP_SYNC; import static org.chromium.chrome.browser.magic_stack.ModuleDelegate.ModuleType.TAB_RESUMPTION; @@ -95,17 +95,6 @@ @VisibleForTesting static final String HISTOGRAM_CONFIGURATION_TURN_OFF_MODULE = "Settings.TurnOffModule"; - private static final String SINGLE_TAB_FRESHNESS_INPUT_CONTEXT = "single_tab_freshness"; - - private static final String PRICE_CHANGE_FRESHNESS_INPUT_CONTEXT = "price_change_freshness"; - - private static final String TAB_RESUMPTION_FRESHNESS_INPUT_CONTEXT = "tab_resumption_freshness"; - - private static final String SAFETY_HUB_FRESHNESS_INPUT_CONTEXT = "safety_hub_freshness"; - - private static final String AUXILIARY_SEARCH_FRESHNESS_INPUT_CONTEXT = - "auxiliary_search_freshness"; - /** * Returns a string name of a module. Remember to update the variant ModuleType in * tools/metrics/histograms/metadata/magic_stack/histograms.xml when adding a new module type @@ -128,7 +117,7 @@ return "AuxiliarySearch"; case DEFAULT_BROWSER_PROMO: return "DefaultBrowserPromo"; - case TAB_GROUPS: + case TAB_GROUP: return "TabGroupPromo"; case TAB_GROUP_SYNC: return "TabGroupSyncPromo"; @@ -140,29 +129,6 @@ } } - /** - * Returns the freshness score key used by InputContext for the given module. Remember to update - * the variant ModuleType in tools/metrics/histograms/metadata/magic_stack/histograms.xml when - * adding a new module type - */ - public static String getFreshnessInputContextString(@ModuleType int moduleType) { - switch (moduleType) { - case SINGLE_TAB: - return SINGLE_TAB_FRESHNESS_INPUT_CONTEXT; - case PRICE_CHANGE: - return PRICE_CHANGE_FRESHNESS_INPUT_CONTEXT; - case TAB_RESUMPTION: - return TAB_RESUMPTION_FRESHNESS_INPUT_CONTEXT; - case SAFETY_HUB: - return SAFETY_HUB_FRESHNESS_INPUT_CONTEXT; - case AUXILIARY_SEARCH: - return AUXILIARY_SEARCH_FRESHNESS_INPUT_CONTEXT; - default: - assert false : "Module type not supported!"; - return null; - } - } - public static Integer convertLabelToModuleType(String label) { switch (label) { case "SingleTab": @@ -178,7 +144,7 @@ case "DefaultBrowserPromo": return DEFAULT_BROWSER_PROMO; case "TabGroupPromo": - return TAB_GROUPS; + return TAB_GROUP; case "TabGroupSyncPromo": return TAB_GROUP_SYNC; case "QuickDeletePromo":
diff --git a/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/ModuleDelegate.java b/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/ModuleDelegate.java index c2877e0..8ed7bcf 100644 --- a/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/ModuleDelegate.java +++ b/chrome/browser/magic_stack/android/java/src/org/chromium/chrome/browser/magic_stack/ModuleDelegate.java
@@ -31,7 +31,7 @@ ModuleType.DEPRECATED_EDUCATIONAL_TIP, ModuleType.AUXILIARY_SEARCH, ModuleType.DEFAULT_BROWSER_PROMO, - ModuleType.TAB_GROUPS, + ModuleType.TAB_GROUP, ModuleType.TAB_GROUP_SYNC, ModuleType.QUICK_DELETE, ModuleType.NUM_ENTRIES @@ -45,7 +45,7 @@ int DEPRECATED_EDUCATIONAL_TIP = 4; int AUXILIARY_SEARCH = 5; int DEFAULT_BROWSER_PROMO = 6; - int TAB_GROUPS = 7; + int TAB_GROUP = 7; int TAB_GROUP_SYNC = 8; int QUICK_DELETE = 9; int NUM_ENTRIES = 10;
diff --git a/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesCoordinatorUnitTest.java b/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesCoordinatorUnitTest.java index db1922e..6a477cd 100644 --- a/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesCoordinatorUnitTest.java +++ b/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesCoordinatorUnitTest.java
@@ -145,7 +145,6 @@ @After public void tearDown() { mCoordinator.destroy(); - FeatureList.setTestValues(null); } @Test
diff --git a/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesMediatorUnitTest.java b/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesMediatorUnitTest.java index 8ae585e1..525bf32 100644 --- a/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesMediatorUnitTest.java +++ b/chrome/browser/magic_stack/android/junit/src/org/chromium/chrome/browser/magic_stack/HomeModulesMediatorUnitTest.java
@@ -585,7 +585,7 @@ ModuleType.SAFETY_HUB, ModuleType.AUXILIARY_SEARCH, ModuleType.DEFAULT_BROWSER_PROMO, - ModuleType.TAB_GROUPS, + ModuleType.TAB_GROUP, ModuleType.TAB_GROUP_SYNC, ModuleType.QUICK_DELETE); assertEquals(expectedModuleSet, mMediator.getFilteredEnabledModuleSet()); @@ -600,7 +600,7 @@ ModuleType.SAFETY_HUB, ModuleType.AUXILIARY_SEARCH, ModuleType.DEFAULT_BROWSER_PROMO, - ModuleType.TAB_GROUPS, + ModuleType.TAB_GROUP, ModuleType.TAB_GROUP_SYNC, ModuleType.QUICK_DELETE); assertEquals(expectedModuleSet, mMediator.getFilteredEnabledModuleSet()); @@ -627,7 +627,7 @@ ModuleType.SAFETY_HUB, ModuleType.AUXILIARY_SEARCH, ModuleType.DEFAULT_BROWSER_PROMO, - ModuleType.TAB_GROUPS, + ModuleType.TAB_GROUP, ModuleType.TAB_GROUP_SYNC, ModuleType.QUICK_DELETE); assertEquals(expectedModuleSet, mMediator.getFilteredEnabledModuleSet());
diff --git a/chrome/browser/navigation_predictor/navigation_predictor.h b/chrome/browser/navigation_predictor/navigation_predictor.h index 8b97cee..de41ead6 100644 --- a/chrome/browser/navigation_predictor/navigation_predictor.h +++ b/chrome/browser/navigation_predictor/navigation_predictor.h
@@ -154,8 +154,7 @@ std::optional<base::TimeTicks> pointer_over_timestamp; size_t pointer_hovering_over_count = 0u; }; - std::unordered_map<AnchorId, AnchorElementData, typename AnchorId::Hasher> - anchors_; + std::unordered_map<AnchorId, AnchorElementData> anchors_; // It is the anchor element that the user has recently interacted // with and is a good candidate for the ML model to predict the next user // click. @@ -166,8 +165,7 @@ // Mapping between the anchor ID for the anchors that we track and the index // that this anchor will have in the UKM logs. - std::unordered_map<AnchorId, int, typename AnchorId::Hasher> - tracked_anchor_id_to_index_; + std::unordered_map<AnchorId, int> tracked_anchor_id_to_index_; // URLs that were sent to the prediction service. // We store hashes of URLs, rather than URLs themselves, to save memory.
diff --git a/chrome/browser/nearby_sharing/nearby_share_delegate_impl.cc b/chrome/browser/nearby_sharing/nearby_share_delegate_impl.cc index df240f3c..821c1c77 100644 --- a/chrome/browser/nearby_sharing/nearby_share_delegate_impl.cc +++ b/chrome/browser/nearby_sharing/nearby_share_delegate_impl.cc
@@ -38,8 +38,6 @@ base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds()); } -const gfx::VectorIcon kEmptyIcon; - } // namespace NearbyShareDelegateImpl::NearbyShareDelegateImpl( @@ -245,7 +243,7 @@ return on_icon ? kNearbyShareInternalIcon : kNearbyShareInternalOffIcon; } #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) - return kEmptyIcon; + return gfx::VectorIcon::EmptyIcon(); } std::u16string NearbyShareDelegateImpl::GetPlaceholderFeatureName() const {
diff --git a/chrome/browser/partnercustomizations/java/src/org/chromium/chrome/browser/partnercustomizations/PartnerCustomizationsUmaUnitTest.java b/chrome/browser/partnercustomizations/java/src/org/chromium/chrome/browser/partnercustomizations/PartnerCustomizationsUmaUnitTest.java index d7eed9b2..f16ee1f 100644 --- a/chrome/browser/partnercustomizations/java/src/org/chromium/chrome/browser/partnercustomizations/PartnerCustomizationsUmaUnitTest.java +++ b/chrome/browser/partnercustomizations/java/src/org/chromium/chrome/browser/partnercustomizations/PartnerCustomizationsUmaUnitTest.java
@@ -150,7 +150,7 @@ @Test public void testOnFinishNativeInitializationEnabled_beforeNativeInit() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); mPartnerCustomizationsUma.onFinishNativeInitializationOrEnabled( mActivityLifecycleDispatcherMock, () -> mDidCall = true); NativeInitObserver observer = captureObserverFromLifecycleMock(); @@ -168,7 +168,7 @@ @Test public void testOnFinishNativeInitializationEnabled_beforeNativeInitDisabled() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); mPartnerCustomizationsUma.onFinishNativeInitializationOrEnabled( mActivityLifecycleDispatcherMock, () -> mDidCall = true); NativeInitObserver observer = captureObserverFromLifecycleMock(); @@ -528,7 +528,7 @@ @Test public void testCreateNtpIncorrectlyBeforeCustomization() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(NTP_INCORRECTLY, NOT_CACHED, SOME_DELEGATE); expectInitializationCompleted( @@ -553,7 +553,7 @@ @Test public void testCreateNtpCorrectlyBeforeCustomization() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(NTP_CORRECTLY, NOT_CACHED, SOME_DELEGATE); expectInitializationCompleted( @@ -578,7 +578,7 @@ @Test public void testCreateNtpUnknownBeforeCustomization() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(NTP_UNKNOWN, NOT_CACHED, SOME_DELEGATE); expectInitializationCompleted(builder, NOT_CACHED, SOME_DELEGATE, CANCELLED, UNUSED_TIME); @@ -601,7 +601,7 @@ @Test public void testCreatePartnerHomepageBeforeCustomization() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(PARTNER_CUSTOM_HOMEPAGE, NOT_CACHED, SOME_DELEGATE); expectInitializationCompleted( @@ -626,7 +626,7 @@ @Test public void testCreateOtherHomepageBeforeCustomization() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(OTHER_CUSTOM_HOMEPAGE, false, SOME_DELEGATE); expectInitializationCompleted( @@ -659,7 +659,7 @@ @Test public void testCreateNtpCorrectlyCached() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(NTP_CORRECTLY, CACHED, SOME_DELEGATE); expectInitializationCompleted( @@ -684,7 +684,7 @@ @Test public void testCreatePartnerHomepageCached() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(PARTNER_CUSTOM_HOMEPAGE, CACHED, SOME_DELEGATE); expectInitializationCompleted( @@ -709,7 +709,7 @@ @Test public void testCreateNtpCorrectlyAfterCustomization() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(NTP_CORRECTLY, NOT_CACHED, SOME_DELEGATE); expectInitializationCompleted( @@ -731,7 +731,7 @@ @Test public void testCreatePartnerHomepageAfterCustomization() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(PARTNER_CUSTOM_HOMEPAGE, NOT_CACHED, SOME_DELEGATE); expectInitializationCompleted( @@ -757,7 +757,7 @@ @Test public void testCreateInitialTabCalledBeforeCustomizationStarts() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder beforeStartedBuilder = HistogramWatcher.newBuilder() .expectNoRecords( @@ -794,7 +794,7 @@ @Test public void testCreateInitialTabCalledMultipleTimes() { // Unset test values so that FeatureList#isInitialized returns false. - FeatureList.setTestValues(null); + FeatureList.removeAllTestOverrides(); HistogramWatcher.Builder builder = expectCustomizationOutcome(PARTNER_CUSTOM_HOMEPAGE, NOT_CACHED, SOME_DELEGATE); expectInitializationCompleted(
diff --git a/chrome/browser/password_manager/android/password_store_android_backend.h b/chrome/browser/password_manager/android/password_store_android_backend.h index 2d45708ed..24e1f121 100644 --- a/chrome/browser/password_manager/android/password_store_android_backend.h +++ b/chrome/browser/password_manager/android/password_store_android_backend.h
@@ -264,8 +264,7 @@ using JobId = PasswordStoreAndroidBackendDispatcherBridge::JobId; // Using a small_map should ensure that we handle rare cases with many jobs // like a bulk deletion just as well as the normal, rather small job load. - using JobMap = base::small_map< - std::unordered_map<JobId, JobReturnHandler, JobId::Hasher>>; + using JobMap = base::small_map<std::unordered_map<JobId, JobReturnHandler>>; using DelayedRetryId = base::IdType32<CancellableRetryCallback>;
diff --git a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc index c13026828..69a633d 100644 --- a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc +++ b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc
@@ -15,6 +15,7 @@ #include "base/containers/contains.h" #include "base/path_service.h" #include "base/task/single_thread_task_runner.h" +#include "base/time/default_clock.h" #include "build/branding_buildflags.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h"
diff --git a/chrome/browser/prefs/incognito_mode_prefs.cc b/chrome/browser/prefs/incognito_mode_prefs.cc index af838c2..ce5660ca 100644 --- a/chrome/browser/prefs/incognito_mode_prefs.cc +++ b/chrome/browser/prefs/incognito_mode_prefs.cc
@@ -118,7 +118,7 @@ #if BUILDFLAG(IS_WIN) return GetWinParentalControls().logging_required; #elif BUILDFLAG(IS_ANDROID) - return chrome::android::PartnerBrowserCustomizations::IsIncognitoDisabled(); + return android::PartnerBrowserCustomizations::IsIncognitoDisabled(); #else return false; #endif
diff --git a/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl.cc b/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl.cc index 291fb5fc..ec4c675 100644 --- a/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl.cc +++ b/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl.cc
@@ -341,6 +341,10 @@ return privacy_sandbox::IsConsentRequired() ? GetProtectedAudienceMeasurementNoticeName(surface_type) : GetThreeAdsAPIsNoticeName(surface_type); + // Ads API UX Enhancements + case PromptAction::kNoticeSiteSuggestedAdsMoreInfoOpened: + case PromptAction::kNoticeAdsMeasurementMoreInfoOpened: + return GetProtectedAudienceMeasurementNoticeName(surface_type); default: return empty_view; } @@ -896,7 +900,8 @@ return; } - // Set correct notice names, ready to receive and log PromptActions + // Set correct notice names, ready to receive and log PromptActions. Update + // GetNoticeName when adding more entries to the switch statement. std::string_view notice_name = GetNoticeName(action, surface_type); switch (action) { @@ -942,14 +947,15 @@ privacy_sandbox::NoticeActionTaken::kSettings, base::Time::Now()); break; } - case PromptAction::kNoticeMoreInfoOpened: { + case PromptAction::kNoticeMoreInfoOpened: + // Ads API UX Enhancements + case PromptAction::kNoticeSiteSuggestedAdsMoreInfoOpened: + case PromptAction::kNoticeAdsMeasurementMoreInfoOpened: { notice_storage->SetNoticeActionTaken( pref_service, notice_name, privacy_sandbox::NoticeActionTaken::kLearnMore, base::Time::Now()); break; } - // TODO(crbug.com/377557616): Update notice storage with new Ads API UX - // Enhancements prompt actions // Restricted notices case PromptAction::kRestrictedNoticeShown: {
diff --git a/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl_unittest.cc b/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl_unittest.cc index 1a85204b..da4c864 100644 --- a/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl_unittest.cc +++ b/chrome/browser/privacy_sandbox/privacy_sandbox_service_impl_unittest.cc
@@ -3030,7 +3030,20 @@ .feature_flag = NoticeFeature(), .shown_type = PromptAction::kNoticeShown, .prompt_action = PromptAction::kNoticeMoreInfoOpened, - .notice_name = privacy_sandbox::kThreeAdsAPIsNoticeModal}})); + .notice_name = privacy_sandbox::kThreeAdsAPIsNoticeModal}, + // Ads API UX Enhancements + {.surface_type = SurfaceType::kDesktop, + .feature_flag = ConsentFeature(), + .shown_type = PromptAction::kNoticeShown, + .prompt_action = PromptAction::kNoticeSiteSuggestedAdsMoreInfoOpened, + .notice_name = + privacy_sandbox::kProtectedAudienceMeasurementNoticeModal}, + {.surface_type = SurfaceType::kDesktop, + .feature_flag = ConsentFeature(), + .shown_type = PromptAction::kNoticeShown, + .prompt_action = PromptAction::kNoticeAdsMeasurementMoreInfoOpened, + .notice_name = + privacy_sandbox::kProtectedAudienceMeasurementNoticeModal}})); class PrivacySandboxServiceM1RestrictedNoticeTest : public PrivacySandboxServiceTest {
diff --git a/chrome/browser/resources/BUILD.gn b/chrome/browser/resources/BUILD.gn index c881c34..b537b61 100644 --- a/chrome/browser/resources/BUILD.gn +++ b/chrome/browser/resources/BUILD.gn
@@ -37,6 +37,7 @@ "gaia_auth_host:resources", "history:resources", "identity_internals:resources", + "inspect:resources", "key_value_pair_viewer_shared:resources", "lens/overlay:resources", "lens/shared:resources",
diff --git a/chrome/browser/resources/PRESUBMIT.py b/chrome/browser/resources/PRESUBMIT.py index 2fc138d..7f0a966 100644 --- a/chrome/browser/resources/PRESUBMIT.py +++ b/chrome/browser/resources/PRESUBMIT.py
@@ -138,21 +138,14 @@ 'chrome/browser/resources/chromeos/', 'chrome/browser/resources/device_log/', 'chrome/browser/resources/explore_sites_internals/', - 'chrome/browser/resources/family_link_user_internals/', - 'chrome/browser/resources/feed_internals/', 'chrome/browser/resources/gaia_auth_host/', 'chrome/browser/resources/hangout_services/', 'chrome/browser/resources/image_editor/', 'chrome/browser/resources/identity_scope_approval_dialog/', - 'chrome/browser/resources/internals/notifications/', - 'chrome/browser/resources/internals/query_tiles/', 'chrome/browser/resources/inspect/', 'chrome/browser/resources/net_internals/', 'chrome/browser/resources/network_speech_synthesis/', 'chrome/browser/resources/new_tab_page_incognito_guest/', - 'chrome/browser/resources/new_tab_page/untrusted/', - 'chrome/browser/resources/offline_pages/', - 'chrome/browser/resources/omnibox/', 'chrome/browser/resources/reading_mode_gdocs_helper/', 'chrome/browser/resources/settings/', 'chrome/browser/resources/tools/',
diff --git a/chrome/browser/resources/ash/settings/device_page/per_device_keyboard.html b/chrome/browser/resources/ash/settings/device_page/per_device_keyboard.html index a26437a..1867e2c2 100644 --- a/chrome/browser/resources/ash/settings/device_page/per_device_keyboard.html +++ b/chrome/browser/resources/ash/settings/device_page/per_device_keyboard.html
@@ -36,7 +36,7 @@ </settings-toggle-button> <iron-collapse opened="[[prefs.settings.language.xkb_auto_repeat_enabled_r2.value]]"> - <div class="settings-box continuation"> + <div class="settings-box"> <div class="start" id="repeatDelayLabel" aria-hidden="true"> $i18n{keyRepeatDelay} </div> @@ -50,7 +50,7 @@ label-max="$i18n{keyRepeatDelayLong}"> </settings-slider> </div> - <div class="settings-box continuation"> + <div class="settings-box"> <div class="start" id="repeatRateLabel" aria-hidden="true"> $i18n{keyRepeatRate} </div>
diff --git a/chrome/browser/resources/history/app.html b/chrome/browser/resources/history/app.html index 7e07e67..374b1562 100644 --- a/chrome/browser/resources/history/app.html +++ b/chrome/browser/resources/history/app.html
@@ -210,6 +210,7 @@ selected="[[tabsContentPage_]]" on-iron-select="updateScrollTarget_"> <history-list id="history" query-state="[[queryState_]]" + is-active="[[getShowHistoryList_(selectedPage_)]]" searched-term="[[queryResult_.info.term]]" pending-delete="{{pendingDelete_}}" query-result="[[queryResult_]]" @@ -220,6 +221,7 @@ <template is="dom-if" if="[[historyClustersSelected_(selectedPage_, showHistoryClusters_)]]"> <history-clusters id="history-clusters" + is-active="[[getShowResultsByGroup_(selectedPage_)]]" query="[[queryState_.searchTerm]]" time-range-start="[[queryStateAfterDate_]]" path="grouped"
diff --git a/chrome/browser/resources/history/app.ts b/chrome/browser/resources/history/app.ts index 5a749db3..18c81978 100644 --- a/chrome/browser/resources/history/app.ts +++ b/chrome/browser/resources/history/app.ts
@@ -395,6 +395,10 @@ return this.selectedPage_ === Page.HISTORY_CLUSTERS; } + private getShowHistoryList_() { + return this.selectedPage_ === Page.HISTORY; + } + private onShowResultsByGroupChanged_(e: CustomEvent<{value: boolean}>) { const showResultsByGroup = e.detail.value; if (showResultsByGroup) {
diff --git a/chrome/browser/resources/history/history_list.ts b/chrome/browser/resources/history/history_list.ts index de68f73..1e9c2c0 100644 --- a/chrome/browser/resources/history/history_list.ts +++ b/chrome/browser/resources/history/history_list.ts
@@ -108,6 +108,13 @@ }, scrollOffset: Number, + // Whether this element is active, i.e. visible to the user. + isActive: { + type: Boolean, + value: true, + observer: 'onIsActiveChanged_', + }, + isEmpty: { type: Boolean, reflectToAttribute: true, @@ -120,9 +127,22 @@ private canDeleteHistory_: boolean = loadTimeData.getBoolean('allowDeletingHistory'); private actionMenuModel_: ActionMenuModel|null = null; + private lastOffsetHeight_: number = 0; + private resizeObserver_: ResizeObserver = new ResizeObserver(() => { + if (this.lastOffsetHeight_ === 0) { + this.lastOffsetHeight_ = this.scrollTarget.offsetHeight; + return; + } + if (this.scrollTarget.offsetHeight > this.lastOffsetHeight_) { + this.lastOffsetHeight_ = this.scrollTarget.offsetHeight; + this.onScrollOrResize_(); + } + }); private resultLoadingDisabled_: boolean = false; - private scrollListener_: EventListener = () => this.onScroll_(); + private scrollDebounce_: number = 200; + private scrollListener_: EventListener = () => this.onScrollOrResize_(); private scrollTimeout_: number|null = null; + isActive: boolean; isEmpty: boolean; searchedTerm: string = ''; selectedItems: Set<number> = new Set(); @@ -641,6 +661,16 @@ !!this.searchedTerm && this.historyData_?.length > 0; } + private onIsActiveChanged_() { + if (this.isActive) { + // Active changed from false to true. Add the scroll observer. + this.scrollTarget.addEventListener('scroll', this.scrollListener_); + } else { + // Active changed from true to false. Remove scroll observer. + this.scrollTarget.removeEventListener('scroll', this.scrollListener_); + } + } + private onScrollTargetChanged_( _newTarget: HTMLElement, oldTarget?: HTMLElement) { // It is possible (eg, when middle clicking the reload button) for all other @@ -649,25 +679,32 @@ this.$['infinite-list'].notifyResize(); if (oldTarget) { + this.resizeObserver_.disconnect(); oldTarget.removeEventListener('scroll', this.scrollListener_); } if (this.scrollTarget) { + this.resizeObserver_.observe(this.scrollTarget); this.scrollTarget.addEventListener('scroll', this.scrollListener_); } } - private onScroll_() { + setScrollDebounceForTest(debounce: number) { + this.scrollDebounce_ = debounce; + } + + private onScrollOrResize_() { // Debounce by 200ms. if (this.scrollTimeout_) { clearTimeout(this.scrollTimeout_); } - this.scrollTimeout_ = setTimeout(() => this.onScrollTimeout_(), 200); + this.scrollTimeout_ = + setTimeout(() => this.onScrollTimeout_(), this.scrollDebounce_); } private onScrollTimeout_() { this.scrollTimeout_ = null; - const lowerScroll = - this.scrollTarget.offsetHeight - this.scrollTarget.scrollTop; + const lowerScroll = this.scrollTarget.scrollHeight - + this.scrollTarget.scrollTop - this.scrollTarget.offsetHeight; if (lowerScroll < 500) { this.onScrollToBottom_(); }
diff --git a/chrome/browser/resources/inspect/BUILD.gn b/chrome/browser/resources/inspect/BUILD.gn new file mode 100644 index 0000000..a29908db --- /dev/null +++ b/chrome/browser/resources/inspect/BUILD.gn
@@ -0,0 +1,22 @@ +# Copyright 2024 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//ui/webui/resources/tools/build_webui.gni") + +assert(!is_android) + +build_webui("build") { + grd_prefix = "inspect" + + static_files = [ + "inspect.css", + "inspect.html", + ] + + # TODO(crbug.com/385341235): Migrate to TypeScript. + non_web_component_files = [ "inspect.js" ] + + ts_definitions = [ "//tools/typescript/definitions/chrome_send.d.ts" ] + ts_deps = [ "//ui/webui/resources/js:build_ts" ] +}
diff --git a/chrome/browser/resources/offline_pages/BUILD.gn b/chrome/browser/resources/offline_pages/BUILD.gn deleted file mode 100644 index 7e90e7e..0000000 --- a/chrome/browser/resources/offline_pages/BUILD.gn +++ /dev/null
@@ -1,19 +0,0 @@ -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//tools/typescript/webui_ts_library.gni") - -webui_ts_library("build_ts") { - root_dir = "." - out_dir = "$target_gen_dir/tsc" - in_files = [ - "offline_internals.ts", - "offline_internals_browser_proxy.ts", - ] - definitions = [ - "//tools/typescript/definitions/chrome_send.d.ts", - "//tools/typescript/definitions/pending.d.ts", - ] - deps = [ "//ui/webui/resources/js:build_ts" ] -}
diff --git a/chrome/browser/resources/offline_pages/DIR_METADATA b/chrome/browser/resources/offline_pages/DIR_METADATA deleted file mode 100644 index f3d5613e..0000000 --- a/chrome/browser/resources/offline_pages/DIR_METADATA +++ /dev/null
@@ -1 +0,0 @@ -mixins: "//components/offline_pages/COMMON_METADATA"
diff --git a/chrome/browser/resources/offline_pages/OWNERS b/chrome/browser/resources/offline_pages/OWNERS deleted file mode 100644 index 901ae80e..0000000 --- a/chrome/browser/resources/offline_pages/OWNERS +++ /dev/null
@@ -1 +0,0 @@ -file://components/offline_pages/OWNERS
diff --git a/chrome/browser/resources/offline_pages/offline_internals.css b/chrome/browser/resources/offline_pages/offline_internals.css deleted file mode 100644 index 01ac8ef1..0000000 --- a/chrome/browser/resources/offline_pages/offline_internals.css +++ /dev/null
@@ -1,68 +0,0 @@ -/* Copyright 2016 The Chromium Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. */ - -h1 { - color: rgb(74, 142, 230); - margin: 0; - padding: 0; -} - -td { - padding: 4px; -} - -tr:nth-child(odd) { - background-color: azure; -} - -th { - background-color: navy; - color: white; - font-weight: bold; - padding: 5px; -} - -table { - margin-bottom: 5px; -} - -ul { - border: 1px solid; - list-style-type: none; - margin-top: 5px; - max-height: 300px; - overflow: auto; - padding: 5px; - width: 100%; -} - -ul li { - list-style-position: outside; - margin: 0 0 0 5px; - padding: 0; -} - -li:nth-child(2n) { - background-color: lavender; -} - -dialog { - border: none; -} - -#current-status { - font-size: 15px; -} - -.dump { - font-family: monospace; - white-space: pre-wrap; -} - -#dump-box { - box-sizing: border-box; - display: block; - resize: none; - width: 100%; -}
diff --git a/chrome/browser/resources/offline_pages/offline_internals.html b/chrome/browser/resources/offline_pages/offline_internals.html deleted file mode 100644 index 8a1d9c5..0000000 --- a/chrome/browser/resources/offline_pages/offline_internals.html +++ /dev/null
@@ -1,150 +0,0 @@ -<!doctype html> -<html lang="en" dir="ltr"> - <head> - <meta charset="utf-8"> - <title>Offline Internals</title> - <meta name="viewport" content="width=device-width"> - <link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> - <link rel="stylesheet" href="offline_internals.css"> - - <script type="module" src="offline_internals.js"></script> - </head> - <body> - <h1>Offline Internals</h1> - <div> - <span id="current-status"></span> - <button id="refresh">Refresh page</button> - <button id="dump">Dump</button> - </div> - <dialog id="dump-modal"> - <textarea id="dump-box" name="json-box" rows="10" cols="40" readonly> - </textarea> - <button id="copy-to-clipboard">Copy</button> - <button id="close-dump">Close</button> - <span id="dump-info"></span> - </dialog> - - <h2>Event Logs</h2> - <div> - <button id="refresh-logs">Refresh Logs</button> - <div> - <input type="checkbox" id="model-checkbox">Page Model Log</input> - </div> - <div> - <input type="checkbox" id="request-checkbox">Request Queue Log</input> - </div> - <div> - <input type="checkbox" id="prefetch-checkbox">Prefetching Log</input> - </div> - <ul id="logs"></ul> - </div> - - <h2>Stored Pages</h2> - <div> - <button id="delete-selected-pages">Delete selected</button> - </div> - <table class="stored-pages-table"> - <thead> - <tr> - <th>#</th> - <th><input type="checkbox" id="toggle-all-stored"></th> - <th>URL</th> - <th>Namespace</th> - <th>Size (Kb)</th> - </tr> - </thead> - <tbody id="stored-pages"> </tbody> - </table> - <template id="stored-pages-table-row"> - <tr> - <td></td> - <td><input type="checkbox" name="stored"></td> - <td><a></a></td> - <td></td> - <td></td> - </tr> - </template> - <div id="page-actions-info" class="dump"></div> - - <h2>Request Queue</h2> - <div> - <button id="delete-selected-requests">Delete selected</button> - </div> - <table class="request-queue-table"> - <thead> - <tr> - <th><input type="checkbox" id="toggle-all-requests"></th> - <th>URL</th> - <th>Created Timestamp</th> - <th>Status</th> - <th>Request Origin</th> - </tr> - </thead> - <tbody id="request-queue"> </tbody> - </table> - <template id="request-queue-table-row"> - <tr> - <td><input type="checkbox" name="requests"></td> - <td></td> - <td></td> - <td></td> - <td></td> - </tr> - </template> - <div id="request-queue-actions-info" class="dump"></div> - <input id="url" type="url" - placeholder="http://www.url1.com, http://www.url2.com, ..."> - <button id="add-to-queue">Load in background</button> - <div id="save-url-state"></div> - - <h2>Prefetching</h2> - <div> - <div> - <button id="schedule-nwake">Schedule NWake</button> - <button id="cancel-nwake">Cancel NWake</button> - </div> - <div> - <input id="generate-urls" type="text" - placeholder="http://www.url1.com, http://www.url2.com, ..."> - <button id="generate-page-bundle">Generate Page Bundle</button> - </div> - <div> - <input id="operation-name" type="text" - placeholder="operations/1234-5678"> - <button id="get-operation">Get Operation</button> - </div> - <div> - <input id="download-name" type="text" placeholder="us/page/1234-5678"> - <button id="download-archive">Download</button> - </div> - </div> - <div> - <input type="checkbox" id="limitless-prefetching-checkbox"> - Enable limitless prefetching - </input> - </div> - <div> - <form id="testing-header-form"> - <fieldset id="testing-header-fieldset"> - <legend>Testing header value:</legend> - <label> - <input type="radio" id="testing-header-default" - name="testing-header" value=""> - Default - </label> - <label> - <input type="radio" id="testing-header-enable" name="testing-header" - value="ForceEnable"> - Force enable - </label> - <label> - <input type="radio" id="testing-header-disable" - name="testing-header" value="ForceDisable"> - Force disable - </label> - </fieldset> - </form> - </div> - <div id="prefetch-actions-info" class="dump"></div> - </body> -</html>
diff --git a/chrome/browser/resources/offline_pages/offline_internals.ts b/chrome/browser/resources/offline_pages/offline_internals.ts deleted file mode 100644 index c1887bc..0000000 --- a/chrome/browser/resources/offline_pages/offline_internals.ts +++ /dev/null
@@ -1,387 +0,0 @@ -// Copyright 2016 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import '/strings.m.js'; - -import {assert} from 'chrome://resources/js/assert.js'; -import {loadTimeData} from 'chrome://resources/js/load_time_data.js'; -import {getRequiredElement} from 'chrome://resources/js/util.js'; - -import type {IsLogging, OfflineInternalsBrowserProxy, OfflinePage, SavePageRequest} from './offline_internals_browser_proxy.js'; -import {OfflineInternalsBrowserProxyImpl} from './offline_internals_browser_proxy.js'; - -let offlinePages: OfflinePage[] = []; - -let savePageRequests: SavePageRequest[] = []; - -const browserProxy: OfflineInternalsBrowserProxy = - OfflineInternalsBrowserProxyImpl.getInstance(); - -/** - * Fill stored pages table. - * @param pages An array object representing stored offline pages. - */ -function fillStoredPages(pages: OfflinePage[]) { - const storedPagesTable = getRequiredElement('stored-pages'); - storedPagesTable.textContent = ''; - - const template = - getRequiredElement<HTMLTemplateElement>('stored-pages-table-row'); - const td = template.content.querySelectorAll('td'); - for (let pageIndex = 0; pageIndex < pages.length; pageIndex++) { - const page = pages[pageIndex]!; - td[0]!.textContent = (pageIndex + 1).toString(); - const checkbox = td[1]!.querySelector('input'); - assert(checkbox); - checkbox.setAttribute('value', page.id); - - const link = td[2]!.querySelector('a'); - assert(link); - link.setAttribute('href', page.onlineUrl); - const maxUrlCharsPerLine = 50; - if (page.onlineUrl.length > maxUrlCharsPerLine) { - link.textContent = ''; - for (let i = 0; i < page.onlineUrl.length; i += maxUrlCharsPerLine) { - link.textContent += page.onlineUrl.slice(i, i + maxUrlCharsPerLine); - link.textContent += '\r\n'; - } - } else { - link.textContent = page.onlineUrl; - } - - td[3]!.textContent = page.namespace; - td[4]!.textContent = (Math.round(Number(page.size) / 1024)).toString(); - - const row = document.importNode(template.content, true); - storedPagesTable.appendChild(row); - } - offlinePages = pages; -} - -/** - * Fill requests table. - * @param requests An array object representing the request queue. - */ -function fillRequestQueue(requests: SavePageRequest[]) { - const requestQueueTable = getRequiredElement('request-queue'); - requestQueueTable.textContent = ''; - - const template = - getRequiredElement<HTMLTemplateElement>('request-queue-table-row'); - const td = template.content.querySelectorAll('td'); - for (const request of requests) { - const checkbox = td[0]!.querySelector('input'); - assert(checkbox); - checkbox.setAttribute('value', request.id); - - td[1]!.textContent = request.onlineUrl; - td[2]!.textContent = new Date(request.creationTime).toString(); - td[3]!.textContent = request.status; - td[4]!.textContent = request.requestOrigin; - - const row = document.importNode(template.content, true); - requestQueueTable.appendChild(row); - } - savePageRequests = requests; -} - -/** - * Fills the event logs section. - * @param logs A list of log strings. - */ -function fillEventLog(logs: string[]) { - const element = getRequiredElement('logs'); - element.textContent = ''; - for (const log of logs) { - const logItem = document.createElement('li'); - logItem.textContent = log; - element.appendChild(logItem); - } -} - -/** - * Refresh all displayed information. - */ -function refreshAll() { - browserProxy.getStoredPages().then(fillStoredPages); - browserProxy.getRequestQueue().then(fillRequestQueue); - browserProxy.getNetworkStatus().then(function(networkStatus) { - getRequiredElement('current-status').textContent = networkStatus; - }); - browserProxy.getLimitlessPrefetchingEnabled().then(function(enabled) { - getRequiredElement<HTMLInputElement>('limitless-prefetching-checkbox') - .checked = enabled; - }); - browserProxy.getPrefetchTestingHeaderValue().then(function(value) { - switch (value) { - case 'ForceEnable': - getRequiredElement<HTMLInputElement>('testing-header-enable').checked = - true; - break; - case 'ForceDisable': - getRequiredElement<HTMLInputElement>('testing-header-disable').checked = - true; - break; - default: - getRequiredElement<HTMLInputElement>('testing-header-default').checked = - true; - } - }); - refreshLog(); -} - -/** - * Callback when pages are deleted. - * @param status The status of the request. - */ -function pagesDeleted(status: string) { - getRequiredElement('page-actions-info').textContent = status; - browserProxy.getStoredPages().then(fillStoredPages); -} - -/** - * Callback when requests are deleted. - */ -function requestsDeleted(status: string) { - getRequiredElement('request-queue-actions-info').textContent = status; - browserProxy.getRequestQueue().then(fillRequestQueue); -} - -/** - * Callback for prefetch actions. - * @param info The result of performing the prefetch actions. - */ -function setPrefetchResult(info: string) { - getRequiredElement('prefetch-actions-info').textContent = info; -} - -/** - * Error callback for prefetch actions. - * @param error The error that resulted from the prefetch call. - */ -function prefetchResultError(error: Error|string) { - const errorText = - error && (error as Error).message ? (error as Error).message : error; - - getRequiredElement('prefetch-actions-info').textContent = - 'Error: ' + errorText; -} - -/** - * Downloads all the stored page and request queue information into a file. - * Also translates all the fields representing datetime into human-readable - * date strings. - * TODO(chili): Create a CSV writer that can abstract out the line joining. - */ -function dumpAsJson() { - const json = JSON.stringify( - {offlinePages: offlinePages, savePageRequests: savePageRequests}, - function(key, value) { - return key.endsWith('Time') ? new Date(value).toString() : value; - }, - 2); - - getRequiredElement<HTMLTextAreaElement>('dump-box').value = json; - getRequiredElement('dump-info').textContent = ''; - getRequiredElement<HTMLDialogElement>('dump-modal').showModal(); - getRequiredElement<HTMLTextAreaElement>('dump-box').select(); -} - -function closeDump() { - getRequiredElement<HTMLDialogElement>('dump-modal').close(); - getRequiredElement<HTMLTextAreaElement>('dump-box').value = ''; -} - -function copyDump() { - getRequiredElement<HTMLTextAreaElement>('dump-box').select(); - document.execCommand('copy'); - getRequiredElement('dump-info').textContent = 'Copied to clipboard!'; -} - -/** - * Updates the status strings. - * @param logStatus Status of logging. - */ -function updateLogStatus(logStatus: IsLogging) { - getRequiredElement<HTMLInputElement>('model-checkbox').checked = - logStatus.modelIsLogging; - getRequiredElement<HTMLInputElement>('request-checkbox').checked = - logStatus.queueIsLogging; - getRequiredElement<HTMLInputElement>('prefetch-checkbox').checked = - logStatus.prefetchIsLogging; -} - -/** - * Sets all checkboxes with a specific name to the same checked status as the - * provided source checkbox. - * @param source The checkbox controlling the checked status. - * @param checkboxesName The name identifying the checkboxes to set. - */ -function toggleAllCheckboxes(source: HTMLInputElement, checkboxesName: string) { - const checkboxes = document.getElementsByName(checkboxesName); - for (const checkbox of checkboxes) { - (checkbox as HTMLInputElement).checked = source.checked; - } -} - -/** - * Return the item ids for the selected checkboxes with a given name. - * @param checkboxesName The name identifying the checkboxes to query. - * @return An array of selected ids. - */ -function getSelectedIdsFor(checkboxesName: string): string[] { - const checkboxes = document.querySelectorAll<HTMLInputElement>( - `input[type="checkbox"][name="${checkboxesName}"]:checked`); - return Array.from(checkboxes).map(c => c.value); -} - -/** - * Refreshes the logs. - */ -function refreshLog() { - browserProxy.getEventLogs().then(fillEventLog); - browserProxy.getLoggingState().then(updateLogStatus); -} - -/** - * Calls scheduleNwake and indicates how long the scheduled delay will be. - */ -function ensureBackgroundTaskScheduledWithDelay() { - browserProxy.scheduleNwake() - .then((result: string) => { - // The delays in these messages should correspond to the scheduling - // delays defined in PrefetchBackgroundTaskScheduler.java. - if (getRequiredElement<HTMLInputElement>( - 'limitless-prefetching-checkbox') - .checked) { - setPrefetchResult( - result + - ' (Limitless mode enabled; background task scheduled to run' + - ' in a few seconds.)'); - } else { - setPrefetchResult( - result + - ' (Limitless mode disabled; background task scheduled to run' + - ' in several minutes.)'); - } - }) - .catch(prefetchResultError); -} - -function initialize() { - const incognito = loadTimeData.getBoolean('isIncognito'); - ['delete-selected-pages', 'delete-selected-requests', 'model-checkbox', - 'request-checkbox', 'refresh'] - .forEach( - el => getRequiredElement<HTMLInputElement>(el).disabled = incognito); - - getRequiredElement('delete-selected-pages').onclick = function() { - const pageIds = getSelectedIdsFor('stored'); - browserProxy.deleteSelectedPages(pageIds).then(pagesDeleted); - }; - getRequiredElement('delete-selected-requests').onclick = function() { - const requestIds = getSelectedIdsFor('requests'); - browserProxy.deleteSelectedRequests(requestIds).then(requestsDeleted); - }; - getRequiredElement('refresh').onclick = refreshAll; - getRequiredElement('dump').onclick = dumpAsJson; - getRequiredElement('close-dump').onclick = closeDump; - getRequiredElement('copy-to-clipboard').onclick = copyDump; - getRequiredElement('model-checkbox').onchange = (evt: Event) => { - browserProxy.setRecordPageModel((evt.target as HTMLInputElement).checked); - }; - getRequiredElement('request-checkbox').onchange = (evt: Event) => { - browserProxy.setRecordRequestQueue( - (evt.target as HTMLInputElement).checked); - }; - getRequiredElement('prefetch-checkbox').onchange = (evt: Event) => { - browserProxy.setRecordPrefetchService( - (evt.target as HTMLInputElement).checked); - }; - getRequiredElement('refresh-logs').onclick = refreshLog; - getRequiredElement('add-to-queue').onclick = function() { - const saveUrls = - getRequiredElement<HTMLInputElement>('url').value.split(','); - let counter = saveUrls.length; - getRequiredElement('save-url-state').textContent = ''; - for (let i = 0; i < saveUrls.length; i++) { - browserProxy.addToRequestQueue(saveUrls[i]!).then(function(state) { - if (state) { - getRequiredElement('save-url-state').textContent += - saveUrls[i] + ' has been added to queue.\n'; - getRequiredElement<HTMLInputElement>('url').value = ''; - counter--; - if (counter === 0) { - browserProxy.getRequestQueue().then(fillRequestQueue); - } - } else { - getRequiredElement('save-url-state').textContent += - saveUrls[i] + ' failed to be added to queue.\n'; - } - }); - } - }; - getRequiredElement('schedule-nwake').onclick = function() { - browserProxy.scheduleNwake() - .then(setPrefetchResult) - .catch(prefetchResultError); - }; - getRequiredElement('cancel-nwake').onclick = function() { - browserProxy.cancelNwake() - .then(setPrefetchResult) - .catch(prefetchResultError); - }; - getRequiredElement('generate-page-bundle').onclick = function() { - browserProxy - .generatePageBundle( - getRequiredElement<HTMLInputElement>('generate-urls').value) - .then(setPrefetchResult) - .catch(prefetchResultError); - }; - getRequiredElement('get-operation').onclick = function() { - browserProxy - .getOperation( - getRequiredElement<HTMLInputElement>('operation-name').value) - .then(setPrefetchResult) - .catch(prefetchResultError); - }; - getRequiredElement('download-archive').onclick = function() { - browserProxy.downloadArchive( - getRequiredElement<HTMLInputElement>('download-name').value); - }; - getRequiredElement('toggle-all-stored').onclick = function() { - toggleAllCheckboxes( - getRequiredElement<HTMLInputElement>('toggle-all-stored'), 'stored'); - }; - getRequiredElement('toggle-all-requests').onclick = function() { - toggleAllCheckboxes( - getRequiredElement<HTMLInputElement>('toggle-all-requests'), - 'requests'); - }; - getRequiredElement('limitless-prefetching-checkbox').onchange = - (evt: Event) => { - const checkbox = evt.target as HTMLInputElement; - browserProxy.setLimitlessPrefetchingEnabled(checkbox.checked); - if (checkbox.checked) { - ensureBackgroundTaskScheduledWithDelay(); - } - }; - // Helper for setting prefetch testing header from a radio button. - const setPrefetchTestingHeader = function(evt: Event) { - browserProxy.setPrefetchTestingHeaderValue( - (evt.target as HTMLInputElement).value); - ensureBackgroundTaskScheduledWithDelay(); - }; - getRequiredElement('testing-header-default').onchange = - setPrefetchTestingHeader; - getRequiredElement('testing-header-enable').onchange = - setPrefetchTestingHeader; - getRequiredElement('testing-header-disable').onchange = - setPrefetchTestingHeader; - if (!incognito) { - refreshAll(); - } -} - -document.addEventListener('DOMContentLoaded', initialize);
diff --git a/chrome/browser/resources/offline_pages/offline_internals_browser_proxy.ts b/chrome/browser/resources/offline_pages/offline_internals_browser_proxy.ts deleted file mode 100644 index 28c53bc..0000000 --- a/chrome/browser/resources/offline_pages/offline_internals_browser_proxy.ts +++ /dev/null
@@ -1,255 +0,0 @@ -// Copyright 2016 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import {sendWithPromise} from 'chrome://resources/js/cr.js'; - -export interface OfflinePage { - onlineUrl: string; - creationTime: number; - id: string; - namespace: string; - size: string; - filePath: string; - lastAccessTime: number; - accessCount: number; - isExpired: string; - requestOrigin: string; -} - -export interface SavePageRequest { - status: string; - onlineUrl: string; - creationTime: number; - id: string; - namespace: string; - lastAttemptTime: number; - requestOrigin: string; -} - -export interface IsLogging { - modelIsLogging: boolean; - queueIsLogging: boolean; - prefetchIsLogging: boolean; -} - -export interface OfflineInternalsBrowserProxy { - /** - * Gets current list of stored pages. - * @return A promise firing when the list is fetched. - */ - getStoredPages(): Promise<OfflinePage[]>; - - /** - * Gets current offline queue requests. - * @return A promise firing when the request queue is fetched. - */ - getRequestQueue(): Promise<SavePageRequest[]>; - - /** - * Deletes a set of pages from stored pages - * @param ids A list of page IDs to delete. - * @return A promise firing when the selected pages are deleted. - */ - deleteSelectedPages(ids: string[]): Promise<string>; - - /** - * Deletes a set of requests from the request queue - * @param ids A list of request IDs to delete. - * @return A promise firing when the selected pages are deleted. - */ - deleteSelectedRequests(ids: string[]): Promise<string>; - - /** - * Sets whether to record logs for stored pages. - * @param shouldLog True if logging should be enabled. - */ - setRecordPageModel(shouldLog: boolean): void; - - /** - * Sets whether to record logs for scheduled requests. - * @param shouldLog True if logging should be enabled. - */ - setRecordRequestQueue(shouldLog: boolean): void; - - /** - * Sets whether to record logs for prefetching. - * @param shouldLog True if logging should be enabled. - */ - setRecordPrefetchService(shouldLog: boolean): void; - - /** - * Sets whether limitless prefetching is enabled. - * @param enabled Whether to enable limitless prefetching. - */ - setLimitlessPrefetchingEnabled(enabled: boolean): void; - - /** - * Gets whether limitless prefetching is enabled. - * @return Whether limitless prefetching is enabled - */ - getLimitlessPrefetchingEnabled(): Promise<boolean>; - - /** - * Sets the value to be sent with the prefetch testing header for - * GeneratePageBundle requests. - * @param value Value to send with X-Offline-Prefetch-Testing. - */ - setPrefetchTestingHeaderValue(value: string): void; - - /** - * Gets the value of the prefetch testing header to be sent with - * GeneratePageBundle requests. - * @return Header value. - */ - getPrefetchTestingHeaderValue(): Promise<string>; - - /** - * Gets the currently recorded logs. - * @return A promise firing when the logs are retrieved. - */ - getEventLogs(): Promise<string[]>; - - /** - * Gets the state of logging (on/off). - * @return A promise firing when the state is retrieved. - */ - getLoggingState(): Promise<IsLogging>; - - /** - * Adds the given url to the background loader queue. - * @param url Url of the page to load later. - * @return A promise firing after added to queue. - * Promise will return true if url has been successfully added. - */ - addToRequestQueue(url: string): Promise<boolean>; - - /** - * Gets the current network status in string form. - * @return A promise firing when the network status is retrieved. - */ - getNetworkStatus(): Promise<string>; - - /** - * Schedules the default NWake task. The returned Promise will reject if - * there is an error while scheduling. - * @return A promise firing when the task has been scheduled. - */ - scheduleNwake(): Promise<string>; - - /** - * Cancels NWake task. - * @return A promise firing when the task has been cancelled. The - * returned Promise will reject if there is an error. - */ - cancelNwake(): Promise<string>; - - /** - * Sends and processes a request to generate page bundle. - * @param urls A list of comma-separated URLs. - * @return A string describing the result. - */ - generatePageBundle(urls: string): Promise<string>; - - /** - * Sends and processes a request to get operation. - * @param name Name of operation. - * @return A string describing the result. - */ - getOperation(name: string): Promise<string>; - - /** - * Downloads an archive. - * @param name Name of archive to download. - */ - downloadArchive(name: string): void; -} - -export class OfflineInternalsBrowserProxyImpl implements - OfflineInternalsBrowserProxy { - getStoredPages() { - return sendWithPromise('getStoredPages'); - } - - getRequestQueue() { - return sendWithPromise('getRequestQueue'); - } - - deleteSelectedPages(ids: string[]) { - return sendWithPromise('deleteSelectedPages', ids); - } - - deleteSelectedRequests(ids: string[]) { - return sendWithPromise('deleteSelectedRequests', ids); - } - - setRecordPageModel(shouldLog: boolean) { - chrome.send('setRecordPageModel', [shouldLog]); - } - - setRecordRequestQueue(shouldLog: boolean) { - chrome.send('setRecordRequestQueue', [shouldLog]); - } - - setRecordPrefetchService(shouldLog: boolean) { - chrome.send('setRecordPrefetchService', [shouldLog]); - } - - setLimitlessPrefetchingEnabled(enabled: boolean) { - chrome.send('setLimitlessPrefetchingEnabled', [enabled]); - } - - getLimitlessPrefetchingEnabled() { - return sendWithPromise('getLimitlessPrefetchingEnabled'); - } - - setPrefetchTestingHeaderValue(value: string) { - chrome.send('setPrefetchTestingHeader', [value]); - } - - getPrefetchTestingHeaderValue() { - return sendWithPromise('getPrefetchTestingHeader'); - } - - getEventLogs() { - return sendWithPromise('getEventLogs'); - } - - getLoggingState() { - return sendWithPromise('getLoggingState'); - } - - addToRequestQueue(url: string) { - return sendWithPromise('addToRequestQueue', url); - } - - getNetworkStatus() { - return sendWithPromise('getNetworkStatus'); - } - - scheduleNwake() { - return sendWithPromise('scheduleNwake'); - } - - cancelNwake() { - return sendWithPromise('cancelNwake'); - } - - generatePageBundle(urls: string) { - return sendWithPromise('generatePageBundle', urls); - } - - getOperation(name: string) { - return sendWithPromise('getOperation', name); - } - - downloadArchive(name: string) { - chrome.send('downloadArchive', [name]); - } - - static getInstance(): OfflineInternalsBrowserProxy { - return instance || (instance = new OfflineInternalsBrowserProxyImpl()); - } -} - -let instance: OfflineInternalsBrowserProxy|null = null;
diff --git a/chrome/browser/safety_hub/android/java/src/org/chromium/chrome/browser/safety_hub/SafetyHubMagicStackBuilder.java b/chrome/browser/safety_hub/android/java/src/org/chromium/chrome/browser/safety_hub/SafetyHubMagicStackBuilder.java index c02a2dbf..38e1d06 100644 --- a/chrome/browser/safety_hub/android/java/src/org/chromium/chrome/browser/safety_hub/SafetyHubMagicStackBuilder.java +++ b/chrome/browser/safety_hub/android/java/src/org/chromium/chrome/browser/safety_hub/SafetyHubMagicStackBuilder.java
@@ -10,6 +10,7 @@ import androidx.annotation.NonNull; +import org.chromium.base.BuildInfo; import org.chromium.base.Callback; import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.supplier.ObservableSupplier; @@ -88,6 +89,9 @@ @Override public boolean isEligible() { + // The Safety Hub is not fully supported on Automotive. + if (BuildInfo.getInstance().isAutomotive) return false; + if (!mProfileSupplier.hasValue()) return false; if (!ChromeFeatureList.sSafetyHub.isEnabled()) {
diff --git a/chrome/browser/search/background/ntp_custom_background_service.cc b/chrome/browser/search/background/ntp_custom_background_service.cc index 196a2ac..fb66d63a 100644 --- a/chrome/browser/search/background/ntp_custom_background_service.cc +++ b/chrome/browser/search/background/ntp_custom_background_service.cc
@@ -232,11 +232,8 @@ std::string resume_token = background_service_->next_image_resume_token(); int64_t timestamp = (clock_->Now() + base::Days(1)).ToTimeT(); - if (base::FeatureList::IsEnabled( - ntp_features::kCustomizeChromeColorExtraction)) { - FetchCustomBackgroundAndExtractBackgroundColor(image.image_url, - image.thumbnail_image_url); - } + FetchCustomBackgroundAndExtractBackgroundColor(image.image_url, + image.thumbnail_image_url); base::Value::Dict background_info = GetBackgroundInfoAsDict( image.image_url, attribution1, attribution2, image.attribution_action_url, @@ -318,9 +315,7 @@ is_backdrop_collection) { background_service_->FetchNextCollectionImage(collection_id, std::nullopt); } else if (background_url.is_valid() && is_backdrop_url) { - if (base::FeatureList::IsEnabled( - ntp_features::kCustomizeChromeColorExtraction) && - thumbnail_url.is_valid()) { + if (thumbnail_url.is_valid()) { FetchCustomBackgroundAndExtractBackgroundColor(background_url, thumbnail_url); } @@ -495,10 +490,7 @@ const base::Value* attribution_action_url = background_info.Find(kNtpCustomBackgroundAttributionActionURL); const base::Value* color = - base::FeatureList::IsEnabled( - ntp_features::kCustomizeChromeColorExtraction) - ? background_info.Find(kNtpCustomBackgroundMainColor) - : nullptr; + background_info.Find(kNtpCustomBackgroundMainColor); custom_background->custom_background_url = custom_background_url; custom_background->is_uploaded_image = false; custom_background->collection_id = collection_id;
diff --git a/chrome/browser/search/background/ntp_custom_background_service_unittest.cc b/chrome/browser/search/background/ntp_custom_background_service_unittest.cc index 01cdb6e..1cfb592 100644 --- a/chrome/browser/search/background/ntp_custom_background_service_unittest.cc +++ b/chrome/browser/search/background/ntp_custom_background_service_unittest.cc
@@ -14,7 +14,6 @@ #include "base/test/bind.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/mock_callback.h" -#include "base/test/scoped_feature_list.h" #include "base/test/simple_test_clock.h" #include "base/time/time.h" #include "base/token.h" @@ -31,7 +30,6 @@ #include "chrome/common/search/instant_types.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/testing_profile.h" -#include "components/search/ntp_features.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_utils.h" @@ -714,11 +712,6 @@ // TODO (crbug/1520873): Fix and re-enable or remove if no longer relevant. TEST_F(NtpCustomBackgroundServiceTest, DISABLED_TestUpdateCustomBackgroundColor) { - // Turn on Color Extraction feature. - base::test::ScopedFeatureList scoped_feature_list; - scoped_feature_list.InitAndEnableFeature( - ntp_features::kCustomizeChromeColorExtraction); - EXPECT_CALL(observer_, OnCustomBackgroundImageUpdated).Times(2); EXPECT_CALL(mock_theme_service(), BuildAutogeneratedThemeFromColor).Times(1); SkBitmap bitmap;
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 8f73abe..0798a64 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -903,10 +903,6 @@ "webui/feed_internals/feed_internals_ui.h", "webui/feed_internals/feedv2_internals_page_handler.cc", "webui/feed_internals/feedv2_internals_page_handler.h", - "webui/offline/offline_internals_ui.cc", - "webui/offline/offline_internals_ui.h", - "webui/offline/offline_internals_ui_message_handler.cc", - "webui/offline/offline_internals_ui_message_handler.h", "webui/webapks/webapks_handler.cc", "webui/webapks/webapks_handler.h", "webui/webapks/webapks_ui.cc", @@ -1409,8 +1405,8 @@ "webui/history_clusters/history_clusters_handler.h", "webui/identity_internals_ui.cc", "webui/identity_internals_ui.h", - "webui/inspect_ui.cc", - "webui/inspect_ui.h", + "webui/inspect/inspect_ui.cc", + "webui/inspect/inspect_ui.h", "webui/managed_ui_handler.cc", "webui/managed_ui_handler.h", "webui/management/management_ui.cc",
diff --git a/chrome/browser/ui/android/default_browser_promo/java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoImpressionCounterTest.java b/chrome/browser/ui/android/default_browser_promo/java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoImpressionCounterTest.java index 8784f1b6..ec991c6 100644 --- a/chrome/browser/ui/android/default_browser_promo/java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoImpressionCounterTest.java +++ b/chrome/browser/ui/android/default_browser_promo/java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoImpressionCounterTest.java
@@ -9,7 +9,6 @@ import android.text.format.DateUtils; -import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -58,11 +57,6 @@ SearchEngineChoiceService.setInstanceForTests(mMockSearchEngineChoiceService); } - @After - public void tearDown() { - FeatureList.setTestValues(null); - } - @Test @DisableFeatures(ChromeFeatureList.DEFAULT_BROWSER_PROMO_ANDROID) public void testGetMaxPromoCount_ExperimentDisabled() {
diff --git a/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinator.java b/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinator.java index 763a912..f9331a0 100644 --- a/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinator.java +++ b/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinator.java
@@ -193,28 +193,23 @@ } private void onInsetsRectsUpdated(@NonNull Rect widestUnoccludedRect) { - mHeuristicResult = - checkIsInDesktopWindow( - mActivity, mInsetObserver, mCaptionBarRectProvider, mHeuristicResult); + mHeuristicResult = checkIsInDesktopWindow(mCaptionBarRectProvider, mHeuristicResult); var isInDesktopWindow = mHeuristicResult == DesktopWindowHeuristicResult.IN_DESKTOP_WINDOW; // Avoid determining the mode when there are no window insets, which may be the case in the // middle of a windowing mode change. Presence of insets indicates that the window is in a // stable state. + assert mInsetObserver.getLastRawWindowInsets() != null + : "Attempt to read the insets too early."; if (mInsetObserver.getLastRawWindowInsets().hasInsets()) { mWindowingMode = AppHeaderUtils.getWindowingMode(mActivity, isInDesktopWindow, mWindowingMode); } - // Use an empty |widestUnoccludedRect| instead of the cached Rect while creating the - // AppHeaderState while not in or while exiting desktop windowing mode, so that it always - // holds a valid state for observers to use. var appHeaderState = new AppHeaderState( mCaptionBarRectProvider.getWindowRect(), - isInDesktopWindow - ? mCaptionBarRectProvider.getWidestUnoccludedRect() - : new Rect(), + widestUnoccludedRect, isInDesktopWindow); if (appHeaderState.equals(mAppHeaderState)) return; @@ -254,8 +249,7 @@ * * <ol type=1> * <li>Caption bar has insets.top > 0; - * <li>There's no bottom insets from the navigation bar; - * <li>Caption bar has 2 bounding rects; + * <li>Widest unoccluded rect in caption bar has space available to draw the tab strip; * <li>Widest unoccluded rect in captionBar insets is connected to the bottom; * </ol> * @@ -263,31 +257,14 @@ * an AppHeaderCoordinator instance, especially the cached {@link AppHeaderState}. */ private static @DesktopWindowHeuristicResult int checkIsInDesktopWindow( - Activity activity, - InsetObserver insetObserver, InsetsRectProvider insetsRectProvider, @DesktopWindowHeuristicResult int currentResult) { @DesktopWindowHeuristicResult int newResult; - assert insetObserver.getLastRawWindowInsets() != null - : "Attempt to read the insets too early."; - var navBarInsets = - insetObserver - .getLastRawWindowInsets() - .getInsets(WindowInsetsCompat.Type.navigationBars()); - - int numOfBoundingRects = insetsRectProvider.getBoundingRects().size(); Insets captionBarInset = insetsRectProvider.getCachedInset(); - if (!activity.isInMultiWindowMode()) { - newResult = DesktopWindowHeuristicResult.NOT_IN_MULTIWINDOW_MODE; - } else if (navBarInsets.bottom > 0) { - // Disable DW mode if there is a navigation bar (though it may or may not be visible / - // dismissed). - newResult = DesktopWindowHeuristicResult.NAV_BAR_BOTTOM_INSETS_PRESENT; - } else if (numOfBoundingRects != 2) { - Log.w(TAG, "Unexpected number of bounding rects is observed! " + numOfBoundingRects); - newResult = DesktopWindowHeuristicResult.CAPTION_BAR_BOUNDING_RECTS_UNEXPECTED_NUMBER; + if (insetsRectProvider.getWidestUnoccludedRect().isEmpty()) { + newResult = DesktopWindowHeuristicResult.WIDEST_UNOCCLUDED_RECT_EMPTY; } else if (captionBarInset.top == 0) { newResult = DesktopWindowHeuristicResult.CAPTION_BAR_TOP_INSETS_ABSENT; } else if (insetsRectProvider.getWidestUnoccludedRect().bottom != captionBarInset.top) {
diff --git a/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinatorUnitTest.java b/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinatorUnitTest.java index 89b4f1f1..15a86dc 100644 --- a/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinatorUnitTest.java +++ b/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderCoordinatorUnitTest.java
@@ -72,6 +72,7 @@ private static final Rect WIDEST_UNOCCLUDED_RECT = new Rect(LEFT_BLOCK, 0, WINDOW_WIDTH - RIGHT_BLOCK, HEADER_HEIGHT); private static final int KEYBOARD_INSET = 736; + private static final int APPEARANCE_LIGHT_CAPTION_BARS = 1 << 8; @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -97,7 +98,6 @@ public void setup() { mActivityScenarioRule.getScenario().onActivity(activity -> mSpyActivity = spy(activity)); mEdgeToEdgeStateProvider = new EdgeToEdgeStateProvider(mSpyActivity.getWindow()); - doReturn(true).when(mSpyActivity).isInMultiWindowMode(); mSpyRootView = spy(mSpyActivity.getWindow().getDecorView()); AppHeaderCoordinator.setInsetsRectProviderForTesting(mInsetsRectProvider); doAnswer(inv -> mLastSeenRawWindowInsets).when(mInsetObserver).getLastRawWindowInsets(); @@ -146,7 +146,8 @@ List.of( new Rect(0, 0, LEFT_BLOCK, HEADER_HEIGHT - 10), new Rect(WINDOW_WIDTH - RIGHT_BLOCK, 0, WINDOW_WIDTH, HEADER_HEIGHT - 10)); - Rect widestUnoccludedRect = new Rect(0, 20, WINDOW_WIDTH, HEADER_HEIGHT - 10); + Rect widestUnoccludedRect = + new Rect(LEFT_BLOCK, 0, WINDOW_WIDTH - RIGHT_BLOCK, HEADER_HEIGHT - 10); setupInsetsRectProvider(insets, blockedRects, widestUnoccludedRect, WINDOW_RECT); notifyInsetsRectObserver(); @@ -157,78 +158,17 @@ } @Test - public void notEnabledWithLessThanTwoBoundingRects() { + public void notEnabledWhenWidestUnoccludedRectIsEmpty() { var watcher = HistogramWatcher.newSingleRecordWatcher( "Android.DesktopWindowHeuristicResult", - DesktopWindowHeuristicResult.CAPTION_BAR_BOUNDING_RECTS_UNEXPECTED_NUMBER); - // Top insets with height of 30. - Insets insets = Insets.of(0, 30, 0, 0); - // Left block: 10 - List<Rect> blockedRects = List.of(new Rect(0, 0, LEFT_BLOCK, 30)); - Rect widestUnoccludedRect = new Rect(LEFT_BLOCK, 0, WINDOW_WIDTH, 30); - setupInsetsRectProvider(insets, blockedRects, widestUnoccludedRect, WINDOW_RECT); + DesktopWindowHeuristicResult.WIDEST_UNOCCLUDED_RECT_EMPTY); + setupInsetsRectProvider(Insets.NONE, List.of(), new Rect(), WINDOW_RECT); notifyInsetsRectObserver(); verifyDesktopWindowingDisabled( - /* error= */ "Desktop Windowing enabled with only one bounding rect."); - watcher.assertExpected(); - } - - @Test - public void notEnabledWithMoreThanTwoBoundingRects() { - var watcher = - HistogramWatcher.newSingleRecordWatcher( - "Android.DesktopWindowHeuristicResult", - DesktopWindowHeuristicResult.CAPTION_BAR_BOUNDING_RECTS_UNEXPECTED_NUMBER); - // Top insets with height of 30. - Insets insets = Insets.of(0, 30, 0, 0); - // Left block: 10, two right block: 5, 15 - List<Rect> blockedRects = - List.of( - new Rect(0, 0, LEFT_BLOCK, 30), - new Rect(WINDOW_WIDTH - RIGHT_BLOCK, 0, WINDOW_WIDTH - 15, 30), - new Rect(WINDOW_WIDTH - 15, 0, WINDOW_WIDTH, 30)); - Rect widestUnoccludedRect = new Rect(LEFT_BLOCK, 0, WINDOW_WIDTH - RIGHT_BLOCK, 30); - setupInsetsRectProvider(insets, blockedRects, widestUnoccludedRect, WINDOW_RECT); - notifyInsetsRectObserver(); - - verifyDesktopWindowingDisabled( - /* error= */ "Desktop Windowing enabled with more than two bounding rects."); - watcher.assertExpected(); - } - - @Test - public void notEnabledWhenNotInMultiWindowMode() { - var watcher = - HistogramWatcher.newSingleRecordWatcher( - "Android.DesktopWindowHeuristicResult", - DesktopWindowHeuristicResult.NOT_IN_MULTIWINDOW_MODE); - doReturn(false).when(mSpyActivity).isInMultiWindowMode(); - setupWithLeftAndRightBoundingRect(); - notifyInsetsRectObserver(); - - verifyDesktopWindowingDisabled( - /* error= */ "Desktop Windowing does not enable when not in multi window mode."); - watcher.assertExpected(); - } - - @Test - public void notEnabledWhenNavBarBottomInsetsSeen() { - var watcher = - HistogramWatcher.newSingleRecordWatcher( - "Android.DesktopWindowHeuristicResult", - DesktopWindowHeuristicResult.NAV_BAR_BOTTOM_INSETS_PRESENT); - setupWithLeftAndRightBoundingRect(); - // Override the last seen raw insets so there's a bottom nav bar insets. - mLastSeenRawWindowInsets = - new WindowInsetsCompat.Builder() - .setInsets(WindowInsetsCompat.Type.navigationBars(), Insets.of(0, 0, 0, 10)) - .build(); - notifyInsetsRectObserver(); - - verifyDesktopWindowingDisabled( - /* error= */ "Desktop Windowing does not enable when there are bottom insets."); + /* error= */ "Desktop windowing should not be enabled when widest unoccluded rect" + + " is empty."); watcher.assertExpected(); } @@ -395,13 +335,13 @@ assertEquals( "Background is dark. Expecting APPEARANCE_LIGHT_CAPTION_BARS not set.", 0, - insetController.getSystemBarsAppearance() & (1 << 8)); + insetController.getSystemBarsAppearance() & APPEARANCE_LIGHT_CAPTION_BARS); mAppHeaderCoordinator.updateForegroundColor(Color.WHITE); assertEquals( "Background is light. Expecting APPEARANCE_LIGHT_CAPTION_BARS set.", - (1 << 8), - insetController.getSystemBarsAppearance() & (1 << 8)); + APPEARANCE_LIGHT_CAPTION_BARS, + insetController.getSystemBarsAppearance() & APPEARANCE_LIGHT_CAPTION_BARS); } @Test
diff --git a/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderUtils.java b/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderUtils.java index 57523ff..086cc2fb 100644 --- a/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderUtils.java +++ b/chrome/browser/ui/android/desktop_windowing/java/src/org/chromium/chrome/browser/ui/desktop_windowing/AppHeaderUtils.java
@@ -23,24 +23,20 @@ @IntDef({ DesktopWindowHeuristicResult.UNKNOWN, DesktopWindowHeuristicResult.IN_DESKTOP_WINDOW, - DesktopWindowHeuristicResult.NOT_IN_MULTIWINDOW_MODE, - DesktopWindowHeuristicResult.NAV_BAR_BOTTOM_INSETS_PRESENT, - DesktopWindowHeuristicResult.CAPTION_BAR_BOUNDING_RECTS_UNEXPECTED_NUMBER, DesktopWindowHeuristicResult.CAPTION_BAR_TOP_INSETS_ABSENT, DesktopWindowHeuristicResult.CAPTION_BAR_BOUNDING_RECT_INVALID_HEIGHT, + DesktopWindowHeuristicResult.WIDEST_UNOCCLUDED_RECT_EMPTY, DesktopWindowHeuristicResult.NUM_ENTRIES, }) public @interface DesktopWindowHeuristicResult { int UNKNOWN = 0; int IN_DESKTOP_WINDOW = 1; - int NOT_IN_MULTIWINDOW_MODE = 2; - int NAV_BAR_BOTTOM_INSETS_PRESENT = 3; - int CAPTION_BAR_BOUNDING_RECTS_UNEXPECTED_NUMBER = 4; - int CAPTION_BAR_TOP_INSETS_ABSENT = 5; - int CAPTION_BAR_BOUNDING_RECT_INVALID_HEIGHT = 6; + int CAPTION_BAR_TOP_INSETS_ABSENT = 2; + int CAPTION_BAR_BOUNDING_RECT_INVALID_HEIGHT = 3; + int WIDEST_UNOCCLUDED_RECT_EMPTY = 4; // Be sure to also update enums.xml when updating these values. - int NUM_ENTRIES = 7; + int NUM_ENTRIES = 5; } // These values are persisted to logs. Entries should not be renumbered and
diff --git a/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/WebContentsDarkModeMessageControllerUnitTest.java b/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/WebContentsDarkModeMessageControllerUnitTest.java index 1a5f5b0..c6f8a683 100644 --- a/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/WebContentsDarkModeMessageControllerUnitTest.java +++ b/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/WebContentsDarkModeMessageControllerUnitTest.java
@@ -18,7 +18,6 @@ import android.content.Context; import android.content.res.Resources; -import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -189,11 +188,6 @@ ShadowWebContentsDarkModeController.sIsFeatureEnabled = true; } - @After - public void tearDown() { - FeatureList.setTestValues(null); - } - private void setOptOut(boolean optOut) { ShadowWebContentsDarkModeController.sIsFeatureEnabled = optOut; if (!optOut) {
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/voice/VoiceRecognitionHandlerUnitTest.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/voice/VoiceRecognitionHandlerUnitTest.java index 8b872e8..9b43540 100644 --- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/voice/VoiceRecognitionHandlerUnitTest.java +++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/voice/VoiceRecognitionHandlerUnitTest.java
@@ -46,7 +46,6 @@ import org.robolectric.shadows.ShadowLog; import org.robolectric.shadows.ShadowLooper; -import org.chromium.base.FeatureList; import org.chromium.base.supplier.ObservableSupplierImpl; import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.util.Feature; @@ -143,7 +142,6 @@ // will be taken care of here. ShadowLooper.shadowMainLooper().idle(); mHandler.removeObserver(mObserver); - FeatureList.setTestValues(null); mProfileSupplier.set(null); ProfileManager.resetForTesting(); }
diff --git a/chrome/browser/ui/android/signin/BUILD.gn b/chrome/browser/ui/android/signin/BUILD.gn index 7c5f081e..9da5fb67 100644 --- a/chrome/browser/ui/android/signin/BUILD.gn +++ b/chrome/browser/ui/android/signin/BUILD.gn
@@ -141,7 +141,6 @@ "java/res/drawable/chrome_sync_logo.xml", "java/res/drawable/history_sync_illustration.xml", "java/res/drawable/history_sync_illustration_alternative.xml", - "java/res/drawable/ic_expand_more_in_circle_24dp.xml", "java/res/layout/account_picker_bottom_sheet_continue_button.xml", "java/res/layout/account_picker_bottom_sheet_header.xml", "java/res/layout/account_picker_bottom_sheet_new_account_row.xml",
diff --git a/chrome/browser/ui/android/signin/java/res/drawable/ic_expand_more_in_circle_24dp.xml b/chrome/browser/ui/android/signin/java/res/drawable/ic_expand_more_in_circle_24dp.xml deleted file mode 100644 index beee009..0000000 --- a/chrome/browser/ui/android/signin/java/res/drawable/ic_expand_more_in_circle_24dp.xml +++ /dev/null
@@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -Copyright 2020 The Chromium Authors -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="24dp" - android:height="24dp" - android:viewportWidth="24" - android:viewportHeight="24"> - <path - android:strokeWidth="1" - android:pathData="M23.5,11.9999C23.5,18.3512 18.3513,23.4999 12,23.4999C5.6487,23.4999 0.5,18.3512 0.5,11.9999C0.5,5.6486 5.6487,0.4999 12,0.4999C18.3513,0.4999 23.5,5.6486 23.5,11.9999Z" - android:strokeColor="@macro/hairline_stroke_color"/> - <path - android:pathData="M12.5892,14.7487C12.4383,14.9039 12.23,14.9999 12,14.9999C11.77,14.9999 11.5617,14.9039 11.4108,14.7487L7.2442,10.463C7.0933,10.3079 7,10.0936 7,9.857C7,9.3839 7.3733,8.9999 7.8333,8.9999C8.0633,8.9999 8.2717,9.0959 8.4225,9.251L12,12.9307L15.5775,9.251C15.7283,9.0959 15.9367,8.9999 16.1667,8.9999C16.6267,8.9999 17,9.3839 17,9.857C17,10.0936 16.9067,10.3079 16.7558,10.463L12.5892,14.7487Z" - android:fillColor="@macro/default_control_color_normal" - android:fillType="evenOdd"/> -</vector>
diff --git a/chrome/browser/ui/android/signin/java/res/layout/fullscreen_signin_bottom_group_view.xml b/chrome/browser/ui/android/signin/java/res/layout/fullscreen_signin_bottom_group_view.xml index 9f3ee07..70316e9 100644 --- a/chrome/browser/ui/android/signin/java/res/layout/fullscreen_signin_bottom_group_view.xml +++ b/chrome/browser/ui/android/signin/java/res/layout/fullscreen_signin_bottom_group_view.xml
@@ -13,11 +13,13 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:foreground="?attr/selectableItemBackground" + android:background="@drawable/account_row_background_rounded_all" android:gravity="center_vertical" android:orientation="horizontal" - android:paddingStart="24dp" - android:paddingEnd="24dp" - android:paddingBottom="8dp"> + android:padding="16dp" + android:layout_marginHorizontal="24dp" + android:layout_marginBottom="16dp" + > <include layout="@layout/account_row" /> @@ -26,7 +28,8 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_marginStart="16dp" - app:srcCompat="@drawable/ic_expand_more_in_circle_24dp" + app:srcCompat="@drawable/ic_expand_more_black_24dp" + app:tint="?attr/colorOnSurfaceVariant" android:importantForAccessibility="no" /> </LinearLayout>
diff --git a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninMediator.java b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninMediator.java index 57d8edd8..002c0c6 100644 --- a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninMediator.java +++ b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninMediator.java
@@ -15,7 +15,6 @@ import org.chromium.base.BuildInfo; import org.chromium.base.Log; -import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.signin.services.IdentityServicesProvider; @@ -254,21 +253,16 @@ mModel.set(FullscreenSigninProperties.IS_SIGNIN_SUPPORTED, isSigninSupported); mModel.set(FullscreenSigninProperties.SHOW_INITIAL_LOAD_PROGRESS_SPINNER, false); - if (ChromeFeatureList.isEnabled( - ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS)) { - if (isSigninSupported) { - mModel.set(FullscreenSigninProperties.TITLE_STRING_ID, mConfig.titleId); - } - SyncService syncService = SyncServiceFactory.getForProfile(profile); - boolean isSyncDataManaged = - IntStream.range(UserSelectableType.FIRST_TYPE, UserSelectableType.LAST_TYPE + 1) - .anyMatch(syncService::isTypeManagedByPolicy); - mModel.set( - FullscreenSigninProperties.SUBTITLE_STRING_ID, - isSyncDataManaged - ? R.string.signin_fre_subtitle_without_sync - : mConfig.subtitleId); + if (isSigninSupported) { + mModel.set(FullscreenSigninProperties.TITLE_STRING_ID, mConfig.titleId); } + SyncService syncService = SyncServiceFactory.getForProfile(profile); + boolean isSyncDataManaged = + IntStream.range(UserSelectableType.FIRST_TYPE, UserSelectableType.LAST_TYPE + 1) + .anyMatch(syncService::isTypeManagedByPolicy); + mModel.set( + FullscreenSigninProperties.SUBTITLE_STRING_ID, + isSyncDataManaged ? R.string.signin_fre_subtitle_without_sync : mConfig.subtitleId); mAllowMetricsAndCrashUploading = !isMetricsReportingDisabledByPolicy; mModel.set(
diff --git a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninViewBinder.java b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninViewBinder.java index 7f0823c..0e361bde 100644 --- a/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninViewBinder.java +++ b/chrome/browser/ui/android/signin/java/src/org/chromium/chrome/browser/ui/signin/fullscreen_signin/FullscreenSigninViewBinder.java
@@ -4,30 +4,20 @@ package org.chromium.chrome.browser.ui.signin.fullscreen_signin; -import android.content.Context; -import android.content.res.ColorStateList; import android.text.method.LinkMovementMethod; import android.transition.AutoTransition; import android.transition.TransitionManager; import android.view.View; -import android.view.ViewGroup.MarginLayoutParams; -import android.widget.ImageView; import android.widget.ProgressBar; import androidx.annotation.DrawableRes; import androidx.annotation.Nullable; import androidx.annotation.StringRes; -import androidx.appcompat.content.res.AppCompatResources; -import androidx.core.widget.ImageViewCompat; -import com.google.android.material.color.MaterialColors; - -import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.signin.services.DisplayableProfileData; import org.chromium.chrome.browser.ui.signin.R; import org.chromium.chrome.browser.ui.signin.SigninUtils; import org.chromium.chrome.browser.ui.signin.account_picker.ExistingAccountRowViewBinder; -import org.chromium.ui.base.ViewUtils; import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyModel; @@ -72,10 +62,6 @@ // this case. initialLoadProgressSpinner.animate().alpha(1.0f).setStartDelay(500); } else { - // Native needs to be ready before feature flag can be checked. Therefore the flag - // guarded layout update is done once the initial loading spinner disappears, since - // native is initialized at this point. - revampSelectedAccountViewIfNecessary(view.getSelectedAccountView()); TransitionManager.beginDelayedTransition(view); initialLoadProgressSpinner.setVisibility(View.GONE); } @@ -239,37 +225,5 @@ view.getSigninProgressText().setVisibility(showSigningInText ? View.VISIBLE : View.GONE); } - // TODO(b/40944124): Move the layout configurations to the xml file after UNO is launched. - public static void revampSelectedAccountViewIfNecessary(View accountPickerView) { - if (ChromeFeatureList.isEnabled( - ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS)) { - Context context = accountPickerView.getContext(); - accountPickerView.setBackground( - AppCompatResources.getDrawable( - context, R.drawable.account_row_background_rounded_all)); - - int padding = ViewUtils.dpToPx(context, 16); - accountPickerView.setPadding(padding, padding, padding, padding); - int sideMargin = ViewUtils.dpToPx(context, 24); - // Total margin should be 24dp but the continue button xml file adds an 8dp top margin. - int bottomMargin = ViewUtils.dpToPx(context, 16); - MarginLayoutParams params = (MarginLayoutParams) accountPickerView.getLayoutParams(); - params.setMargins( - /* left= */ sideMargin, - /* top= */ 0, - /* right= */ sideMargin, - /* bottom= */ bottomMargin); - - ImageView moreArrow = - accountPickerView.findViewById(R.id.signin_fre_selected_account_expand_icon); - moreArrow.setImageResource(R.drawable.ic_expand_more_black_24dp); - ColorStateList colorStateList = - ColorStateList.valueOf( - MaterialColors.getColor( - accountPickerView, R.attr.colorOnSurfaceVariant)); - ImageViewCompat.setImageTintList(moreArrow, colorStateList); - } - } - private FullscreenSigninViewBinder() {} }
diff --git a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarFeaturesTest.java b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarFeaturesTest.java index ba4846c..3235147 100644 --- a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarFeaturesTest.java +++ b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarFeaturesTest.java
@@ -8,7 +8,6 @@ import android.app.Activity; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,11 +32,6 @@ FeatureList.setTestValues(mTestValues); } - @After - public void tearDown() { - FeatureList.setTestValues(null); - } - @Test @Config(qualifiers = "w390dp-h820dp") public void testGetTopSegmentationResultOnPhone() {
diff --git a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/tab_strip/TabStripTransitionCoordinator.java b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/tab_strip/TabStripTransitionCoordinator.java index a3586905..3fa0f52 100644 --- a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/tab_strip/TabStripTransitionCoordinator.java +++ b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/tab_strip/TabStripTransitionCoordinator.java
@@ -196,10 +196,14 @@ boolean wasInDesktopWindow = mAppHeaderState != null && mAppHeaderState.isInDesktopWindow(); boolean isInDesktopWindow = newState.isInDesktopWindow(); boolean desktopWindowingModeChanged = wasInDesktopWindow != isInDesktopWindow; + boolean headerHeightChanged = + mAppHeaderState != null + && mAppHeaderState.getAppHeaderHeight() != newState.getAppHeaderHeight(); - // Force trigger the strip height transition when the app is switching desktop windowing - // mode, to update the strip top padding. - mForceUpdateHeight = desktopWindowingModeChanged; + // Force trigger the strip height transition when: + // 1. The app is switching desktop windowing mode, to update the strip top padding. + // 2. The app header height changes. + mForceUpdateHeight = desktopWindowingModeChanged || headerHeightChanged; // Force fade in an invisible tab strip when the app is exiting desktop windowing mode, and // the height transition is blocked.
diff --git a/chrome/browser/ui/ash/network/network_state_notifier.cc b/chrome/browser/ui/ash/network/network_state_notifier.cc index e7edecb..51d7e8c 100644 --- a/chrome/browser/ui/ash/network/network_state_notifier.cc +++ b/chrome/browser/ui/ash/network/network_state_notifier.cc
@@ -30,6 +30,7 @@ #include "ui/chromeos/devicetype_utils.h" #include "ui/chromeos/shill_error.h" #include "ui/chromeos/strings/grit/ui_chromeos_strings.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/message_center/public/cpp/notification.h" namespace ash { @@ -657,7 +658,8 @@ new message_center::HandleNotificationClickDelegate( base::BindRepeating(&NetworkStateNotifier::ShowMobileDataSubpage, weak_ptr_factory_.GetWeakPtr())), - gfx::kNoneIcon, message_center::SystemNotificationWarningLevel::NORMAL); + gfx::VectorIcon::EmptyIcon(), + message_center::SystemNotificationWarningLevel::NORMAL); SystemNotificationHelper::GetInstance()->Display(notification); }
diff --git a/chrome/browser/ui/ash/shelf/shelf_context_menu.cc b/chrome/browser/ui/ash/shelf/shelf_context_menu.cc index 6146ea2..e09db91b 100644 --- a/chrome/browser/ui/ash/shelf/shelf_context_menu.cc +++ b/chrome/browser/ui/ash/shelf/shelf_context_menu.cc
@@ -36,7 +36,7 @@ #include "ui/color/color_id.h" #include "ui/display/screen.h" #include "ui/display/types/display_constants.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/vector_icons.h" namespace { @@ -232,7 +232,7 @@ case ash::USE_LAUNCH_TYPE_WINDOW: case ash::USE_LAUNCH_TYPE_TABBED_WINDOW: // Check items use a default icon in touchable and default context menus. - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); case ash::DEPRECATED_USE_LAUNCH_TYPE_PINNED: case ash::DEPRECATED_USE_LAUNCH_TYPE_FULLSCREEN: NOTREACHED(); @@ -249,7 +249,7 @@ return views::kLinuxLowDensityIcon; case ash::SWAP_WITH_NEXT: case ash::SWAP_WITH_PREVIOUS: - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); case ash::LAUNCH_APP_SHORTCUT_FIRST: case ash::LAUNCH_APP_SHORTCUT_LAST: case ash::COMMAND_ID_COUNT:
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc index efdf01aa..6ebb069 100644 --- a/chrome/browser/ui/browser_command_controller.cc +++ b/chrome/browser/ui/browser_command_controller.cc
@@ -71,7 +71,7 @@ #include "chrome/browser/ui/web_applications/web_app_dialog_utils.h" #include "chrome/browser/ui/web_applications/web_app_launch_utils.h" #include "chrome/browser/ui/web_applications/web_app_tabbed_utils.h" -#include "chrome/browser/ui/webui/inspect_ui.h" +#include "chrome/browser/ui/webui/inspect/inspect_ui.h" #include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_section.h" #include "chrome/browser/web_applications/web_app_install_params.h" #include "chrome/browser/web_applications/web_app_utils.h"
diff --git a/chrome/browser/ui/content_settings/content_setting_image_model.cc b/chrome/browser/ui/content_settings/content_setting_image_model.cc index 020817f..fe73a32 100644 --- a/chrome/browser/ui/content_settings/content_setting_image_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc
@@ -369,7 +369,7 @@ bool blocked, raw_ptr<const gfx::VectorIcon>* icon, raw_ptr<const gfx::VectorIcon>* badge) { - *badge = &gfx::kNoneIcon; + *badge = &gfx::VectorIcon::EmptyIcon(); GetIconChromeRefresh(type, blocked, icon); } @@ -509,7 +509,7 @@ void ContentSettingImageModel::SetFramebustBlockedIcon() { icon_ = &kOpenInNewOffChromeRefreshIcon; - icon_badge_ = &gfx::kNoneIcon; + icon_badge_ = &gfx::VectorIcon::EmptyIcon(); } // Generic blocked content settings -------------------------------------------- @@ -1222,8 +1222,8 @@ ContentSettingImageModel::ContentSettingImageModel( ImageType image_type, bool image_type_should_notify_accessibility) - : icon_(&gfx::kNoneIcon), - icon_badge_(&gfx::kNoneIcon), + : icon_(&gfx::VectorIcon::EmptyIcon()), + icon_badge_(&gfx::VectorIcon::EmptyIcon()), image_type_(image_type), image_type_should_notify_accessibility_( image_type_should_notify_accessibility) {}
diff --git a/chrome/browser/ui/content_settings/content_setting_media_image_model_unittest.mm b/chrome/browser/ui/content_settings/content_setting_media_image_model_unittest.mm index 0f6c315c..8e206ba 100644 --- a/chrome/browser/ui/content_settings/content_setting_media_image_model_unittest.mm +++ b/chrome/browser/ui/content_settings/content_setting_media_image_model_unittest.mm
@@ -25,7 +25,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/color_palette.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" namespace gfx { @@ -94,16 +93,17 @@ kTestOrigin, {PageSpecificContentSettings::kCameraAccessed}); auth_wrapper.SetMockMediaPermissionStatus(AVAuthorizationStatusAuthorized); content_setting_image_model->Update(web_contents()); - ExpectImageModelState( - *content_setting_image_model, /*is_visible=*/true, /*has_icon=*/true, - l10n_util::GetStringUTF16(IDS_CAMERA_ACCESSED), 0, &gfx::kNoneIcon); + ExpectImageModelState(*content_setting_image_model, /*is_visible=*/true, + /*has_icon=*/true, + l10n_util::GetStringUTF16(IDS_CAMERA_ACCESSED), 0, + &gfx::VectorIcon::EmptyIcon()); auth_wrapper.SetMockMediaPermissionStatus(AVAuthorizationStatusDenied); content_setting_image_model->Update(web_contents()); ExpectImageModelState( *content_setting_image_model, /*is_visible=*/true, /*has_icon=*/true, l10n_util::GetStringUTF16(IDS_CAMERA_TURNED_OFF_IN_MACOS), - IDS_CAMERA_TURNED_OFF, &gfx::kNoneIcon); + IDS_CAMERA_TURNED_OFF, &gfx::VectorIcon::EmptyIcon()); auth_wrapper.SetMockMediaPermissionStatus( AVAuthorizationStatusNotDetermined); content_setting_image_model->Update(web_contents()); @@ -116,16 +116,17 @@ kTestOrigin, {PageSpecificContentSettings::kMicrophoneAccessed}); auth_wrapper.SetMockMediaPermissionStatus(AVAuthorizationStatusAuthorized); content_setting_image_model->Update(web_contents()); - ExpectImageModelState( - *content_setting_image_model, /*is_visible=*/true, /*has_icon=*/true, - l10n_util::GetStringUTF16(IDS_MICROPHONE_ACCESSED), 0, &gfx::kNoneIcon); + ExpectImageModelState(*content_setting_image_model, /*is_visible=*/true, + /*has_icon=*/true, + l10n_util::GetStringUTF16(IDS_MICROPHONE_ACCESSED), 0, + &gfx::VectorIcon::EmptyIcon()); auth_wrapper.SetMockMediaPermissionStatus(AVAuthorizationStatusDenied); content_setting_image_model->Update(web_contents()); ExpectImageModelState( *content_setting_image_model, /*is_visible=*/true, /*has_icon=*/true, l10n_util::GetStringUTF16(IDS_MIC_TURNED_OFF_IN_MACOS), - IDS_MIC_TURNED_OFF, &gfx::kNoneIcon); + IDS_MIC_TURNED_OFF, &gfx::VectorIcon::EmptyIcon()); auth_wrapper.SetMockMediaPermissionStatus( AVAuthorizationStatusNotDetermined); content_setting_image_model->Update(web_contents()); @@ -143,14 +144,14 @@ ExpectImageModelState( *content_setting_image_model, /*is_visible=*/true, /*has_icon=*/true, l10n_util::GetStringUTF16(IDS_MICROPHONE_CAMERA_ALLOWED), 0, - &gfx::kNoneIcon); + &gfx::VectorIcon::EmptyIcon()); auth_wrapper.SetMockMediaPermissionStatus(AVAuthorizationStatusDenied); auth_wrapper.SetMockMediaPermissionStatus(AVAuthorizationStatusDenied); content_setting_image_model->Update(web_contents()); ExpectImageModelState( *content_setting_image_model, /*is_visible=*/true, /*has_icon=*/true, l10n_util::GetStringUTF16(IDS_CAMERA_MIC_TURNED_OFF_IN_MACOS), - IDS_CAMERA_TURNED_OFF, &gfx::kNoneIcon); + IDS_CAMERA_TURNED_OFF, &gfx::VectorIcon::EmptyIcon()); auth_wrapper.SetMockMediaPermissionStatus( AVAuthorizationStatusNotDetermined); auth_wrapper.SetMockMediaPermissionStatus( @@ -177,7 +178,7 @@ /*is_visible=*/true, /*has_icon=*/true, l10n_util::GetStringUTF16(IDS_CAMERA_BLOCKED), 0, - &gfx::kNoneIcon); + &gfx::VectorIcon::EmptyIcon()); } // Microphone blocked per site. @@ -190,7 +191,7 @@ /*is_visible=*/true, /*has_icon=*/true, l10n_util::GetStringUTF16(IDS_MICROPHONE_BLOCKED), - 0, &gfx::kNoneIcon); + 0, &gfx::VectorIcon::EmptyIcon()); } // Microphone & camera blocked per site @@ -205,7 +206,7 @@ *content_setting_image_model, /*is_visible=*/true, /*has_icon=*/true, l10n_util::GetStringUTF16(IDS_MICROPHONE_CAMERA_BLOCKED), 0, - &gfx::kNoneIcon); + &gfx::VectorIcon::EmptyIcon()); } } }
diff --git a/chrome/browser/ui/lens/lens_overlay_controller_browsertest.cc b/chrome/browser/ui/lens/lens_overlay_controller_browsertest.cc index f97cfff2..6c989d8 100644 --- a/chrome/browser/ui/lens/lens_overlay_controller_browsertest.cc +++ b/chrome/browser/ui/lens/lens_overlay_controller_browsertest.cc
@@ -3682,16 +3682,8 @@ ASSERT_TRUE(controller->state() == State::kOverlay); } -// TODO(b/340886492): Fix and reenable test on MSAN. -#if defined(MEMORY_SANITIZER) -#define MAYBE_OverlayClosesSidePanelBeforeOpening \ - DISABLED_OverlayClosesSidePanelBeforeOpening -#else -#define MAYBE_OverlayClosesSidePanelBeforeOpening \ - OverlayClosesSidePanelBeforeOpening -#endif IN_PROC_BROWSER_TEST_F(LensOverlayControllerBrowserTest, - MAYBE_OverlayClosesSidePanelBeforeOpening) { + OverlayClosesSidePanelBeforeOpening) { WaitForPaint(); // State should start in off.
diff --git a/chrome/browser/ui/ui_features.cc b/chrome/browser/ui/ui_features.cc index 36659e39..908ecaf 100644 --- a/chrome/browser/ui/ui_features.cc +++ b/chrome/browser/ui/ui_features.cc
@@ -412,12 +412,6 @@ base::FEATURE_DISABLED_BY_DEFAULT); #endif -// Reduce resource usage when view is hidden by not rendering loading animation. -// TODO(crbug.com/40224168): Clean up the feature in M117. -BASE_FEATURE(kStopLoadingAnimationForHiddenWindow, - "StopLoadingAnimationForHiddenWindow", - base::FEATURE_ENABLED_BY_DEFAULT); - #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) BASE_FEATURE(kUsePortalAccentColor, "UsePortalAccentColor",
diff --git a/chrome/browser/ui/ui_features.h b/chrome/browser/ui/ui_features.h index 1d2a76a..ca66a66 100644 --- a/chrome/browser/ui/ui_features.h +++ b/chrome/browser/ui/ui_features.h
@@ -244,8 +244,6 @@ BASE_DECLARE_FEATURE(kViewsJSAppModalDialog); #endif -BASE_DECLARE_FEATURE(kStopLoadingAnimationForHiddenWindow); - #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) BASE_DECLARE_FEATURE(kUsePortalAccentColor); #endif
diff --git a/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc b/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc index a79f678..f10e7333 100644 --- a/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc +++ b/chrome/browser/ui/views/autofill/payments/local_card_migration_icon_view.cc
@@ -18,7 +18,7 @@ #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/animation/ink_drop.h" @@ -132,7 +132,7 @@ LocalCardMigrationFlowStep::MIGRATION_FAILED) { return vector_icons::kBlockedBadgeIcon; } - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } ManageMigrationUiController* LocalCardMigrationIconView::GetController() const {
diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc index 58cee3c..98e4295 100644 --- a/chrome/browser/ui/views/content_setting_bubble_contents.cc +++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc
@@ -35,7 +35,7 @@ #include "ui/color/color_provider.h" #include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/size.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button_factory.h" #include "ui/views/controls/button/radio_button.h" @@ -154,7 +154,7 @@ *item.image, ui::kColorLabelForeground, GetLayoutConstant(LOCATION_BAR_ICON_SIZE), item.has_blocked_badge ? &vector_icons::kBlockedBadgeIcon - : &gfx::kNoneIcon)); + : &gfx::VectorIcon::EmptyIcon())); } std::unique_ptr<views::View> item_contents;
diff --git a/chrome/browser/ui/views/extensions/extensions_menu_main_page_view_unittest.cc b/chrome/browser/ui/views/extensions/extensions_menu_main_page_view_unittest.cc index dfd3bf9..b3957ff 100644 --- a/chrome/browser/ui/views/extensions/extensions_menu_main_page_view_unittest.cc +++ b/chrome/browser/ui/views/extensions/extensions_menu_main_page_view_unittest.cc
@@ -37,6 +37,7 @@ #include "extensions/test/test_extension_dir.h" #include "testing/gmock/include/gmock/gmock.h" #include "ui/gfx/image/image_unittest_util.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/views/controls/styled_label.h" #include "ui/views/vector_icons.h" #include "ui/views/view_utils.h"
diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc index 01673da..b46d231 100644 --- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc +++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc
@@ -297,12 +297,7 @@ bool restored) { DesktopWindowTreeHostWin::HandleWindowMinimizedOrRestored(restored); - // This is necessary since OnWidgetVisibilityChanged() doesn't get called on - // Windows when the window is minimized or restored. - if (base::FeatureList::IsEnabled( - features::kStopLoadingAnimationForHiddenWindow)) { - browser_view_->UpdateLoadingAnimations(restored); - } + browser_view_->UpdateLoadingAnimations(restored); } std::string BrowserDesktopWindowTreeHostWin::GetWorkspace() const {
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 18a0160d..5d1842b 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1662,12 +1662,8 @@ } void BrowserView::UpdateLoadingAnimations(bool is_visible) { - bool should_animate = browser_->tab_strip_model()->TabsAreLoading(); - - if (base::FeatureList::IsEnabled( - features::kStopLoadingAnimationForHiddenWindow)) { - should_animate &= is_visible; - } + const bool should_animate = + is_visible && browser_->tab_strip_model()->TabsAreLoading(); if (should_animate == loading_animation_timer_.IsRunning()) { // Early return if the loading animation state doesn't change. @@ -2767,10 +2763,7 @@ void BrowserView::OnWidgetVisibilityChanged(views::Widget* widget, bool visible) { - if (base::FeatureList::IsEnabled( - features::kStopLoadingAnimationForHiddenWindow)) { - UpdateLoadingAnimations(visible); - } + UpdateLoadingAnimations(visible); } std::optional<bool> BrowserView::GetCanResizeFromWebAPI() const {
diff --git a/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc b/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc index 795989d0..777ebb47 100644 --- a/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc +++ b/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc
@@ -360,31 +360,6 @@ } } -// Class for BrowserView unit tests for the loading animation feature. -// Creates a Browser with a |features_list| where -// kStopLoadingAnimationForHiddenWindow is enabled before setting GPU thread. -class BrowserViewTestWithStopLoadingAnimationForHiddenWindow - : public BrowserViewTest { - public: - BrowserViewTestWithStopLoadingAnimationForHiddenWindow() { - feature_list_.InitAndEnableFeature( - features::kStopLoadingAnimationForHiddenWindow); - } - - BrowserViewTestWithStopLoadingAnimationForHiddenWindow( - const BrowserViewTestWithStopLoadingAnimationForHiddenWindow&) = delete; - BrowserViewTestWithStopLoadingAnimationForHiddenWindow& operator=( - const BrowserViewTestWithStopLoadingAnimationForHiddenWindow&) = delete; - - protected: - BrowserView* browser_view() { - return BrowserView::GetBrowserViewForBrowser(browser()); - } - - private: - base::test::ScopedFeatureList feature_list_; -}; - // TODO(b/342017720): Re-enable on Mac #if BUILDFLAG(IS_MAC) #define MAYBE_LoadingAnimationChangeOnMinimizeAndRestore \ @@ -393,7 +368,7 @@ #define MAYBE_LoadingAnimationChangeOnMinimizeAndRestore \ LoadingAnimationChangeOnMinimizeAndRestore #endif // BUILDFLAG(IS_MAC) -IN_PROC_BROWSER_TEST_F(BrowserViewTestWithStopLoadingAnimationForHiddenWindow, +IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_LoadingAnimationChangeOnMinimizeAndRestore) { auto* contents = browser()->tab_strip_model()->GetActiveWebContents(); content::TestNavigationObserver navigation_watcher(
diff --git a/chrome/browser/ui/views/frame/browser_view_unittest.cc b/chrome/browser/ui/views/frame/browser_view_unittest.cc index 3dd1fb8..c2466a0 100644 --- a/chrome/browser/ui/views/frame/browser_view_unittest.cc +++ b/chrome/browser/ui/views/frame/browser_view_unittest.cc
@@ -63,26 +63,6 @@ namespace { -// Class for BrowserView unit tests for the loading animation feature. -// Creates a Browser with a |features_list| where -// kStopLoadingAnimationForHiddenWindow is enabled before setting GPU thread. -class BrowserViewTestWithStopLoadingAnimationForHiddenWindow - : public TestWithBrowserView { - public: - BrowserViewTestWithStopLoadingAnimationForHiddenWindow() { - feature_list_.InitAndEnableFeature( - features::kStopLoadingAnimationForHiddenWindow); - } - - BrowserViewTestWithStopLoadingAnimationForHiddenWindow( - const BrowserViewTestWithStopLoadingAnimationForHiddenWindow&) = delete; - BrowserViewTestWithStopLoadingAnimationForHiddenWindow& operator=( - const BrowserViewTestWithStopLoadingAnimationForHiddenWindow&) = delete; - - private: - base::test::ScopedFeatureList feature_list_; -}; - // Tab strip bounds depend on the window frame sizes. gfx::Point ExpectedTabStripRegionOrigin(BrowserView* browser_view) { gfx::Rect tabstrip_bounds(browser_view->frame()->GetBoundsForTabStripRegion( @@ -743,8 +723,7 @@ // Tests Feature to ensure that the loading animation is not rendered after the // window changes to hidden. -TEST_F(BrowserViewTestWithStopLoadingAnimationForHiddenWindow, - LoadingAnimationNotRenderedWhenWindowHidden) { +TEST_F(TestWithBrowserView, LoadingAnimationNotRenderedWhenWindowHidden) { TabActivitySimulator tab_activity_simulator; content::WebContents* web_contents = tab_activity_simulator.AddWebContentsAndNavigate(
diff --git a/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc b/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc index 93b88f9..65a0df8 100644 --- a/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc +++ b/chrome/browser/ui/views/frame/desktop_browser_frame_aura.cc
@@ -67,11 +67,8 @@ aura::Window::OcclusionState new_state, const SkRegion& occluded_region) { if (browser_view_) { - if (base::FeatureList::IsEnabled( - features::kStopLoadingAnimationForHiddenWindow)) { - browser_view_->UpdateLoadingAnimations( - new_state == aura::Window::OcclusionState::VISIBLE); - } + browser_view_->UpdateLoadingAnimations( + new_state == aura::Window::OcclusionState::VISIBLE); } }
diff --git a/chrome/browser/ui/views/glic/border/BUILD.gn b/chrome/browser/ui/views/glic/border/BUILD.gn index 65114e4..55cb49f 100644 --- a/chrome/browser/ui/views/glic/border/BUILD.gn +++ b/chrome/browser/ui/views/glic/border/BUILD.gn
@@ -1,11 +1,15 @@ -source_set("browser_tests") { +# Copyright 2024 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("interactive_ui_tests") { testonly = true defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] sources = [ "border_view_browsertest.cc" ] deps = [ "//chrome/browser", - "//chrome/browser:browser_process", "//chrome/browser/ui", + "//chrome/common", "//chrome/test:test_support", "//content/test:test_support", ]
diff --git a/chrome/browser/ui/views/glic/border/border_view.cc b/chrome/browser/ui/views/glic/border/border_view.cc index ae9f53b3..d4e5907 100644 --- a/chrome/browser/ui/views/glic/border/border_view.cc +++ b/chrome/browser/ui/views/glic/border/border_view.cc
@@ -50,14 +50,20 @@ void BorderView::OnPaint(gfx::Canvas* canvas) { // TODO(baranerf): Modify this to a variable width when adding animation. - constexpr static int kBorderWidth = 5; + // + // Note: | | | + // |<-- 5px -->|<-- 5px -->| + // | outside | visible | + // + // So only half of the width are inside the visible viewport. + constexpr static int kBorderWidth = 10; views::View::OnPaint(canvas); cc::PaintFlags flags; flags.setStyle(cc::PaintFlags::kStroke_Style); flags.setColor(GetColorProvider()->GetColor(ui::kColorSysPrimary)); flags.setStrokeWidth(kBorderWidth); - canvas->DrawRect(GetContentsBounds(), flags); + canvas->DrawRect(gfx::RectF(GetContentsBounds()), flags); } void BorderView::OnChildViewAdded(views::View* observed_view,
diff --git a/chrome/browser/ui/views/glic/border/border_view_browsertest.cc b/chrome/browser/ui/views/glic/border/border_view_browsertest.cc index 20006977..b513340 100644 --- a/chrome/browser/ui/views/glic/border/border_view_browsertest.cc +++ b/chrome/browser/ui/views/glic/border/border_view_browsertest.cc
@@ -4,15 +4,23 @@ #include "chrome/browser/ui/views/glic/border/border_view.h" +#include "base/test/bind.h" +#include "base/test/test_future.h" +#include "cc/test/pixel_test_utils.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/test/base/in_process_browser_test.h" +#include "components/viz/common/frame_timing_details.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/metadata/metadata_header_macros.h" #include "ui/base/metadata/metadata_impl_macros.h" +#include "ui/compositor/compositor.h" +#include "ui/compositor/layer.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/snapshot/snapshot.h" namespace glic { @@ -139,4 +147,153 @@ return info.param ? "CompetingSibling" : "RegularSibling"; }); +namespace { + +class BorderViewPixelTest : public InProcessBrowserTest { + public: + BorderViewPixelTest() = default; + ~BorderViewPixelTest() override = default; + + void SetUp() override { + EnablePixelOutput(); + InProcessBrowserTest::SetUp(); + } + + static SkBitmap ConstructExpectedBitmap(const gfx::Size& size, + SkColor border_color, + SkColor center_color, + int border_width) { + SkBitmap bitmap; + SkImageInfo info = + SkImageInfo::Make(size.width(), size.height(), kRGBA_8888_SkColorType, + kUnpremul_SkAlphaType); + bitmap.allocPixels(info); + bitmap.eraseColor(center_color); + SkCanvas canvas(bitmap, SkSurfaceProps{}); + SkPaint border; + border.setColor(border_color); + border.setStyle(SkPaint::Style::kStroke_Style); + border.setStrokeWidth(border_width); + canvas.drawRect(SkRect::MakeXYWH(0, 0, size.width(), size.height()), + border); + return bitmap; + } + + // TODO(crbug.com/386220498): Look into the feasibility of Skia gold tests. + static void ExpectTwoBitmapsAreEqual(const SkBitmap& actual, + const SkBitmap& expected, + int bottom_rows_to_exclude) { + ASSERT_EQ(actual.dimensions(), expected.dimensions()) + << actual.dimensions().width() << "x" << actual.dimensions().height() + << " vs " << expected.dimensions().width() << "x" + << expected.dimensions().height(); + + int num_pixel_mismatch = 0; + gfx::Rect err_bounding_box; + + for (int r = 0; r < actual.height() - bottom_rows_to_exclude; ++r) { + for (int c = 0; c < actual.width(); ++c) { + if (actual.getColor(c, r) != expected.getColor(c, r)) { + ++num_pixel_mismatch; + err_bounding_box.Union(gfx::Rect(c, r, 1, 1)); + } + } + } + if (num_pixel_mismatch != 0) { + EXPECT_TRUE(false) << "Number of pixel mismatches: " << num_pixel_mismatch + << "; error bounding box: " + << err_bounding_box.ToString() << "; actual bitmap " + << cc::GetPNGDataUrl(actual); + } + } + + static void WaitForCompositorFlush(content::WebContents* web_contents) { + ForceNewCompositorFrameFromBrowser(web_contents); + WaitForBrowserCompositorFramePresented(web_contents); + } +}; +} // namespace + +IN_PROC_BROWSER_TEST_F(BorderViewPixelTest, Basic) { + // TODO(crbug.com/385828490): We should exercise the proper closing flow. + // Currently the BookmarkModel has a dangling observer during destruction, if + // the glic UI is toggled. + auto* border = + browser()->window()->AsBrowserView()->contents_web_view()->glic_border(); + + ASSERT_EQ(browser()->tab_strip_model()->GetTabCount(), 1); + auto* web_contents = + browser()->tab_strip_model()->GetTabAtIndex(0)->GetContents(); + + { + SCOPED_TRACE("Start animation"); + border->StartAnimation(); + // Makes sure the pixels are on the screen. + WaitForCompositorFlush(web_contents); + } + + auto* browser_view = browser()->window()->AsBrowserView(); + + gfx::Rect capture_rect = web_contents->GetViewBounds(); + const auto& browser_view_screen_bounds = browser_view->GetBoundsInScreen(); + const auto& browser_view_bounds = browser_view->bounds(); + // TODO(liuwilliam): We should only use the screen coordinates, instead mixing + // screen and view coords. Currently the WebContents's screen coordinates are + // not exposed (see `ui::NativeViewHost`). + // + // Example: + // web_contents->GetViewBounds() 14,97 1042x689 + // browser_view->GetBoundsInScreen() 14,10 1042x776 + // browser_view->bounds() 4,0 1042x776 + // capture_rect 4,87 1042x689 + capture_rect.Offset(-browser_view_screen_bounds.OffsetFromOrigin()); + capture_rect.Offset(browser_view_bounds.OffsetFromOrigin()); + + int bottom_rows_to_exclude = 0; +#if BUILDFLAG(IS_MAC) + // Exclude the bottom 15 rows from the comparison because the rounded bottom + // corners. + bottom_rows_to_exclude = 15; +#endif + + gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); + + { + SCOPED_TRACE("Assert border"); + base::test::TestFuture<gfx::Image> result; + ui::GrabWindowSnapshot(native_window, capture_rect, result.GetCallback()); + // Makes sure our CopyOutputRequest is served. We won't get the results back + // if Viz doesn't activate a frame. + WaitForCompositorFlush(web_contents); + + SkBitmap expected = ConstructExpectedBitmap( + capture_rect.size(), + /*border_color=*/ + browser()->GetBrowserView().GetColorProvider()->GetColor( + ui::kColorSysPrimary), + /*center_color=*/SkColors::kWhite.toSkColor(), /*border_width=*/10); + ExpectTwoBitmapsAreEqual(result.Get().AsBitmap(), expected, + bottom_rows_to_exclude); + } + { + SCOPED_TRACE("Cancel animation"); + // TODO(crbug.com/385828490): Ditto. + border->CancelAnimation(); + WaitForCompositorFlush(web_contents); + } + { + SCOPED_TRACE("Assert no border"); + base::test::TestFuture<gfx::Image> result; + ui::GrabWindowSnapshot(native_window, capture_rect, result.GetCallback()); + WaitForCompositorFlush(web_contents); + + SkBitmap expected = ConstructExpectedBitmap( + capture_rect.size(), + /*border_color=*/SkColors::kWhite.toSkColor(), + /*center_color=*/SkColors::kWhite.toSkColor(), /*border_width=*/10); + ExpectTwoBitmapsAreEqual(result.Get().AsBitmap(), expected, + bottom_rows_to_exclude); + } +} + } // namespace glic
diff --git a/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc b/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc index 6dc55d5..4c88245e 100644 --- a/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc +++ b/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc
@@ -21,7 +21,7 @@ #include "ui/color/color_id.h" #include "ui/color/color_provider.h" #include "ui/gfx/color_utils.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/background.h" #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/interaction/element_tracker_views.h" @@ -166,7 +166,7 @@ return const_cast<decltype(*icon_)>(*icon_); } - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } ui::ColorId OmniboxChipButton::GetForegroundColorId() const {
diff --git a/chrome/browser/ui/views/location_bar/omnibox_chip_button.h b/chrome/browser/ui/views/location_bar/omnibox_chip_button.h index d4a5609..2d0862f 100644 --- a/chrome/browser/ui/views/location_bar/omnibox_chip_button.h +++ b/chrome/browser/ui/views/location_bar/omnibox_chip_button.h
@@ -11,7 +11,6 @@ #include "ui/base/metadata/metadata_header_macros.h" #include "ui/base/models/image_model.h" #include "ui/gfx/animation/slide_animation.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" #include "ui/views/controls/button/md_text_button.h" @@ -97,7 +96,7 @@ // without text. bool fully_collapsed_ = false; - raw_ptr<const gfx::VectorIcon> icon_ = &gfx::kNoneIcon; + raw_ptr<const gfx::VectorIcon> icon_ = &gfx::VectorIcon::EmptyIcon(); base::ObserverList<Observer> observers_; };
diff --git a/chrome/browser/ui/views/page_action/BUILD.gn b/chrome/browser/ui/views/page_action/BUILD.gn index 40c0325..56f5a8d 100644 --- a/chrome/browser/ui/views/page_action/BUILD.gn +++ b/chrome/browser/ui/views/page_action/BUILD.gn
@@ -24,6 +24,7 @@ public_deps = [ "//base", + "//chrome/browser:browser_public_dependencies", "//chrome/browser/ui/actions:actions_headers", "//ui/actions:actions_headers", "//ui/base/metadata",
diff --git a/chrome/browser/ui/views/page_action/page_action_icon_view.cc b/chrome/browser/ui/views/page_action/page_action_icon_view.cc index e72ae48..bdd666f7 100644 --- a/chrome/browser/ui/views/page_action/page_action_icon_view.cc +++ b/chrome/browser/ui/views/page_action/page_action_icon_view.cc
@@ -22,6 +22,7 @@ #include "ui/events/event.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/native_theme/native_theme.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/animation/flood_fill_ink_drop_ripple.h" @@ -213,7 +214,7 @@ } const gfx::VectorIcon& PageActionIconView::GetVectorIconBadge() const { - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } ui::ImageModel PageActionIconView::GetSizedIconImage(int size) const {
diff --git a/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc b/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc index 4af23ecd..acc65ae 100644 --- a/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc +++ b/chrome/browser/ui/views/page_action/page_action_icon_view_unittest.cc
@@ -11,7 +11,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/color_palette.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/controls/button/button.h" #include "ui/views/widget/widget_utils.h" @@ -96,7 +96,7 @@ // PageActionIconView: void OnExecuting(ExecuteSource execute_source) override {} const gfx::VectorIcon& GetVectorIcon() const override { - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } void UpdateImpl() override {}
diff --git a/chrome/browser/ui/views/page_info/page_info_view_factory.cc b/chrome/browser/ui/views/page_info/page_info_view_factory.cc index 6a778d3..e7a53e45 100644 --- a/chrome/browser/ui/views/page_info/page_info_view_factory.cc +++ b/chrome/browser/ui/views/page_info/page_info_view_factory.cc
@@ -37,7 +37,7 @@ #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" #include "ui/color/color_id.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button_factory.h" @@ -464,7 +464,7 @@ return ui::ImageModel::FromVectorIcon(*icon, ui::kColorIcon, GetIconSize()); } - icon = &gfx::kNoneIcon; + icon = &gfx::VectorIcon::EmptyIcon(); switch (info.type) { case ContentSettingsType::COOKIES: icon = &vector_icons::kDatabaseIcon; @@ -594,7 +594,7 @@ // is not currently conncted to the system. // TODO(crbug.com/40672237): Check the connected status of devices and // change the icon to one that reflects that status. - const gfx::VectorIcon* icon = &gfx::kNoneIcon; + const gfx::VectorIcon* icon = &gfx::VectorIcon::EmptyIcon(); switch (object.ui_info->content_settings_type) { case ContentSettingsType::USB_CHOOSER_DATA: icon = &vector_icons::kUsbIcon;
diff --git a/chrome/browser/ui/views/permissions/chip/permission_chip_view.cc b/chrome/browser/ui/views/permissions/chip/permission_chip_view.cc index 79a4efb..f421295 100644 --- a/chrome/browser/ui/views/permissions/chip/permission_chip_view.cc +++ b/chrome/browser/ui/views/permissions/chip/permission_chip_view.cc
@@ -24,7 +24,7 @@ #include "ui/color/color_id.h" #include "ui/color/color_provider.h" #include "ui/gfx/color_utils.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/background.h" #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/painter.h" @@ -203,7 +203,7 @@ return const_cast<decltype(*icon_)>(*icon_); } - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } SkColor PermissionChipView::GetForegroundColor() const {
diff --git a/chrome/browser/ui/views/permissions/chip/permission_chip_view.h b/chrome/browser/ui/views/permissions/chip/permission_chip_view.h index 3a0cb70..97ed525 100644 --- a/chrome/browser/ui/views/permissions/chip/permission_chip_view.h +++ b/chrome/browser/ui/views/permissions/chip/permission_chip_view.h
@@ -15,7 +15,6 @@ #include "ui/base/metadata/metadata_header_macros.h" #include "ui/base/models/image_model.h" #include "ui/gfx/animation/slide_animation.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" #include "ui/views/controls/button/md_text_button.h" #include "ui/views/view_tracker.h" @@ -153,7 +152,7 @@ bool fully_collapsed_ = false; bool is_divider_visible_ = false; - raw_ptr<const gfx::VectorIcon> icon_ = &gfx::kNoneIcon; + raw_ptr<const gfx::VectorIcon> icon_ = &gfx::VectorIcon::EmptyIcon(); base::ObserverList<Observer> observers_; };
diff --git a/chrome/browser/ui/views/permissions/embedded_permission_prompt_base_view.cc b/chrome/browser/ui/views/permissions/embedded_permission_prompt_base_view.cc index ae1fb8b..fd3b61d 100644 --- a/chrome/browser/ui/views/permissions/embedded_permission_prompt_base_view.cc +++ b/chrome/browser/ui/views/permissions/embedded_permission_prompt_base_view.cc
@@ -25,7 +25,7 @@ #include "ui/base/ui_base_features.h" #include "ui/display/screen.h" #include "ui/gfx/geometry/rect.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/label.h" @@ -137,7 +137,7 @@ } const gfx::VectorIcon& EmbeddedPermissionPromptBaseView::GetIcon() const { - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } bool EmbeddedPermissionPromptBaseView::ShowLoadingIcon() const {
diff --git a/chrome/browser/ui/views/permissions/midi_permissions_flow_interactive_uitest.cc b/chrome/browser/ui/views/permissions/midi_permissions_flow_interactive_uitest.cc index e28a59c..24c9f0e 100644 --- a/chrome/browser/ui/views/permissions/midi_permissions_flow_interactive_uitest.cc +++ b/chrome/browser/ui/views/permissions/midi_permissions_flow_interactive_uitest.cc
@@ -25,7 +25,7 @@ #include "net/dns/mock_host_resolver.h" #include "third_party/blink/public/common/features.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/interaction/interaction_test_util_views.h" #include "ui/views/interaction/interactive_views_test.h" #include "ui/views/view_utils.h" @@ -171,7 +171,7 @@ EXPECT_EQ(element_view->get_icon_for_testing(), &vector_icons::kMidiOffChromeRefreshIcon); EXPECT_EQ(element_view->get_icon_badge_for_testing(), - &gfx::kNoneIcon); + &gfx::VectorIcon::EmptyIcon()); EXPECT_EQ(element_view->get_tooltip_text_for_testing(), l10n_util::GetStringUTF16( IDS_BLOCKED_MIDI_SYSEX_MESSAGE)); @@ -191,7 +191,7 @@ EXPECT_EQ(element_view->get_icon_for_testing(), &vector_icons::kMidiChromeRefreshIcon); EXPECT_EQ(element_view->get_icon_badge_for_testing(), - &gfx::kNoneIcon); + &gfx::VectorIcon::EmptyIcon()); EXPECT_EQ(element_view->get_tooltip_text_for_testing(), l10n_util::GetStringUTF16( IDS_ALLOWED_MIDI_SYSEX_MESSAGE));
diff --git a/chrome/browser/ui/views/permissions/permission_indicators_interactive_uitest.cc b/chrome/browser/ui/views/permissions/permission_indicators_interactive_uitest.cc index 6134a56..0562e64 100644 --- a/chrome/browser/ui/views/permissions/permission_indicators_interactive_uitest.cc +++ b/chrome/browser/ui/views/permissions/permission_indicators_interactive_uitest.cc
@@ -17,7 +17,7 @@ #include "content/public/test/browser_test_utils.h" #include "net/dns/mock_host_resolver.h" #include "ui/base/ui_base_features.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/interaction/interaction_test_util_views.h" namespace { @@ -120,7 +120,7 @@ CheckViewProperty( ContentSettingImageView::kMediaActivityIndicatorElementId, &ContentSettingImageView::get_icon_badge_for_testing, - &gfx::kNoneIcon), + &gfx::VectorIcon::EmptyIcon()), ExecuteJs(kWebContentsElementId, "stopCamera"), WaitForHide(ContentSettingImageView::kMediaActivityIndicatorElementId)); } @@ -146,7 +146,7 @@ CheckViewProperty( ContentSettingImageView::kMediaActivityIndicatorElementId, &ContentSettingImageView::get_icon_badge_for_testing, - &gfx::kNoneIcon), + &gfx::VectorIcon::EmptyIcon()), ExecuteJs(kWebContentsElementId, "requestCamera"), // `getUserMedia` is async, so wait until media stream is opened. WaitForStateChange(kWebContentsElementId, GetCameraStreamStateChange()), @@ -159,7 +159,7 @@ CheckViewProperty( ContentSettingImageView::kMediaActivityIndicatorElementId, &ContentSettingImageView::get_icon_badge_for_testing, - &gfx::kNoneIcon), + &gfx::VectorIcon::EmptyIcon()), ExecuteJs(kWebContentsElementId, "stopCamera"), ExecuteJs(kWebContentsElementId, "stopMic"), WaitForHide(ContentSettingImageView::kMediaActivityIndicatorElementId));
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view.cc b/chrome/browser/ui/views/profiles/profile_menu_view.cc index 2a1d24d..5a27590 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view.cc +++ b/chrome/browser/ui/views/profiles/profile_menu_view.cc
@@ -87,6 +87,7 @@ #include "ui/gfx/image/canvas_image_source.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia_operations.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/strings/grit/ui_strings.h" #include "ui/views/accessibility/view_accessibility.h"
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view_base.cc b/chrome/browser/ui/views/profiles/profile_menu_view_base.cc index 5383396d..b658386 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view_base.cc +++ b/chrome/browser/ui/views/profiles/profile_menu_view_base.cc
@@ -50,6 +50,7 @@ #include "ui/gfx/canvas.h" #include "ui/gfx/image/canvas_image_source.h" #include "ui/gfx/image/image_skia_operations.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" #include "ui/strings/grit/ui_strings.h" #include "ui/views/accessibility/view_accessibility.h" @@ -1042,7 +1043,7 @@ views::BoxLayout::Orientation::kVertical)); } - if (&icon == &gfx::kNoneIcon) { + if (&icon == &gfx::VectorIcon::EmptyIcon()) { features_container_->AddChildView(std::make_unique<HoverButton>( base::BindRepeating(&ProfileMenuViewBase::ButtonPressed, base::Unretained(this), std::move(action)),
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view_base.h b/chrome/browser/ui/views/profiles/profile_menu_view_base.h index 535f051c..0a9d1f86c 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view_base.h +++ b/chrome/browser/ui/views/profiles/profile_menu_view_base.h
@@ -24,7 +24,7 @@ #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/models/image_model.h" #include "ui/color/color_id.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/bubble/bubble_dialog_delegate_view.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/flex_layout_view.h" @@ -191,10 +191,11 @@ void AddShortcutFeatureButton(const gfx::VectorIcon& icon, const std::u16string& text, base::RepeatingClosure action); - void AddFeatureButton(const std::u16string& text, - base::RepeatingClosure action, - const gfx::VectorIcon& icon = gfx::kNoneIcon, - float icon_to_image_ratio = 1.0f); + void AddFeatureButton( + const std::u16string& text, + base::RepeatingClosure action, + const gfx::VectorIcon& icon = gfx::VectorIcon::EmptyIcon(), + float icon_to_image_ratio = 1.0f); void SetProfileManagementHeading(const std::u16string& heading); void AddAvailableProfile(const ui::ImageModel& image_model, const std::u16string& name,
diff --git a/chrome/browser/ui/views/sharing/sharing_icon_view.cc b/chrome/browser/ui/views/sharing/sharing_icon_view.cc index be5fc76..596828d 100644 --- a/chrome/browser/ui/views/sharing/sharing_icon_view.cc +++ b/chrome/browser/ui/views/sharing/sharing_icon_view.cc
@@ -11,8 +11,8 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/compositor/layer.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/scoped_canvas.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/strings/grit/ui_strings.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/animation/ink_drop.h" @@ -160,7 +160,8 @@ } const gfx::VectorIcon& SharingIconView::GetVectorIconBadge() const { - return should_show_error_ ? vector_icons::kBlockedBadgeIcon : gfx::kNoneIcon; + return should_show_error_ ? vector_icons::kBlockedBadgeIcon + : gfx::VectorIcon::EmptyIcon(); } void SharingIconView::OnExecuting( @@ -173,7 +174,8 @@ const gfx::VectorIcon& SharingIconView::GetVectorIcon() const { auto* controller = GetController(); - return controller ? controller->GetVectorIcon() : gfx::kNoneIcon; + return controller ? controller->GetVectorIcon() + : gfx::VectorIcon::EmptyIcon(); } void SharingIconView::SetAccessibleIsIgnoredIfNeeded() {
diff --git a/chrome/browser/ui/views/sharing/sharing_icon_view_unittest.cc b/chrome/browser/ui/views/sharing/sharing_icon_view_unittest.cc index 32d1a6cc..ec19ad0 100644 --- a/chrome/browser/ui/views/sharing/sharing_icon_view_unittest.cc +++ b/chrome/browser/ui/views/sharing/sharing_icon_view_unittest.cc
@@ -18,7 +18,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/color_palette.h" -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/controls/button/button.h" #include "ui/views/widget/widget_utils.h" @@ -85,7 +85,7 @@ // PageActionIconView: void OnExecuting(ExecuteSource execute_source) override {} const gfx::VectorIcon& GetVectorIcon() const override { - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } void UpdateImpl() override {} };
diff --git a/chrome/browser/ui/views/sharing_hub/sharing_hub_bubble_view_impl_unittest.cc b/chrome/browser/ui/views/sharing_hub/sharing_hub_bubble_view_impl_unittest.cc index ab9cf22a..6bcf4ee 100644 --- a/chrome/browser/ui/views/sharing_hub/sharing_hub_bubble_view_impl_unittest.cc +++ b/chrome/browser/ui/views/sharing_hub/sharing_hub_bubble_view_impl_unittest.cc
@@ -79,12 +79,10 @@ return widget->GetFocusManager()->GetFocusedView(); } -const gfx::VectorIcon kEmptyIcon; - const std::vector<sharing_hub::SharingHubAction> kFirstPartyActions = { - {0, u"Feed to Dino", &kEmptyIcon, "feed-to-dino", 0}, - {1, u"Reverse Star", &kEmptyIcon, "reverse-star", 0}, - {2, u"Pastelify", &kEmptyIcon, "pastelify", 0}, + {0, u"Feed to Dino", &gfx::VectorIcon::EmptyIcon(), "feed-to-dino", 0}, + {1, u"Reverse Star", &gfx::VectorIcon::EmptyIcon(), "reverse-star", 0}, + {2, u"Pastelify", &gfx::VectorIcon::EmptyIcon(), "pastelify", 0}, }; } // namespace
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 8ce5d3b0..23bb8c2 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -496,7 +496,6 @@ source_view->GetMirroredXInView(source_view_offset)) / source_view->width(); } - ref->InitWindowCreatePoint(); ref->initial_selection_model_ = std::move(initial_selection_model); ref->window_finder_ = std::make_unique<WindowFinder>(); @@ -869,43 +868,6 @@ /////////////////////////////////////////////////////////////////////////////// // TabDragController, private: -void TabDragController::InitWindowCreatePoint() { - // window_create_point_ is only used in CompleteDrag() (through - // GetWindowCreatePoint() to get the start point of the docked window) when - // the attached_context_ is NULL and all the window's related bound - // information are obtained from source_context_. So, we need to get the - // first_tab based on source_context_, not attached_context_. Otherwise, - // the window_create_point_ is not in the correct coordinate system. Please - // refer to http://crbug.com/6223 comment #15 for detailed information. - views::View* first_tab = source_context_->GetTabAt(0); - views::View::ConvertPointToWidget(first_tab, &first_source_tab_point_); - window_create_point_ = first_source_tab_point_; - window_create_point_.Offset(mouse_offset_.x(), mouse_offset_.y()); -} - -gfx::Point TabDragController::GetWindowCreatePoint( - const gfx::Point& origin) const { - // If the cursor is outside the monitor area, move it inside. For example, - // dropping a tab onto the task bar on Windows produces this situation. - gfx::Rect work_area = - display::Screen::GetScreen()->GetDisplayNearestPoint(origin).work_area(); - gfx::Point create_point(origin); - if (!work_area.IsEmpty()) { - if (create_point.x() < work_area.x()) { - create_point.set_x(work_area.x()); - } else if (create_point.x() > work_area.right()) { - create_point.set_x(work_area.right()); - } - if (create_point.y() < work_area.y()) { - create_point.set_y(work_area.y()); - } else if (create_point.y() > work_area.bottom()) { - create_point.set_y(work_area.bottom()); - } - } - return gfx::Point(create_point.x() - window_create_point_.x(), - create_point.y() - window_create_point_.y()); -} - void TabDragController::SaveFocus() { DCHECK(source_context_); old_focused_view_tracker_->SetView( @@ -1876,6 +1838,7 @@ } void TabDragController::RevertDrag() { + CHECK(attached_context_); // If we're dragging a saved tab group, suspend tracking during the revert. // Otherwise, the group will get emptied out as we revert all the tabs. MaybePauseTrackingSavedTabGroup(); @@ -1893,18 +1856,16 @@ MaybeResumeTrackingSavedTabGroup(); - if (attached_context_) { - if (did_restore_window_) { - MaximizeAttachedWindow(); + if (did_restore_window_) { + MaximizeAttachedWindow(); + } + if (attached_context_ == source_context_) { + source_context_->StoppedDragging(); + if (header_drag_) { + source_context_->GetTabStripModel()->MoveTabGroup(group_.value()); } - if (attached_context_ == source_context_) { - source_context_->StoppedDragging(); - if (header_drag_) { - source_context_->GetTabStripModel()->MoveTabGroup(group_.value()); - } - } else { - attached_context_->DraggedTabsDetached(); - } + } else { + attached_context_->DraggedTabsDetached(); } // If tabs were closed during this drag, the initial selection might include @@ -2015,6 +1976,7 @@ void TabDragController::RevertDragAt(size_t drag_index) { CHECK_NE(current_state_, DragState::kNotStarted); + CHECK(attached_context_); CHECK(source_context_); // We can't revert if `contents` was destroyed during the drag, or if this is // a group header. @@ -2037,53 +1999,45 @@ ? std::make_optional(drag_data.value().group_id) : std::nullopt; - if (attached_context_) { - int index = attached_context_->GetTabStripModel()->GetIndexOfWebContents( - data->contents); - if (attached_context_ != source_context_) { - std::unique_ptr<base::AutoReset<bool>> removing_last_tab_setter; - if (attached_context_->GetTabStripModel()->count() == 1) { - removing_last_tab_setter = std::make_unique<base::AutoReset<bool>>( - &is_removing_last_tab_for_revert_, true); - } - // The Tab was inserted into another TabDragContext. We need to - // put it back into the original one. Marking the view as detached tells - // the TabStrip to not animate its closure, as it's actually being moved. - data->attached_view->set_detached(); - std::unique_ptr<tabs::TabModel> detached_tab = - attached_context_->GetTabStripModel()->DetachTabAtForInsertion(index); - // No-longer removing the last tab, so reset state. - removing_last_tab_setter.reset(); - // TODO(beng): (Cleanup) seems like we should use Attach() for this - // somehow. - source_context_->GetTabStripModel()->InsertDetachedTabAt( - target_index, std::move(detached_tab), - (data->pinned ? AddTabTypes::ADD_PINNED : 0), existing_group); - } else { - // The Tab was moved within the TabDragContext where the drag - // was initiated. Move it back to the starting location. + const int index = + attached_context_->GetTabStripModel()->GetIndexOfWebContents( + data->contents); + if (attached_context_ != source_context_) { + std::unique_ptr<base::AutoReset<bool>> removing_last_tab_setter; + if (attached_context_->GetTabStripModel()->count() == 1) { + removing_last_tab_setter = std::make_unique<base::AutoReset<bool>>( + &is_removing_last_tab_for_revert_, true); + } + // The Tab was inserted into another TabDragContext. We need to + // put it back into the original one. Marking the view as detached tells + // the TabStrip to not animate its closure, as it's actually being moved. + data->attached_view->set_detached(); + std::unique_ptr<tabs::TabModel> detached_tab = + attached_context_->GetTabStripModel()->DetachTabAtForInsertion(index); + // No-longer removing the last tab, so reset state. + removing_last_tab_setter.reset(); + // TODO(beng): (Cleanup) seems like we should use Attach() for this + // somehow. + source_context_->GetTabStripModel()->InsertDetachedTabAt( + target_index, std::move(detached_tab), + (data->pinned ? AddTabTypes::ADD_PINNED : 0), existing_group); + } else { + // The Tab was moved within the TabDragContext where the drag + // was initiated. Move it back to the starting location. - // If the target index is to the right, then other unreverted tabs are - // occupying indices between this tab and the target index. Those - // unreverted tabs will later be reverted to the right of the target - // index, so we skip those indices. - if (target_index > index) { - for (size_t i = drag_index + 1; i < drag_data_.size(); ++i) { - if (drag_data_[i].contents) { - ++target_index; - } + // If the target index is to the right, then other unreverted tabs are + // occupying indices between this tab and the target index. Those + // unreverted tabs will later be reverted to the right of the target + // index, so we skip those indices. + if (target_index > index) { + for (size_t i = drag_index + 1; i < drag_data_.size(); ++i) { + if (drag_data_[i].contents) { + ++target_index; } } - source_context_->GetTabStripModel()->MoveWebContentsAt( - index, target_index, false, existing_group); } - } else { - // The Tab was detached from the TabDragContext where the drag - // began, and has not been attached to any other TabDragContext. - // We need to put it back into the source TabDragContext. - source_context_->GetTabStripModel()->InsertDetachedTabAt( - target_index, std::move(data->owned_tab), - (data->pinned ? AddTabTypes::ADD_PINNED : 0), existing_group); + source_context_->GetTabStripModel()->MoveWebContentsAt( + index, target_index, false, existing_group); } if (drag_data.has_value() && !existing_group.has_value()) { @@ -2094,73 +2048,46 @@ } void TabDragController::CompleteDrag() { - DCHECK_NE(current_state_, DragState::kNotStarted); + CHECK_NE(current_state_, DragState::kNotStarted); + CHECK(attached_context_); - if (attached_context_) { - if (is_dragging_new_browser_ || did_restore_window_) { - if (IsSnapped(attached_context_)) { - was_source_maximized_ = false; - was_source_fullscreen_ = false; - } + if (is_dragging_new_browser_ || did_restore_window_) { + if (IsSnapped(attached_context_)) { + was_source_maximized_ = false; + was_source_fullscreen_ = false; + } - // If source window was maximized - maximize the new window as well. + // If source window was maximized - maximize the new window as well. #if !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_MAC) - // Keeping maximized state breaks snap to Grid on Windows when dragging - // tabs from maximized windows. TODO:(crbug.com/727051) Explore doing this - // for other desktop OS's. kMaximizedStateRetainedOnTabDrag in - // tab_drag_controller_interactive_uitest.cc will need to be initialized - // to false on each desktop OS that changes this behavior. - // macOS opts out since this maps maximize to fullscreen, which can - // violate user expectations and interacts poorly with some window - // management actions. - if (was_source_maximized_ || was_source_fullscreen_) { - MaximizeAttachedWindow(); - } + // Keeping maximized state breaks snap to Grid on Windows when dragging + // tabs from maximized windows. TODO:(crbug.com/727051) Explore doing this + // for other desktop OS's. kMaximizedStateRetainedOnTabDrag in + // tab_drag_controller_interactive_uitest.cc will need to be initialized + // to false on each desktop OS that changes this behavior. + // macOS opts out since this maps maximize to fullscreen, which can + // violate user expectations and interacts poorly with some window + // management actions. + if (was_source_maximized_ || was_source_fullscreen_) { + MaximizeAttachedWindow(); + } #endif // !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_MAC) - } - attached_context_->StoppedDragging(); + } + attached_context_->StoppedDragging(); - // Tabbed PWAs with a home tab should have a home tab in every window. - // This means when dragging tabs out to create a new window, a home tab - // needs to be added. - if (is_dragging_new_browser_) { - Browser* new_browser = - BrowserView::GetBrowserViewForNativeWindow( - attached_context_->GetWidget()->GetNativeWindow()) - ->browser(); - - if (new_browser->app_controller() && - new_browser->app_controller()->has_tab_strip()) { - web_app::MaybeAddPinnedHomeTab(new_browser, - new_browser->app_controller()->app_id()); - } - } - } else { - // Compel the model to construct a new window for the detached - // WebContentses. - views::Widget* widget = source_context_->GetWidget(); - gfx::Rect window_bounds(widget->GetRestoredBounds()); - window_bounds.set_origin(GetWindowCreatePoint(last_point_in_screen_)); - - base::AutoReset<bool> setter(&is_mutating_, true); - - std::vector<TabStripModelDelegate::NewStripContents> tabs; - for (auto& drag_datum : drag_data_) { - TabStripModelDelegate::NewStripContents item; - // We should have owned_contents here, this CHECK is used to gather data - // for https://crbug.com/677806. - CHECK(drag_datum.owned_tab); - item.tab = std::move(drag_datum.owned_tab); - item.add_types = - drag_datum.pinned ? AddTabTypes::ADD_PINNED : AddTabTypes::ADD_NONE; - tabs.push_back(std::move(item)); - } - + // Tabbed PWAs with a home tab should have a home tab in every window. + // This means when dragging tabs out to create a new window, a home tab + // needs to be added. + if (is_dragging_new_browser_) { Browser* new_browser = - source_context_->GetTabStripModel()->delegate()->CreateNewStripWithTabs( - std::move(tabs), window_bounds, widget->IsMaximized()); - ResetSelection(new_browser->tab_strip_model()); - new_browser->window()->Show(); + BrowserView::GetBrowserViewForNativeWindow( + attached_context_->GetWidget()->GetNativeWindow()) + ->browser(); + + if (new_browser->app_controller() && + new_browser->app_controller()->has_tab_strip()) { + web_app::MaybeAddPinnedHomeTab(new_browser, + new_browser->app_controller()->app_id()); + } } if (header_drag_) {
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.h b/chrome/browser/ui/views/tabs/tab_drag_controller.h index 5d82163..dcf0a33 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.h +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.h
@@ -382,10 +382,6 @@ void OnActiveStripWebContentsReplaced(content::WebContents* previous, content::WebContents* next); - // Initialize the offset used to calculate the position to create windows - // in |GetWindowCreatePoint|. This should only be invoked from |Init|. - void InitWindowCreatePoint(); - // TabDragWithScrollManager: gfx::Point GetLastPointInScreen() override; views::View* GetAttachedContext() override; @@ -395,10 +391,6 @@ void MoveAttached(const gfx::Point& point_in_screen, bool just_attached) override; - // Returns the point where a detached window should be created given the - // current mouse position |origin|. - gfx::Point GetWindowCreatePoint(const gfx::Point& origin) const; - void UpdateDockInfo(const gfx::Point& point_in_screen); // Saves focus in the window that the drag initiated from. Focus will be @@ -691,12 +683,6 @@ // source view. float offset_to_width_ratio_; - // A hint to use when positioning new windows created by detaching Tabs. This - // is the distance of the mouse from the top left of the dragged tab as if it - // were the distance of the mouse from the top left of the first tab in the - // attached TabDragContext from the top left of the window. - gfx::Point window_create_point_; - // Location of the first tab in the source tabstrip in screen coordinates. // This is used to calculate |window_create_point_|. gfx::Point first_source_tab_point_;
diff --git a/chrome/browser/ui/views/tabs/tab_strip_control_button.cc b/chrome/browser/ui/views/tabs/tab_strip_control_button.cc index de812ac..f8544a9 100644 --- a/chrome/browser/ui/views/tabs/tab_strip_control_button.cc +++ b/chrome/browser/ui/views/tabs/tab_strip_control_button.cc
@@ -59,7 +59,6 @@ const int TabStripControlButton::kIconSize = 16; const gfx::Size TabStripControlButton::kButtonSize{28, 28}; -const gfx::VectorIcon kEmptyIcon; TabStripControlButton::TabStripControlButton( TabStripController* tab_strip_controller, @@ -82,7 +81,7 @@ Edge animated_flat_edge) : TabStripControlButton(tab_strip_controller, std::move(callback), - kEmptyIcon, + gfx::VectorIcon::EmptyIcon(), text, fixed_flat_edge, animated_flat_edge) {}
diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc index b3a069e8..5d9cf4d 100644 --- a/chrome/browser/ui/views/task_manager_view.cc +++ b/chrome/browser/ui/views/task_manager_view.cc
@@ -405,6 +405,10 @@ // Redraw the table immediately by scheduling a paint since the rows most // likely changed in between switching models. tab_table_->OnItemsChanged(/*start=*/0, table_model_->RowCount()); + + // Model row count may differ, leading to off-screen row rendering. Recompute + // scroll position. + tab_table_->InvalidateLayout(); } void TaskManagerView::TabSelectedAt(int index) {
diff --git a/chrome/browser/ui/views/toolbar/pinned_action_toolbar_button.cc b/chrome/browser/ui/views/toolbar/pinned_action_toolbar_button.cc index c2476adf..f478b657 100644 --- a/chrome/browser/ui/views/toolbar/pinned_action_toolbar_button.cc +++ b/chrome/browser/ui/views/toolbar/pinned_action_toolbar_button.cc
@@ -32,16 +32,13 @@ #include "ui/color/color_id.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/insets.h" +#include "ui/gfx/vector_icon_types.h" #include "ui/views/accessibility/view_accessibility.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button_controller.h" #include "ui/views/view_class_properties.h" #include "ui/views/view_utils.h" -namespace { -const gfx::VectorIcon kEmptyIcon; -} // namespace - DEFINE_UI_CLASS_PROPERTY_TYPE(PinnedToolbarActionFlexPriority) DEFINE_UI_CLASS_PROPERTY_KEY( std::underlying_type_t<PinnedToolbarActionFlexPriority>, @@ -456,7 +453,7 @@ if (image_model.IsVectorIcon()) { action_view_->SetVectorIcon(action_view_->IsIconVisible() ? *image_model.GetVectorIcon().vector_icon() - : kEmptyIcon); + : gfx::VectorIcon::EmptyIcon()); } else { action_view_->SetImageModel( views::Button::STATE_NORMAL,
diff --git a/chrome/browser/ui/views/toolbar/toolbar_controller.cc b/chrome/browser/ui/views/toolbar/toolbar_controller.cc index 89dbca47..7f7e1137 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_controller.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_controller.cc
@@ -29,6 +29,7 @@ #include "components/vector_icons/vector_icons.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/mojom/menu_source_type.mojom.h" +#include "ui/gfx/paint_vector_icon.h" #include "ui/menus/simple_menu_model.h" #include "ui/views/controls/menu/menu_item_view.h" #include "ui/views/controls/menu/menu_model_adapter.h"
diff --git a/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac.cc b/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac.cc index 50f6b341..d802f43 100644 --- a/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac.cc +++ b/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac.cc
@@ -68,7 +68,7 @@ IN_PROC_BROWSER_TEST_F(WebAppIntegration, IncompatibleAppShim) { // Install and close the PWA. - helper_.CreateShortcut(Site::kStandalone, WindowOptions::kWindowed); + helper_.InstallMenuOption(Site::kStandalone); helper_.CheckWindowCreated(); helper_.ClosePwa(); // Now mess up the shortcut. @@ -84,7 +84,8 @@ web_app::startup::SetStartupDoneCallbackForTesting(base::BindOnce( []() { apps::TakeShimStartupDoneCallbackForTesting().Run(); })); - helper_.LaunchFromPlatformShortcut(Site::kStandalone); + helper_.LaunchFromPlatformShortcut(Site::kStandalone, + /*allow_shim_failure=*/true); helper_.CheckWindowCreated(); }
diff --git a/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc b/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc index bbd72a80..97071b3 100644 --- a/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc +++ b/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc
@@ -87,6 +87,7 @@ #include "chrome/browser/web_applications/app_service/web_app_publisher_helper.h" #include "chrome/browser/web_applications/commands/run_on_os_login_command.h" #include "chrome/browser/web_applications/externally_managed_app_manager.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h" #include "chrome/browser/web_applications/isolated_web_apps/test/test_signed_web_bundle_builder.h" @@ -1792,7 +1793,13 @@ AfterStateChangeAction(); } +#if BUILDFLAG(IS_MAC) +void WebAppIntegrationTestDriver::LaunchFromPlatformShortcut( + Site site, + bool allow_shim_failure) { +#else void WebAppIntegrationTestDriver::LaunchFromPlatformShortcut(Site site) { +#endif #if BUILDFLAG(IS_CHROMEOS) NOTREACHED() << "Not implemented on Chrome OS."; #else @@ -1824,10 +1831,19 @@ had_open_browsers = true; } } + if (app_browser_ || had_open_browsers) { + EXPECT_FALSE(allow_shim_failure) + << "Allowing shim launch failures while there are already open " + "browsers will result in flaky tests, as there is nothing to wait " + "for to detect the launch."; + } base::RunLoop run_loop; apps::SetMacShimStartupDoneCallbackForTesting(run_loop.QuitClosure()); - ASSERT_TRUE(LaunchFromAppShim(site, /*urls=*/{}, - /*wait_for_complete_launch=*/true)); + bool launch_result = LaunchFromAppShim(site, /*urls=*/{}, + /*wait_for_complete_launch=*/true); + if (!allow_shim_failure) { + ASSERT_TRUE(launch_result); + } run_loop.Run(); if (!app_browser_ && !had_open_browsers) { browser_added_waiter.Wait(); @@ -1838,6 +1854,10 @@ EXPECT_TRUE(AppBrowserController::IsForWebApp(app_browser(), app_id)); } } else { + EXPECT_FALSE(allow_shim_failure) + << "Allowing shim launch failures for browser-tab PWAs could result in " + "flaky tests because there is nothing to wait for to detect the " + "launch."; base::RunLoop run_loop; apps::SetMacShimStartupDoneCallbackForTesting(run_loop.QuitClosure()); ASSERT_TRUE(LaunchFromAppShim(site, /*urls=*/{},
diff --git a/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.h b/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.h index 6f0f72c71..1a216b9 100644 --- a/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.h +++ b/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.h
@@ -305,9 +305,14 @@ void LaunchFromChromeApps(Site site); void LaunchFromLaunchIcon(Site site); void LaunchFromMenuOption(Site site); - void LaunchFromPlatformShortcut(Site site); #if BUILDFLAG(IS_MAC) void LaunchFromAppShimFallback(Site site); + // If `allow_shim_failure` is set to true, this won't assert that the initial + // app shim launch was successful. The step will still verify that the launch + // was eventually successful. + void LaunchFromPlatformShortcut(Site site, bool allow_shim_failure = false); +#else + void LaunchFromPlatformShortcut(Site site); #endif void OpenAppSettingsFromChromeApps(Site site); void OpenAppSettingsFromAppMenu(Site site);
diff --git a/chrome/browser/ui/web_applications/sub_apps_permissions_policy_browsertest.cc b/chrome/browser/ui/web_applications/sub_apps_permissions_policy_browsertest.cc index 6285b32..9ee68d5 100644 --- a/chrome/browser/ui/web_applications/sub_apps_permissions_policy_browsertest.cc +++ b/chrome/browser/ui/web_applications/sub_apps_permissions_policy_browsertest.cc
@@ -10,6 +10,7 @@ #include "base/types/expected.h" #include "chrome/browser/ui/web_applications/sub_apps_service_impl.h" #include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h" #include "chrome/browser/web_applications/isolated_web_apps/test/isolated_web_app_builder.h"
diff --git a/chrome/browser/ui/web_applications/sub_apps_service_impl_browsertest.cc b/chrome/browser/ui/web_applications/sub_apps_service_impl_browsertest.cc index b8c8bc2..6ec64879 100644 --- a/chrome/browser/ui/web_applications/sub_apps_service_impl_browsertest.cc +++ b/chrome/browser/ui/web_applications/sub_apps_service_impl_browsertest.cc
@@ -15,6 +15,7 @@ #include "base/test/test_future.h" #include "chrome/browser/notifications/notification_display_service_tester.h" #include "chrome/browser/permissions/permission_decision_auto_blocker_factory.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/web_applications/sub_apps_install_dialog_controller.h"
diff --git a/chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.cc b/chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.cc index c3d61d7c..1b08ec4 100644 --- a/chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.cc +++ b/chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.cc
@@ -14,6 +14,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_navigator_params.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h" #include "chrome/browser/web_applications/test/web_app_test_utils.h"
diff --git a/chrome/browser/ui/webui/app_management/web_app_settings_page_handler.cc b/chrome/browser/ui/webui/app_management/web_app_settings_page_handler.cc index e5851b4..ed0b02c 100644 --- a/chrome/browser/ui/webui/app_management/web_app_settings_page_handler.cc +++ b/chrome/browser/ui/webui/app_management/web_app_settings_page_handler.cc
@@ -14,6 +14,7 @@ #include "chrome/browser/web_applications/app_service/web_app_publisher_helper.h" #include "chrome/browser/web_applications/web_app_command_scheduler.h" #include "chrome/browser/web_applications/web_app_provider.h" +#include "chrome/browser/web_applications/web_app_ui_manager.h" #include "chrome/browser/web_applications/web_app_utils.h" #include "chrome/common/chrome_features.h" #include "components/url_formatter/elide_url.h"
diff --git a/chrome/browser/ui/webui/ash/notification_tester/notification_tester_handler.cc b/chrome/browser/ui/webui/ash/notification_tester/notification_tester_handler.cc index 488e5ae..d4b1de1 100644 --- a/chrome/browser/ui/webui/ash/notification_tester/notification_tester_handler.cc +++ b/chrome/browser/ui/webui/ash/notification_tester/notification_tester_handler.cc
@@ -175,7 +175,7 @@ return kSmartphoneIcon; } - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); } std::vector<message_center::ButtonInfo>
diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc b/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc index 543f7e09..aa32e8f 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc
@@ -414,7 +414,6 @@ "chrome://explore-sites-internals", "chrome://internals/notifications", "chrome://internals/query-tiles", - "chrome://offline-internals", "chrome://snippets-internals", "chrome://webapks", #endif
diff --git a/chrome/browser/ui/webui/chrome_web_ui_configs.cc b/chrome/browser/ui/webui/chrome_web_ui_configs.cc index ab5ef2f..609a5fc9 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_configs.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_configs.cc
@@ -83,7 +83,7 @@ #include "chrome/browser/ui/webui/feedback/feedback_ui.h" #include "chrome/browser/ui/webui/history/history_ui.h" #include "chrome/browser/ui/webui/identity_internals_ui.h" -#include "chrome/browser/ui/webui/inspect_ui.h" +#include "chrome/browser/ui/webui/inspect/inspect_ui.h" #if BUILDFLAG(ENABLE_SESSION_SERVICE) #include "chrome/browser/ui/webui/internals/internals_ui.h" #endif // BUILDFLAG(ENABLE_SESSION_SERVICE) @@ -114,7 +114,6 @@ #include "chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.h" #else // !BUILDFLAG(IS_ANDROID) #include "chrome/browser/ui/webui/feed_internals/feed_internals_ui.h" -#include "chrome/browser/ui/webui/offline/offline_internals_ui.h" #include "chrome/browser/ui/webui/webapks/webapks_ui.h" #endif // !BUILDFLAG(IS_ANDROID) @@ -275,7 +274,6 @@ #if BUILDFLAG(IS_ANDROID) map.AddWebUIConfig(std::make_unique<FeedInternalsUIConfig>()); - map.AddWebUIConfig(std::make_unique<OfflineInternalsUIConfig>()); map.AddWebUIConfig(std::make_unique<WebApksUIConfig>()); #else // BUILDFLAG(IS_ANDROID) #if !BUILDFLAG(IS_CHROMEOS)
diff --git a/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler.cc b/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler.cc index c501125..1561ccde 100644 --- a/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler.cc +++ b/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler.cc
@@ -152,6 +152,7 @@ item->source_passage = scored_url_row.GetBestPassage(); } + item->is_url_known_to_sync = scored_url_row.is_url_known_to_sync; mojom_search_result->items.push_back(std::move(item)); } page_->SearchResultChanged(std::move(mojom_search_result));
diff --git a/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler_unittest.cc b/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler_unittest.cc index 9678c2d..8e7ac66 100644 --- a/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler_unittest.cc +++ b/chrome/browser/ui/webui/cr_components/history_embeddings/history_embeddings_handler_unittest.cc
@@ -194,6 +194,7 @@ scored_url_row.row.set_last_visit(base::Time::Now() - base::Hours(1)); history_embeddings::ScoredUrlRow other_scored_url_row = scored_url_row; other_scored_url_row.row = history::URLRow(GURL("http://other.com")); + other_scored_url_row.is_url_known_to_sync = true; history_embeddings::SearchResult embeddings_result; embeddings_result.scored_url_rows = { @@ -231,6 +232,7 @@ scored_url_row.row.last_visit().InMillisecondsFSinceUnixEpoch()); EXPECT_EQ(mojo_result->items[0]->url_for_display, "google.com"); EXPECT_EQ(mojo_result->items[0]->answer_data.is_null(), true); + EXPECT_EQ(mojo_result->items[0]->is_url_known_to_sync, false); EXPECT_EQ(mojo_result->items[1]->url.spec(), "http://other.com/"); EXPECT_EQ(mojo_result->items[1]->url_for_display, "other.com"); EXPECT_EQ(mojo_result->items[1]->answer_data.is_null(), false); @@ -238,6 +240,7 @@ 1u); EXPECT_EQ(mojo_result->items[1]->answer_data->answer_text_directives[0], "text fragment"); + EXPECT_EQ(mojo_result->items[1]->is_url_known_to_sync, true); } TEST_F(HistoryEmbeddingsHandlerTest, RecordsMetrics) {
diff --git a/chrome/browser/ui/webui/inspect_ui.cc b/chrome/browser/ui/webui/inspect/inspect_ui.cc similarity index 98% rename from chrome/browser/ui/webui/inspect_ui.cc rename to chrome/browser/ui/webui/inspect/inspect_ui.cc index f53da7d..a29d591 100644 --- a/chrome/browser/ui/webui/inspect_ui.cc +++ b/chrome/browser/ui/webui/inspect/inspect_ui.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/inspect_ui.h" +#include "chrome/browser/ui/webui/inspect/inspect_ui.h" #include <memory> #include <utility> @@ -24,7 +24,8 @@ #include "chrome/browser/ui/webui/theme_source.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" -#include "chrome/grit/browser_resources.h" +#include "chrome/grit/inspect_resources.h" +#include "chrome/grit/inspect_resources_map.h" #include "components/prefs/pref_service.h" #include "components/ui_devtools/devtools_server.h" #include "components/ui_devtools/switches.h" @@ -115,9 +116,8 @@ void CreateAndAddInspectUIHTMLSource(Profile* profile) { content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd( profile, chrome::kChromeUIInspectHost); - source->AddResourcePath("inspect.css", IDR_INSPECT_CSS); - source->AddResourcePath("inspect.js", IDR_INSPECT_JS); - source->SetDefaultResource(IDR_INSPECT_HTML); + source->AddResourcePaths(kInspectResources); + source->SetDefaultResource(IDR_INSPECT_INSPECT_HTML); source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources chrome://webui-test 'self';");
diff --git a/chrome/browser/ui/webui/inspect_ui.h b/chrome/browser/ui/webui/inspect/inspect_ui.h similarity index 95% rename from chrome/browser/ui/webui/inspect_ui.h rename to chrome/browser/ui/webui/inspect/inspect_ui.h index 96e683b..8b9f53c 100644 --- a/chrome/browser/ui/webui/inspect_ui.h +++ b/chrome/browser/ui/webui/inspect/inspect_ui.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_INSPECT_INSPECT_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_INSPECT_INSPECT_UI_H_ #include <map> #include <memory> @@ -108,4 +108,4 @@ std::unique_ptr<PortForwardingStatusSerializer> port_status_serializer_; }; -#endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_INSPECT_INSPECT_UI_H_
diff --git a/chrome/browser/ui/webui/offline/DIR_METADATA b/chrome/browser/ui/webui/offline/DIR_METADATA deleted file mode 100644 index 087a55d..0000000 --- a/chrome/browser/ui/webui/offline/DIR_METADATA +++ /dev/null
@@ -1,7 +0,0 @@ -monorail: { - component: "UI>Browser>Offline" -} -team_email: "offline-dev@chromium.org" -buganizer_public: { - component_id: 1457370 -}
diff --git a/chrome/browser/ui/webui/offline/OWNERS b/chrome/browser/ui/webui/offline/OWNERS deleted file mode 100644 index 901ae80e..0000000 --- a/chrome/browser/ui/webui/offline/OWNERS +++ /dev/null
@@ -1 +0,0 @@ -file://components/offline_pages/OWNERS
diff --git a/chrome/browser/ui/webui/offline/offline_internals_ui.cc b/chrome/browser/ui/webui/offline/offline_internals_ui.cc deleted file mode 100644 index 6cbfed0..0000000 --- a/chrome/browser/ui/webui/offline/offline_internals_ui.cc +++ /dev/null
@@ -1,45 +0,0 @@ -// Copyright 2016 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/offline/offline_internals_ui.h" - -#include <memory> - -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h" -#include "chrome/common/url_constants.h" -#include "chrome/grit/browser_resources.h" -#include "content/public/browser/web_ui.h" -#include "content/public/browser/web_ui_controller.h" -#include "content/public/browser/web_ui_data_source.h" -#include "services/network/public/mojom/content_security_policy.mojom.h" - -OfflineInternalsUI::OfflineInternalsUI(content::WebUI* web_ui) - : content::WebUIController(web_ui) { - // chrome://offline-internals source. - Profile* profile = Profile::FromWebUI(web_ui); - content::WebUIDataSource* html_source = - content::WebUIDataSource::CreateAndAdd( - profile, chrome::kChromeUIOfflineInternalsHost); - - html_source->OverrideContentSecurityPolicy( - network::mojom::CSPDirectiveName::TrustedTypes, - "trusted-types parse-html-subset;"); - // Required resources. - html_source->UseStringsJs(); - html_source->AddResourcePath("offline_internals.css", - IDR_OFFLINE_INTERNALS_CSS); - html_source->AddResourcePath("offline_internals.js", - IDR_OFFLINE_INTERNALS_JS); - html_source->AddResourcePath("offline_internals_browser_proxy.js", - IDR_OFFLINE_INTERNALS_BROWSER_PROXY_JS); - html_source->SetDefaultResource(IDR_OFFLINE_INTERNALS_HTML); - - html_source->AddBoolean("isIncognito", profile->IsOffTheRecord()); - - web_ui->AddMessageHandler( - std::make_unique<offline_internals::OfflineInternalsUIMessageHandler>()); -} - -OfflineInternalsUI::~OfflineInternalsUI() = default;
diff --git a/chrome/browser/ui/webui/offline/offline_internals_ui.h b/chrome/browser/ui/webui/offline/offline_internals_ui.h deleted file mode 100644 index a46e7db4..0000000 --- a/chrome/browser/ui/webui/offline/offline_internals_ui.h +++ /dev/null
@@ -1,34 +0,0 @@ -// Copyright 2016 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_H_ - -#include "chrome/common/webui_url_constants.h" -#include "content/public/browser/web_ui_controller.h" -#include "content/public/browser/webui_config.h" -#include "content/public/common/url_constants.h" - -class OfflineInternalsUI; - -class OfflineInternalsUIConfig - : public content::DefaultWebUIConfig<OfflineInternalsUI> { - public: - OfflineInternalsUIConfig() - : DefaultWebUIConfig(content::kChromeUIScheme, - chrome::kChromeUIOfflineInternalsHost) {} -}; - -// The WebUI for chrome://offline-internals. -class OfflineInternalsUI : public content::WebUIController { - public: - explicit OfflineInternalsUI(content::WebUI* web_ui); - - OfflineInternalsUI(const OfflineInternalsUI&) = delete; - OfflineInternalsUI& operator=(const OfflineInternalsUI&) = delete; - - ~OfflineInternalsUI() override; -}; - -#endif // CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_H_
diff --git a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc b/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc deleted file mode 100644 index 3236d8c9..0000000 --- a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc +++ /dev/null
@@ -1,507 +0,0 @@ -// Copyright 2016 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h" - -#include <stdint.h> -#include <stdlib.h> - -#include <algorithm> -#include <utility> - -#include "base/functional/bind.h" -#include "base/json/json_writer.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/strings/utf_string_conversions.h" -#include "base/uuid.h" -#include "base/values.h" -#include "build/build_config.h" -#include "chrome/browser/offline_pages/offline_page_model_factory.h" -#include "chrome/browser/offline_pages/request_coordinator_factory.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_key.h" -#include "chrome/common/channel_info.h" -#include "chrome/common/chrome_content_client.h" -#include "components/offline_pages/core/client_namespace_constants.h" -#include "components/offline_pages/core/offline_page_feature.h" -#include "content/public/browser/web_ui.h" -#include "net/base/network_change_notifier.h" - -namespace offline_internals { -// TODO(crbug.com/40260641): Remove all prefetch references from the internals -// page. - -namespace { - -std::string GetStringFromDeletePageResult( - offline_pages::DeletePageResult value) { - switch (value) { - case offline_pages::DeletePageResult::SUCCESS: - return "Success"; - case offline_pages::DeletePageResult::CANCELLED: - return "Cancelled"; - case offline_pages::DeletePageResult::STORE_FAILURE: - return "Store failure"; - case offline_pages::DeletePageResult::DEVICE_FAILURE: - return "Device failure"; - case offline_pages::DeletePageResult::DEPRECATED_NOT_FOUND: - return "Not found"; - } - NOTREACHED(); -} - -std::string GetStringFromDeleteRequestResults( - const offline_pages::MultipleItemStatuses& results) { - // If any requests failed, return "failure", else "success". - for (const auto& result : results) { - if (result.second == offline_pages::ItemActionStatus::STORE_ERROR) { - return "Store failure, could not delete one or more requests"; - } - } - - return "Success"; -} - -std::string GetStringFromSavePageStatus() { - return "Available"; -} - -} // namespace - -OfflineInternalsUIMessageHandler::OfflineInternalsUIMessageHandler() - : offline_page_model_(nullptr), request_coordinator_(nullptr) {} - -OfflineInternalsUIMessageHandler::~OfflineInternalsUIMessageHandler() = default; - -void OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages( - const base::Value::List& args) { - CHECK_EQ(2u, args.size()); - std::string callback_id = args[0].GetString(); - - std::vector<int64_t> offline_ids; - const base::Value::List& offline_ids_from_arg = args[1].GetList(); - for (const auto& arg : offline_ids_from_arg) { - std::string value = arg.GetString(); - int64_t int_value; - base::StringToInt64(value, &int_value); - offline_ids.push_back(int_value); - } - - offline_pages::PageCriteria criteria; - criteria.offline_ids = std::move(offline_ids); - offline_page_model_->DeletePagesWithCriteria( - criteria, - base::BindOnce( - &OfflineInternalsUIMessageHandler::HandleDeletedPagesCallback, - weak_ptr_factory_.GetWeakPtr(), callback_id)); -} - -void OfflineInternalsUIMessageHandler::HandleDeleteSelectedRequests( - const base::Value::List& args) { - CHECK_EQ(2u, args.size()); - std::string callback_id = args[0].GetString(); - - std::vector<int64_t> offline_ids; - const base::Value::List& offline_ids_from_arg = args[1].GetList(); - for (const auto& arg : offline_ids_from_arg) { - std::string value = arg.GetString(); - int64_t int_value; - base::StringToInt64(value, &int_value); - offline_ids.push_back(int_value); - } - - // Call RequestCoordinator to delete them - if (request_coordinator_) { - request_coordinator_->RemoveRequests( - offline_ids, - base::BindOnce( - &OfflineInternalsUIMessageHandler::HandleDeletedRequestsCallback, - weak_ptr_factory_.GetWeakPtr(), callback_id)); - } -} - -void OfflineInternalsUIMessageHandler::HandleDeletedPagesCallback( - std::string callback_id, - offline_pages::DeletePageResult result) { - ResolveJavascriptCallback(base::Value(callback_id), - base::Value(GetStringFromDeletePageResult(result))); -} - -void OfflineInternalsUIMessageHandler::HandleDeletedRequestsCallback( - std::string callback_id, - const offline_pages::MultipleItemStatuses& results) { - ResolveJavascriptCallback( - base::Value(callback_id), - base::Value(GetStringFromDeleteRequestResults(results))); -} - -void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback( - std::string callback_id, - const offline_pages::MultipleOfflinePageItemResult& pages) { - base::Value::List results; - for (const auto& page : pages) { - base::Value::Dict offline_page; - offline_page.Set("onlineUrl", page.url.spec()); - offline_page.Set("namespace", page.client_id.name_space); - offline_page.Set("size", static_cast<int>(page.file_size)); - offline_page.Set("id", base::NumberToString(page.offline_id)); - offline_page.Set("filePath", page.file_path.MaybeAsASCII()); - offline_page.Set("creationTime", - page.creation_time.InMillisecondsFSinceUnixEpoch()); - offline_page.Set("lastAccessTime", - page.last_access_time.InMillisecondsFSinceUnixEpoch()); - offline_page.Set("accessCount", page.access_count); - offline_page.Set("originalUrl", page.original_url_if_different.spec()); - offline_page.Set("requestOrigin", page.request_origin); - results.Append(std::move(offline_page)); - } - // Sort by creation order. - std::sort(results.begin(), results.end(), [](const auto& a, const auto& b) { - return a.GetDict().FindDouble("creationTime").value() < - b.GetDict().FindDouble("creationTime").value(); - }); - - ResolveJavascriptCallback(base::Value(callback_id), results); -} - -void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback( - std::string callback_id, - std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests) { - base::Value::List save_page_requests; - for (const auto& request : requests) { - base::Value::Dict save_page_request; - save_page_request.Set("onlineUrl", request->url().spec()); - save_page_request.Set( - "creationTime", - request->creation_time().InMillisecondsFSinceUnixEpoch()); - save_page_request.Set("status", GetStringFromSavePageStatus()); - save_page_request.Set("namespace", request->client_id().name_space); - save_page_request.Set( - "lastAttemptTime", - request->last_attempt_time().InMillisecondsFSinceUnixEpoch()); - save_page_request.Set("id", base::NumberToString(request->request_id())); - save_page_request.Set("originalUrl", request->original_url().spec()); - save_page_request.Set("requestOrigin", request->request_origin()); - save_page_requests.Append(std::move(save_page_request)); - } - ResolveJavascriptCallback(base::Value(callback_id), save_page_requests); -} - -void OfflineInternalsUIMessageHandler::HandleGetRequestQueue( - const base::Value::List& args) { - AllowJavascript(); - const std::string& callback_id = args[0].GetString(); - - if (request_coordinator_) { - request_coordinator_->GetAllRequests(base::BindOnce( - &OfflineInternalsUIMessageHandler::HandleRequestQueueCallback, - weak_ptr_factory_.GetWeakPtr(), callback_id)); - } else { - base::Value::List results; - ResolveJavascriptCallback(base::Value(callback_id), results); - } -} - -void OfflineInternalsUIMessageHandler::HandleGetStoredPages( - const base::Value::List& args) { - AllowJavascript(); - const std::string& callback_id = args[0].GetString(); - - if (offline_page_model_) { - offline_page_model_->GetAllPages(base::BindOnce( - &OfflineInternalsUIMessageHandler::HandleStoredPagesCallback, - weak_ptr_factory_.GetWeakPtr(), callback_id)); - } else { - base::Value::List results; - ResolveJavascriptCallback(base::Value(callback_id), results); - } -} - -void OfflineInternalsUIMessageHandler::HandleSetRecordPageModel( - const base::Value::List& args) { - AllowJavascript(); - CHECK(!args.empty()); - const bool should_record = args[0].GetBool(); - if (offline_page_model_) { - offline_page_model_->GetLogger()->SetIsLogging(should_record); - } -} - -void OfflineInternalsUIMessageHandler::HandleGetNetworkStatus( - const base::Value::List& args) { - AllowJavascript(); - const base::Value& callback_id = args[0]; - - ResolveJavascriptCallback( - callback_id, - base::Value(net::NetworkChangeNotifier::IsOffline() ? "Offline" - : "Online")); -} - -void OfflineInternalsUIMessageHandler::HandleScheduleNwake( - const base::Value::List& args) { - AllowJavascript(); - const base::Value& callback_id = args[0]; - - RejectJavascriptCallback(callback_id, - base::Value("No prefetch service available.")); -} - -void OfflineInternalsUIMessageHandler::HandleCancelNwake( - const base::Value::List& args) { - AllowJavascript(); - const base::Value& callback_id = args[0]; - - RejectJavascriptCallback(callback_id, - base::Value("No prefetch service available.")); -} - -void OfflineInternalsUIMessageHandler::HandleGeneratePageBundle( - const base::Value::List& args) { - AllowJavascript(); - const std::string& callback_id = args[0].GetString(); - - RejectJavascriptCallback(base::Value(callback_id), - base::Value("No prefetch service available.")); -} - -void OfflineInternalsUIMessageHandler::HandleGetOperation( - const base::Value::List& args) { - AllowJavascript(); - const std::string& callback_id = args[0].GetString(); - - RejectJavascriptCallback(base::Value(callback_id), - base::Value("No prefetch service available.")); -} - -void OfflineInternalsUIMessageHandler::HandleDownloadArchive( - const base::Value::List& args) { - AllowJavascript(); - std::string name = args[0].GetString(); - base::TrimWhitespaceASCII(name, base::TRIM_ALL, &name); -} - -void OfflineInternalsUIMessageHandler::HandleSetRecordRequestQueue( - const base::Value::List& args) { - AllowJavascript(); - CHECK(!args.empty()); - const bool should_record = args[0].GetBool(); - if (request_coordinator_) { - request_coordinator_->GetLogger()->SetIsLogging(should_record); - } -} - -void OfflineInternalsUIMessageHandler::HandleSetRecordPrefetchService( - const base::Value::List& args) { - AllowJavascript(); - CHECK(!args.empty()); -} - -void OfflineInternalsUIMessageHandler::HandleSetLimitlessPrefetchingEnabled( - const base::Value::List& args) {} - -void OfflineInternalsUIMessageHandler::HandleGetLimitlessPrefetchingEnabled( - const base::Value::List& args) { - AllowJavascript(); - const base::Value& callback_id = args[0]; - - ResolveJavascriptCallback(callback_id, base::Value(false)); -} - -void OfflineInternalsUIMessageHandler::HandleSetPrefetchTestingHeader( - const base::Value::List& args) {} - -void OfflineInternalsUIMessageHandler::HandleGetPrefetchTestingHeader( - const base::Value::List& args) {} - -void OfflineInternalsUIMessageHandler::HandleGetLoggingState( - const base::Value::List& args) { - AllowJavascript(); - const base::Value& callback_id = args[0]; - - base::Value::Dict result; - result.Set("modelIsLogging", - offline_page_model_ - ? offline_page_model_->GetLogger()->GetIsLogging() - : false); - result.Set("queueIsLogging", - request_coordinator_ - ? request_coordinator_->GetLogger()->GetIsLogging() - : false); - bool prefetch_logging = false; - result.Set("prefetchIsLogging", prefetch_logging); - ResolveJavascriptCallback(callback_id, result); -} - -void OfflineInternalsUIMessageHandler::HandleGetEventLogs( - const base::Value::List& args) { - AllowJavascript(); - const base::Value& callback_id = args[0]; - - std::vector<std::string> logs; - if (offline_page_model_) { - offline_page_model_->GetLogger()->GetLogs(&logs); - } - if (request_coordinator_) { - request_coordinator_->GetLogger()->GetLogs(&logs); - } - std::sort(logs.begin(), logs.end()); - - base::Value::List result; - for (const std::string& log : logs) { - result.Append(log); - } - - ResolveJavascriptCallback(callback_id, result); -} - -void OfflineInternalsUIMessageHandler::HandleAddToRequestQueue( - const base::Value::List& args) { - const std::string& callback_id = args[0].GetString(); - - if (request_coordinator_) { - const std::string& url = args[1].GetString(); - - // To be visible in Downloads UI, these items need a well-formed GUID - // and AsyncNamespace in their ClientId. - std::ostringstream id_stream; - id_stream << base::Uuid::GenerateRandomV4().AsLowercaseString(); - - offline_pages::RequestCoordinator::SavePageLaterParams params; - params.url = GURL(url); - params.client_id = offline_pages::ClientId(offline_pages::kAsyncNamespace, - id_stream.str()); - request_coordinator_->SavePageLater( - params, - base::BindOnce( - &OfflineInternalsUIMessageHandler::HandleSavePageLaterCallback, - weak_ptr_factory_.GetWeakPtr(), callback_id)); - } else { - ResolveJavascriptCallback(base::Value(callback_id), base::Value(false)); - } -} - -void OfflineInternalsUIMessageHandler::HandleSavePageLaterCallback( - std::string callback_id, - offline_pages::AddRequestResult result) { - ResolveJavascriptCallback( - base::Value(callback_id), - base::Value(result == offline_pages::AddRequestResult::SUCCESS)); -} - -void OfflineInternalsUIMessageHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "deleteSelectedPages", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "deleteSelectedRequests", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleDeleteSelectedRequests, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getRequestQueue", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleGetRequestQueue, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getStoredPages", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleGetStoredPages, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getEventLogs", - base::BindRepeating(&OfflineInternalsUIMessageHandler::HandleGetEventLogs, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "setRecordRequestQueue", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleSetRecordRequestQueue, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "setRecordPageModel", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleSetRecordPageModel, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "setRecordPrefetchService", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleSetRecordPrefetchService, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "setLimitlessPrefetchingEnabled", - base::BindRepeating(&OfflineInternalsUIMessageHandler:: - HandleSetLimitlessPrefetchingEnabled, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getLimitlessPrefetchingEnabled", - base::BindRepeating(&OfflineInternalsUIMessageHandler:: - HandleGetLimitlessPrefetchingEnabled, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "setPrefetchTestingHeader", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleSetPrefetchTestingHeader, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getPrefetchTestingHeader", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleGetPrefetchTestingHeader, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getLoggingState", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleGetLoggingState, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "addToRequestQueue", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleAddToRequestQueue, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getNetworkStatus", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleGetNetworkStatus, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "scheduleNwake", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleScheduleNwake, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "cancelNwake", - base::BindRepeating(&OfflineInternalsUIMessageHandler::HandleCancelNwake, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "generatePageBundle", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleGeneratePageBundle, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getOperation", - base::BindRepeating(&OfflineInternalsUIMessageHandler::HandleGetOperation, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "downloadArchive", - base::BindRepeating( - &OfflineInternalsUIMessageHandler::HandleDownloadArchive, - base::Unretained(this))); - - // Get the offline page model associated with this web ui. - Profile* profile = Profile::FromWebUI(web_ui()); - offline_page_model_ = - offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); - request_coordinator_ = - offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); -} - -void OfflineInternalsUIMessageHandler::OnJavascriptDisallowed() { - weak_ptr_factory_.InvalidateWeakPtrs(); -} - -} // namespace offline_internals
diff --git a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h b/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h deleted file mode 100644 index 8b71f29..0000000 --- a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h +++ /dev/null
@@ -1,142 +0,0 @@ -// Copyright 2016 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_H_ - -#include <memory> -#include <string> -#include <vector> - -#include "base/memory/raw_ptr.h" -#include "base/memory/weak_ptr.h" -#include "base/values.h" -#include "components/offline_pages/core/background/request_coordinator.h" -#include "components/offline_pages/core/background/save_page_request.h" -#include "components/offline_pages/core/offline_page_model.h" -#include "components/offline_pages/core/offline_store_types.h" -#include "content/public/browser/web_ui_message_handler.h" - -namespace offline_pages { -enum class GetRequestsResult; -} - -namespace offline_internals { - -// Class acting as a controller of the chrome://offline-internals WebUI. -class OfflineInternalsUIMessageHandler : public content::WebUIMessageHandler { - public: - OfflineInternalsUIMessageHandler(); - - OfflineInternalsUIMessageHandler(const OfflineInternalsUIMessageHandler&) = - delete; - OfflineInternalsUIMessageHandler& operator=( - const OfflineInternalsUIMessageHandler&) = delete; - - ~OfflineInternalsUIMessageHandler() override; - - // WebUIMessageHandler implementation. - void RegisterMessages() override; - void OnJavascriptDisallowed() override; - - private: - // Delete selected list of page ids from the store. - void HandleDeleteSelectedPages(const base::Value::List& args); - - // Delete selected list of requests from the request queue. - void HandleDeleteSelectedRequests(const base::Value::List& args); - - // Load Request Queue info. - void HandleGetRequestQueue(const base::Value::List& args); - - // Load Stored pages info. - void HandleGetStoredPages(const base::Value::List& args); - - // Set whether to record offline page model events. - void HandleSetRecordPageModel(const base::Value::List& args); - - // Set whether to record request queue events. - void HandleSetRecordRequestQueue(const base::Value::List& args); - - // Set whether to record prefetch service events. - void HandleSetRecordPrefetchService(const base::Value::List& args); - - // Set whether to enable limitless prefetching. - void HandleSetLimitlessPrefetchingEnabled(const base::Value::List& args); - - // Get whether limitless prefetching is enabled. - void HandleGetLimitlessPrefetchingEnabled(const base::Value::List& args); - - // Set whether to enable sending the testing header when making - // GeneratePageBundle requests. - void HandleSetPrefetchTestingHeader(const base::Value::List& args); - - // Get whether we are sending the testing header for GeneratePageBundle - // requests. - void HandleGetPrefetchTestingHeader(const base::Value::List& args); - - // Load all offline services' event logs. - void HandleGetEventLogs(const base::Value::List& args); - - // Load whether logs are being recorded. - void HandleGetLoggingState(const base::Value::List& args); - - // Adds a url to the background loader queue. - void HandleAddToRequestQueue(const base::Value::List& args); - - // Load whether device is currently offline. - void HandleGetNetworkStatus(const base::Value::List& args); - - // Schedules an NWake signal. - void HandleScheduleNwake(const base::Value::List& args); - - // Cancels an NWake signal. - void HandleCancelNwake(const base::Value::List& args); - - // Sends and processes the request to generate page bundle. - void HandleGeneratePageBundle(const base::Value::List& args); - - // Sends and processes a request to get the info about an operation. - void HandleGetOperation(const base::Value::List& args); - - // Downloads an archive. - void HandleDownloadArchive(const base::Value::List& args); - - // Callback for async GetAllPages calls. - void HandleStoredPagesCallback( - std::string callback_id, - const offline_pages::MultipleOfflinePageItemResult& pages); - - // Callback for async GetRequests calls. - void HandleRequestQueueCallback( - std::string callback_id, - std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests); - - // Callback for DeletePage/DeleteAllPages calls. - void HandleDeletedPagesCallback(std::string callback_id, - const offline_pages::DeletePageResult result); - - // Callback for DeleteRequest/DeleteAllRequests calls. - void HandleDeletedRequestsCallback( - std::string callback_id, - const offline_pages::MultipleItemStatuses& results); - - // Callback for SavePageLater calls. - void HandleSavePageLaterCallback(std::string callback_id, - offline_pages::AddRequestResult result); - - // Offline page model to call methods on. - raw_ptr<offline_pages::OfflinePageModel> offline_page_model_; - - // Request coordinator for background offline actions. - raw_ptr<offline_pages::RequestCoordinator> request_coordinator_; - - // Factory for creating references in callbacks. - base::WeakPtrFactory<OfflineInternalsUIMessageHandler> weak_ptr_factory_{ - this}; -}; - -} // namespace offline_internals - -#endif // CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_H_
diff --git a/chrome/browser/ui/webui/searchbox/BUILD.gn b/chrome/browser/ui/webui/searchbox/BUILD.gn index 3352910..a0b5795e 100644 --- a/chrome/browser/ui/webui/searchbox/BUILD.gn +++ b/chrome/browser/ui/webui/searchbox/BUILD.gn
@@ -6,9 +6,9 @@ source_set("searchbox") { sources = [ - "contextual_searchbox_handler.cc", - "contextual_searchbox_handler.h", "lens_searchbox_client.h", + "lens_searchbox_handler.cc", + "lens_searchbox_handler.h", "realbox_handler.cc", "realbox_handler.h", "searchbox_handler.cc",
diff --git a/chrome/browser/ui/webui/searchbox/contextual_searchbox_handler.cc b/chrome/browser/ui/webui/searchbox/contextual_searchbox_handler.cc deleted file mode 100644 index 9062037..0000000 --- a/chrome/browser/ui/webui/searchbox/contextual_searchbox_handler.cc +++ /dev/null
@@ -1,18 +0,0 @@ -// Copyright 2024 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/searchbox/contextual_searchbox_handler.h" - -ContextualSearchboxHandler::ContextualSearchboxHandler( - mojo::PendingReceiver<searchbox::mojom::PageHandler> pending_page_handler, - Profile* profile, - content::WebContents* web_contents, - MetricsReporter* metrics_reporter, - OmniboxController* omnibox_controller) - : SearchboxHandler(std::move(pending_page_handler), - profile, - web_contents, - metrics_reporter) {} - -ContextualSearchboxHandler::~ContextualSearchboxHandler() = default;
diff --git a/chrome/browser/ui/webui/searchbox/contextual_searchbox_handler.h b/chrome/browser/ui/webui/searchbox/contextual_searchbox_handler.h deleted file mode 100644 index f9608974..0000000 --- a/chrome/browser/ui/webui/searchbox/contextual_searchbox_handler.h +++ /dev/null
@@ -1,25 +0,0 @@ -// Copyright 2024 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_SEARCHBOX_CONTEXTUAL_SEARCHBOX_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_SEARCHBOX_CONTEXTUAL_SEARCHBOX_HANDLER_H_ - -#include "chrome/browser/ui/webui/searchbox/searchbox_handler.h" -#include "components/omnibox/browser/omnibox.mojom.h" - -// Browser-side handler for bidirectional communication with the WebUI -// contextual searchbox. -class ContextualSearchboxHandler : public SearchboxHandler { - public: - ContextualSearchboxHandler( - mojo::PendingReceiver<searchbox::mojom::PageHandler> pending_page_handler, - Profile* profile, - content::WebContents* web_contents, - MetricsReporter* metrics_reporter, - OmniboxController* omnibox_controller); - - ~ContextualSearchboxHandler() override; -}; - -#endif // CHROME_BROWSER_UI_WEBUI_SEARCHBOX_CONTEXTUAL_SEARCHBOX_HANDLER_H_
diff --git a/chrome/browser/ui/webui/searchbox/lens_searchbox_handler.cc b/chrome/browser/ui/webui/searchbox/lens_searchbox_handler.cc new file mode 100644 index 0000000..ed5e7ad --- /dev/null +++ b/chrome/browser/ui/webui/searchbox/lens_searchbox_handler.cc
@@ -0,0 +1,314 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/searchbox/lens_searchbox_handler.h" + +#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" +#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" +#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" +#include "chrome/browser/omnibox/autocomplete_controller_emitter_factory.h" +#include "chrome/browser/predictors/autocomplete_action_predictor.h" +#include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" +#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service.h" +#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service_factory.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/search_engines/template_url_service_factory.h" +#include "chrome/browser/ui/webui/searchbox/lens_searchbox_client.h" +#include "components/lens/lens_features.h" +#include "components/lens/proto/server/lens_overlay_response.pb.h" +#include "components/omnibox/browser/autocomplete_match_type.h" +#include "components/omnibox/browser/omnibox_client.h" +#include "components/omnibox/browser/omnibox_controller.h" +#include "components/prefs/pref_service.h" +#include "components/sessions/core/session_id.h" +#include "third_party/metrics_proto/omnibox_event.pb.h" +#include "url/gurl.h" + +namespace { +// Interface that allows the Lens searchbox to interact with its embedder +// (i.e., LensOverlayController). +class LensOmniboxClient : public OmniboxClient { + public: + LensOmniboxClient(Profile* profile, + content::WebContents* web_contents, + LensSearchboxClient* lens_searchbox_client); + ~LensOmniboxClient() override; + + // OmniboxClient: + std::unique_ptr<AutocompleteProviderClient> CreateAutocompleteProviderClient() + override; + PrefService* GetPrefs() override; + SessionID GetSessionID() const override; + const GURL& GetURL() const override; + const PrefService* GetPrefs() const override; + AutocompleteControllerEmitter* GetAutocompleteControllerEmitter() override; + TemplateURLService* GetTemplateURLService() override; + const AutocompleteSchemeClassifier& GetSchemeClassifier() const override; + AutocompleteClassifier* GetAutocompleteClassifier() override; + bool ShouldDefaultTypedNavigationsToHttps() const override; + int GetHttpsPortForTesting() const override; + bool IsUsingFakeHttpsForHttpsUpgradeTesting() const override; + std::u16string GetFormattedFullURL() const override; + std::u16string GetURLForDisplay() const override; + metrics::OmniboxEventProto::PageClassification GetPageClassification( + bool is_prefetch) const override; + GURL GetNavigationEntryURL() const override; + std::optional<lens::proto::LensOverlaySuggestInputs> + GetLensOverlaySuggestInputs() const override; + void OnThumbnailRemoved() override; + security_state::SecurityLevel GetSecurityLevel() const override; + net::CertStatus GetCertStatus() const override; + const gfx::VectorIcon& GetVectorIcon() const override; + void OnURLOpenedFromOmnibox(OmniboxLog* log) override; + void OnAutocompleteAccept( + const GURL& destination_url, + TemplateURLRef::PostContent* post_content, + WindowOpenDisposition disposition, + ui::PageTransition transition, + AutocompleteMatchType::Type match_type, + base::TimeTicks match_selection_timestamp, + bool destination_url_entered_without_scheme, + bool destination_url_entered_with_http_scheme, + const std::u16string& text, + const AutocompleteMatch& match, + const AutocompleteMatch& alternative_nav_match) override; + base::WeakPtr<OmniboxClient> AsWeakPtr() override; + + void SetLensSearchboxClientForTesting( // IN-TEST + LensSearchboxClient* lens_searchbox_client) { + lens_searchbox_client_ = lens_searchbox_client; + } + + private: + raw_ptr<Profile> profile_; + raw_ptr<content::WebContents> web_contents_; + raw_ptr<LensSearchboxClient> lens_searchbox_client_; + ChromeAutocompleteSchemeClassifier scheme_classifier_; + // This is unused, but needed for `GetVectorIcon()`. + gfx::VectorIcon vector_icon_{nullptr, 0u, ""}; + base::WeakPtrFactory<LensOmniboxClient> weak_factory_{this}; +}; +LensOmniboxClient::LensOmniboxClient(Profile* profile, + content::WebContents* web_contents, + LensSearchboxClient* lens_searchbox_client) + : profile_(profile), + web_contents_(web_contents), + lens_searchbox_client_(lens_searchbox_client), + scheme_classifier_(ChromeAutocompleteSchemeClassifier(profile)) {} + +LensOmniboxClient::~LensOmniboxClient() = default; + +std::unique_ptr<AutocompleteProviderClient> +LensOmniboxClient::CreateAutocompleteProviderClient() { + return std::make_unique<ChromeAutocompleteProviderClient>(profile_); +} + +PrefService* LensOmniboxClient::GetPrefs() { + return profile_->GetPrefs(); +} + +SessionID LensOmniboxClient::GetSessionID() const { + return lens_searchbox_client_->GetTabId(); +} + +const GURL& LensOmniboxClient::GetURL() const { + return lens_searchbox_client_->GetPageURL(); +} + +const PrefService* LensOmniboxClient::GetPrefs() const { + return profile_->GetPrefs(); +} + +AutocompleteControllerEmitter* +LensOmniboxClient::GetAutocompleteControllerEmitter() { + return AutocompleteControllerEmitterFactory::GetForBrowserContext(profile_); +} + +TemplateURLService* LensOmniboxClient::GetTemplateURLService() { + return TemplateURLServiceFactory::GetForProfile(profile_); +} + +const AutocompleteSchemeClassifier& LensOmniboxClient::GetSchemeClassifier() + const { + return scheme_classifier_; +} + +AutocompleteClassifier* LensOmniboxClient::GetAutocompleteClassifier() { + return AutocompleteClassifierFactory::GetForProfile(profile_); +} + +bool LensOmniboxClient::ShouldDefaultTypedNavigationsToHttps() const { + return false; +} + +int LensOmniboxClient::GetHttpsPortForTesting() const { + return 0; +} + +bool LensOmniboxClient::IsUsingFakeHttpsForHttpsUpgradeTesting() const { + return false; +} + +std::u16string LensOmniboxClient::GetFormattedFullURL() const { + return u""; +} + +std::optional<lens::proto::LensOverlaySuggestInputs> +LensOmniboxClient::GetLensOverlaySuggestInputs() const { + return lens_searchbox_client_->GetLensSuggestInputs(); +} + +void LensOmniboxClient::OnThumbnailRemoved() { + lens_searchbox_client_->OnThumbnailRemoved(); +} + +std::u16string LensOmniboxClient::GetURLForDisplay() const { + return u""; +} + +metrics::OmniboxEventProto::PageClassification +LensOmniboxClient::GetPageClassification(bool is_prefetch) const { + return lens_searchbox_client_->GetPageClassification(); +} + +GURL LensOmniboxClient::GetNavigationEntryURL() const { + return GURL(); +} + +security_state::SecurityLevel LensOmniboxClient::GetSecurityLevel() const { + return security_state::SecurityLevel::NONE; +} + +net::CertStatus LensOmniboxClient::GetCertStatus() const { + return 0; +} + +const gfx::VectorIcon& LensOmniboxClient::GetVectorIcon() const { + return vector_icon_; +} + +void LensOmniboxClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { + if (auto* search_prefetch_service = + SearchPrefetchServiceFactory::GetForProfile(profile_)) { + search_prefetch_service->OnURLOpenedFromOmnibox(log); + } + predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_) + ->OnOmniboxOpenedUrl(*log); +} + +void LensOmniboxClient::OnAutocompleteAccept( + const GURL& destination_url, + TemplateURLRef::PostContent* post_content, + WindowOpenDisposition disposition, + ui::PageTransition transition, + AutocompleteMatchType::Type match_type, + base::TimeTicks match_selection_timestamp, + bool destination_url_entered_without_scheme, + bool destination_url_entered_with_http_scheme, + const std::u16string& text, + const AutocompleteMatch& match, + const AutocompleteMatch& alternative_nav_match) { + lens_searchbox_client_->OnSuggestionAccepted( + destination_url, match.type, + match.subtypes.contains(omnibox::SUBTYPE_ZERO_PREFIX)); +} + +base::WeakPtr<OmniboxClient> LensOmniboxClient::AsWeakPtr() { + return weak_factory_.GetWeakPtr(); +} + +} // namespace + +LensSearchboxHandler::LensSearchboxHandler( + mojo::PendingReceiver<searchbox::mojom::PageHandler> pending_page_handler, + Profile* profile, + content::WebContents* web_contents, + MetricsReporter* metrics_reporter, + LensSearchboxClient* lens_searchbox_client) + : SearchboxHandler(std::move(pending_page_handler), + profile, + web_contents, + metrics_reporter), + lens_searchbox_client_(lens_searchbox_client) { + owned_controller_ = std::make_unique<OmniboxController>( + /*view=*/nullptr, + std::make_unique<LensOmniboxClient>(profile_, web_contents_, + lens_searchbox_client), + lens::features::GetLensSearchboxAutocompleteTimeout()); + controller_ = owned_controller_.get(); + + autocomplete_controller_observation_.Observe(autocomplete_controller()); +} + +LensSearchboxHandler::~LensSearchboxHandler() = default; + +void LensSearchboxHandler::SetPage( + mojo::PendingRemote<searchbox::mojom::Page> pending_page) { + SearchboxHandler::SetPage(std::move(pending_page)); + + // The client may have text waiting to be sent to the searchbox that it + // couldn't do earlier since the page binding was not set. So now we let the + // client know the binding is ready. + lens_searchbox_client_->OnPageBound(); +} + +void LensSearchboxHandler::OnFocusChanged(bool focused) { + SearchboxHandler::OnFocusChanged(focused); + lens_searchbox_client_->OnFocusChanged(focused); +} + +void LensSearchboxHandler::QueryAutocomplete(const std::u16string& input, + bool prevent_inline_autocomplete) { + lens_searchbox_client_->OnTextModified(); + + SearchboxHandler::QueryAutocomplete(input, prevent_inline_autocomplete); +} + +void LensSearchboxHandler::SetInputText(const std::string& input_text) { + page_->SetInputText(input_text); +} + +void LensSearchboxHandler::SetThumbnail(const std::string& thumbnail_url) { + page_->SetThumbnail(thumbnail_url); +} + +void LensSearchboxHandler::OnThumbnailRemoved() { + omnibox_controller()->client()->OnThumbnailRemoved(); +} + +void LensSearchboxHandler::SetLensSearchboxClientForTesting( + LensSearchboxClient* lens_searchbox_client) { + lens_searchbox_client_ = lens_searchbox_client; + static_cast<LensOmniboxClient*>(omnibox_controller()->client()) + ->SetLensSearchboxClientForTesting(lens_searchbox_client); // IN-TEST +} + +void LensSearchboxHandler::OnAutocompleteStopTimerTriggered( + const AutocompleteInput& input) { + // Only notify the lens controller when autocomplete stop timer is triggered + // for zero suggest inputs. + if (input.IsZeroSuggest() && autocomplete_controller()->done()) { + lens_searchbox_client_->ShowGhostLoaderErrorState(); + } +} + +void LensSearchboxHandler::OnResultChanged(AutocompleteController* controller, + bool default_match_changed) { + SearchboxHandler::OnResultChanged(controller, default_match_changed); + // Show the ghost loader error state if the result is empty on the last + // async pass of the autocomplete controller (there will not be anymore + // updates). controller->done() itself is not a sufficient check since it + // takes into account kStop update types which occurs when a user unfocuses + // the searchbox, and the error state should not be shown in this case. + if (controller->done() && + controller->last_update_type() == + AutocompleteController::UpdateType::kLastAsyncPass && + controller->result().empty()) { + lens_searchbox_client_->ShowGhostLoaderErrorState(); + } + + if (controller->input().IsZeroSuggest() && !controller->result().empty()) { + lens_searchbox_client_->OnZeroSuggestShown(); + } +}
diff --git a/chrome/browser/ui/webui/searchbox/lens_searchbox_handler.h b/chrome/browser/ui/webui/searchbox/lens_searchbox_handler.h new file mode 100644 index 0000000..2db61efa --- /dev/null +++ b/chrome/browser/ui/webui/searchbox/lens_searchbox_handler.h
@@ -0,0 +1,68 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_SEARCHBOX_LENS_SEARCHBOX_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_SEARCHBOX_LENS_SEARCHBOX_HANDLER_H_ + +#include "chrome/browser/ui/webui/searchbox/searchbox_handler.h" +#include "components/omnibox/browser/omnibox.mojom.h" + +class MetricsReporter; +class LensSearchboxClient; +class Profile; + +// Browser-side handler for bidirectional communication with the WebUI +// lens overlay and side panel searchboxes. +class LensSearchboxHandler : public SearchboxHandler { + public: + LensSearchboxHandler( + mojo::PendingReceiver<searchbox::mojom::PageHandler> pending_page_handler, + Profile* profile, + content::WebContents* web_contents, + MetricsReporter* metrics_reporter, + LensSearchboxClient* lens_searchbox_client); + + ~LensSearchboxHandler() override; + + // searchbox::mojom::PageHandler: + void SetPage( + mojo::PendingRemote<searchbox::mojom::Page> pending_page) override; + void OnFocusChanged(bool focused) override; + void QueryAutocomplete(const std::u16string& input, + bool prevent_inline_autocomplete) override; + void DeleteAutocompleteMatch(uint8_t line, const GURL& url) override {} + void ToggleSuggestionGroupIdVisibility(int32_t suggestion_group_id) override { + } + void ExecuteAction(uint8_t line, + uint8_t action_index, + const GURL& url, + base::TimeTicks match_selection_timestamp, + uint8_t mouse_button, + bool alt_key, + bool ctrl_key, + bool meta_key, + bool shift_key) override {} + void PopupElementSizeChanged(const gfx::Size& size) override {} + void OnThumbnailRemoved() override; + + // Invoked by LensOverlayController. + void SetInputText(const std::string& input_text); + // Invoked by LensOverlayController. + void SetThumbnail(const std::string& thumbnail_url); + + void SetLensSearchboxClientForTesting( + LensSearchboxClient* lens_searchbox_client); + + // AutocompleteController::Observer: + void OnAutocompleteStopTimerTriggered( + const AutocompleteInput& input) override; + void OnResultChanged(AutocompleteController* controller, + bool default_match_changed) override; + + private: + // Owns this. + raw_ptr<LensSearchboxClient> lens_searchbox_client_; +}; + +#endif // CHROME_BROWSER_UI_WEBUI_SEARCHBOX_LENS_SEARCHBOX_HANDLER_H_
diff --git a/chrome/browser/ui/webui/web_app_internals/iwa_internals_handler.cc b/chrome/browser/ui/webui/web_app_internals/iwa_internals_handler.cc index 7f6a193d..4fd4914 100644 --- a/chrome/browser/ui/webui/web_app_internals/iwa_internals_handler.cc +++ b/chrome/browser/ui/webui/web_app_internals/iwa_internals_handler.cc
@@ -27,6 +27,7 @@ #include "chrome/browser/web_applications/isolated_web_apps/update_manifest/update_manifest.h" #include "chrome/browser/web_applications/isolated_web_apps/update_manifest/update_manifest_fetcher.h" #include "chrome/browser/web_applications/locks/app_lock.h" +#include "chrome/browser/web_applications/web_app_command_scheduler.h" #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registry_update.h"
diff --git a/chrome/browser/vr/elements/draw_phase.cc b/chrome/browser/vr/elements/draw_phase.cc index 9157a246..ff2270f 100644 --- a/chrome/browser/vr/elements/draw_phase.cc +++ b/chrome/browser/vr/elements/draw_phase.cc
@@ -2,31 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/40285824): Remove this and convert code to safer constructs. -#pragma allow_unsafe_buffers -#endif - #include "chrome/browser/vr/elements/draw_phase.h" +#include <array> +#include <string> + +#include "base/check_op.h" + namespace vr { namespace { -static const char* g_draw_phase_strings[] = { +// LINT.IfChange(DrawPhaseType) +static std::array<const char*, kNumDrawPhases + 1> g_draw_phase_strings = { "kPhaseNone", "kPhaseBackground", "kPhaseForeground", "kPhaseOverlayForeground", }; - -static_assert( - kNumDrawPhases + 1 == std::size(g_draw_phase_strings), - "Mismatch between the DrawPhase enum and the corresponding strings"); - +// LINT.ThenChange(//chrome/browser/vr/elements/draw_phase.h:DrawPhaseType) } // namespace std::string DrawPhaseToString(DrawPhase phase) { + CHECK_GE(kNumDrawPhases, phase); return g_draw_phase_strings[phase]; }
diff --git a/chrome/browser/vr/elements/draw_phase.h b/chrome/browser/vr/elements/draw_phase.h index 2175d0c..9b38810 100644 --- a/chrome/browser/vr/elements/draw_phase.h +++ b/chrome/browser/vr/elements/draw_phase.h
@@ -12,6 +12,7 @@ // Each draw phase is rendered independently in the order specified below. // TODO(crbug.com/41361860): We don't really need all these draw phases as // the draw order depends on an element's insert order. +// LINT.IfChange(DrawPhaseType) enum DrawPhase : int { // kPhaseNone is to be used for elements that do not draw. Eg, layouts. kPhaseNone = 0, @@ -20,6 +21,7 @@ kPhaseOverlayForeground, kNumDrawPhases = kPhaseOverlayForeground }; +// LINT.ThenChange(//chrome/browser/vr/elements/draw_phase.cc:DrawPhaseType) std::string DrawPhaseToString(DrawPhase phase);
diff --git a/chrome/browser/vr/elements/ui_element_name.cc b/chrome/browser/vr/elements/ui_element_name.cc index 0599bb6..7e80ae66 100644 --- a/chrome/browser/vr/elements/ui_element_name.cc +++ b/chrome/browser/vr/elements/ui_element_name.cc
@@ -2,20 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/40285824): Remove this and convert code to safer constructs. -#pragma allow_unsafe_buffers -#endif - #include "chrome/browser/vr/elements/ui_element_name.h" +#include <array> + #include "base/check_op.h" namespace vr { namespace { -static const char* g_ui_element_name_strings[] = { +// LINT.IfChange(UiElementName) +static std::array<const char*, kNumUiElementNames> g_ui_element_name_strings = { "kNone", "kRoot", "kWebVrRoot", @@ -48,16 +46,12 @@ "kMidiConnectedIndicator", "kWebXrMidiConnectedIndicator", }; - -static_assert( - kNumUiElementNames == std::size(g_ui_element_name_strings), - "Mismatch between the kUiElementName enum and the corresponding array " - "of strings."); +// LINT.ThenChange(//chrome/browser/vr/elements/ui_element_name.h:UiElementName) } // namespace std::string UiElementNameToString(UiElementName name) { - DCHECK_GT(kNumUiElementNames, name); + CHECK_GT(kNumUiElementNames, name); return g_ui_element_name_strings[name]; }
diff --git a/chrome/browser/vr/elements/ui_element_name.h b/chrome/browser/vr/elements/ui_element_name.h index 913b62ffa..d0e4d3b 100644 --- a/chrome/browser/vr/elements/ui_element_name.h +++ b/chrome/browser/vr/elements/ui_element_name.h
@@ -12,6 +12,7 @@ namespace vr { // These identifiers serve as stable, semantic identifiers for UI elements. +// LINT.IfChange(UiElementName) enum UiElementName { kNone = 0, kRoot, @@ -48,6 +49,7 @@ // This must be last. kNumUiElementNames, }; +// LINT.ThenChange(//chrome/browser/vr/elements/ui_element_name.cc:UiElementName) VR_UI_EXPORT std::string UiElementNameToString(UiElementName name);
diff --git a/chrome/browser/vr/elements/ui_element_type.cc b/chrome/browser/vr/elements/ui_element_type.cc index 1268ce71..aea5cad 100644 --- a/chrome/browser/vr/elements/ui_element_type.cc +++ b/chrome/browser/vr/elements/ui_element_type.cc
@@ -2,37 +2,27 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/40285824): Remove this and convert code to safer constructs. -#pragma allow_unsafe_buffers -#endif - #include "chrome/browser/vr/elements/ui_element_type.h" +#include <array> + #include "base/check_op.h" namespace vr { namespace { -static const char* g_ui_element_type_strings[] = { - "kTypeNone", - "kTypeScaledDepthAdjuster", - "kTypePromptBackground", - "kTypePromptIcon", - "kTypePromptText", - "kTypeSpacer", +// LINT.IfChange(UiElementType) +static std::array<const char*, kNumUiElementTypes> g_ui_element_type_strings = { + "kTypeNone", "kTypeScaledDepthAdjuster", "kTypePromptBackground", + "kTypePromptIcon", "kTypePromptText", "kTypeSpacer", }; - -static_assert( - kNumUiElementTypes == std::size(g_ui_element_type_strings), - "Mismatch between the kUiElementType enum and the corresponding array " - "of strings."); +// LINT.ThenChange(//chrome/browser/vr/elements/ui_element_type.h:UiElementType) } // namespace std::string UiElementTypeToString(UiElementType type) { - DCHECK_GT(kNumUiElementTypes, type); + CHECK_GT(kNumUiElementTypes, type); return g_ui_element_type_strings[type]; }
diff --git a/chrome/browser/vr/elements/ui_element_type.h b/chrome/browser/vr/elements/ui_element_type.h index 87738f10..e07e7752 100644 --- a/chrome/browser/vr/elements/ui_element_type.h +++ b/chrome/browser/vr/elements/ui_element_type.h
@@ -13,6 +13,7 @@ // These identifiers serve as stable, semantic identifiers for UI elements. // These are not unique, analogous to CSS classes. +// LINT.IfChange(UiElementType) enum UiElementType { kTypeNone = 0, kTypeScaledDepthAdjuster, @@ -24,6 +25,7 @@ // This must be last. kNumUiElementTypes, }; +// LINT.ThenChange(//chrome/browser/vr/elements/ui_element_type.vv:UiElementType) VR_UI_EXPORT std::string UiElementTypeToString(UiElementType type);
diff --git a/chrome/browser/vr/test/mock_xr_device_hook_base.cc b/chrome/browser/vr/test/mock_xr_device_hook_base.cc index f6973fa..9f3c6a58 100644 --- a/chrome/browser/vr/test/mock_xr_device_hook_base.cc +++ b/chrome/browser/vr/test/mock_xr_device_hook_base.cc
@@ -2,11 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/40285824): Remove this and convert code to safer constructs. -#pragma allow_unsafe_buffers -#endif - #include "chrome/browser/vr/test/mock_xr_device_hook_base.h" #include "content/public/test/xr_test_utils.h" @@ -227,8 +222,7 @@ device::ControllerFrameData ret; // Because why shouldn't a 64 button controller exist? ret.supported_buttons = UINT64_MAX; - memset(ret.axis_data, 0, - sizeof(device::ControllerAxisData) * device::kMaxNumAxes); + std::ranges::fill(ret.axis_data, device::ControllerAxisData{}); ret.role = role; ret.is_valid = true; // Identity matrix.
diff --git a/chrome/browser/vr/test/mock_xr_device_hook_base.h b/chrome/browser/vr/test/mock_xr_device_hook_base.h index 0375d8f..f616546 100644 --- a/chrome/browser/vr/test/mock_xr_device_hook_base.h +++ b/chrome/browser/vr/test/mock_xr_device_hook_base.h
@@ -63,8 +63,8 @@ void SetCanCreateSession(bool can_create_session); protected: - device_test::mojom::TrackedDeviceClass - tracked_classes_[device::kMaxTrackedDevices]; + std::array<device_test::mojom::TrackedDeviceClass, device::kMaxTrackedDevices> + tracked_classes_; base::flat_map<unsigned int, device::ControllerFrameData> controller_data_map_; std::queue<device_test::mojom::EventData> event_data_queue_;
diff --git a/chrome/browser/vr/webxr_vr_input_browser_test.cc b/chrome/browser/vr/webxr_vr_input_browser_test.cc index 6208ea6..070e2b77 100644 --- a/chrome/browser/vr/webxr_vr_input_browser_test.cc +++ b/chrome/browser/vr/webxr_vr_input_browser_test.cc
@@ -2,11 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/40285824): Remove this and convert code to safer constructs. -#pragma allow_unsafe_buffers -#endif - #include <atomic> #include "base/containers/contains.h" @@ -175,7 +170,8 @@ bool is_valid) { auto controller_data = GetCurrentControllerData(index); controller_data.pose_data.is_valid = is_valid; - device_to_origin.GetColMajorF(controller_data.pose_data.device_to_origin); + device_to_origin.GetColMajorF( + controller_data.pose_data.device_to_origin.data()); UpdateControllerAndWait(index, controller_data); } @@ -840,11 +836,11 @@ } std::string TransformToColMajorString(const gfx::Transform& t) { - float array[16]; - t.GetColMajorF(array); + std::array<float, 16> array; + t.GetColMajorF(array.data()); std::string array_string = "["; - for (int i = 0; i < 16; i++) { - array_string += base::NumberToString(array[i]) + ","; + for (const auto& val : array) { + array_string += base::NumberToString(val) + ","; } array_string.pop_back(); array_string.push_back(']');
diff --git a/chrome/browser/web_applications/BUILD.gn b/chrome/browser/web_applications/BUILD.gn index f013858..6e09804 100644 --- a/chrome/browser/web_applications/BUILD.gn +++ b/chrome/browser/web_applications/BUILD.gn
@@ -243,6 +243,7 @@ "os_integration/protocol_handling_sub_manager.h", "os_integration/run_on_os_login_sub_manager.cc", "os_integration/run_on_os_login_sub_manager.h", + "os_integration/shortcut_creation_reason.h", "os_integration/shortcut_menu_handling_sub_manager.cc", "os_integration/shortcut_menu_handling_sub_manager.h", "os_integration/shortcut_sub_manager.cc", @@ -337,6 +338,8 @@ "web_app_launch_queue.h", "web_app_logging.cc", "web_app_logging.h", + "web_app_management_type.cc", + "web_app_management_type.h", "web_app_origin_association_manager.cc", "web_app_origin_association_manager.h", "web_app_origin_association_task.cc",
diff --git a/chrome/browser/web_applications/commands/external_app_resolution_command.cc b/chrome/browser/web_applications/commands/external_app_resolution_command.cc index a36bfea..a32cf1e 100644 --- a/chrome/browser/web_applications/commands/external_app_resolution_command.cc +++ b/chrome/browser/web_applications/commands/external_app_resolution_command.cc
@@ -17,6 +17,7 @@ #include "base/notreached.h" #include "base/strings/to_string.h" #include "base/values.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/web_applications/commands/web_app_command.h" #include "chrome/browser/web_applications/commands/web_app_uninstall_command.h" #include "chrome/browser/web_applications/external_install_options.h"
diff --git a/chrome/browser/web_applications/commands/external_app_resolution_command.h b/chrome/browser/web_applications/commands/external_app_resolution_command.h index 148aa7b..651e1be 100644 --- a/chrome/browser/web_applications/commands/external_app_resolution_command.h +++ b/chrome/browser/web_applications/commands/external_app_resolution_command.h
@@ -56,9 +56,9 @@ // command. class ExternalAppResolutionCommand : public WebAppCommand<SharedWebContentsLock, - ExternallyManagedAppManager::InstallResult> { + ExternallyManagedAppManagerInstallResult> { public: - using InstallResult = ExternallyManagedAppManager::InstallResult; + using InstallResult = ExternallyManagedAppManagerInstallResult; using InstalledCallback = base::OnceCallback<void(InstallResult)>; ExternalAppResolutionCommand(Profile& profile,
diff --git a/chrome/browser/web_applications/commands/navigate_and_trigger_install_dialog_command_browsertest.cc b/chrome/browser/web_applications/commands/navigate_and_trigger_install_dialog_command_browsertest.cc index 3690ffc..013960b 100644 --- a/chrome/browser/web_applications/commands/navigate_and_trigger_install_dialog_command_browsertest.cc +++ b/chrome/browser/web_applications/commands/navigate_and_trigger_install_dialog_command_browsertest.cc
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/web_applications/commands/navigate_and_trigger_install_dialog_command.h" + #include "base/run_loop.h" #include "base/test/bind.h" #include "base/test/scoped_feature_list.h"
diff --git a/chrome/browser/web_applications/externally_managed_app_manager.cc b/chrome/browser/web_applications/externally_managed_app_manager.cc index d66b9dd..abd95518 100644 --- a/chrome/browser/web_applications/externally_managed_app_manager.cc +++ b/chrome/browser/web_applications/externally_managed_app_manager.cc
@@ -32,6 +32,7 @@ #include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registry_update.h" #include "chrome/browser/web_applications/web_app_sync_bridge.h" +#include "chrome/browser/web_applications/web_app_ui_manager.h" #include "chrome/browser/web_applications/web_contents/web_app_data_retriever.h" #include "chrome/browser/web_applications/web_contents/web_contents_manager.h" #include "chrome/common/chrome_features.h" @@ -43,23 +44,27 @@ namespace web_app { -ExternallyManagedAppManager::InstallResult::InstallResult() = default; +ExternallyManagedAppManagerInstallResult:: + ExternallyManagedAppManagerInstallResult() = default; -ExternallyManagedAppManager::InstallResult::InstallResult( - webapps::InstallResultCode code, - std::optional<webapps::AppId> app_id, - bool did_uninstall_and_replace) +ExternallyManagedAppManagerInstallResult:: + ExternallyManagedAppManagerInstallResult( + webapps::InstallResultCode code, + std::optional<webapps::AppId> app_id, + bool did_uninstall_and_replace) : code(code), app_id(std::move(app_id)), did_uninstall_and_replace(did_uninstall_and_replace) {} -ExternallyManagedAppManager::InstallResult::InstallResult( - const InstallResult&) = default; +ExternallyManagedAppManagerInstallResult:: + ExternallyManagedAppManagerInstallResult( + const ExternallyManagedAppManagerInstallResult&) = default; -ExternallyManagedAppManager::InstallResult::~InstallResult() = default; +ExternallyManagedAppManagerInstallResult:: + ~ExternallyManagedAppManagerInstallResult() = default; -bool ExternallyManagedAppManager::InstallResult::operator==( - const InstallResult& other) const { +bool ExternallyManagedAppManagerInstallResult::operator==( + const ExternallyManagedAppManagerInstallResult& other) const { return std::tie(code, app_id, did_uninstall_and_replace) == std::tie(other.code, other.app_id, other.did_uninstall_and_replace); } @@ -379,7 +384,7 @@ std::move(front->callback) .Run(install_options.install_url, - ExternallyManagedAppManager::InstallResult( + ExternallyManagedAppManagerInstallResult( webapps::InstallResultCode::kSuccessAlreadyInstalled, app_id)); continue; @@ -454,7 +459,7 @@ } void ExternallyManagedAppManager::OnInstalled( - ExternallyManagedAppManager::InstallResult result) { + ExternallyManagedAppManagerInstallResult result) { if (result.app_id && IsSuccess(result.code)) { MaybeEnqueueServiceWorkerRegistration( current_install_->task->install_options()); @@ -601,7 +606,7 @@ void ExternallyManagedAppManager::InstallForSynchronizeCallback( ExternalInstallSource source, const GURL& install_url, - ExternallyManagedAppManager::InstallResult result) { + ExternallyManagedAppManagerInstallResult result) { if (!IsSuccess(result.code)) { LOG(ERROR) << install_url << " from install source " << static_cast<int>(source) << " failed to install with reason " @@ -690,7 +695,7 @@ std::ostream& operator<<( std::ostream& out, - const ExternallyManagedAppManager::InstallResult& install_result) { + const ExternallyManagedAppManagerInstallResult& install_result) { base::Value::Dict output; output.Set("code", base::ToString(install_result.code)); output.Set("app_id", base::ToString(install_result.app_id));
diff --git a/chrome/browser/web_applications/externally_managed_app_manager.h b/chrome/browser/web_applications/externally_managed_app_manager.h index 44c09d4..d94ab94 100644 --- a/chrome/browser/web_applications/externally_managed_app_manager.h +++ b/chrome/browser/web_applications/externally_managed_app_manager.h
@@ -45,6 +45,25 @@ enum class RegistrationResultCode { kSuccess, kAlreadyRegistered, kTimeout }; +struct ExternallyManagedAppManagerInstallResult { + ExternallyManagedAppManagerInstallResult(); + explicit ExternallyManagedAppManagerInstallResult( + webapps::InstallResultCode code, + std::optional<webapps::AppId> app_id = std::nullopt, + bool did_uninstall_and_replace = false); + ExternallyManagedAppManagerInstallResult( + const ExternallyManagedAppManagerInstallResult&); + ~ExternallyManagedAppManagerInstallResult(); + + bool operator==(const ExternallyManagedAppManagerInstallResult& other) const; + + webapps::InstallResultCode code; + std::optional<webapps::AppId> app_id; + bool did_uninstall_and_replace = false; + // When adding fields, please update the `==` and `<<` operators to include + // the new field. +}; + // ExternallyManagedAppManager installs, uninstalls, and updates apps that are // externally managed. This means that they are not installed by the user, but // instead through a different system (enterprise installs, device default @@ -67,22 +86,7 @@ // re-initiated, and if successful, the placeholder app is removed. class ExternallyManagedAppManager { public: - struct InstallResult { - InstallResult(); - explicit InstallResult(webapps::InstallResultCode code, - std::optional<webapps::AppId> app_id = std::nullopt, - bool did_uninstall_and_replace = false); - InstallResult(const InstallResult&); - ~InstallResult(); - - bool operator==(const InstallResult& other) const; - - webapps::InstallResultCode code; - std::optional<webapps::AppId> app_id; - bool did_uninstall_and_replace = false; - // When adding fields, please update the `==` and `<<` operators to include - // the new field. - }; + using InstallResult = ExternallyManagedAppManagerInstallResult; using OnceInstallCallback = base::OnceCallback<void(const GURL& install_url, InstallResult result)>;
diff --git a/chrome/browser/web_applications/externally_managed_app_manager_impl_unittest.cc b/chrome/browser/web_applications/externally_managed_app_manager_impl_unittest.cc index 6ae602a14..5588adb 100644 --- a/chrome/browser/web_applications/externally_managed_app_manager_impl_unittest.cc +++ b/chrome/browser/web_applications/externally_managed_app_manager_impl_unittest.cc
@@ -436,7 +436,7 @@ WebAppManagement::Type install_source, const GURL& install_url, webapps::WebappUninstallSource uninstall_source, - UninstallJob::Callback callback, + UninstallCallback callback, const base::Location& location = FROM_HERE) override { uninstall_external_web_app_urls_.push_back(install_url); @@ -459,7 +459,7 @@ const webapps::AppId& app_id, WebAppManagement::Type install_source, webapps::WebappUninstallSource uninstall_source, - UninstallJob::Callback callback, + UninstallCallback callback, const base::Location& location = FROM_HERE) override { UnregisterApp(app_id); base::SequencedTaskRunner::GetCurrentDefault()->PostTask(
diff --git a/chrome/browser/web_applications/isolated_web_apps/garbage_collect_storage_partitions_command_browsertest.cc b/chrome/browser/web_applications/isolated_web_apps/garbage_collect_storage_partitions_command_browsertest.cc index f8cd3c5..bda4f02 100644 --- a/chrome/browser/web_applications/isolated_web_apps/garbage_collect_storage_partitions_command_browsertest.cc +++ b/chrome/browser/web_applications/isolated_web_apps/garbage_collect_storage_partitions_command_browsertest.cc
@@ -20,6 +20,7 @@ #include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h" #include "chrome/browser/web_applications/commands/web_app_uninstall_command.h" #include "chrome/browser/web_applications/isolated_web_apps/get_controlled_frame_partition_command.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager.h b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager.h index 517737c..8980bc5 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager.h +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager.h
@@ -15,8 +15,9 @@ #include "base/memory/weak_ptr.h" #include "base/one_shot_event.h" #include "base/types/expected.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" -#include "chrome/browser/web_applications/web_app_command_scheduler.h" +#include "components/keep_alive_registry/scoped_keep_alive.h" namespace base { class CommandLine;
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager_unittest.cc b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager_unittest.cc index 123cae0..c068abb 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager_unittest.cc +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_installation_manager_unittest.cc
@@ -23,6 +23,7 @@ #include "base/types/expected.h" #include "base/values.h" #include "chrome/browser/policy/developer_tools_policy_handler.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/test/fake_web_app_provider.h" #include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.cc b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.cc index 8514b26..0da1b86 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.cc +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.cc
@@ -338,25 +338,28 @@ return *Profile::FromBrowserContext(web_contents_->GetBrowserContext()); } -IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::UpdateInfo( - IwaSourceWithModeAndFileOp source, - std::optional<base::Version> expected_version, - bool allow_downgrades) +IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo:: + IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo( + IwaSourceWithModeAndFileOp source, + std::optional<base::Version> expected_version, + bool allow_downgrades) : source_(std::move(source)), expected_version_(std::move(expected_version)), allow_downgrades_(allow_downgrades) {} -IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::~UpdateInfo() = default; +IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo:: + ~IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo() = default; -IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::UpdateInfo( - const UpdateInfo&) = default; +IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo:: + IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo( + const IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo&) = default; -IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo& -IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::operator=( - const UpdateInfo&) = default; +IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo& +IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo::operator=( + const IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo&) = default; -base::Value -IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo::AsDebugValue() const { +base::Value IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo::AsDebugValue() + const { return base::Value( base::Value::Dict() .Set("source", source_.ToDebugValue())
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h index 99b6aa3..77f8122 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h
@@ -17,7 +17,6 @@ #include "base/sequence_checker.h" #include "base/types/expected.h" #include "base/types/optional_ref.h" -#include "base/values.h" #include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h" #include "chrome/browser/web_applications/commands/web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_command_helper.h" @@ -35,6 +34,10 @@ class Profile; +namespace base { +class Value; +} // namespace base + namespace content { class WebContents; } // namespace content @@ -65,6 +68,33 @@ std::ostream& os, const IsolatedWebAppUpdatePrepareAndStoreCommandError& error); +class IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo { + public: + IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo( + IwaSourceWithModeAndFileOp source, + std::optional<base::Version> expected_version, + bool allow_downgrades = false); + ~IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo(); + + IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo( + const IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo&); + IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo& operator=( + const IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo&); + + base::Value AsDebugValue() const; + + const IwaSourceWithModeAndFileOp& source() const { return source_; } + const std::optional<base::Version>& expected_version() const { + return expected_version_; + } + bool allow_downgrades() const { return allow_downgrades_; } + + private: + IwaSourceWithModeAndFileOp source_; + std::optional<base::Version> expected_version_; + bool allow_downgrades_; +}; + using IsolatedWebAppUpdatePrepareAndStoreCommandResult = base::expected<IsolatedWebAppUpdatePrepareAndStoreCommandSuccess, IsolatedWebAppUpdatePrepareAndStoreCommandError>; @@ -76,29 +106,7 @@ : public WebAppCommand<AppLock, IsolatedWebAppUpdatePrepareAndStoreCommandResult> { public: - class UpdateInfo { - public: - UpdateInfo(IwaSourceWithModeAndFileOp source, - std::optional<base::Version> expected_version, - bool allow_downgrades = false); - ~UpdateInfo(); - - UpdateInfo(const UpdateInfo&); - UpdateInfo& operator=(const UpdateInfo&); - - base::Value AsDebugValue() const; - - const IwaSourceWithModeAndFileOp& source() const { return source_; } - const std::optional<base::Version>& expected_version() const { - return expected_version_; - } - bool allow_downgrades() const { return allow_downgrades_; } - - private: - IwaSourceWithModeAndFileOp source_; - std::optional<base::Version> expected_version_; - bool allow_downgrades_; - }; + using UpdateInfo = IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo; // `update_info` specifies the location of the update for the IWA referred to // in `url_info`. This command is safe to run even if the IWA is not installed
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_uninstall_browsertest.cc b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_uninstall_browsertest.cc index 4bfb3c9..119c4d8 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_uninstall_browsertest.cc +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_uninstall_browsertest.cc
@@ -15,6 +15,7 @@ #include "base/test/gmock_expected_support.h" #include "base/test/test_future.h" #include "base/threading/thread_restrictions.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h" #include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task.h b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task.h index 6af08b2..cf1b6b7 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task.h +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task.h
@@ -15,15 +15,16 @@ #include "base/types/expected.h" #include "base/version.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_downloader.h" +#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h" #include "chrome/browser/web_applications/isolated_web_apps/update_manifest/update_manifest.h" #include "chrome/browser/web_applications/isolated_web_apps/update_manifest/update_manifest_fetcher.h" -#include "chrome/browser/web_applications/web_app_command_scheduler.h" -#include "chrome/browser/web_applications/web_app_registrar.h" #include "components/webapps/common/web_app_id.h" #include "net/base/net_errors.h" namespace web_app { +class WebAppCommandScheduler; +class WebAppRegistrar; class IwaUpdateDiscoveryTaskParams { public:
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task_unittest.cc b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task_unittest.cc index c96439b..bf9fb80f 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task_unittest.cc +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task_unittest.cc
@@ -32,6 +32,7 @@ #include "chrome/browser/web_applications/test/web_app_test.h" #include "chrome/browser/web_applications/web_app_command_scheduler.h" #include "chrome/browser/web_applications/web_app_provider.h" +#include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_contents/web_contents_manager.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager_browsertest.cc b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager_browsertest.cc index d64a680..79cac84 100644 --- a/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager_browsertest.cc +++ b/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager_browsertest.cc
@@ -27,10 +27,12 @@ #include "base/types/expected.h" #include "chrome/browser/component_updater/iwa_key_distribution_component_installer.h" #include "chrome/browser/prefs/session_startup_pref.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/web_applications/app_browser_controller.h" #include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h" +#include "chrome/browser/web_applications/isolated_web_apps/cleanup_orphaned_isolated_web_apps_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_storage_location.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_installer.cc b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_installer.cc index 4607175..c687abd7 100644 --- a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_installer.cc +++ b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_installer.cc
@@ -7,6 +7,7 @@ #include "base/lazy_instance.h" #include "base/types/expected_macros.h" #include "chrome/browser/web_applications/callback_utils.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_downloader.h" #include "chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_external_install_options.h" #include "chrome/browser/web_applications/isolated_web_apps/update_manifest/update_manifest.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.cc b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.cc index 40bcfcf9..ebdf2c29 100644 --- a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.cc +++ b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.cc
@@ -35,6 +35,8 @@ #include "base/task/sequenced_task_runner.h" #include "base/time/time.h" #include "base/types/expected.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/web_applications/isolated_web_apps/cleanup_orphaned_isolated_web_apps_command.h" #include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.h b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.h index 0f767c17..70211445 100644 --- a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.h +++ b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.h
@@ -18,6 +18,7 @@ #include "chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_external_install_options.h" #include "chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_installer.h" #include "chrome/browser/web_applications/web_app_command_scheduler.h" +#include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_change_registrar.h" #include "net/base/backoff_entry.h"
diff --git a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager_unittest.cc b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager_unittest.cc index c06b73c4a..edfda8f 100644 --- a/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager_unittest.cc +++ b/chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager_unittest.cc
@@ -33,6 +33,7 @@ #include "chrome/browser/component_updater/iwa_key_distribution_component_installer.h" #include "chrome/browser/profiles/profile_test_util.h" #include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h" +#include "chrome/browser/web_applications/isolated_web_apps/cleanup_orphaned_isolated_web_apps_command.h" #include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_storage_location.h" @@ -963,7 +964,7 @@ const webapps::AppId& app_id, WebAppManagement::Type management_type, webapps::WebappUninstallSource uninstall_source, - UninstallJob::Callback callback, + UninstallCallback callback, const base::Location& location) override { tried_to_uninstall_ = true; EXPECT_TRUE(base::Contains(expected_apps_to_remove_, app_id));
diff --git a/chrome/browser/web_applications/isolated_web_apps/test/mock_isolated_web_app_install_command_wrapper.cc b/chrome/browser/web_applications/isolated_web_apps/test/mock_isolated_web_app_install_command_wrapper.cc index 48a152b..2284dbc 100644 --- a/chrome/browser/web_applications/isolated_web_apps/test/mock_isolated_web_app_install_command_wrapper.cc +++ b/chrome/browser/web_applications/isolated_web_apps/test/mock_isolated_web_app_install_command_wrapper.cc
@@ -8,9 +8,11 @@ #include "base/memory/raw_ptr.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h" #include "chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_manager.h" #include "chrome/browser/web_applications/web_app_command_scheduler.h" +#include "chrome/browser/web_applications/web_contents/web_app_data_retriever.h" #include "chrome/browser/web_applications/web_contents/web_contents_manager.h" #include "content/public/browser/web_contents.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/web_applications/manifest_update_manager_browsertest.cc b/chrome/browser/web_applications/manifest_update_manager_browsertest.cc index 73c3d516..2dc546f 100644 --- a/chrome/browser/web_applications/manifest_update_manager_browsertest.cc +++ b/chrome/browser/web_applications/manifest_update_manager_browsertest.cc
@@ -70,6 +70,7 @@ #include "chrome/browser/web_applications/web_app_install_finalizer.h" #include "chrome/browser/web_applications/web_app_install_info.h" #include "chrome/browser/web_applications/web_app_install_params.h" +#include "chrome/browser/web_applications/web_app_origin_association_manager.h" #include "chrome/browser/web_applications/web_app_proto_utils.h" #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_registrar.h"
diff --git a/chrome/browser/web_applications/os_integration/os_integration_sub_manager.h b/chrome/browser/web_applications/os_integration/os_integration_sub_manager.h index 4a88816..3a56611a 100644 --- a/chrome/browser/web_applications/os_integration/os_integration_sub_manager.h +++ b/chrome/browser/web_applications/os_integration/os_integration_sub_manager.h
@@ -8,11 +8,13 @@ #include <optional> #include "base/functional/callback_forward.h" -#include "chrome/browser/web_applications/os_integration/web_app_shortcut.h" -#include "chrome/browser/web_applications/proto/web_app_os_integration_state.pb.h" +#include "chrome/browser/web_applications/os_integration/shortcut_creation_reason.h" #include "components/webapps/common/web_app_id.h" namespace web_app { +namespace proto { +class WebAppOsIntegrationState; +} // namespace proto struct SynchronizeOsOptions { // This option will always unregister all os integration, despite what may be
diff --git a/chrome/browser/web_applications/os_integration/run_on_os_login_sub_manager.h b/chrome/browser/web_applications/os_integration/run_on_os_login_sub_manager.h index 5e1374c5..50ab21e 100644 --- a/chrome/browser/web_applications/os_integration/run_on_os_login_sub_manager.h +++ b/chrome/browser/web_applications/os_integration/run_on_os_login_sub_manager.h
@@ -20,6 +20,7 @@ namespace web_app { class WebAppProvider; +struct ShortcutInfo; class RunOnOsLoginSubManager : public OsIntegrationSubManager { public:
diff --git a/chrome/browser/web_applications/os_integration/shortcut_creation_reason.h b/chrome/browser/web_applications/os_integration/shortcut_creation_reason.h new file mode 100644 index 0000000..a05fa6b --- /dev/null +++ b/chrome/browser/web_applications/os_integration/shortcut_creation_reason.h
@@ -0,0 +1,19 @@ +// Copyright 2025 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_WEB_APPLICATIONS_OS_INTEGRATION_SHORTCUT_CREATION_REASON_H_ +#define CHROME_BROWSER_WEB_APPLICATIONS_OS_INTEGRATION_SHORTCUT_CREATION_REASON_H_ + +namespace web_app { + +// This encodes the cause of shortcut creation as the correct behavior in each +// case is implementation specific. +enum ShortcutCreationReason { + SHORTCUT_CREATION_BY_USER, + SHORTCUT_CREATION_AUTOMATED, +}; + +} // namespace web_app + +#endif // CHROME_BROWSER_WEB_APPLICATIONS_OS_INTEGRATION_SHORTCUT_CREATION_REASON_H_
diff --git a/chrome/browser/web_applications/os_integration/web_app_shortcut.h b/chrome/browser/web_applications/os_integration/web_app_shortcut.h index 3d5e54a..b2a53b9 100644 --- a/chrome/browser/web_applications/os_integration/web_app_shortcut.h +++ b/chrome/browser/web_applications/os_integration/web_app_shortcut.h
@@ -15,6 +15,7 @@ #include "base/functional/callback_helpers.h" #include "base/sequence_checker.h" #include "build/build_config.h" +#include "chrome/browser/web_applications/os_integration/shortcut_creation_reason.h" #include "chrome/browser/web_applications/web_app_constants.h" #include "chrome/browser/web_applications/web_app_install_info.h" #include "components/webapps/common/web_app_id.h" @@ -160,12 +161,6 @@ bool operator!=(const ShortcutLocations& location1, const ShortcutLocations& location2); -// This encodes the cause of shortcut creation as the correct behavior in each -// case is implementation specific. -enum ShortcutCreationReason { - SHORTCUT_CREATION_BY_USER, - SHORTCUT_CREATION_AUTOMATED, -}; // Compute a deterministic name based on data in the shortcut_info. std::string GenerateApplicationNameFromInfo(const ShortcutInfo& shortcut_info);
diff --git a/chrome/browser/web_applications/preinstalled_web_app_manager_browsertest.cc b/chrome/browser/web_applications/preinstalled_web_app_manager_browsertest.cc index 57c6e81..226a622 100644 --- a/chrome/browser/web_applications/preinstalled_web_app_manager_browsertest.cc +++ b/chrome/browser/web_applications/preinstalled_web_app_manager_browsertest.cc
@@ -27,6 +27,7 @@ #include "chrome/browser/apps/intent_helper/preferred_apps_test_util.h" #include "chrome/browser/apps/link_capturing/link_capturing_feature_test_support.h" #include "chrome/browser/extensions/extension_browsertest.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/web_applications/test/ssl_test_utils.h" #include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
diff --git a/chrome/browser/web_applications/scope_extension_info.cc b/chrome/browser/web_applications/scope_extension_info.cc index 8f1f23e..2a20b39 100644 --- a/chrome/browser/web_applications/scope_extension_info.cc +++ b/chrome/browser/web_applications/scope_extension_info.cc
@@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/web_applications/scope_extension_info.h" + #include <tuple> -#include "chrome/browser/web_applications/scope_extension_info.h" +#include "base/values.h" namespace web_app {
diff --git a/chrome/browser/web_applications/scope_extension_info.h b/chrome/browser/web_applications/scope_extension_info.h index 0d1298f4..1e4592e 100644 --- a/chrome/browser/web_applications/scope_extension_info.h +++ b/chrome/browser/web_applications/scope_extension_info.h
@@ -9,9 +9,12 @@ #include <unordered_map> #include "base/containers/flat_set.h" -#include "base/values.h" #include "url/origin.h" +namespace base { +class Value; +} // namespace base + namespace web_app { // Contains information about a web app's scope extension information derived
diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h index 5ddcc53..63cc46f 100644 --- a/chrome/browser/web_applications/web_app.h +++ b/chrome/browser/web_applications/web_app.h
@@ -507,7 +507,7 @@ webapps::AppId app_id_; // This set always contains at least one source. - WebAppManagementTypes sources_{}; + WebAppManagementTypes sources_; std::string name_; std::string description_;
diff --git a/chrome/browser/web_applications/web_app_command_scheduler.cc b/chrome/browser/web_applications/web_app_command_scheduler.cc index f6666dc..d6dd227 100644 --- a/chrome/browser/web_applications/web_app_command_scheduler.cc +++ b/chrome/browser/web_applications/web_app_command_scheduler.cc
@@ -42,6 +42,7 @@ #include "chrome/browser/web_applications/commands/os_integration_synchronize_command.h" #include "chrome/browser/web_applications/commands/run_on_os_login_command.h" #include "chrome/browser/web_applications/commands/set_user_display_mode_command.h" +#include "chrome/browser/web_applications/commands/uninstall_all_user_installed_web_apps_command.h" #include "chrome/browser/web_applications/commands/update_file_handler_command.h" #include "chrome/browser/web_applications/commands/update_protocol_handler_approval_command.h" #include "chrome/browser/web_applications/commands/web_app_icon_diagnostic_command.h" @@ -449,7 +450,7 @@ void WebAppCommandScheduler::UninstallAllUserInstalledWebApps( webapps::WebappUninstallSource uninstall_source, - UninstallAllUserInstalledWebAppsCommand::Callback callback, + UninstallAllUserInstalledWebAppsCallback callback, const base::Location& location) { provider_->command_manager().ScheduleCommand( std::make_unique<UninstallAllUserInstalledWebAppsCommand>(
diff --git a/chrome/browser/web_applications/web_app_command_scheduler.h b/chrome/browser/web_applications/web_app_command_scheduler.h index 328c190..a5da50a6 100644 --- a/chrome/browser/web_applications/web_app_command_scheduler.h +++ b/chrome/browser/web_applications/web_app_command_scheduler.h
@@ -18,29 +18,23 @@ #include "base/memory/raw_ref.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" +#include "base/types/expected.h" #include "base/version.h" -#include "chrome/browser/web_applications/commands/external_app_resolution_command.h" -#include "chrome/browser/web_applications/commands/fetch_installability_for_chrome_management.h" +#include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/web_applications/commands/internal/callback_command.h" -#include "chrome/browser/web_applications/commands/manifest_update_check_command.h" -#include "chrome/browser/web_applications/commands/manifest_update_finalize_command.h" -#include "chrome/browser/web_applications/commands/navigate_and_trigger_install_dialog_command.h" -#include "chrome/browser/web_applications/commands/uninstall_all_user_installed_web_apps_command.h" -#include "chrome/browser/web_applications/external_install_options.h" -#include "chrome/browser/web_applications/externally_managed_app_manager.h" -#include "chrome/browser/web_applications/isolated_web_apps/cleanup_orphaned_isolated_web_apps_command.h" -#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h" -#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_prepare_and_store_update_command.h" -#include "chrome/browser/web_applications/jobs/uninstall/uninstall_job.h" +#include "chrome/browser/web_applications/os_integration/os_integration_sub_manager.h" #include "chrome/browser/web_applications/web_app_command_manager.h" #include "chrome/browser/web_applications/web_app_install_params.h" +#include "chrome/browser/web_applications/web_app_management_type.h" #include "chrome/browser/web_applications/web_app_provider.h" -#include "chrome/browser/web_applications/web_app_ui_manager.h" +#include "components/services/app_service/public/cpp/app_launch_util.h" #include "components/webapps/browser/installable/installable_metrics.h" +#include "components/webapps/browser/uninstall_result_code.h" #include "components/webapps/common/web_app_id.h" class GURL; class Profile; +class Browser; namespace content { class StoragePartitionConfig; @@ -58,18 +52,33 @@ class IsolatedWebAppInstallSource; class IsolatedWebAppUrlInfo; +class IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo; class IsolationData; class SignedWebBundleMetadata; class WebApp; class WebAppProvider; enum class ApiApprovalState; enum class FallbackBehavior; +enum class InstallableCheckResult; enum class IsolatedInstallabilityCheckResult; +enum class LaunchWebAppWindowSetting; +enum class RunOnOsLoginMode; +enum class ManifestUpdateCheckResult; +enum class ManifestUpdateResult; +enum class NavigateAndTriggerInstallDialogCommandResult; +struct CleanupOrphanedIsolatedWebAppsCommandError; +struct CleanupOrphanedIsolatedWebAppsCommandSuccess; struct ComputedAppSize; +struct ExternalInstallOptions; +struct ExternallyManagedAppManagerInstallResult; +struct InstallIsolatedWebAppCommandError; +struct InstallIsolatedWebAppCommandSuccess; struct IsolatedWebAppApplyUpdateCommandError; +struct IsolatedWebAppUpdatePrepareAndStoreCommandError; +struct IsolatedWebAppUpdatePrepareAndStoreCommandSuccess; struct SynchronizeOsOptions; -struct WebAppInstallInfo; struct WebAppIconDiagnosticResult; +struct WebAppInstallInfo; // The command scheduler is the main API to access the web app system. The // scheduler internally ensures: @@ -85,7 +94,9 @@ class WebAppCommandScheduler { public: using ManifestWriteCallback = - ManifestUpdateFinalizeCommand::ManifestWriteCallback; + base::OnceCallback<void(const GURL& url, + const webapps::AppId& app_id, + ManifestUpdateResult result)>; using InstallIsolatedWebAppCallback = base::OnceCallback<void( base::expected<InstallIsolatedWebAppCommandSuccess, InstallIsolatedWebAppCommandError>)>; @@ -97,6 +108,17 @@ using WebInstallFromUrlCommandCallback = base::OnceCallback<void(const GURL& manifest_id, webapps::InstallResultCode code)>; + using UninstallCallback = + base::OnceCallback<void(webapps::UninstallResultCode)>; + using LaunchWebAppCallback = + base::OnceCallback<void(base::WeakPtr<Browser> browser, + base::WeakPtr<content::WebContents> web_contents, + apps::LaunchContainer container)>; + using LaunchWebAppDebugValueCallback = + base::OnceCallback<void(base::WeakPtr<Browser> browser, + base::WeakPtr<content::WebContents> web_contents, + apps::LaunchContainer container, + base::Value debug_value)>; explicit WebAppCommandScheduler(Profile& profile); virtual ~WebAppCommandScheduler(); @@ -144,11 +166,13 @@ const WebAppInstallParams& install_params, const base::Location& location = FROM_HERE); + using ExternalInstallCallback = + base::OnceCallback<void(ExternallyManagedAppManagerInstallResult)>; // Install web apps managed by `ExternallyInstalledAppManager`. void InstallExternallyManagedApp( const ExternalInstallOptions& external_install_options, std::optional<webapps::AppId> installed_placeholder_app_id, - ExternalAppResolutionCommand::InstalledCallback installed_callback, + ExternalInstallCallback installed_callback, const base::Location& location = FROM_HERE); void PersistFileHandlersUserChoice( @@ -157,6 +181,9 @@ base::OnceClosure callback, const base::Location& location = FROM_HERE); + using ManifestUpdateCheckCompletedCallback = base::OnceCallback<void( + ManifestUpdateCheckResult check_result, + std::unique_ptr<WebAppInstallInfo> new_install_info)>; // Schedule a command that performs fetching data from the manifest // for a manifest update. void ScheduleManifestUpdateCheck( @@ -164,7 +191,7 @@ const webapps::AppId& app_id, base::Time check_time, base::WeakPtr<content::WebContents> contents, - ManifestUpdateCheckCommand::CompletedCallback callback, + ManifestUpdateCheckCompletedCallback callback, const base::Location& location = FROM_HERE); // Schedules a command that performs the data writes into the DB for @@ -178,12 +205,20 @@ ManifestWriteCallback callback, const base::Location& location = FROM_HERE); + using FetchInstallabilityForChromeManagementCallback = + base::OnceCallback<void(InstallableCheckResult result, + std::optional<webapps::AppId> app_id)>; void FetchInstallabilityForChromeManagement( const GURL& url, base::WeakPtr<content::WebContents> web_contents, FetchInstallabilityForChromeManagementCallback callback, const base::Location& location = FROM_HERE); + // The navigation will always succeed. The `result` indicates whether the + // command was able to trigger the install dialog. + using NavigateAndTriggerInstallDialogCommandCallback = + base::OnceCallback<void( + NavigateAndTriggerInstallDialogCommandResult result)>; void ScheduleNavigateAndTriggerInstallDialog( const GURL& install_url, const GURL& origin_url, @@ -208,6 +243,9 @@ CleanupOrphanedIsolatedWebAppsCallback callback, const base::Location& call_location = FROM_HERE); + using PrepareAndStoreIsolatedWebAppUpdateCallback = base::OnceCallback<void( + base::expected<IsolatedWebAppUpdatePrepareAndStoreCommandSuccess, + IsolatedWebAppUpdatePrepareAndStoreCommandError>)>; // Schedules a command to prepare the update of an Isolated Web App. // `update_info` specifies the location of the update for the IWA referred to // in `url_info`. This command is safe to run even if the IWA is not installed @@ -215,12 +253,11 @@ // the update succeeds, then the `update_info` is persisted in the // `IsolationData::pending_update_info()` of the IWA in the Web App database. virtual void PrepareAndStoreIsolatedWebAppUpdate( - const IsolatedWebAppUpdatePrepareAndStoreCommand::UpdateInfo& update_info, + const IsolatedWebAppUpdatePrepareAndStoreCommandUpdateInfo& update_info, const IsolatedWebAppUrlInfo& url_info, std::unique_ptr<ScopedKeepAlive> optional_keep_alive, std::unique_ptr<ScopedProfileKeepAlive> optional_profile_keep_alive, - base::OnceCallback<void(IsolatedWebAppUpdatePrepareAndStoreCommandResult)> - callback, + PrepareAndStoreIsolatedWebAppUpdateCallback callback, const base::Location& call_location = FROM_HERE); // Schedules a command to apply a prepared pending update of an Isolated Web @@ -280,7 +317,7 @@ WebAppManagement::Type install_source, const GURL& install_url, webapps::WebappUninstallSource uninstall_source, - UninstallJob::Callback callback, + UninstallCallback callback, const base::Location& location = FROM_HERE); // Schedules a command that removes an install sources from a given web app. @@ -295,7 +332,7 @@ const webapps::AppId& app_id, WebAppManagement::Type install_management, webapps::WebappUninstallSource uninstall_source, - UninstallJob::Callback callback, + UninstallCallback callback, const base::Location& location = FROM_HERE); // Removes all management types that the user can remove, adds the @@ -309,13 +346,15 @@ void RemoveUserUninstallableManagements( const webapps::AppId& app_id, webapps::WebappUninstallSource uninstall_source, - UninstallJob::Callback callback, + UninstallCallback callback, const base::Location& location = FROM_HERE); + using UninstallAllUserInstalledWebAppsCallback = + base::OnceCallback<void(const std::optional<std::string>& error_message)>; // Schedules a command that uninstalls all user-installed web apps. void UninstallAllUserInstalledWebApps( webapps::WebappUninstallSource uninstall_source, - UninstallAllUserInstalledWebAppsCommand::Callback callback, + UninstallAllUserInstalledWebAppsCallback callback, const base::Location& location = FROM_HERE); // Completely removes the web_app from the database by removing all management @@ -330,7 +369,7 @@ base::PassKey<WebAppSyncBridge>, const webapps::AppId& app_id, webapps::WebappUninstallSource uninstall_source, - UninstallJob::Callback callback, + UninstallCallback callback, const base::Location& location = FROM_HERE); // Schedules a command that updates run on os login to provided `login_mode`
diff --git a/chrome/browser/web_applications/web_app_constants.cc b/chrome/browser/web_applications/web_app_constants.cc index dfcda2b1..08a59d3 100644 --- a/chrome/browser/web_applications/web_app_constants.cc +++ b/chrome/browser/web_applications/web_app_constants.cc
@@ -13,109 +13,6 @@ const char kRunOnOsLoginModeWindowed[] = "windowed"; -static_assert(WebAppManagement::kMinValue == 0, - "Source enum should be zero based"); - -static_assert(WebAppManagementTypes::All().Has(WebAppManagement::kMinValue), - "WebAppManagementTypes is missing an enum value"); -static_assert(WebAppManagementTypes::All().Has(WebAppManagement::kMaxValue), - "WebAppManagementTypes is missing an enum value"); -static_assert(WebAppManagementTypes::kValueCount == - WebAppManagement::kMaxValue + 1, - "WebAppManagementTypes is missing an enum value"); - -// WebAppManagement types that can't be uninstalled by the user. Counterpart to -// kUserUninstallableSources. -constexpr WebAppManagementTypes kNotUserUninstallableSources = { - WebAppManagement::kSystem, WebAppManagement::kIwaShimlessRma, - WebAppManagement::kKiosk, WebAppManagement::kPolicy, - WebAppManagement::kIwaPolicy, -}; - -constexpr bool AllWebAppManagementTypesListed() { - for (int i = WebAppManagement::Type::kMinValue; - i < WebAppManagement::Type::kMaxValue; ++i) { - WebAppManagement::Type t = static_cast<WebAppManagement::Type>(i); - - if (!kUserUninstallableSources.Has(t) && - !kNotUserUninstallableSources.Has(t)) { - return false; - } - } - - return true; -} - -// When adding a new WebAppManagement::Type, mark whether or not it is -// uninstallable by adding it to the appropriate WebAppManagementTypes constant. -// -// Note: A nicer way to do this would be to compute kUserUninstallableSources -// using a constexpr function which includes an exhaustive switch statement over -// WebAppManagement::Types. Such a method would use base::Union to accumulate -// sources, which is only constexpr once std::bitset::operator| is constexpr in -// C++23. -static_assert(AllWebAppManagementTypesListed(), - "All WebAppManagement::Types must be listed in either " - "web_app::kUserUninstallableSources or " - "web_app::kNotUserUninstallableSources"); - -namespace WebAppManagement { -std::ostream& operator<<(std::ostream& os, WebAppManagement::Type type) { - switch (type) { - case WebAppManagement::Type::kSystem: - return os << "System"; - case WebAppManagement::Type::kKiosk: - return os << "Kiosk"; - case WebAppManagement::Type::kPolicy: - return os << "Policy"; - case WebAppManagement::Type::kOem: - return os << "OEM"; - case WebAppManagement::Type::kSubApp: - return os << "SubApp"; - case WebAppManagement::Type::kWebAppStore: - return os << "WebAppStore"; - case WebAppManagement::Type::kOneDriveIntegration: - return os << "OneDriveIntegration"; - case WebAppManagement::Type::kSync: - return os << "Sync"; - case WebAppManagement::Type::kUserInstalled: - return os << "UserInstalled"; - case WebAppManagement::Type::kIwaShimlessRma: - return os << "IwaShimlessRma"; - case WebAppManagement::Type::kIwaPolicy: - return os << "IwaPolicy"; - case WebAppManagement::Type::kIwaUserInstalled: - return os << "IwaUserInstalled"; - case WebAppManagement::Type::kApsDefault: - return os << "ApsDefault"; - case WebAppManagement::Type::kDefault: - return os << "Default"; - } -} - -bool IsIwaType(WebAppManagement::Type type) { - switch (type) { - case WebAppManagement::kSystem: - case WebAppManagement::kKiosk: - case WebAppManagement::kPolicy: - case WebAppManagement::kOem: - case WebAppManagement::kSubApp: - case WebAppManagement::kWebAppStore: - case WebAppManagement::kOneDriveIntegration: - case WebAppManagement::kSync: - case WebAppManagement::kUserInstalled: - case WebAppManagement::kApsDefault: - case WebAppManagement::kDefault: - return false; - case WebAppManagement::kIwaPolicy: - case WebAppManagement::kIwaShimlessRma: - case WebAppManagement::kIwaUserInstalled: - return true; - } -} - -} // namespace WebAppManagement - std::ostream& operator<<(std::ostream& os, RunOnOsLoginMode mode) { switch (mode) { case RunOnOsLoginMode::kWindowed:
diff --git a/chrome/browser/web_applications/web_app_constants.h b/chrome/browser/web_applications/web_app_constants.h index 6b1d34a..21ba06c 100644 --- a/chrome/browser/web_applications/web_app_constants.h +++ b/chrome/browser/web_applications/web_app_constants.h
@@ -13,11 +13,13 @@ #include <optional> #include <string> -#include "base/containers/enum_set.h" #include "base/functional/callback_forward.h" #include "build/build_config.h" #include "third_party/blink/public/common/manifest/manifest.h" #include "third_party/blink/public/mojom/manifest/display_mode.mojom-forward.h" +// TODO(https://crbug.com/387302159): Remove this include after dependent files +// include this on their own. +#include "chrome/browser/web_applications/web_app_management_type.h" namespace webapps { enum class WebappUninstallSource; @@ -25,64 +27,6 @@ namespace web_app { -// Installations of Web Apps have different sources of management. Apps can be -// installed by different management systems - for example an app can be both -// installed by the user and by policy. Keeping track of which installation -// managers have installed a web app allows for them to be installed by multiple -// managers at the same time, and uninstalls from one manager doesn't affect -// another - the app will stay installed as long as at least one management -// source has it installed. -// -// This enum is also used to rank installation sources, so the ordering matters. -// This enum should be zero based: values are used as index in a bitset. -// We don't use this enum values in prefs or metrics: enumerators can be -// reordered. This enum is not a strongly typed enum class: it supports implicit -// conversion to int and <> comparison operators. -namespace WebAppManagement { -enum Type { - kMinValue = 0, - kSystem = kMinValue, - kIwaShimlessRma, - // Installed by Kiosk on Chrome OS. - kKiosk, - kPolicy, - kIwaPolicy, - // Installed by APS (App Preload Service) on ChromeOS as an OEM app. - kOem, - kSubApp, - kWebAppStore, - kOneDriveIntegration, - // User-installed web apps are managed by the sync system.or - // user-installed apps without overlaps this is the only source that will be - // set. - kSync, - kUserInstalled, - kIwaUserInstalled, - // Installed by APS (App Preload Service) on ChromeOS as a default app. These - // have the same UX as kDefault apps, but are are not managed by - // PreinstalledWebAppManager. - kApsDefault, - // This value is used by both the PreinstalledWebAppManager AND the - // AndroidSmsAppSetupControllerImpl, which is a potential conflict in the - // future. - // TODO(dmurph): Add a new source here so that the - // AndroidSmsAppSetupControllerImpl has its own source, and migrate those - // installations to have the new source. - // https://crbug.com/1314055 - kDefault, - kMaxValue = kDefault, -}; - -std::ostream& operator<<(std::ostream& os, WebAppManagement::Type type); - -bool IsIwaType(WebAppManagement::Type type); - -} // namespace WebAppManagement - -using WebAppManagementTypes = base::EnumSet<WebAppManagement::Type, - WebAppManagement::kMinValue, - WebAppManagement::kMaxValue>; - // ExternallyManagedAppManager: Where an app was installed from. This affects // what flags will be used when installing the app. // @@ -282,33 +226,6 @@ using ResultCallback = base::OnceCallback<void(Result)>; -// Management types that can be uninstalled by the user. -// Note: These work directly with the `webapps::IsUserUninstall` function - any -// source that returns true there can uninstall these types but not others, and -// will CHECK-fail in RemoveWebAppJob otherwise. -// All WebAppManagement::Types must be listed in either this constant or -// kNotUserUninstallableSources (located in the cc file). -constexpr WebAppManagementTypes kUserUninstallableSources = { - WebAppManagement::kDefault, - WebAppManagement::kApsDefault, - WebAppManagement::kSync, - WebAppManagement::kUserInstalled, - WebAppManagement::kWebAppStore, - WebAppManagement::kSubApp, - WebAppManagement::kOem, - WebAppManagement::kOneDriveIntegration, - WebAppManagement::kIwaUserInstalled, -}; - -// Management types that resulted from a user web app install. -constexpr WebAppManagementTypes kUserDrivenInstallSources = { - WebAppManagement::kSync, - WebAppManagement::kUserInstalled, - WebAppManagement::kWebAppStore, - WebAppManagement::kOneDriveIntegration, - WebAppManagement::kIwaUserInstalled, -}; - } // namespace web_app #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_CONSTANTS_H_
diff --git a/chrome/browser/web_applications/web_app_install_params.h b/chrome/browser/web_applications/web_app_install_params.h index 7bef57d..b016d1f 100644 --- a/chrome/browser/web_applications/web_app_install_params.h +++ b/chrome/browser/web_applications/web_app_install_params.h
@@ -11,7 +11,7 @@ #include <string> #include <vector> -#include "base/functional/callback.h" +#include "base/functional/callback_forward.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h" #include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
diff --git a/chrome/browser/web_applications/web_app_management_type.cc b/chrome/browser/web_applications/web_app_management_type.cc new file mode 100644 index 0000000..4b49c9b2 --- /dev/null +++ b/chrome/browser/web_applications/web_app_management_type.cc
@@ -0,0 +1,113 @@ +// Copyright 2025 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/web_applications/web_app_management_type.h" + +#include <ostream> + +namespace web_app { + +static_assert(WebAppManagement::kMinValue == 0, + "Source enum should be zero based"); + +static_assert(WebAppManagementTypes::All().Has(WebAppManagement::kMinValue), + "WebAppManagementTypes is missing an enum value"); +static_assert(WebAppManagementTypes::All().Has(WebAppManagement::kMaxValue), + "WebAppManagementTypes is missing an enum value"); +static_assert(WebAppManagementTypes::kValueCount == + WebAppManagement::kMaxValue + 1, + "WebAppManagementTypes is missing an enum value"); + +// WebAppManagement types that can't be uninstalled by the user. Counterpart to +// kUserUninstallableSources. +constexpr WebAppManagementTypes kNotUserUninstallableSources = { + WebAppManagement::kSystem, WebAppManagement::kIwaShimlessRma, + WebAppManagement::kKiosk, WebAppManagement::kPolicy, + WebAppManagement::kIwaPolicy, +}; + +constexpr bool AllWebAppManagementTypesListed() { + for (int i = WebAppManagement::Type::kMinValue; + i < WebAppManagement::Type::kMaxValue; ++i) { + WebAppManagement::Type t = static_cast<WebAppManagement::Type>(i); + + if (!kUserUninstallableSources.Has(t) && + !kNotUserUninstallableSources.Has(t)) { + return false; + } + } + + return true; +} + +// When adding a new WebAppManagement::Type, mark whether or not it is +// uninstallable by adding it to the appropriate WebAppManagementTypes constant. +// +// Note: A nicer way to do this would be to compute kUserUninstallableSources +// using a constexpr function which includes an exhaustive switch statement over +// WebAppManagement::Types. Such a method would use base::Union to accumulate +// sources, which is only constexpr once std::bitset::operator| is constexpr in +// C++23. +static_assert(AllWebAppManagementTypesListed(), + "All WebAppManagement::Types must be listed in either " + "web_app::kUserUninstallableSources or " + "web_app::kNotUserUninstallableSources"); + +namespace WebAppManagement { +std::ostream& operator<<(std::ostream& os, WebAppManagement::Type type) { + switch (type) { + case WebAppManagement::Type::kSystem: + return os << "System"; + case WebAppManagement::Type::kKiosk: + return os << "Kiosk"; + case WebAppManagement::Type::kPolicy: + return os << "Policy"; + case WebAppManagement::Type::kOem: + return os << "OEM"; + case WebAppManagement::Type::kSubApp: + return os << "SubApp"; + case WebAppManagement::Type::kWebAppStore: + return os << "WebAppStore"; + case WebAppManagement::Type::kOneDriveIntegration: + return os << "OneDriveIntegration"; + case WebAppManagement::Type::kSync: + return os << "Sync"; + case WebAppManagement::Type::kUserInstalled: + return os << "UserInstalled"; + case WebAppManagement::Type::kIwaShimlessRma: + return os << "IwaShimlessRma"; + case WebAppManagement::Type::kIwaPolicy: + return os << "IwaPolicy"; + case WebAppManagement::Type::kIwaUserInstalled: + return os << "IwaUserInstalled"; + case WebAppManagement::Type::kApsDefault: + return os << "ApsDefault"; + case WebAppManagement::Type::kDefault: + return os << "Default"; + } +} + +bool IsIwaType(WebAppManagement::Type type) { + switch (type) { + case WebAppManagement::kSystem: + case WebAppManagement::kKiosk: + case WebAppManagement::kPolicy: + case WebAppManagement::kOem: + case WebAppManagement::kSubApp: + case WebAppManagement::kWebAppStore: + case WebAppManagement::kOneDriveIntegration: + case WebAppManagement::kSync: + case WebAppManagement::kUserInstalled: + case WebAppManagement::kApsDefault: + case WebAppManagement::kDefault: + return false; + case WebAppManagement::kIwaPolicy: + case WebAppManagement::kIwaShimlessRma: + case WebAppManagement::kIwaUserInstalled: + return true; + } +} + +} // namespace WebAppManagement +} // namespace web_app
diff --git a/chrome/browser/web_applications/web_app_management_type.h b/chrome/browser/web_applications/web_app_management_type.h new file mode 100644 index 0000000..e8205e2 --- /dev/null +++ b/chrome/browser/web_applications/web_app_management_type.h
@@ -0,0 +1,101 @@ +// Copyright 2025 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MANAGEMENT_TYPE_H_ +#define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MANAGEMENT_TYPE_H_ + +#include <iosfwd> + +#include "base/containers/enum_set.h" + +namespace web_app { + +// Installations of Web Apps have different sources of management. Apps can be +// installed by different management systems - for example an app can be both +// installed by the user and by policy. Keeping track of which installation +// managers have installed a web app allows for them to be installed by multiple +// managers at the same time, and uninstalls from one manager doesn't affect +// another - the app will stay installed as long as at least one management +// source has it installed. +// +// This enum is also used to rank installation sources, so the ordering matters. +// This enum should be zero based: values are used as index in a bitset. +// We don't use this enum values in prefs or metrics: enumerators can be +// reordered. This enum is not a strongly typed enum class: it supports implicit +// conversion to int and <> comparison operators. +namespace WebAppManagement { +enum Type { + kMinValue = 0, + kSystem = kMinValue, + kIwaShimlessRma, + // Installed by Kiosk on Chrome OS. + kKiosk, + kPolicy, + kIwaPolicy, + // Installed by APS (App Preload Service) on ChromeOS as an OEM app. + kOem, + kSubApp, + kWebAppStore, + kOneDriveIntegration, + // User-installed web apps are managed by the sync system.or + // user-installed apps without overlaps this is the only source that will be + // set. + kSync, + kUserInstalled, + kIwaUserInstalled, + // Installed by APS (App Preload Service) on ChromeOS as a default app. These + // have the same UX as kDefault apps, but are are not managed by + // PreinstalledWebAppManager. + kApsDefault, + // This value is used by both the PreinstalledWebAppManager AND the + // AndroidSmsAppSetupControllerImpl, which is a potential conflict in the + // future. + // TODO(dmurph): Add a new source here so that the + // AndroidSmsAppSetupControllerImpl has its own source, and migrate those + // installations to have the new source. + // https://crbug.com/1314055 + kDefault, + kMaxValue = kDefault, +}; + +std::ostream& operator<<(std::ostream& os, WebAppManagement::Type type); + +bool IsIwaType(WebAppManagement::Type type); + +} // namespace WebAppManagement + +using WebAppManagementTypes = base::EnumSet<WebAppManagement::Type, + WebAppManagement::kMinValue, + WebAppManagement::kMaxValue>; + +// Management types that can be uninstalled by the user. +// Note: These work directly with the `webapps::IsUserUninstall` function - any +// source that returns true there can uninstall these types but not others, and +// will CHECK-fail in RemoveWebAppJob otherwise. +// All WebAppManagement::Types must be listed in either this constant or +// kNotUserUninstallableSources (located in the cc file). +inline constexpr WebAppManagementTypes kUserUninstallableSources = { + WebAppManagement::kDefault, + WebAppManagement::kApsDefault, + WebAppManagement::kSync, + WebAppManagement::kUserInstalled, + WebAppManagement::kWebAppStore, + WebAppManagement::kSubApp, + WebAppManagement::kOem, + WebAppManagement::kOneDriveIntegration, + WebAppManagement::kIwaUserInstalled, +}; + +// Management types that resulted from a user web app install. +inline constexpr WebAppManagementTypes kUserDrivenInstallSources = { + WebAppManagement::kSync, + WebAppManagement::kUserInstalled, + WebAppManagement::kWebAppStore, + WebAppManagement::kOneDriveIntegration, + WebAppManagement::kIwaUserInstalled, +}; + +} // namespace web_app + +#endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MANAGEMENT_TYPE_H_
diff --git a/chrome/browser/web_applications/web_app_run_on_os_login_manager_browsertest.cc b/chrome/browser/web_applications/web_app_run_on_os_login_manager_browsertest.cc index b9bc2bd..ff66e97 100644 --- a/chrome/browser/web_applications/web_app_run_on_os_login_manager_browsertest.cc +++ b/chrome/browser/web_applications/web_app_run_on_os_login_manager_browsertest.cc
@@ -25,6 +25,7 @@ #include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h" #include "chrome/browser/ui/web_applications/web_app_browsertest_base.h" #include "chrome/browser/ui/web_applications/web_app_run_on_os_login_notification.h" +#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_server_mixin.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h" #include "chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_constants.h"
diff --git a/chrome/build/android-arm32.pgo.txt b/chrome/build/android-arm32.pgo.txt index 2a07b09b..7eaf475 100644 --- a/chrome/build/android-arm32.pgo.txt +++ b/chrome/build/android-arm32.pgo.txt
@@ -1 +1 @@ -chrome-android32-main-1735818720-c2f2924392cbd668d2c2bacb19eb11eb92d00c17-5bf4d88ca251c22931064af72a88452bb3918d1d.profdata +chrome-android32-main-1735840793-31caf47e5a38cba6737b8c405842713bb00c66bf-797b874f30e5951ec0056a2284e7c29e852ccfcf.profdata
diff --git a/chrome/build/android-arm64.pgo.txt b/chrome/build/android-arm64.pgo.txt index 527f7b6..14230a8 100644 --- a/chrome/build/android-arm64.pgo.txt +++ b/chrome/build/android-arm64.pgo.txt
@@ -1 +1 @@ -chrome-android64-main-1735833257-dc30766517abddb0cf959335d85f63ee16dbfbf1-fc1eded9c99631b9e9d38f362b39cef7ece70097.profdata +chrome-android64-main-1735848304-2abed4a07638002a7bab58ee73b22c9e4c99b0e1-e783032573ca03d90480f52ba1840407ca2e4d50.profdata
diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index 951a99c6..61ea445 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt
@@ -1 +1 @@ -chrome-linux-main-1735796835-4a604d70f5e8a3a15676cdfe9f5b227e580f4aac-d1925e3f72b5c496a7702e51a698160e7599d30e.profdata +chrome-linux-main-1735840793-f776ebef82098951020cf05169fcd31e19ad9bb0-797b874f30e5951ec0056a2284e7c29e852ccfcf.profdata
diff --git a/chrome/build/mac-arm.pgo.txt b/chrome/build/mac-arm.pgo.txt index cc27669..73b61a9 100644 --- a/chrome/build/mac-arm.pgo.txt +++ b/chrome/build/mac-arm.pgo.txt
@@ -1 +1 @@ -chrome-mac-arm-main-1735826308-10d61009d694f10f2a78b1df43c1cb58bee4d090-1b5daa2f72abc5ca8e71d1c06977ab343cb08fbc.profdata +chrome-mac-arm-main-1735840793-f28c63861fb85bee3484ed2849ced46bb0a76ecb-797b874f30e5951ec0056a2284e7c29e852ccfcf.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index bf4d2ae..ff6a8a9 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1735818720-ab6603b8b2054512772f760587df08abb8d48984-5bf4d88ca251c22931064af72a88452bb3918d1d.profdata +chrome-mac-main-1735840793-a8f137e9775199315ed5d5235c5b0f5a1d91375b-797b874f30e5951ec0056a2284e7c29e852ccfcf.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index cf6af5eb4..41ee12a3 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1735796835-fb46f67b218c0ccfe4b83c6bc45f4711586fb68f-d1925e3f72b5c496a7702e51a698160e7599d30e.profdata +chrome-win32-main-1735818720-7c93113697fabce4ae0f495196730c619850546e-5bf4d88ca251c22931064af72a88452bb3918d1d.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index e30cbbc..f5621104 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1735808360-8b52c21c9a4906924564a9fa2395ac809a0c365c-cc171de8614cfe5f5af75a9aec9b93e75d0200b0.profdata +chrome-win64-main-1735818720-2b42f684703e98b591fc7a11a0cafca855bc5911-5bf4d88ca251c22931064af72a88452bb3918d1d.profdata
diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni index b6b0e0d77..bb15e797 100644 --- a/chrome/chrome_paks.gni +++ b/chrome/chrome_paks.gni
@@ -177,6 +177,7 @@ "$root_gen_dir/chrome/history_resources.pak", "$root_gen_dir/chrome/identity_internals_resources.pak", "$root_gen_dir/chrome/inline_login_resources.pak", + "$root_gen_dir/chrome/inspect_resources.pak", "$root_gen_dir/chrome/key_value_pair_viewer_shared_resources.pak", "$root_gen_dir/chrome/lens_shared_resources.pak", "$root_gen_dir/chrome/lens_untrusted_resources.pak",
diff --git a/chrome/common/profiler/core_unwinders_android.cc b/chrome/common/profiler/core_unwinders_android.cc index e2541903..7bd0839 100644 --- a/chrome/common/profiler/core_unwinders_android.cc +++ b/chrome/common/profiler/core_unwinders_android.cc
@@ -24,6 +24,7 @@ #include "build/branding_buildflags.h" #include "build/build_config.h" #include "chrome/common/channel_info.h" +#include "chrome/common/profiler/native_unwinder_android_map_delegate_impl.h" #include "chrome/common/profiler/process_type.h" #include "components/sampling_profiler/process_type.h" #include "components/version_info/channel.h" @@ -80,9 +81,9 @@ // Encapsulates the setup required to create the Chrome unwinder on 32 bit // Android. #if ARM32_UNWINDING_SUPPORTED -class ChromeUnwinderCreator { +class ChromeUnwinderAndroid32Creator { public: - ChromeUnwinderCreator() { + ChromeUnwinderAndroid32Creator() { constexpr char kCfiFileName[] = "assets/unwind_cfi_32_v2"; constexpr char kSplitName[] = "stack_unwinder"; @@ -93,8 +94,10 @@ chrome_cfi_file_.Initialize(base::File(fd), cfi_region); CHECK(mapped_file_ok); } - ChromeUnwinderCreator(const ChromeUnwinderCreator&) = delete; - ChromeUnwinderCreator& operator=(const ChromeUnwinderCreator&) = delete; + ChromeUnwinderAndroid32Creator(const ChromeUnwinderAndroid32Creator&) = + delete; + ChromeUnwinderAndroid32Creator& operator=( + const ChromeUnwinderAndroid32Creator&) = delete; std::unique_ptr<base::Unwinder> Create() { return std::make_unique<base::ChromeUnwinderAndroid32>( @@ -125,22 +128,31 @@ // it involves some additional latency. CHECK_NE(getpid(), gettid()); -#if ARM64_UNWINDING_SUPPORTED - // For now, we only use Libunwindstack on 64 bit (no other unwinders). - return CreateLibunwindstackUnwinders(); -#else static base::NoDestructor<NativeUnwinderAndroidMapDelegateImpl> map_delegate; - static base::NoDestructor<ChromeUnwinderCreator> chrome_unwinder_creator; +#if ARM32_UNWINDING_SUPPORTED + static base::NoDestructor<ChromeUnwinderAndroid32Creator> + chrome_unwinder_android_32_creator; +#endif // Note order matters: the more general unwinder must appear first in the // vector. std::vector<std::unique_ptr<base::Unwinder>> unwinders; unwinders.push_back(std::make_unique<base::NativeUnwinderAndroid>( reinterpret_cast<uintptr_t>(&__executable_start), map_delegate.get())); - unwinders.push_back(chrome_unwinder_creator->Create()); - - return unwinders; +#if ARM32_UNWINDING_SUPPORTED + // ARM32 requires our custom Chrome unwinder. + unwinders.push_back(chrome_unwinder_android_32_creator->Create()); +#else + // ARM64 builds with frame pointers so we can use FramePointerUnwinder there. + unwinders.push_back(std::make_unique<base::FramePointerUnwinder>( + base::BindRepeating([](const base::Frame& current_frame) { + return current_frame.module && + current_frame.module->GetBaseAddress() == + reinterpret_cast<uintptr_t>(&__executable_start); + }), + /*is_system_unwinder=*/false)); #endif + return unwinders; } // Manages installation of the module prerequisite for unwinding. Android, in @@ -237,8 +249,21 @@ return base::StackSamplingProfiler::UnwindersFactory(); } #if UNWINDING_SUPPORTED +#if ARM32_UNWINDING_SUPPORTED LoadModule(); return base::BindOnce(CreateCoreUnwinders); +#else // ARM32_UNWINDING_SUPPORTED + // On ARM64 for now, mimic the existing support for browser main thread, which + // uses the libunwindstack unwinder. + // TODO(crbug.com/380487894): determine if we can avoid this special case and + // just use the core unwinders, based on observed data quality. + if (GetProfilerProcessType(*base::CommandLine::ForCurrentProcess()) == + sampling_profiler::ProfilerProcessType::kBrowser && + getpid() == gettid()) { + return CreateLibunwindstackUnwinderFactory(); + } + return base::BindOnce(CreateCoreUnwinders); +#endif // ARM32_UNWINDING_SUPPORTED #else // UNWINDING_SUPPORTED return base::StackSamplingProfiler::UnwindersFactory(); #endif // UNWINDING_SUPPORTED
diff --git a/chrome/common/webui_url_constants.cc b/chrome/common/webui_url_constants.cc index cf266775..19aba49b 100644 --- a/chrome/common/webui_url_constants.cc +++ b/chrome/common/webui_url_constants.cc
@@ -172,7 +172,6 @@ #endif #endif #if BUILDFLAG(IS_ANDROID) - kChromeUIOfflineInternalsHost, kChromeUISnippetsInternalsHost, kChromeUIWebApksHost, #endif
diff --git a/chrome/common/webui_url_constants.h b/chrome/common/webui_url_constants.h index f751c86..baad2321 100644 --- a/chrome/common/webui_url_constants.h +++ b/chrome/common/webui_url_constants.h
@@ -293,7 +293,6 @@ "chrome-native://bookmarks/"; inline constexpr char kChromeUINativeExploreURL[] = "chrome-native://explore"; inline constexpr char kChromeUINativeNewTabURL[] = "chrome-native://newtab/"; -inline constexpr char kChromeUIOfflineInternalsHost[] = "offline-internals"; inline constexpr char kChromeUISnippetsInternalsHost[] = "snippets-internals"; inline constexpr char kChromeUIWebApksHost[] = "webapks"; #else
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 5275009..955387d5 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -2471,9 +2471,6 @@ "//chrome/browser/glic/launcher:browser_tests", ] } - if (enable_glic) { - deps += [ "//chrome/browser/ui/views/glic/border:browser_tests" ] - } allow_circular_includes_from = [ "//chrome/browser/optimization_guide:browser_tests" ] @@ -3448,6 +3445,8 @@ "../browser/accessibility/live_caption/live_caption_speech_recognition_host_browsertest.h", ] + deps += [ "//components/live_caption:utils" ] + if (is_win || is_mac || is_linux) { sources += [ "../browser/accessibility/live_caption/live_caption_automatic_language_download_browsertest.cc" ] } @@ -10811,6 +10810,10 @@ "//ui/web_dialogs:test_support", ] + if (enable_glic) { + deps += [ "//chrome/browser/ui/views/glic/border:interactive_ui_tests" ] + } + if (!is_chrome_for_testing) { deps += [ "//chrome/browser/search_engine_choice",
diff --git a/chrome/test/data/browsing_topics/topics-writable-pixel.png b/chrome/test/data/browsing_topics/topics-writable-pixel.png new file mode 100644 index 0000000..818c71d --- /dev/null +++ b/chrome/test/data/browsing_topics/topics-writable-pixel.png Binary files differ
diff --git a/chrome/test/data/browsing_topics/topics-writable-pixel.png.mock-http-headers b/chrome/test/data/browsing_topics/topics-writable-pixel.png.mock-http-headers new file mode 100644 index 0000000..90c64ce3 --- /dev/null +++ b/chrome/test/data/browsing_topics/topics-writable-pixel.png.mock-http-headers
@@ -0,0 +1,4 @@ +HTTP/1.1 {{STATUS}} +Access-Control-Allow-Origin: * +{{OBSERVE_BROWSING_TOPICS_HEADER}} +{{REDIRECT_HEADER}}
diff --git a/chrome/test/data/browsing_topics/topics-writable-pixel2.png b/chrome/test/data/browsing_topics/topics-writable-pixel2.png new file mode 100644 index 0000000..818c71d --- /dev/null +++ b/chrome/test/data/browsing_topics/topics-writable-pixel2.png Binary files differ
diff --git a/chrome/test/data/browsing_topics/topics-writable-pixel2.png.mock-http-headers b/chrome/test/data/browsing_topics/topics-writable-pixel2.png.mock-http-headers new file mode 100644 index 0000000..90c64ce3 --- /dev/null +++ b/chrome/test/data/browsing_topics/topics-writable-pixel2.png.mock-http-headers
@@ -0,0 +1,4 @@ +HTTP/1.1 {{STATUS}} +Access-Control-Allow-Origin: * +{{OBSERVE_BROWSING_TOPICS_HEADER}} +{{REDIRECT_HEADER}}
diff --git a/chrome/test/data/controlled_frame/webrequest_event_handlers.window.js b/chrome/test/data/controlled_frame/webrequest_event_handlers.window.js index b684b720..ce3683cf 100644 --- a/chrome/test/data/controlled_frame/webrequest_event_handlers.window.js +++ b/chrome/test/data/controlled_frame/webrequest_event_handlers.window.js
@@ -15,7 +15,6 @@ {name: 'onBeforeRequest', shouldTrigger: true}, {name: 'onBeforeSendHeaders', shouldTrigger: true}, {name: 'onCompleted', shouldTrigger: true}, - {name: 'onErrorOccurred', shouldTrigger: false}, {name: 'onHeadersReceived', shouldTrigger: true}, {name: 'onHeadersReceived', shouldTrigger: true}, {name: 'onSendHeaders', shouldTrigger: true}, @@ -36,6 +35,13 @@ eventCounter.bind({name: eventName}), {urls: ['<all_urls>']}); } + // Temporarily add special case for onErrorOccurred here to monitor it being + // triggered in the CI. + // TODO(crbug.com/386380410): clean up. + window['occurredErrors'] = []; + controlledframe.request.onErrorOccurred.addListener(function(details) { + window['occurredErrors'].push(details.error); + }, {urls: ['<all_urls>']}); const targetUrl = new URL(controlledframe.src); targetUrl.pathname = '/handbag.png'; @@ -61,4 +67,15 @@ window['count' + eventName]} time(s).`); } } + + // Temporarily add special case for onErrorOccurred here to monitor it being + // triggered in the CI. + // TODO(crbug.com/386380410): clean up. + assert_true( + window['occurredErrors'].length === 0, + `\nonErrorOccurred triggered ${ + window['occurredErrors'].length} times, errors are:\n${ + window['occurredErrors'] + .map((item, index) => `${index + 1}. ${item}`) + .join('\n')}\n`); }, 'WebRequest Event Handlers');
diff --git a/chrome/test/data/webui/BUILD.gn b/chrome/test/data/webui/BUILD.gn index 25ae80d..b42b30e3 100644 --- a/chrome/test/data/webui/BUILD.gn +++ b/chrome/test/data/webui/BUILD.gn
@@ -298,6 +298,7 @@ deps = [ "//chrome/test:test_support", + "//components/history_clusters/core", "//components/password_manager/content/common", "//components/power_bookmarks/core:features", "//components/search",
diff --git a/chrome/test/data/webui/cr_components/cr_components_browsertest.cc b/chrome/test/data/webui/cr_components/cr_components_browsertest.cc index 54b22c3..7d37189f 100644 --- a/chrome/test/data/webui/cr_components/cr_components_browsertest.cc +++ b/chrome/test/data/webui/cr_components/cr_components_browsertest.cc
@@ -114,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(CrComponentsHistoryClustersTest, All) { RunTest("cr_components/history_clusters/history_clusters_test.js", - "mocha.run()"); + "runMochaSuite('HistoryClustersTest')"); } IN_PROC_BROWSER_TEST_F(CrComponentsHistoryClustersTest, Cluster) {
diff --git a/chrome/test/data/webui/cr_components/cr_components_interactive_test.cc b/chrome/test/data/webui/cr_components/cr_components_interactive_test.cc index ab45ea7..8f53a0e 100644 --- a/chrome/test/data/webui/cr_components/cr_components_interactive_test.cc +++ b/chrome/test/data/webui/cr_components/cr_components_interactive_test.cc
@@ -4,6 +4,7 @@ #include "chrome/common/webui_url_constants.h" #include "chrome/test/base/web_ui_mocha_browser_test.h" +#include "components/history_clusters/core/features.h" #include "content/public/test/browser_test.h" typedef WebUIMochaFocusTest CrComponentsFocusTest; @@ -12,3 +13,20 @@ set_test_loader_host(chrome::kChromeUINewTabPageHost); RunTest("cr_components/most_visited_focus_test.js", "mocha.run()"); } + +class CrComponentsHistoryClustersFocusTest : public WebUIMochaFocusTest { + protected: + CrComponentsHistoryClustersFocusTest() { + scoped_feature_list_.InitAndEnableFeature( + history_clusters::internal::kJourneysImages); + set_test_loader_host(chrome::kChromeUIHistoryHost); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +IN_PROC_BROWSER_TEST_F(CrComponentsHistoryClustersFocusTest, All) { + RunTest("cr_components/history_clusters/history_clusters_test.js", + "runMochaSuite('HistoryClustersFocusTest')"); +}
diff --git a/chrome/test/data/webui/cr_components/history_clusters/history_clusters_test.ts b/chrome/test/data/webui/cr_components/history_clusters/history_clusters_test.ts index 00821ce..d194bfb 100644 --- a/chrome/test/data/webui/cr_components/history_clusters/history_clusters_test.ts +++ b/chrome/test/data/webui/cr_components/history_clusters/history_clusters_test.ts
@@ -12,7 +12,7 @@ import {PageImageServiceBrowserProxy} from 'chrome://resources/cr_components/page_image_service/browser_proxy.js'; import {ClientId as PageImageServiceClientId, PageImageServiceHandlerRemote} from 'chrome://resources/cr_components/page_image_service/page_image_service.mojom-webui.js'; import {loadTimeData} from 'chrome://resources/js/load_time_data.js'; -import {assertEquals, assertTrue} from 'chrome://webui-test/chai_assert.js'; +import {assertEquals, assertGT, assertTrue} from 'chrome://webui-test/chai_assert.js'; import {flushTasks} from 'chrome://webui-test/polymer_test_util.js'; import {TestMock} from 'chrome://webui-test/test_mock.js'; import {eventToPromise, microtasksFinished} from 'chrome://webui-test/test_util.js'; @@ -33,7 +33,59 @@ new PageImageServiceBrowserProxy(imageServiceHandler)); } -suite('history-clusters', () => { +function getTestVisit(rawData?: RawVisitData): URLVisit { + const rawVisitData: RawVisitData = rawData || { + url: {url: ''}, + visitTime: {internalValue: BigInt(0)}, + }; + + return { + visitId: BigInt(1), + normalizedUrl: {url: 'https://www.google.com'}, + urlForDisplay: 'https://www.google.com', + pageTitle: '', + titleMatchPositions: [], + urlForDisplayMatchPositions: [], + duplicates: [], + relativeDate: '', + annotations: [], + debugInfo: {}, + rawVisitData: rawVisitData, + isKnownToSync: false, + hasUrlKeyedImage: false, + }; +} + +function getTestCluster(id: bigint, visits: URLVisit[]) { + return { + id: id, + visits: visits, + label: '', + labelMatchPositions: [], + relatedSearches: [], + imageUrl: null, + fromPersistence: false, + debugInfo: null, + tabGroupName: null, + }; +} + +function getTestResult(): QueryResult { + const cluster1: Cluster = getTestCluster(BigInt(111), [getTestVisit()]); + + const cluster2: Cluster = getTestCluster(BigInt(222), []); + + const queryResult: QueryResult = { + query: '', + clusters: [cluster1, cluster2], + canLoadMore: false, + isContinuation: false, + }; + + return queryResult; +} + +suite('HistoryClustersTest', () => { suiteSetup(() => { loadTimeData.overrideValues({ isHistoryClustersImagesEnabled: true, @@ -46,64 +98,6 @@ createBrowserProxy(); }); - function getTestVisit(): URLVisit { - const rawVisitData: RawVisitData = { - url: {url: ''}, - visitTime: {internalValue: BigInt(0)}, - }; - - return { - visitId: BigInt(1), - normalizedUrl: {url: 'https://www.google.com'}, - urlForDisplay: 'https://www.google.com', - pageTitle: '', - titleMatchPositions: [], - urlForDisplayMatchPositions: [], - duplicates: [], - relativeDate: '', - annotations: [], - debugInfo: {}, - rawVisitData: rawVisitData, - isKnownToSync: false, - hasUrlKeyedImage: false, - }; - } - - function getTestResult(): QueryResult { - const cluster1: Cluster = { - id: BigInt(111), - visits: [getTestVisit()], - label: '', - labelMatchPositions: [], - relatedSearches: [], - imageUrl: null, - fromPersistence: false, - debugInfo: null, - tabGroupName: null, - }; - - const cluster2: Cluster = { - id: BigInt(222), - visits: [], - label: '', - labelMatchPositions: [], - relatedSearches: [], - imageUrl: null, - fromPersistence: false, - debugInfo: null, - tabGroupName: null, - }; - - const queryResult: QueryResult = { - query: '', - clusters: [cluster1, cluster2], - canLoadMore: false, - isContinuation: false, - }; - - return queryResult; - } - async function setupClustersElement() { const clustersElement = new HistoryClustersElement(); document.body.appendChild(clustersElement); @@ -371,3 +365,214 @@ clustersElement.shadowRoot!.querySelectorAll('history-cluster').length); }); }); + +suite('HistoryClustersFocusTest', () => { + suiteSetup(() => { + loadTimeData.overrideValues({ + isHistoryClustersImagesEnabled: true, + }); + }); + + setup(() => { + document.body.innerHTML = window.trustedTypes!.emptyHTML; + createBrowserProxy(); + }); + + // Set up a clusters element that has a fixed size parent and scrollable + // <div> as the scrollTarget for the list. This simulates a smaller window, + // so we don't have to implicitly rely on the size of the window in browser + // tests, which may vary and is not controllable from the test, and allows + // the element to scroll for any content past a default 300px height. + async function setupScrollableClustersElement(): + Promise<HistoryClustersElement> { + document.body.style.height = '300px'; + document.body.style.maxHeight = '300px'; + document.body.style.overflow = 'hidden'; + + const scrollTarget = document.createElement('div'); + scrollTarget.style.height = '100%'; + scrollTarget.style.overflowY = 'auto'; + document.body.appendChild(scrollTarget); + + const clustersElement = new HistoryClustersElement(); + clustersElement.scrollTarget = scrollTarget; + clustersElement.setScrollDebounceForTest(1); + scrollTarget.appendChild(clustersElement); + // Set item size estimate to measured size of items - the amount they are + // allowed to overflow (i.e. 'overflow-clip-margin' * 2). This means that + // the estimated scroll height should not change significantly on scroll, + // which is important when trying to scroll to specific px values to trigger + // or not trigger cluster loading. + clustersElement.$.clusters.itemSize = 141 - 16; + + const query = (await handler.whenCalled('startQueryClusters'))[0]; + assertEquals(query, ''); + handler.reset(); + + return clustersElement; + } + + // Set up some test clusters used by the tests below. These are intentionally + // all 1 visit clusters so that all elements have the same height so that we + // can predicatably scroll to a certain px value before the end and have the + // average item height, which is used to compute scroll height, not change. + const visit1 = getTestVisit( + {url: {url: 'www.chromium.org'}, visitTime: {internalValue: BigInt(1)}}); + const visit2 = getTestVisit({ + url: {url: 'chrome://extensions'}, + visitTime: {internalValue: BigInt(2)}, + }); + const visit3 = getTestVisit( + {url: {url: 'chrome://settings'}, visitTime: {internalValue: BigInt(3)}}); + const cluster1: Cluster = getTestCluster(BigInt(111), [visit1]); + const cluster2: Cluster = getTestCluster(BigInt(222), [visit2]); + const cluster3: Cluster = getTestCluster(BigInt(333), [visit3]); + + test('Cluster removed loads more clusters', async () => { + const clustersElement = await setupScrollableClustersElement(); + // Initial result doesn't fill the entire height, so more clusters are + // requested. + callbackRouterRemote.onClustersQueryResult({ + query: '', + clusters: [cluster1], + canLoadMore: true, + isContinuation: false, + }); + await handler.whenCalled('loadMoreClusters'); + + const continuationResult: QueryResult = { + query: '', + clusters: [cluster2, cluster3], + canLoadMore: true, + isContinuation: true, + }; + callbackRouterRemote.onClustersQueryResult(continuationResult); + await new Promise(resolve => requestIdleCallback(resolve)); + assertEquals(1, handler.getCallCount('loadMoreClusters')); + handler.reset(); + + assertEquals( + 3, + clustersElement.shadowRoot!.querySelectorAll('history-cluster').length); + + // Visit 1 and visit 2 are removed. This opens up new space for more + // clusters to be loaded, so more clusters should be requested. + callbackRouterRemote.onVisitsRemoved([visit1]); + await Promise.all([ + callbackRouterRemote.$.flushForTesting(), + eventToPromise('remove-cluster', clustersElement), + ]); + callbackRouterRemote.onVisitsRemoved([visit2]); + await Promise.all([ + callbackRouterRemote.$.flushForTesting(), + eventToPromise('remove-cluster', clustersElement), + ]); + await handler.whenCalled('loadMoreClusters'); + + callbackRouterRemote.onClustersQueryResult( + Object.assign(continuationResult, {canLoadMore: false})); + await new Promise(resolve => requestIdleCallback(resolve)); + assertEquals(1, handler.getCallCount('loadMoreClusters')); + + // Cluster 1 is removed since it contained only 1 visit, which matched the + // removed one. 1 more cluster is added for a total of 3. + assertEquals( + 3, + clustersElement.shadowRoot!.querySelectorAll('history-cluster').length); + }); + + test('Scroll to load more clusters', async () => { + const clustersElement = await setupScrollableClustersElement(); + + // Set up some test data. We intentionally load a lot of clusters for this + // test so that the scroll height will be much larger than 300px. + const clusters = []; + for (let i = 0; i < 10; i++) { + clusters.push(...[cluster1, cluster2, cluster3]); + } + callbackRouterRemote.onClustersQueryResult({ + query: '', + clusters: clusters, + canLoadMore: true, + isContinuation: false, + }); + await new Promise(resolve => requestIdleCallback(resolve)); + + const scrollTarget = document.body.querySelector('div'); + assertTrue(!!scrollTarget); + // This check ensures the line below actually scrolls. + assertGT(scrollTarget.scrollHeight, scrollTarget.offsetHeight + 600); + // Scroll to just under the threshold to make sure more clusters don't load. + scrollTarget.scrollTop = + scrollTarget.scrollHeight - scrollTarget.offsetHeight - 600; + // Wait longer than scroll debounce and for the clusters to be rendered. + await Promise.all([ + new Promise(resolve => setTimeout(resolve, 10)), + eventToPromise('viewport-filled', clustersElement), + ]); + await microtasksFinished(); + assertEquals(0, handler.getCallCount('loadMoreClusters')); + + // Scroll to within 500px of the scroll height. More clusters should be + // requested. + scrollTarget.scrollTop = + scrollTarget.scrollHeight - scrollTarget.offsetHeight - 400; + await handler.whenCalled('loadMoreClusters'); + + // Simulate more clusters loaded. + callbackRouterRemote.onClustersQueryResult({ + query: '', + clusters: [cluster1, cluster2, cluster3], + canLoadMore: true, + isContinuation: true, + }); + await new Promise(resolve => requestIdleCallback(resolve)); + assertEquals(1, handler.getCallCount('loadMoreClusters')); + handler.reset(); + + // If history-clusters isn't active, scrolling doesn't load more. In prod + // code this value is only set if the clusters are not visible (e.g. not + // the active tab in the chrome://history UI). + assertGT( + scrollTarget.scrollHeight, + scrollTarget.offsetHeight + scrollTarget.scrollTop + 500); + clustersElement.isActive = false; + await microtasksFinished(); + scrollTarget.scrollTop = + scrollTarget.scrollHeight - scrollTarget.offsetHeight - 400; + // Wait longer than scroll debounce. + await new Promise(resolve => setTimeout(resolve, 10)); + assertEquals(0, handler.getCallCount('loadMoreClusters')); + }); + + test('Resize to load more clusters', async () => { + const clustersElement = await setupScrollableClustersElement(); + clustersElement.setScrollDebounceForTest(1); + + // This result should fill the default 300px height. + callbackRouterRemote.onClustersQueryResult({ + query: '', + clusters: [ + cluster1, + cluster2, + cluster3, + cluster1, + cluster2, + cluster3, + cluster1, + ], + canLoadMore: true, + isContinuation: false, + }); + // Wait longer than scroll debounce. + await new Promise(resolve => requestIdleCallback(resolve)); + assertEquals(0, handler.getCallCount('loadMoreClusters')); + + // Resize the clusters element by resizing its parent (simulates resizing + // browser window). More clusters should be requested. + document.body.style.maxHeight = '1000px'; + document.body.style.height = '1000px'; + await handler.whenCalled('loadMoreClusters'); + assertEquals(1, handler.getCallCount('loadMoreClusters')); + }); +});
diff --git a/chrome/test/data/webui/cr_components/history_embeddings/history_embeddings_test.ts b/chrome/test/data/webui/cr_components/history_embeddings/history_embeddings_test.ts index ea1d7bc2..91a7c5f 100644 --- a/chrome/test/data/webui/cr_components/history_embeddings/history_embeddings_test.ts +++ b/chrome/test/data/webui/cr_components/history_embeddings/history_embeddings_test.ts
@@ -33,6 +33,7 @@ sourcePassage: 'Google description', lastUrlVisitTimestamp: 1000, answerData: null, + isUrlKnownToSync: false, }, { title: 'Youtube', @@ -43,6 +44,7 @@ sourcePassage: 'Youtube description', lastUrlVisitTimestamp: 2000, answerData: null, + isUrlKnownToSync: false, }, ]; @@ -319,6 +321,7 @@ sourcePassage: 'Answer description', lastUrlVisitTimestamp: 2000, answerData: {answerTextDirectives: []}, + isUrlKnownToSync: false, }; element.searchResultChangedForTesting({ query: 'some query', @@ -831,6 +834,7 @@ sourcePassage: 'Answer description', lastUrlVisitTimestamp: 2000, answerData: {answerTextDirectives: []}, + isUrlKnownToSync: false, }; element.searchResultChangedForTesting({ @@ -875,6 +879,7 @@ sourcePassage: 'Answer description', lastUrlVisitTimestamp: 2000, answerData: {answerTextDirectives: directives}, + isUrlKnownToSync: false, }; element.searchResultChangedForTesting({
diff --git a/chrome/test/data/webui/history/history_list_test.ts b/chrome/test/data/webui/history/history_list_test.ts index 994681b..d49b063 100644 --- a/chrome/test/data/webui/history/history_list_test.ts +++ b/chrome/test/data/webui/history/history_list_test.ts
@@ -55,9 +55,10 @@ * and the lazy loaded module has been loaded. */ function finishSetup( - queryResults: HistoryEntry[], query?: string): Promise<any> { + queryResults: HistoryEntry[], finished: boolean = true, + query?: string): Promise<any> { testService.setQueryResult( - {info: createHistoryInfo(query), value: queryResults}); + {info: {finished: finished, term: query || ''}, value: queryResults}); document.body.appendChild(app); element = app.$.history; @@ -369,7 +370,8 @@ test('ChangingSearchDeselectsItems', async function() { await finishSetup( - [createHistoryEntry('2016-06-9', 'https://www.example.com')], 'ex'); + [createHistoryEntry('2016-06-9', 'https://www.example.com')], true, + 'ex'); await flushTasks(); const item = element.shadowRoot!.querySelector('history-item')!; item.$.checkbox.click(); @@ -722,6 +724,74 @@ `Found 4 exact matches for 'new query'`, multipleResultsMessage); }); + test('ScrollingLoadsMore', async () => { + // Simulate a shorter window to make this easier. + document.body.style.maxHeight = '300px'; + document.body.style.height = '300px'; + const results = [...TEST_HISTORY_RESULTS, ...ADDITIONAL_RESULTS]; + await finishSetup(results, /*finished=*/ false); + testService.reset(); + // Make scroll debounce shorter to shorten some wait times below. + element.setScrollDebounceForTest(1); + + assertTrue(!!app.scrollTarget); + // This check ensures the line below actually scrolls. + assertGT( + app.scrollTarget.scrollHeight, app.scrollTarget.offsetHeight + 600); + // Scroll to just under the threshold to make sure more results don't load. + app.scrollTarget.scrollTop = + app.scrollTarget.scrollHeight - app.scrollTarget.offsetHeight - 600; + // Wait longer than scroll debounce. + await new Promise(resolve => setTimeout(resolve, 10)); + assertEquals(0, testService.getCallCount('queryHistoryContinuation')); + + // Set up more results. + testService.setQueryResult({ + info: {finished: false, term: ''}, + value: [ + createHistoryEntry('2013-02-13 10:00', 'https://en.wikipedia.org'), + createHistoryEntry('2013-02-13 9:50', 'https://www.youtube.com'), + createHistoryEntry('2013-02-11', 'https://www.google.com'), + createHistoryEntry('2013-02-10', 'https://www.example.com'), + ], + }); + + // Scroll to within 500px of the scroll height. More results should be + // requested. + app.scrollTarget.scrollTop = + app.scrollTarget.scrollHeight - app.scrollTarget.offsetHeight - 400; + await testService.whenCalled('queryHistoryContinuation'); + await flushTasks(); + assertEquals(1, testService.getCallCount('queryHistoryContinuation')); + testService.reset(); + + // Should not respond to scroll when inactive. + element.isActive = false; + flush(); + // This check ensures the line below actually scrolls. + assertGT( + app.scrollTarget.scrollHeight, app.scrollTarget.offsetHeight + 500); + app.scrollTarget.scrollTop = + app.scrollTarget.scrollHeight - app.scrollTarget.offsetHeight - 400; + // Wait longer than scroll debounce. + await new Promise(resolve => setTimeout(resolve, 10)); + assertEquals(0, testService.getCallCount('queryHistoryContinuation')); + }); + + test('ResizingLoadsMore', async () => { + // Simulate a shorter window to make this easier. + document.body.style.maxHeight = '300px'; + document.body.style.height = '300px'; + await finishSetup(TEST_HISTORY_RESULTS, /*finished=*/ false); + testService.reset(); + + // Simulate resizing the window. More results should be loaded. + document.body.style.maxHeight = '800px'; + document.body.style.height = '800px'; + await testService.whenCalled('queryHistoryContinuation'); + assertEquals(1, testService.getCallCount('queryHistoryContinuation')); + }); + teardown(function() { app.dispatchEvent(new CustomEvent( 'change-query', {bubbles: true, composed: true, detail: {search: ''}}));
diff --git a/chrome/test/data/webui/history/history_ui_browsertest.cc b/chrome/test/data/webui/history/history_ui_browsertest.cc index fd51678b..97db19b 100644 --- a/chrome/test/data/webui/history/history_ui_browsertest.cc +++ b/chrome/test/data/webui/history/history_ui_browsertest.cc
@@ -171,6 +171,14 @@ RunTestCase("AnnouncesExactMatches"); } +IN_PROC_BROWSER_TEST_F(HistoryListTest, ScrollingLoadsMore) { + RunTestCase("ScrollingLoadsMore"); +} + +IN_PROC_BROWSER_TEST_F(HistoryListTest, ResizingLoadsMore) { + RunTestCase("ResizingLoadsMore"); +} + class HistoryProductSpecificationsListTest : public WebUIMochaBrowserTest { protected: HistoryProductSpecificationsListTest() {
diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index 6ae7915..f8292fe 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM
@@ -1 +1 @@ -16147.0.0-1065812 \ No newline at end of file +16147.0.0-1065818 \ No newline at end of file
diff --git a/chromeos/ash/components/boca/BUILD.gn b/chromeos/ash/components/boca/BUILD.gn index 6229ed4..775c608 100644 --- a/chromeos/ash/components/boca/BUILD.gn +++ b/chromeos/ash/components/boca/BUILD.gn
@@ -71,6 +71,8 @@ sources = [ "spotlight/register_screen_request.cc", "spotlight/register_screen_request.h", + "spotlight/spotlight_service.cc", + "spotlight/spotlight_service.h", "spotlight/view_screen_request.cc", "spotlight/view_screen_request.h", ] @@ -78,6 +80,7 @@ ":boca", "//base", "//chromeos/ash/components/boca/session_api", + "//components/signin/public/identity_manager", "//google_apis/common:common", "//net", ] @@ -95,6 +98,7 @@ "invalidations/invalidation_service_impl_unittest.cc", "notifications/boca_notification_handler_unittest.cc", "spotlight/register_screen_request_unittest.cc", + "spotlight/spotlight_service_unittest.cc", "spotlight/view_screen_request_unittest.cc", ]
diff --git a/chromeos/ash/components/boca/babelorca/BUILD.gn b/chromeos/ash/components/boca/babelorca/BUILD.gn index 424641e4..4cc74786 100644 --- a/chromeos/ash/components/boca/babelorca/BUILD.gn +++ b/chromeos/ash/components/boca/babelorca/BUILD.gn
@@ -113,6 +113,7 @@ "//base", "//components/live_caption", "//components/live_caption:live_translate", + "//components/live_caption:utils", "//components/prefs", "//media/mojo/mojom:speech_recognition", "//net/traffic_annotation",
diff --git a/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.cc b/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.cc index d6581b0..5c8d69765 100644 --- a/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.cc +++ b/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.cc
@@ -130,8 +130,21 @@ const std::string& source_language, const std::string& target_language, bool is_final, - const std::string& result) { - std::string formatted_result = result; + const captions::TranslateEvent& event) { + // In case of error just return the non-translated text and dip + // out. + // + // TODO(384018894) Record error metrics? + // TODO(384026579) Communicate something went wrong to the + // end user. + if (!event.has_value()) { + VLOG(1) << event.error(); + std::move(callback).Run( + media::SpeechRecognitionResult(original_transcription, is_final)); + return; + } + + std::string formatted_result = event.value(); bool is_non_ideographic_source_or_ideographic_target = IsNonIdeographicSourceOrIdeographicTarget(source_language, @@ -147,7 +160,7 @@ if (is_non_ideographic_source_or_ideographic_target && is_final) { translation_cache_.Clear(); } else if (is_non_ideographic_source_or_ideographic_target) { - translation_cache_.InsertIntoCache(original_transcription, result, + translation_cache_.InsertIntoCache(original_transcription, event.value(), source_language, target_language); } else if (is_final) { // Append a space after final results when translating from an ideographic
diff --git a/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.h b/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.h index 4b60640a..691a834 100644 --- a/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.h +++ b/chromeos/ash/components/boca/babelorca/babel_orca_caption_translator.h
@@ -50,7 +50,7 @@ const std::string& source_language, const std::string& target_language, bool is_final, - const std::string& result); + const captions::TranslateEvent& event); std::optional<std::string> current_source_language_; std::optional<std::string> current_target_language_;
diff --git a/chromeos/ash/components/boca/babelorca/babel_orca_translation_dispatcher.h b/chromeos/ash/components/boca/babelorca/babel_orca_translation_dispatcher.h index 98b5ec4..4c11edb 100644 --- a/chromeos/ash/components/boca/babelorca/babel_orca_translation_dispatcher.h +++ b/chromeos/ash/components/boca/babelorca/babel_orca_translation_dispatcher.h
@@ -8,20 +8,18 @@ #include <optional> #include <string> -#include "components/live_caption/translation_dispatcher.h" +#include "components/live_caption/translation_util.h" namespace ash::babelorca { class BabelOrcaTranslationDipsatcher { public: - // TODO(avynn): Investigate if this should be a protected constructor for - // interface. virtual ~BabelOrcaTranslationDipsatcher() = default; virtual void GetTranslation(const std::string& result, const std::string& source_language, const std::string& target_language, - captions::OnTranslateEventCallback callback) = 0; + captions::TranslateEventCallback callback) = 0; }; } // namespace ash::babelorca
diff --git a/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.cc b/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.cc index 4562fe9..2d4c22d 100644 --- a/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.cc +++ b/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.cc
@@ -4,7 +4,7 @@ #include "chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.h" -#include "components/live_caption/translation_dispatcher.h" +#include "components/live_caption/translation_util.h" namespace ash::babelorca { @@ -17,9 +17,10 @@ const std::string& result, const std::string& source_language, const std::string& target_language, - captions::OnTranslateEventCallback callback) { + captions::TranslateEventCallback callback) { ++num_translation_calls_; - std::move(callback).Run(injected_result_.value_or(result)); + std::move(callback).Run( + captions::TranslateEvent(injected_result_.value_or(result))); } void FakeBabelOrcaTranslationDispatcher::InjectTranslationResult(
diff --git a/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.h b/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.h index 75db1a59..8810928 100644 --- a/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.h +++ b/chromeos/ash/components/boca/babelorca/fakes/fake_translation_dispatcher.h
@@ -10,7 +10,7 @@ #include <string> #include "chromeos/ash/components/boca/babelorca/babel_orca_translation_dispatcher.h" -#include "components/live_caption/translation_dispatcher.h" +#include "components/live_caption/translation_util.h" #include "media/mojo/mojom/speech_recognition_result.h" namespace ash::babelorca { @@ -18,18 +18,13 @@ class FakeBabelOrcaTranslationDispatcher : public BabelOrcaTranslationDipsatcher { public: - using CustomGetTranslationHandle = base::RepeatingCallback<void( - const std::string& result, - const std::string& source_language, - const std::string& target_language, - captions::OnTranslateEventCallback callback)>; FakeBabelOrcaTranslationDispatcher(); ~FakeBabelOrcaTranslationDispatcher() override; void GetTranslation(const std::string& result, const std::string& source_language, const std::string& target_language, - captions::OnTranslateEventCallback callback) override; + captions::TranslateEventCallback callback) override; int GetNumGetTranslationCalls() { return num_translation_calls_; }
diff --git a/chromeos/ash/components/boca/session_api/constants.h b/chromeos/ash/components/boca/session_api/constants.h index 30f7f29a..5c3178c 100644 --- a/chromeos/ash/components/boca/session_api/constants.h +++ b/chromeos/ash/components/boca/session_api/constants.h
@@ -100,7 +100,7 @@ inline constexpr char kSpotlightConnectionParam[] = "spotlightConnectionParam"; inline constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation = - net::DefineNetworkTrafficAnnotation("boca_classroom_integration", R"( + net::DefineNetworkTrafficAnnotation("boca_server_integration", R"( semantics: { sender: "Boca" description: "Provide ChromeOS access to school tools server"
diff --git a/chromeos/ash/components/boca/spotlight/spotlight_service.cc b/chromeos/ash/components/boca/spotlight/spotlight_service.cc new file mode 100644 index 0000000..b71aedb --- /dev/null +++ b/chromeos/ash/components/boca/spotlight/spotlight_service.cc
@@ -0,0 +1,88 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ash/components/boca/spotlight/spotlight_service.h" + +#include <vector> + +#include "base/task/thread_pool.h" +#include "chromeos/ash/components/boca/boca_app_client.h" +#include "chromeos/ash/components/boca/session_api/constants.h" +#include "components/signin/public/identity_manager/identity_manager.h" +#include "google_apis/common/auth_service.h" +#include "google_apis/common/request_sender.h" + +namespace ash::boca { + +SpotlightService::SpotlightService() : sender_(CreateRequestSender()) {} +SpotlightService::SpotlightService( + std::unique_ptr<google_apis::RequestSender> sender) + : sender_(std::move(sender)) {} + +SpotlightService::~SpotlightService() = default; + +std::unique_ptr<google_apis::RequestSender> +SpotlightService::CreateRequestSender() { + std::vector<std::string> scopes = {kSchoolToolsAuthScope}; + auto url_loader_factory = BocaAppClient::Get()->GetURLLoaderFactory(); + auto* identity_manager = BocaAppClient::Get()->GetIdentityManager(); + + if (!identity_manager) { + return nullptr; + } + auto auth_service = std::make_unique<google_apis::AuthService>( + identity_manager, + identity_manager->GetPrimaryAccountId(signin::ConsentLevel::kSignin), + url_loader_factory, scopes); + + return std::make_unique<google_apis::RequestSender>( + std::move(auth_service), url_loader_factory, + base::ThreadPool::CreateSequencedTaskRunner( + {base::MayBlock(), + /* `USER_VISIBLE` is because the requested/returned data is visible + to the user on Web UI surfaces. */ + base::TaskPriority::USER_VISIBLE, + base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}), + /*custom_user_agent=*/"", kTrafficAnnotation); +} + +void SpotlightService::ViewScreen(std::string student_gaia_id, + std::string url_base, + ViewScreenRequestCallback callback) { + auto* const current_session = + BocaAppClient::Get()->GetSessionManager()->GetCurrentSession(); + if (!current_session) { + std::move(callback).Run( + base::unexpected(google_apis::ApiErrorCode::CANCELLED)); + return; + } + if (!current_session->student_statuses().contains(student_gaia_id)) { + std::move(callback).Run( + base::unexpected(google_apis::ApiErrorCode::CANCELLED)); + return; + } + auto student_devices = + current_session->student_statuses().at(student_gaia_id).devices(); + if (student_devices.empty()) { + std::move(callback).Run( + base::unexpected(google_apis::ApiErrorCode::CANCELLED)); + + return; + } + auto student_device_id = current_session->student_statuses() + .at(student_gaia_id) + .devices() + .begin() + ->first; + // TODO(crbug.com/386420367): Support multiple devices. Currently only view + // screen from first device in student device, + ViewScreenParam view_screen_param{ + current_session->teacher().gaia_id(), BocaAppClient::Get()->GetDeviceId(), + std::move(student_gaia_id), std::move(student_device_id)}; + auto view_screen_request = std::make_unique<ViewScreenRequest>( + sender_.get(), current_session->session_id(), + std::move(view_screen_param), std::move(url_base), std::move(callback)); + sender_->StartRequestWithAuthRetry(std::move(view_screen_request)); +} +} // namespace ash::boca
diff --git a/chromeos/ash/components/boca/spotlight/spotlight_service.h b/chromeos/ash/components/boca/spotlight/spotlight_service.h new file mode 100644 index 0000000..4d0a7703 --- /dev/null +++ b/chromeos/ash/components/boca/spotlight/spotlight_service.h
@@ -0,0 +1,41 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_ASH_COMPONENTS_BOCA_SPOTLIGHT_SPOTLIGHT_SERVICE_H_ +#define CHROMEOS_ASH_COMPONENTS_BOCA_SPOTLIGHT_SPOTLIGHT_SERVICE_H_ +#include <memory> + +#include "base/functional/callback_forward.h" +#include "chromeos/ash/components/boca/spotlight/view_screen_request.h" + +namespace google_apis { +class RequestSender; +} + +namespace ash::boca { + +// A separate request sender for spotlight action. It can be in parallel with +// other session requests. +class SpotlightService { + public: + SpotlightService(); + explicit SpotlightService(std::unique_ptr<google_apis::RequestSender> sender); + SpotlightService(const SpotlightService&) = delete; + SpotlightService& operator=(const SpotlightService&) = delete; + virtual ~SpotlightService(); + + virtual std::unique_ptr<google_apis::RequestSender> CreateRequestSender(); + + virtual void ViewScreen(std::string student_gaia_id, + std::string url_base, + ViewScreenRequestCallback callback); + + google_apis::RequestSender* sender() { return sender_.get(); } + + private: + std::unique_ptr<google_apis::RequestSender> sender_; +}; +} // namespace ash::boca + +#endif // CHROMEOS_ASH_COMPONENTS_BOCA_SPOTLIGHT_SPOTLIGHT_SERVICE_H_
diff --git a/chromeos/ash/components/boca/spotlight/spotlight_service_unittest.cc b/chromeos/ash/components/boca/spotlight/spotlight_service_unittest.cc new file mode 100644 index 0000000..2580fab7 --- /dev/null +++ b/chromeos/ash/components/boca/spotlight/spotlight_service_unittest.cc
@@ -0,0 +1,209 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ash/components/boca/spotlight/spotlight_service.h" + +#include "base/test/test_future.h" +#include "chromeos/ash/components/boca/boca_app_client.h" +#include "chromeos/ash/components/boca/proto/session.pb.h" +#include "components/signin/public/identity_manager/identity_manager.h" +#include "components/signin/public/identity_manager/identity_test_environment.h" +#include "content/public/test/browser_task_environment.h" +#include "google_apis/common/dummy_auth_service.h" +#include "google_apis/common/request_sender.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "net/test/embedded_test_server/http_request.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "services/network/test/test_shared_url_loader_factory.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using ::net::test_server::BasicHttpResponse; +using ::net::test_server::HttpMethod; +using ::net::test_server::HttpRequest; +using ::net::test_server::HttpResponse; +using ::testing::_; +using ::testing::DoAll; +using ::testing::Invoke; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; +using ::testing::StrictMock; +using ::testing::WithArg; + +namespace ash::boca { +namespace { +constexpr char kGaiaId[] = "123"; +constexpr char kUserEmail[] = "cat@gmail.com"; +constexpr char kDeviceId[] = "device0"; +constexpr char kStudentDeviceId[] = "device1"; +constexpr char kStudentId[] = "student"; + +::boca::Session GetCommonTestSession() { + ::boca::Session session; + session.set_session_state(::boca::Session::ACTIVE); + session.set_session_id("session_id"); + auto* teacher = session.mutable_teacher(); + teacher->set_gaia_id(kGaiaId); + ::boca::StudentStatus status; + (*status.mutable_devices())[kStudentDeviceId] = ::boca::StudentDevice(); + (*session.mutable_student_statuses())[kStudentId] = std::move(status); + return session; +} + +class MockRequestHandler { + public: + static std::unique_ptr<HttpResponse> CreateSuccessfulResponse() { + auto response = std::make_unique<BasicHttpResponse>(); + response->set_code(net::HTTP_OK); + return response; + } + + static std::unique_ptr<HttpResponse> CreateFailedResponse() { + auto response = std::make_unique<BasicHttpResponse>(); + response->set_code(net::HTTP_INTERNAL_SERVER_ERROR); + return response; + } + + MOCK_METHOD(std::unique_ptr<HttpResponse>, + HandleRequest, + (const HttpRequest&)); +}; + +class MockBocaAppClient : public BocaAppClient { + public: + MOCK_METHOD(BocaSessionManager*, GetSessionManager, (), (override)); + MOCK_METHOD(signin::IdentityManager*, GetIdentityManager, (), (override)); + MOCK_METHOD(scoped_refptr<network::SharedURLLoaderFactory>, + GetURLLoaderFactory, + (), + (override)); + MOCK_METHOD(std::string, GetDeviceId, (), (override)); +}; + +class MockSessionManager : public BocaSessionManager { + public: + explicit MockSessionManager(SessionClientImpl* session_client_impl) + : BocaSessionManager(session_client_impl, + AccountId::FromUserEmail(kUserEmail), + /*=is_producer*/ false) {} + MOCK_METHOD((::boca::Session*), GetCurrentSession, (), (override)); + ~MockSessionManager() override = default; +}; + +class SpotlightServiceTest : public testing::Test { + public: + SpotlightServiceTest() = default; + void SetUp() override { + ON_CALL(boca_app_client_, GetIdentityManager()) + .WillByDefault(Return(identity_test_env_.identity_manager())); + + ON_CALL(boca_app_client_, GetDeviceId()).WillByDefault(Return(kDeviceId)); + boca_session_manager_ = + std::make_unique<StrictMock<MockSessionManager>>(nullptr); + test_server_.RegisterRequestHandler( + base::BindRepeating(&MockRequestHandler::HandleRequest, + base::Unretained(&request_handler_))); + + ON_CALL(boca_app_client_, GetSessionManager()) + .WillByDefault(Return(boca_session_manager_.get())); + + ASSERT_TRUE(test_server_.Start()); + } + + protected: + std::unique_ptr<google_apis::RequestSender> MakeRequestSender() { + return std::make_unique<google_apis::RequestSender>( + std::make_unique<google_apis::DummyAuthService>(), + test_shared_loader_factory_, + task_environment_.GetMainThreadTaskRunner(), "test-user-agent", + TRAFFIC_ANNOTATION_FOR_TESTS); + } + content::BrowserTaskEnvironment task_environment_{ + base::test::TaskEnvironment::TimeSource::MOCK_TIME, + base::test::TaskEnvironment::MainThreadType::IO}; + scoped_refptr<network::TestSharedURLLoaderFactory> + test_shared_loader_factory_ = + base::MakeRefCounted<network::TestSharedURLLoaderFactory>( + /*network_service=*/nullptr, + /*is_trusted=*/true); + NiceMock<MockBocaAppClient> boca_app_client_; + signin::IdentityTestEnvironment identity_test_env_; + net::EmbeddedTestServer test_server_; + testing::StrictMock<MockRequestHandler> request_handler_; + std::unique_ptr<StrictMock<MockSessionManager>> boca_session_manager_; + SpotlightService spotlight_service_{MakeRequestSender()}; +}; + +TEST_F(SpotlightServiceTest, TestViewScreenSucceed) { + auto session = GetCommonTestSession(); + EXPECT_CALL(*boca_session_manager_, GetCurrentSession()) + .WillOnce(Return(&session)); + base::test::TestFuture<base::expected<bool, google_apis::ApiErrorCode>> + future; + + net::test_server::HttpRequest http_request; + EXPECT_CALL(request_handler_, HandleRequest(_)) + .WillOnce(DoAll(SaveArg<0>(&http_request), + Return(MockRequestHandler::CreateSuccessfulResponse()))); + spotlight_service_.ViewScreen(kStudentId, test_server_.base_url().spec(), + future.GetCallback()); + auto result = future.Get(); + EXPECT_EQ(net::test_server::METHOD_POST, http_request.method); + + EXPECT_EQ("/v1/sessions/session_id/viewScreen:initiate", + http_request.relative_url); + EXPECT_EQ("application/json", http_request.headers["Content-Type"]); + auto* contentData = + "{\"hostDevice\":{\"deviceInfo\":{\"deviceId\":\"device1\"},\"user\":{" + "\"gaiaId\":\"student\"}},\"teacherClientDevice\":{\"deviceInfo\":{" + "\"deviceId\":\"device0\"},\"user\":{\"gaiaId\":\"123\"}}}"; + ASSERT_TRUE(http_request.has_content); + EXPECT_EQ(contentData, http_request.content); + EXPECT_TRUE(result.value()); +} + +TEST_F(SpotlightServiceTest, TestViewScreenWithEmptySession) { + EXPECT_CALL(*boca_session_manager_, GetCurrentSession()) + .WillOnce(Return(nullptr)); + base::test::TestFuture<base::expected<bool, google_apis::ApiErrorCode>> + future; + + spotlight_service_.ViewScreen(kStudentId, test_server_.base_url().spec(), + future.GetCallback()); + auto result = future.Get(); + EXPECT_FALSE(result.has_value()); + EXPECT_EQ(google_apis::ApiErrorCode::CANCELLED, result.error()); +} + +TEST_F(SpotlightServiceTest, TestViewScreenWithInvalidStudent) { + auto session = GetCommonTestSession(); + EXPECT_CALL(*boca_session_manager_, GetCurrentSession()) + .WillOnce(Return(&session)); + base::test::TestFuture<base::expected<bool, google_apis::ApiErrorCode>> + future; + + spotlight_service_.ViewScreen( + "differentStudent", test_server_.base_url().spec(), future.GetCallback()); + auto result = future.Get(); + EXPECT_FALSE(result.has_value()); + EXPECT_EQ(google_apis::ApiErrorCode::CANCELLED, result.error()); +} + +TEST_F(SpotlightServiceTest, TestViewScreenWithEmptyDeviceList) { + auto session = GetCommonTestSession(); + (*session.mutable_student_statuses())[kStudentId] = ::boca::StudentStatus(); + EXPECT_CALL(*boca_session_manager_, GetCurrentSession()) + .WillOnce(Return(&session)); + base::test::TestFuture<base::expected<bool, google_apis::ApiErrorCode>> + future; + spotlight_service_.ViewScreen(kStudentId, test_server_.base_url().spec(), + future.GetCallback()); + auto result = future.Get(); + EXPECT_FALSE(result.has_value()); + EXPECT_EQ(google_apis::ApiErrorCode::CANCELLED, result.error()); +} +} // namespace + +} // namespace ash::boca
diff --git a/chromeos/ash/components/boca/spotlight/view_screen_request.cc b/chromeos/ash/components/boca/spotlight/view_screen_request.cc index a2b9455..e26fb74 100644 --- a/chromeos/ash/components/boca/spotlight/view_screen_request.cc +++ b/chromeos/ash/components/boca/spotlight/view_screen_request.cc
@@ -47,13 +47,14 @@ ViewScreenRequest::ViewScreenRequest(google_apis::RequestSender* sender, std::string session_id, ViewScreenParam view_screen_param, + std::string url_base, ViewScreenRequestCallback callback) : UrlFetchRequestBase(sender, google_apis::ProgressCallback(), google_apis::ProgressCallback()), session_id_(std::move(session_id)), view_screen_param_(std::move(view_screen_param)), - url_base_(kSchoolToolsApiBaseUrl), + url_base_(std::move(url_base)), callback_(std::move(callback)) {} ViewScreenRequest ::~ViewScreenRequest() = default;
diff --git a/chromeos/ash/components/boca/spotlight/view_screen_request.h b/chromeos/ash/components/boca/spotlight/view_screen_request.h index d74af18..dfad8b6 100644 --- a/chromeos/ash/components/boca/spotlight/view_screen_request.h +++ b/chromeos/ash/components/boca/spotlight/view_screen_request.h
@@ -42,6 +42,7 @@ ViewScreenRequest(google_apis::RequestSender* sender, std::string session_id, ViewScreenParam view_screen_param, + std::string url_base, ViewScreenRequestCallback callback); ViewScreenRequest(const ViewScreenRequest&) = delete; ViewScreenRequest& operator=(const ViewScreenRequest&) = delete;
diff --git a/chromeos/ash/components/boca/spotlight/view_screen_request_unittest.cc b/chromeos/ash/components/boca/spotlight/view_screen_request_unittest.cc index 0b1b81f..e79454c 100644 --- a/chromeos/ash/components/boca/spotlight/view_screen_request_unittest.cc +++ b/chromeos/ash/components/boca/spotlight/view_screen_request_unittest.cc
@@ -115,7 +115,8 @@ std::unique_ptr<ViewScreenRequest> request = std::make_unique<ViewScreenRequest>( request_sender(), std::move(session_id), - ViewScreenParam("1", "d1", "2", "d2"), future.GetCallback()); + ViewScreenParam("1", "d1", "2", "d2"), kSchoolToolsApiBaseUrl, + future.GetCallback()); request->OverrideURLForTesting(test_server_.base_url().spec()); request_sender()->StartRequestWithAuthRetry(std::move(request)); @@ -148,7 +149,8 @@ std::unique_ptr<ViewScreenRequest> request = std::make_unique<ViewScreenRequest>( request_sender(), std::move(session_id), - ViewScreenParam("1", "d1", "2", "d2"), future.GetCallback()); + ViewScreenParam("1", "d1", "2", "d2"), kSchoolToolsApiBaseUrl, + future.GetCallback()); request->OverrideURLForTesting(test_server_.base_url().spec());
diff --git a/chromeos/ash/components/phonehub/COMMON_METADATA b/chromeos/ash/components/phonehub/COMMON_METADATA index 675682b..65c0948 100644 --- a/chromeos/ash/components/phonehub/COMMON_METADATA +++ b/chromeos/ash/components/phonehub/COMMON_METADATA
@@ -1,4 +1,4 @@ buganizer { component_id: 1131837 } -team_email: "chromeos-cross-device-eng@google.com " +team_email: "chromeos-cross-device-eng@google.com"
diff --git a/chromeos/ash/services/nearby/COMMON_METADATA b/chromeos/ash/services/nearby/COMMON_METADATA index d6d7997..db2a691 100644 --- a/chromeos/ash/services/nearby/COMMON_METADATA +++ b/chromeos/ash/services/nearby/COMMON_METADATA
@@ -1,4 +1,4 @@ buganizer { component_id: 1131838 } -team_email: "chromeos-cross-device-eng@google.com " +team_email: "chromeos-cross-device-eng@google.com"
diff --git a/clank b/clank index 4d4cf098..9538b5c 160000 --- a/clank +++ b/clank
@@ -1 +1 @@ -Subproject commit 4d4cf09821c697212343fc07e330cf0438982470 +Subproject commit 9538b5ce9a3291d7c7ad7bd04a9e31d15812fe28
diff --git a/components/OWNERS b/components/OWNERS index 6126953..65b6bc1 100644 --- a/components/OWNERS +++ b/components/OWNERS
@@ -14,6 +14,7 @@ per-file autofill_prediction_improvements_strings.grdp=file://components/autofill_ai/OWNERS per-file bookmark_bar_strings.grdp=file://components/bookmarks/OWNERS per-file browsing_data_strings.grdp=file://components/browsing_data/OWNERS +per-file collaboration_strings.grdp=file://components/collaboration/OWNERS per-file commerce_strings.grdp=file://components/commerce_strings_grdp/OWNERS per-file compose_strings.grdp=file://components/compose_strings_grdp/OWNERS per-file crash_strings.grdp=file://components/crash/OWNERS
diff --git a/components/autofill/content/browser/content_autofill_client.h b/components/autofill/content/browser/content_autofill_client.h index 01e5625..814cecfe 100644 --- a/components/autofill/content/browser/content_autofill_client.h +++ b/components/autofill/content/browser/content_autofill_client.h
@@ -16,6 +16,8 @@ namespace autofill { // Common base class for those AutofillClients that have the //content layer. +// +// There must be at most one instance per content::WebContents. class ContentAutofillClient : public AutofillClient, public content::WebContentsUserData<ContentAutofillClient> {
diff --git a/components/autofill/content/browser/content_autofill_driver_factory.h b/components/autofill/content/browser/content_autofill_driver_factory.h index f64e9a0..3ef30a64 100644 --- a/components/autofill/content/browser/content_autofill_driver_factory.h +++ b/components/autofill/content/browser/content_autofill_driver_factory.h
@@ -28,9 +28,11 @@ class ContentAutofillDriver; class ScopedAutofillManagersObservation; -// Manages lifetime of ContentAutofillDriver. Owned by ContentAutofillClient, -// therefore one Factory per WebContents. Creates one Driver per -// RenderFrameHost. +// Creates one ContentAutofillDriver per content::RenderFrameHost and manages +// its lifecycle corresponding to the content::RenderFrameHost's lifecycle. +// +// Owned by ContentAutofillClient, therefore there is one +// ContentAutofillDriverFactory per content::WebContents. class ContentAutofillDriverFactory : public AutofillDriverFactory, public content::WebContentsObserver { public:
diff --git a/components/autofill/core/browser/foundations/autofill_driver_factory.h b/components/autofill/core/browser/foundations/autofill_driver_factory.h index 1ee14d9e..45e8c634 100644 --- a/components/autofill/core/browser/foundations/autofill_driver_factory.h +++ b/components/autofill/core/browser/foundations/autofill_driver_factory.h
@@ -13,6 +13,13 @@ // The common interface for platform-dependent AutofillDriver factories: // - ContentAutofillDriverFactory // - AutofillDriverIOSFactory +// +// AutofillDriverFactory must create at most one AutofillDriver per frame-like +// object (e.g., content::RenderFrameHost) and manage their lifecycle +// corresponding to the frame-like object's lifecycle. +// +// AutofillDriverFactory must be owned by AutofillClient, so there is at most +// one instance per tab-like object (e.g., content::WebContents). class AutofillDriverFactory { public: using LifecycleState = AutofillDriver::LifecycleState;
diff --git a/components/autofill/core/browser/foundations/browser_autofill_manager.cc b/components/autofill/core/browser/foundations/browser_autofill_manager.cc index 9ac566b5..f52dd542 100644 --- a/components/autofill/core/browser/foundations/browser_autofill_manager.cc +++ b/components/autofill/core/browser/foundations/browser_autofill_manager.cc
@@ -1001,6 +1001,8 @@ if (client().IsAutofillProfileEnabled()) { metrics_->address_form_event_logger.OnFormSubmitted(*submitted_form); + metrics_->address_form_event_logger + .LogAutofillAddressOnTypingCorrectnessMetrics(*submitted_form); } if (client().IsAutofillPaymentMethodsEnabled()) { metrics_->credit_card_form_event_logger.set_signin_state_for_metrics( @@ -1716,8 +1718,10 @@ } void BrowserAutofillManager::OnDidFillAddressOnTypingSuggestion( - const FieldGlobalId& field_id) { - metrics_->address_form_event_logger.OnDidAcceptAutofillOnTyping(field_id); + const FieldGlobalId& field_id, + const std::u16string& value) { + metrics_->address_form_event_logger.OnDidAcceptAutofillOnTyping(field_id, + value); } void BrowserAutofillManager::UndoAutofill(
diff --git a/components/autofill/core/browser/foundations/browser_autofill_manager.h b/components/autofill/core/browser/foundations/browser_autofill_manager.h index da75660f..273fdb7 100644 --- a/components/autofill/core/browser/foundations/browser_autofill_manager.h +++ b/components/autofill/core/browser/foundations/browser_autofill_manager.h
@@ -166,8 +166,8 @@ // Logs metrics when the user accepts a // `SuggestionType::kAddressEntryOnTyping` suggestion on the field represented // by `field_id`. - virtual void OnDidFillAddressOnTypingSuggestion( - const FieldGlobalId& field_id); + virtual void OnDidFillAddressOnTypingSuggestion(const FieldGlobalId& field_id, + const std::u16string& value); // Calls UndoAutofillImpl and logs metrics. Virtual for testing. virtual void UndoAutofill(mojom::ActionPersistence action_persistence,
diff --git a/components/autofill/core/browser/metrics/form_events/address_form_event_logger.cc b/components/autofill/core/browser/metrics/form_events/address_form_event_logger.cc index c50620b..2a61429 100644 --- a/components/autofill/core/browser/metrics/form_events/address_form_event_logger.cc +++ b/components/autofill/core/browser/metrics/form_events/address_form_event_logger.cc
@@ -7,6 +7,7 @@ #include <algorithm> #include <iterator> #include <memory> +#include <string> #include "base/metrics/histogram_functions.h" #include "base/metrics/user_metrics.h" @@ -108,8 +109,10 @@ } void AddressFormEventLogger::OnDidAcceptAutofillOnTyping( - FieldGlobalId field_global_id) { + FieldGlobalId field_global_id, + const std::u16string& value) { CHECK(fields_where_autofill_on_typing_was_shown_.contains(field_global_id)); + autofill_on_typing_value_used_[field_global_id] = value; base::UmaHistogramBoolean("Autofill.AddressSuggestionOnTypingAcceptance", true); fields_where_autofill_on_typing_was_shown_.erase(field_global_id); @@ -157,6 +160,39 @@ ProfileCategoriesToMetricBucket(profile_categories_filled_)); } +void AddressFormEventLogger::LogAutofillAddressOnTypingCorrectnessMetrics( + const FormStructure& form) { + const std::vector<std::unique_ptr<AutofillField>>& submitted_form_fields = + form.fields(); + + // For each field in the submitted form, record its value. + auto submitted_fields_values = + base::MakeFlatMap<FieldGlobalId, std::u16string>( + submitted_form_fields, {}, + [](const std::unique_ptr<AutofillField>& field) { + return std::make_pair(field->global_id(), + field->value(ValueSemantics::kCurrent)); + }); + // Used to delete fields for which correctness was logged from + // `autofill_on_typing_value_used_`. + std::set<FieldGlobalId> logged_correctness_for_field; + for (const auto& [field_global_id, filled_value] : + autofill_on_typing_value_used_) { + if (submitted_fields_values.contains(field_global_id)) { + base::UmaHistogramBoolean( + "Autofill.EditedAutofilledFieldAtSubmission.AddressOnTyping", + filled_value == submitted_fields_values.at(field_global_id)); + logged_correctness_for_field.insert(field_global_id); + } + } + + // Remove from `autofill_on_typing_value_used_` fields for which correctness + // metrics were logged. + for (const FieldGlobalId field : logged_correctness_for_field) { + autofill_on_typing_value_used_.erase(field); + } +} + void AddressFormEventLogger::RecordFillingCorrectness(LogBuffer& logs) const { FormEventLoggerBase::RecordFillingCorrectness(logs); // Non-empty because correctness is only logged when an Autofill
diff --git a/components/autofill/core/browser/metrics/form_events/address_form_event_logger.h b/components/autofill/core/browser/metrics/form_events/address_form_event_logger.h index 72fa17e..c6e9dc4 100644 --- a/components/autofill/core/browser/metrics/form_events/address_form_event_logger.h +++ b/components/autofill/core/browser/metrics/form_events/address_form_event_logger.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_FORM_EVENTS_ADDRESS_FORM_EVENT_LOGGER_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_FORM_EVENTS_ADDRESS_FORM_EVENT_LOGGER_H_ +#include <map> #include <set> #include <string> @@ -52,7 +53,9 @@ void OnDidShownAutofillOnTyping(FieldGlobalId field_global_id); - void OnDidAcceptAutofillOnTyping(FieldGlobalId field_global_id); + void OnDidAcceptAutofillOnTyping(FieldGlobalId field_global_id, + const std::u16string& value); + void LogAutofillAddressOnTypingCorrectnessMetrics(const FormStructure& form); protected: void RecordPollSuggestions() override; @@ -84,6 +87,11 @@ // Defines fields where `SuggestionType::kAddressEntryOnTyping` // suggestions were shown. std::set<FieldGlobalId> fields_where_autofill_on_typing_was_shown_; + // For fields where `SuggestionType::kAddressEntryOnTyping` suggestions were + // accepted, stored the filled value. This is used later + // for correctness metrics emission. + std::map<FieldGlobalId, std::u16string> autofill_on_typing_value_used_; + size_t record_type_count_ = 0; };
diff --git a/components/autofill/core/browser/metrics/form_events/address_form_event_logger_unittest.cc b/components/autofill/core/browser/metrics/form_events/address_form_event_logger_unittest.cc index b632c148..bfa2588 100644 --- a/components/autofill/core/browser/metrics/form_events/address_form_event_logger_unittest.cc +++ b/components/autofill/core/browser/metrics/form_events/address_form_event_logger_unittest.cc
@@ -247,23 +247,45 @@ TEST_F(AutofillAddressOnTypingMetricsTest, EmitMetrics) { base::HistogramTester histogram_tester_; FormData form = test::GetFormData({.fields = {{}, {}, {}}}); - - // See and accept first suggestion. + // Simulate that the autofill manager has seen this form on page load. + SeeForm(form); + // See, accept and do not correct the first suggestion. static constexpr DenseSet<SuggestionType> kShownSuggestionTypes = { SuggestionType::kAddressEntryOnTyping, SuggestionType::kSeparator, SuggestionType::kManageAddress}; autofill_manager().DidShowSuggestions(kShownSuggestionTypes, form, form.fields()[0].global_id()); + const std::u16string filled_value = u"Jon snow"; autofill_manager().OnDidFillAddressOnTypingSuggestion( - form.fields()[0].global_id()); + form.fields()[0].global_id(), filled_value); + std::vector<FormFieldData> form_fields = form.ExtractFields(); + // Note that the first field value has the same as the one from the first + // suggestion. + form_fields[0].set_value(filled_value); + form.set_fields(std::move(form_fields)); // Only see second suggestion. autofill_manager().DidShowSuggestions(kShownSuggestionTypes, form, form.fields()[1].global_id()); + // See, accept and edit the third suggestion. + autofill_manager().DidShowSuggestions(kShownSuggestionTypes, form, + form.fields()[2].global_id()); + autofill_manager().OnDidFillAddressOnTypingSuggestion( + form.fields()[2].global_id(), filled_value); + form_fields = form.ExtractFields(); + // Set the third field value as something different from what was autofilled, + // simulating a correction. + form_fields[2].set_value(u"Sansa Stark"); + form.set_fields(std::move(form_fields)); + + SubmitForm(form); ResetDriverToCommitMetrics(); EXPECT_THAT(histogram_tester_.GetAllSamples( "Autofill.AddressSuggestionOnTypingAcceptance"), + BucketsAre(base::Bucket(false, 1), base::Bucket(true, 2))); + EXPECT_THAT(histogram_tester_.GetAllSamples( + "Autofill.EditedAutofilledFieldAtSubmission.AddressOnTyping"), BucketsAre(base::Bucket(false, 1), base::Bucket(true, 1))); }
diff --git a/components/autofill/core/browser/ui/autofill_external_delegate.cc b/components/autofill/core/browser/ui/autofill_external_delegate.cc index 140230a..7aeda8a 100644 --- a/components/autofill/core/browser/ui/autofill_external_delegate.cc +++ b/components/autofill/core/browser/ui/autofill_external_delegate.cc
@@ -1149,7 +1149,8 @@ profile, query_form_.global_id(), query_field_.global_id(), TriggerSourceFromSuggestionTriggerSource(trigger_source_)); } else if (suggestion.type == SuggestionType::kAddressEntryOnTyping) { - manager_->OnDidFillAddressOnTypingSuggestion(query_field_.global_id()); + manager_->OnDidFillAddressOnTypingSuggestion(query_field_.global_id(), + filling_value); } } }
diff --git a/components/autofill/core/browser/ui/autofill_external_delegate_unittest.cc b/components/autofill/core/browser/ui/autofill_external_delegate_unittest.cc index 04e1a42..f3be75d 100644 --- a/components/autofill/core/browser/ui/autofill_external_delegate_unittest.cc +++ b/components/autofill/core/browser/ui/autofill_external_delegate_unittest.cc
@@ -314,7 +314,7 @@ (override)); MOCK_METHOD(void, OnDidFillAddressOnTypingSuggestion, - (const FieldGlobalId&), + (const FieldGlobalId&, const std::u16string&), (override)); private: @@ -2433,8 +2433,11 @@ profile.GetRawInfo(*suggestion.field_by_field_filling_type_used), SuggestionType::kAddressEntryOnTyping, std::optional(NAME_FULL))); EXPECT_CALL(manager(), OnDidFillAddressFormFillingSuggestion).Times(0); - EXPECT_CALL(manager(), - OnDidFillAddressOnTypingSuggestion(IsQueriedFieldId())); + EXPECT_CALL( + manager(), + OnDidFillAddressOnTypingSuggestion( + IsQueriedFieldId(), + profile.GetRawInfo(*suggestion.field_by_field_filling_type_used))); external_delegate().DidAcceptSuggestion(suggestion, SuggestionPosition{.row = 0});
diff --git a/components/autofill/ios/browser/BUILD.gn b/components/autofill/ios/browser/BUILD.gn index dbee431..b2e72ac 100644 --- a/components/autofill/ios/browser/BUILD.gn +++ b/components/autofill/ios/browser/BUILD.gn
@@ -10,6 +10,8 @@ sources = [ "autofill_agent.h", "autofill_agent.mm", + "autofill_client_ios.h", + "autofill_client_ios.mm", "autofill_client_ios_bridge.h", "autofill_driver_ios.h", "autofill_driver_ios.mm", @@ -129,6 +131,8 @@ "mock_password_autofill_agent_delegate.mm", "new_frame_catcher.h", "new_frame_catcher.mm", + "test_autofill_client_ios.h", + "test_autofill_client_ios.mm", "test_autofill_java_script_feature_container.h", "test_autofill_java_script_feature_container.mm", "test_autofill_manager_injector.h",
diff --git a/components/autofill/ios/browser/autofill_across_iframes_unittest.mm b/components/autofill/ios/browser/autofill_across_iframes_unittest.mm index 08857824..10d7747 100644 --- a/components/autofill/ios/browser/autofill_across_iframes_unittest.mm +++ b/components/autofill/ios/browser/autofill_across_iframes_unittest.mm
@@ -29,6 +29,7 @@ #import "components/autofill/ios/browser/autofill_util.h" #import "components/autofill/ios/browser/mock_password_autofill_agent_delegate.h" #import "components/autofill/ios/browser/new_frame_catcher.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/browser/test_autofill_manager_injector.h" #import "components/autofill/ios/common/features.h" #import "components/autofill/ios/form_util/autofill_test_with_web_state.h" @@ -427,10 +428,8 @@ autofill_agent_ = [[AutofillAgent alloc] initWithPrefService:prefs_.get() webState:web_state()]; - // Driver factory needs to exist before any call to - // `AutofillDriverIOS::FromWebStateAndWebFrame`, or we crash. - autofill::AutofillDriverIOSFactory::CreateForWebState( - web_state(), &autofill_client_, /*bridge=*/autofill_agent_); + autofill_client_ = std::make_unique<autofill::TestAutofillClientIOS>( + web_state(), autofill_agent_); // Password autofill agent needs to exist before any call to fill data. autofill::PasswordAutofillAgent::CreateForWebState(web_state(), @@ -575,7 +574,7 @@ GURL url = test_server_.GetURL("/testpage"); web::test::LoadUrl(web_state(), url); web_state()->WasShown(); - autofill_client_.set_last_committed_primary_main_frame_url(url); + autofill_client_->set_last_committed_primary_main_frame_url(url); } // Returns the frame that corresponds to `frame_id`. @@ -670,7 +669,7 @@ std::unique_ptr<TestAutofillManagerInjector<TestAutofillManager>> autofill_manager_injector_; std::unique_ptr<PrefService> prefs_; - autofill::TestAutofillClient autofill_client_; + std::unique_ptr<autofill::TestAutofillClientIOS> autofill_client_; AutofillAgent* autofill_agent_; autofill::MockPasswordAutofillAgentDelegate delegate_mock_; base::test::ScopedFeatureList feature_list_;
diff --git a/components/autofill/ios/browser/autofill_agent_unittests.mm b/components/autofill/ios/browser/autofill_agent_unittests.mm index 28cc9a8..ae5393fe 100644 --- a/components/autofill/ios/browser/autofill_agent_unittests.mm +++ b/components/autofill/ios/browser/autofill_agent_unittests.mm
@@ -39,6 +39,7 @@ #import "components/autofill/ios/browser/autofill_util.h" #import "components/autofill/ios/browser/mock_password_autofill_agent_delegate.h" #import "components/autofill/ios/browser/password_autofill_agent.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/common/field_data_manager_factory_ios.h" #import "components/autofill/ios/form_util/form_handlers_java_script_feature.h" #import "components/autofill/ios/form_util/form_util_java_script_feature.h" @@ -108,6 +109,10 @@ AutofillAgentTests(const AutofillAgentTests&) = delete; AutofillAgentTests& operator=(const AutofillAgentTests&) = delete; + // This *should* be true so that the tests mimic production code behavior, but + // one legacy test crashes if we pass a non-nil AutofillAgent. + virtual bool should_set_autofill_driver_ios_bridge() const { return true; } + void AddWebFrame(std::unique_ptr<web::WebFrame> frame) { fake_web_frames_manager_->AddWebFrame(std::move(frame)); } @@ -155,6 +160,10 @@ autofill_agent_ = [[AutofillAgent alloc] initWithPrefService:prefs_.get() webState:&fake_web_state_]; + + client_ = std::make_unique<autofill::TestAutofillClientIOS>( + &fake_web_state_, + should_set_autofill_driver_ios_bridge() ? autofill_agent_ : nil); } std::unique_ptr<web::FakeWebFrame> CreateMainWebFrame() { @@ -177,7 +186,7 @@ std::unique_ptr<PrefService> prefs_; // The client_ needs to outlive the fake_web_state_, which owns the // frames. - autofill::TestAutofillClient client_; + std::unique_ptr<autofill::TestAutofillClientIOS> client_; web::FakeWebState fake_web_state_; raw_ptr<web::FakeWebFrame> fake_main_frame_ = nullptr; raw_ptr<web::FakeWebFramesManager> fake_web_frames_manager_ = nullptr; @@ -190,8 +199,6 @@ // not autofilled are skipped. Tests logic based on renderer ids usage. TEST_F(AutofillAgentTests, OnFormDataFilledTestWithFrameMessagingUsingRendererIDs) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - std::vector<autofill::FormFieldData::FillData> fill_data; autofill::FormFieldData field; field.set_form_control_type(autofill::FormControlType::kInputText); @@ -242,8 +249,6 @@ // Tests that `fillSpecificFormField` in `autofill_agent_` dispatches the // correct javascript call to the autofill controller. TEST_F(AutofillAgentTests, FillSpecificFormField) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - autofill::FormFieldData field; field.set_form_control_type(autofill::FormControlType::kInputText); field.set_label(u"Card number"); @@ -268,8 +273,6 @@ // successfully. TEST_F(AutofillAgentTests, FillSpecificFormField_UpdateWithResults_WhenSuccess) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - std::vector<autofill::FormFieldData::FillData> fields = MinimalFormFieldDataForFilling(); const std::u16string& field_value = fields[0].value; @@ -306,8 +309,6 @@ // failed. TEST_F(AutofillAgentTests, FillSpecificFormField_UpdateWithResults_WhenFailure) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - std::vector<autofill::FormFieldData::FillData> fields = MinimalFormFieldDataForFilling(); const std::u16string& field_value = fields[0].value; @@ -341,9 +342,6 @@ // Tests that `ApplyFieldAction` in `AutofillDriverIOS` dispatches the // correct javascript call to the autofill controller. TEST_F(AutofillAgentTests, DriverFillSpecificFormField) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, - autofill_agent_); - autofill::FormFieldData field; field.set_form_control_type(autofill::FormControlType::kInputText); field.set_label(u"Card number"); @@ -371,9 +369,6 @@ // Tests that `ApplyFieldAction` with `ActionPersistence::kPreview`in // `AutofillDriverIOS` does not dispatch a JS call. TEST_F(AutofillAgentTests, DriverPreviewSpecificFormField) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, - autofill_agent_); - autofill::FormFieldData field; field.set_form_control_type(autofill::FormControlType::kInputText); field.set_label(u"Card number"); @@ -885,12 +880,17 @@ class AutofillAgentTestFrameInitializationOrderFrames : public AutofillAgentTests { public: + // If we do pass `autofill_agent_` to `client_` (which would then pass it on + // to the AutofillDriverIOS objects), then the test fixture crashes during + // destruction. + // + // TODO(crbug.com/40100455): Understand what happens at destruction and fix + // this. Then eliminate should_set_autofill_driver_ios_bridge(). + bool should_set_autofill_driver_ios_bridge() const override { return false; } + void SetUp() override { AutofillAgentTests::SetUp(); RemoveWebFrame(fake_main_frame_->GetFrameId()); - ASSERT_FALSE(AutofillDriverIOSFactory::FromWebState(&fake_web_state_)); - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, - nil); } }; @@ -1013,8 +1013,6 @@ TEST_F(AutofillAgentTests, FillData_UpdateWithResults) { auto test_recorder = std::make_unique<ukm::TestAutoSetUkmRecorder>(); - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - std::vector<autofill::FormFieldData::FillData> fields = MinimalFormFieldDataForFilling(); const std::u16string& field_value = fields[0].value; @@ -1061,8 +1059,6 @@ // Tests that if there is an unknown field id in the results, the agent isn't // notified. TEST_F(AutofillAgentTests, FillData_UnknowFieldIdInResults) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - std::vector<autofill::FormFieldData::FillData> fields = MinimalFormFieldDataForFilling(); const FieldRendererId unknown_field_id = FieldRendererId(101); @@ -1090,8 +1086,6 @@ // Tests selecting an autocomplete suggestion. TEST_F(AutofillAgentTests, DidSelectSuggestion_AutocompleteEntry) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - FormRendererId form_id(1); FieldRendererId field1_id(2); const std::u16string field1_value = u"test-value"; @@ -1140,8 +1134,6 @@ } TEST_F(AutofillAgentTests, DidSelectSuggestion_ClearFormEntry) { - AutofillDriverIOSFactory::CreateForWebState(&fake_web_state_, &client_, nil); - FormRendererId form_id(1); FieldRendererId field1_id(2); FieldRendererId field2_id(3);
diff --git a/components/autofill/ios/browser/autofill_client_ios.h b/components/autofill/ios/browser/autofill_client_ios.h new file mode 100644 index 0000000..0048aea --- /dev/null +++ b/components/autofill/ios/browser/autofill_client_ios.h
@@ -0,0 +1,74 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_IOS_BROWSER_AUTOFILL_CLIENT_IOS_H_ +#define COMPONENTS_AUTOFILL_IOS_BROWSER_AUTOFILL_CLIENT_IOS_H_ + +#import "base/memory/raw_ptr.h" +#import "components/autofill/core/browser/foundations/autofill_client.h" +#import "components/autofill/ios/browser/autofill_driver_ios_factory.h" +#import "ios/web/public/web_state.h" + +namespace autofill { + +// Common base class for all AutofillClients on iOS. +// +// There must be at most one instance per web::WebState. Generally, +// AutofillClientIOS should be owned (perhaps indirectly) by a +// web::WebStateUserData object. +class AutofillClientIOS : public AutofillClient { + public: + // A function pointer rather than a base::RepeatingCallback to facilitate + // insertion into a set. + using FromWebStateImpl = AutofillClientIOS* (*)(web::WebState*); + + // Returns the `AutofillClientIOS` that is associated with `web_state`, if any + // exists. + static AutofillClientIOS* FromWebState(web::WebState* web_state); + + // At most one `AutofillClientIOS` may exist per `web_state` at any point in + // time. + // + // Callers must guarantee that after construction of an + // `AutofillClientIOS(from_web_state_impl, web_state, bridge)`, + // `from_web_state_impl(web_state)` returns a pointer to this + // AutofillClientIOS. + // If and when that is the case, `FromWebState(web_state)` returns the + // AutofillClientIOS. + // + // Typically, `from_web_state_impl` is identical for all instances of a + // specific subclass of AutofillClientIOS. + // + // For example, ChromeAutofillClientIOS is owned by AutofillTabHelper, which + // is WebStateUserData. Therefore, all ChromeAutofillClientIOS instances pass + // a pointer to the function calls AutofillTabHelper::FromWebContents() and + // then returns the AutofillTabHelper's AutofillClientIOS. + // Similarly for WebAutofillClientIOS and other implementations. + AutofillClientIOS(FromWebStateImpl from_web_state_impl, + web::WebState* web_state, + id<AutofillDriverIOSBridge> bridge); + AutofillClientIOS(const AutofillClientIOS&) = delete; + AutofillClientIOS& operator=(const AutofillClientIOS&) = delete; + ~AutofillClientIOS() override; + + web::WebState* web_state() const { return web_state_.get(); } + + // Intentionally final to allow it to be called during construction (in + // particular, transitively by members of subclasses). + AutofillDriverIOSFactory& GetAutofillDriverFactory() final; + + private: + // Currently, this dangles at the time of ~AutofillClientIOS() because + // ~WebState() has already run at the time. + // TODO(crbug.com/380442588): Change to WeakPtr and define the contract. Also + // explain how and why the destruction order works in production code in + // Chrome and WebView. + raw_ptr<web::WebState> web_state_; + + AutofillDriverIOSFactory autofill_driver_factory_; +}; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_IOS_BROWSER_AUTOFILL_CLIENT_IOS_H_
diff --git a/components/autofill/ios/browser/autofill_client_ios.mm b/components/autofill/ios/browser/autofill_client_ios.mm new file mode 100644 index 0000000..a6f4a26e --- /dev/null +++ b/components/autofill/ios/browser/autofill_client_ios.mm
@@ -0,0 +1,46 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "components/autofill/ios/browser/autofill_client_ios.h" + +#import "base/containers/flat_set.h" +#import "base/no_destructor.h" + +namespace autofill { + +namespace { + +base::flat_set<AutofillClientIOS::FromWebStateImpl>& GetFromWebStateImpls() { + static base::NoDestructor<base::flat_set<AutofillClientIOS::FromWebStateImpl>> + g_from_web_state_impls; + return *g_from_web_state_impls; +} + +} // namespace + +// static +AutofillClientIOS* AutofillClientIOS::FromWebState(web::WebState* web_state) { + for (FromWebStateImpl from_web_state_impl : GetFromWebStateImpls()) { + if (AutofillClientIOS* client = from_web_state_impl(web_state)) { + return client; + } + } + return nullptr; +} + +AutofillClientIOS::AutofillClientIOS(FromWebStateImpl from_web_state_impl, + web::WebState* web_state, + id<AutofillDriverIOSBridge> bridge) + : web_state_(web_state), autofill_driver_factory_(web_state, this, bridge) { + CHECK(from_web_state_impl); + GetFromWebStateImpls().insert(from_web_state_impl); +} + +AutofillClientIOS::~AutofillClientIOS() = default; + +AutofillDriverIOSFactory& AutofillClientIOS::GetAutofillDriverFactory() { + return autofill_driver_factory_; +} + +} // namespace autofill
diff --git a/components/autofill/ios/browser/autofill_driver_ios.mm b/components/autofill/ios/browser/autofill_driver_ios.mm index 1bbf2d52..6f4c45e 100644 --- a/components/autofill/ios/browser/autofill_driver_ios.mm +++ b/components/autofill/ios/browser/autofill_driver_ios.mm
@@ -22,6 +22,7 @@ #import "components/autofill/core/common/field_data_manager.h" #import "components/autofill/core/common/mojom/autofill_types.mojom-shared.h" #import "components/autofill/core/common/unique_ids.h" +#import "components/autofill/ios/browser/autofill_client_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_bridge.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_java_script_feature.h" @@ -69,8 +70,10 @@ AutofillDriverIOS* AutofillDriverIOS::FromWebStateAndWebFrame( web::WebState* web_state, web::WebFrame* web_frame) { - return AutofillDriverIOSFactory::FromWebState(web_state)->DriverForFrame( - web_frame); + if (AutofillClientIOS* client = AutofillClientIOS::FromWebState(web_state)) { + return client->GetAutofillDriverFactory().DriverForFrame(web_frame); + } + return nullptr; } // static
diff --git a/components/autofill/ios/browser/autofill_driver_ios_factory.h b/components/autofill/ios/browser/autofill_driver_ios_factory.h index b51fb0a7..8ec5ec2 100644 --- a/components/autofill/ios/browser/autofill_driver_ios_factory.h +++ b/components/autofill/ios/browser/autofill_driver_ios_factory.h
@@ -10,14 +10,12 @@ #import <string> #import "base/memory/raw_ptr.h" -#import "base/types/pass_key.h" #import "components/autofill/core/browser/foundations/autofill_client.h" #import "components/autofill/core/browser/foundations/autofill_driver_factory.h" #import "components/autofill/core/browser/foundations/autofill_driver_router.h" #import "components/autofill/ios/browser/autofill_driver_ios_bridge.h" #import "ios/web/public/js_messaging/web_frames_manager.h" #import "ios/web/public/web_state_observer.h" -#import "ios/web/public/web_state_user_data.h" namespace web { class WebFrame; @@ -28,12 +26,13 @@ class AutofillDriverIOS; -// This factory will keep the parameters needed to create an AutofillDriverIOS. -// These parameters only depend on the web_state, so there is one -// AutofillDriverIOSFactory per WebState. +// Creates one AutofillDriverIOS per web::WebState and manages its lifecycle +// corresponding to the web::WebState's lifecycle. +// +// Owned by AutofillClientIOS, therefore there is one AutofillDriverIOSFactory +// per web::WebState. class AutofillDriverIOSFactory final : public AutofillDriverFactory, - public web::WebStateUserData<AutofillDriverIOSFactory>, public web::WebStateObserver, public web::WebFramesManager::Observer { public: @@ -62,6 +61,10 @@ LifecycleState new_state) final; }; + AutofillDriverIOSFactory(web::WebState* web_state, + AutofillClient* client, + id<AutofillDriverIOSBridge> bridge); + ~AutofillDriverIOSFactory() override; // Returns the AutofillDriverIOS for `web_frame`. Creates the driver if @@ -71,15 +74,8 @@ AutofillDriverRouter& router() { return router_; } private: - friend class web::WebStateUserData<AutofillDriverIOSFactory>; friend class AutofillDriverIOSFactoryTestApi; - // Creates a AutofillDriverIOSFactory that will store all the - // needed to create a AutofillDriverIOS. - AutofillDriverIOSFactory(web::WebState* web_state, - AutofillClient* client, - id<AutofillDriverIOSBridge> bridge); - void TearDown(); // web::WebStateObserver: @@ -121,8 +117,6 @@ // The maximum number of coexisting drivers over the lifetime of this factory. // TODO: crbug.com/365097975 - Remove the counter and the metric. size_t max_drivers_ = 0; - - WEB_STATE_USER_DATA_KEY_DECL(); }; } // namespace autofill
diff --git a/components/autofill/ios/browser/autofill_driver_ios_factory.mm b/components/autofill/ios/browser/autofill_driver_ios_factory.mm index d62d0ddc..d96f152 100644 --- a/components/autofill/ios/browser/autofill_driver_ios_factory.mm +++ b/components/autofill/ios/browser/autofill_driver_ios_factory.mm
@@ -11,6 +11,7 @@ #import "base/metrics/histogram_functions.h" #import "components/autofill/ios/browser/autofill_driver_ios.h" #import "components/autofill/ios/browser/autofill_java_script_feature.h" +#import "ios/web/public/web_state.h" namespace autofill { @@ -138,6 +139,4 @@ return driver.get(); } -WEB_STATE_USER_DATA_KEY_IMPL(AutofillDriverIOSFactory) - } // namespace autofill
diff --git a/components/autofill/ios/browser/autofill_driver_ios_factory_unittest.mm b/components/autofill/ios/browser/autofill_driver_ios_factory_unittest.mm index 1c6e1deb..64fcd51 100644 --- a/components/autofill/ios/browser/autofill_driver_ios_factory_unittest.mm +++ b/components/autofill/ios/browser/autofill_driver_ios_factory_unittest.mm
@@ -6,7 +6,6 @@ #import <memory> -#import "components/autofill/core/browser/foundations/test_autofill_client.h" #import "components/autofill/core/common/autofill_test_utils.h" #import "components/autofill/core/common/test_matchers.h" #import "components/autofill/ios/browser/autofill_driver_ios.h" @@ -14,6 +13,7 @@ #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory_test_api.h" #import "components/autofill/ios/browser/autofill_java_script_feature.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "ios/web/public/test/fakes/fake_browser_state.h" #import "ios/web/public/test/fakes/fake_web_frame.h" #import "ios/web/public/test/fakes/fake_web_frames_manager.h" @@ -106,8 +106,7 @@ web_state_.SetContentIsHTML(true); web_state_.SetBrowserState(GetBrowserState()); web_frames_manager().AddObserver(&pre_factory_); - ASSERT_FALSE(AutofillDriverIOSFactory::FromWebState(&web_state_)); - AutofillDriverIOSFactory::CreateForWebState(&web_state_, &client_, nil); + client_ = std::make_unique<TestAutofillClientIOS>(&web_state_, nil); factory().AddObserver(&factory_observer_); web_frames_manager().AddObserver(&post_factory_); } @@ -144,7 +143,7 @@ } AutofillDriverIOSFactory& factory() { - return *AutofillDriverIOSFactory::FromWebState(&web_state_); + return client_->GetAutofillDriverFactory(); } MockWebFramesManagerObserver& pre_factory() { return pre_factory_; } @@ -169,7 +168,7 @@ MockWebFramesManagerObserver pre_factory_; MockWebFramesManagerObserver post_factory_; MockAutofillDriverIOSFactoryObserver factory_observer_; - TestAutofillClient client_; + std::unique_ptr<TestAutofillClientIOS> client_; web::FakeWebState web_state_; };
diff --git a/components/autofill/ios/browser/autofill_xhr_sumission_detection_unittest.mm b/components/autofill/ios/browser/autofill_xhr_sumission_detection_unittest.mm index aef25ad..b27ca69 100644 --- a/components/autofill/ios/browser/autofill_xhr_sumission_detection_unittest.mm +++ b/components/autofill/ios/browser/autofill_xhr_sumission_detection_unittest.mm
@@ -20,6 +20,7 @@ #import "components/autofill/ios/browser/autofill_driver_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_java_script_feature.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/browser/test_autofill_manager_injector.h" #import "components/autofill/ios/common/field_data_manager_factory_ios.h" #import "ios/web/public/test/fakes/fake_web_frame.h" @@ -72,8 +73,8 @@ // Driver factory needs to exist before any call to // `AutofillDriverIOS::FromWebStateAndWebFrame`, or we crash. - autofill::AutofillDriverIOSFactory::CreateForWebState( - &web_state_, &autofill_client_, /*bridge=*/nil); + autofill_client_ = + std::make_unique<TestAutofillClientIOS>(&web_state_, /*bridge=*/nil); // Replace AutofillManager with the test implementation. autofill_manager_injector_ = @@ -100,7 +101,7 @@ } base::test::TaskEnvironment task_environment_; - autofill::TestAutofillClient autofill_client_; + std::unique_ptr<TestAutofillClientIOS> autofill_client_; web::FakeWebState web_state_; raw_ptr<web::FakeWebFramesManager> web_frames_manager_; std::unique_ptr<TestAutofillManagerInjector<TestingAutofillManager>>
diff --git a/components/autofill/ios/browser/test_autofill_client_ios.h b/components/autofill/ios/browser/test_autofill_client_ios.h new file mode 100644 index 0000000..2025d58 --- /dev/null +++ b/components/autofill/ios/browser/test_autofill_client_ios.h
@@ -0,0 +1,57 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_IOS_BROWSER_TEST_AUTOFILL_CLIENT_IOS_H_ +#define COMPONENTS_AUTOFILL_IOS_BROWSER_TEST_AUTOFILL_CLIENT_IOS_H_ + +#import "components/autofill/core/browser/foundations/test_autofill_client.h" +#import "components/autofill/ios/browser/autofill_client_ios.h" + +namespace web { +class WebState; +} + +namespace autofill { + +// Helper functions for WithFakedFromWebState(). +AutofillClientIOS* FakeFromWebState(web::WebState* web_state); +void AddToFakeWebStateRegistry(AutofillClientIOS* client); +void RemoveFromFakeWebStateRegistry(AutofillClientIOS* client); + +// Mixin that registers `T` with a test-only registry so that +// AutofillClientIOS::FromWebState() finds `T`. +template <typename T> + requires(std::derived_from<T, AutofillClientIOS>) +class WithFakedFromWebState : public T { + public: + template <typename... Args> + explicit WithFakedFromWebState(Args&&... args) + : T(&FakeFromWebState, std::forward<Args>(args)...) { + AddToFakeWebStateRegistry(this); + } + + ~WithFakedFromWebState() override { + // In production code, the destruction order of WebState and WebState is + // complicated and counterintuitive, but guarantees that WebStateDestroyed() + // is fired before AutofillClientIOS is destroyed. + // + // This is important so that all AutofillDriverIOS (and their + // AutofillManagers) are destroyed *before* the AutofillClient is destroyed. + // + // The following line approximates the production code's behavior and + // guarantees that all AutofillDriverIOS are destroyed before the destructor + // of `T` is called. + static_cast<web::WebStateObserver&>(T::GetAutofillDriverFactory()) + .WebStateDestroyed(AutofillClientIOS::web_state()); + RemoveFromFakeWebStateRegistry(this); + } +}; + +// A variant of TestAutofillClient that is be associated with a web::WebState. +using TestAutofillClientIOS = + WithFakedFromWebState<TestAutofillClientTemplate<AutofillClientIOS>>; + +} // namespace autofill + +#endif // COMPONENTS_AUTOFILL_IOS_BROWSER_TEST_AUTOFILL_CLIENT_IOS_H_
diff --git a/components/autofill/ios/browser/test_autofill_client_ios.mm b/components/autofill/ios/browser/test_autofill_client_ios.mm new file mode 100644 index 0000000..effbb6e --- /dev/null +++ b/components/autofill/ios/browser/test_autofill_client_ios.mm
@@ -0,0 +1,33 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "components/autofill/ios/browser/test_autofill_client_ios.h" + +#import "base/containers/flat_map.h" +#import "base/no_destructor.h" +#import "ios/web/public/web_state.h" + +namespace autofill { + +namespace { +base::flat_map<web::WebState*, AutofillClientIOS*>& GetDriverRegistry() { + static base::NoDestructor<base::flat_map<web::WebState*, AutofillClientIOS*>> + g_web_state_to_driver; + return *g_web_state_to_driver; +} +} // namespace + +AutofillClientIOS* FakeFromWebState(web::WebState* web_state) { + return GetDriverRegistry()[web_state]; +} + +void AddToFakeWebStateRegistry(AutofillClientIOS* client) { + GetDriverRegistry()[client->web_state()] = client; +} + +void RemoveFromFakeWebStateRegistry(AutofillClientIOS* client) { + GetDriverRegistry()[client->web_state()] = nullptr; +} + +} // namespace autofill
diff --git a/components/autofill/ios/browser/test_autofill_manager_injector.h b/components/autofill/ios/browser/test_autofill_manager_injector.h index fd916e2..bc3e894 100644 --- a/components/autofill/ios/browser/test_autofill_manager_injector.h +++ b/components/autofill/ios/browser/test_autofill_manager_injector.h
@@ -15,6 +15,7 @@ #import "components/autofill/core/browser/foundations/autofill_driver_test_api.h" #import "components/autofill/core/browser/foundations/autofill_manager_test_api.h" #import "components/autofill/core/browser/foundations/browser_autofill_manager.h" +#import "components/autofill/ios/browser/autofill_client_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_driver_ios_test_api.h" @@ -47,8 +48,10 @@ class TestAutofillManagerInjector : public AutofillDriverIOSFactory::Observer { public: explicit TestAutofillManagerInjector(web::WebState* web_state) - : web_state_(web_state), - factory_(AutofillDriverIOSFactory::FromWebState(web_state)) { + : web_state_(web_state) { + AutofillClientIOS& client = + CHECK_DEREF(AutofillClientIOS::FromWebState(web_state)); + factory_ = &(client.GetAutofillDriverFactory()); test_api(*factory_).AddObserverAtIndex(this, 0); web::WebFramesManager& frames_manager = CHECK_DEREF(
diff --git a/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java b/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java index 87bfa0a..c7a8781 100644 --- a/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java +++ b/components/browser_ui/contacts_picker/android/java/src/org/chromium/components/browser_ui/contacts_picker/ContactsPickerDialogTest.java
@@ -30,13 +30,13 @@ import org.mockito.Mock; import org.mockito.Mockito; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.BaseActivityTestRule; import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.util.Batch; import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.Feature; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.blink.mojom.ContactIconBlob; import org.chromium.components.browser_ui.contacts_picker.test.R; import org.chromium.components.browser_ui.widget.RecyclerViewTestUtils; @@ -59,12 +59,12 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; /** Tests for the ContactsPickerDialog class. */ @RunWith(BaseJUnit4ClassRunner.class) @Batch(Batch.PER_CLASS) +@EnableFeatures(ContactsPickerFeatureList.CONTACTS_PICKER_SELECT_ALL) public class ContactsPickerDialogTest implements ContactsPickerListener, SelectionObserver<ContactDetails> { @ClassRule @@ -153,9 +153,6 @@ when(mWebContents.isDestroyed()).thenReturn(false); when(mWebContents.getVisibility()).thenReturn(Visibility.VISIBLE); - FeatureList.setTestFeatures( - Collections.singletonMap( - ContactsPickerFeatureList.CONTACTS_PICKER_SELECT_ALL, true)); mIcon = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mIcon); canvas.drawColor(Color.BLUE);
diff --git a/components/browser_ui/desktop_windowing/android/java/src/org/chromium/components/browser_ui/desktop_windowing/AppHeaderState.java b/components/browser_ui/desktop_windowing/android/java/src/org/chromium/components/browser_ui/desktop_windowing/AppHeaderState.java index 13ec799..6722ad9 100644 --- a/components/browser_ui/desktop_windowing/android/java/src/org/chromium/components/browser_ui/desktop_windowing/AppHeaderState.java +++ b/components/browser_ui/desktop_windowing/android/java/src/org/chromium/components/browser_ui/desktop_windowing/AppHeaderState.java
@@ -93,9 +93,6 @@ /** Return whether the state is valid. */ boolean isValid() { - if (!mIsInDesktopWindow) { - return mWidestUnoccludedRect.isEmpty(); - } return (mAppWindowRect.isEmpty() && mWidestUnoccludedRect.isEmpty()) || mAppWindowRect.contains(mWidestUnoccludedRect); }
diff --git a/components/browsing_topics/browsing_topics_service_impl.cc b/components/browsing_topics/browsing_topics_service_impl.cc index 8db5bef6..75e86d8f 100644 --- a/components/browsing_topics/browsing_topics_service_impl.cc +++ b/components/browsing_topics/browsing_topics_service_impl.cc
@@ -270,7 +270,14 @@ // <iframe src=[url] browsingtopics> request. kObserveViaIframeAttributeApi = 5, - kMaxValue = kObserveViaIframeAttributeApi, + // Get topics via <img src=[url] browsingtopics>. + kGetViaImgAttributeApi = 6, + + // Observe topics via the "Sec-Browsing-Topics: ?1" response header for the + // <img src=[url] browsingtopics> request. + kObserveViaImgAttributeApi = 7, + + kMaxValue = kObserveViaImgAttributeApi, }; void RecordBrowsingTopicsApiActionTypeMetrics(ApiCallerSource caller_source, @@ -314,6 +321,24 @@ return; } + if (caller_source == ApiCallerSource::kImgAttribute) { + if (get_topics) { + DCHECK(!observe); + + base::UmaHistogramEnumeration( + kBrowsingTopicsApiActionTypeHistogramId, + BrowsingTopicsApiActionType::kGetViaImgAttributeApi); + return; + } + + DCHECK(observe); + base::UmaHistogramEnumeration( + kBrowsingTopicsApiActionTypeHistogramId, + BrowsingTopicsApiActionType::kObserveViaImgAttributeApi); + + return; + } + DCHECK_EQ(caller_source, ApiCallerSource::kFetch); if (get_topics) {
diff --git a/components/browsing_topics/common/common_types.h b/components/browsing_topics/common/common_types.h index c7f373e..dbfe3d33e 100644 --- a/components/browsing_topics/common/common_types.h +++ b/components/browsing_topics/common/common_types.h
@@ -40,6 +40,9 @@ // The API usage is from <iframe src=[url] browsingtopics>. kIframeAttribute, + + // The API usage is from <img src=[url] browsingtopics>. + kImgAttribute, }; // Represents the different reasons why the topics API access is denied. These
diff --git a/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlagUnitTest.java b/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlagUnitTest.java index 6e03341f..7824076 100644 --- a/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlagUnitTest.java +++ b/components/cached_flags/android/java/src/org/chromium/components/cached_flags/CachedFlagUnitTest.java
@@ -130,7 +130,7 @@ CachedFlag featureB = new CachedFlag(mFeatureMap, FEATURE_B, true); // Force different values - FeatureList.setTestFeatures(A_ON_B_OFF); + FeatureList.setTestValues(A_ON_B_OFF); // Verify that the forced value is returned. assertIsEnabledMatches(A_ON_B_OFF, featureA, featureB);
diff --git a/components/collaboration/internal/BUILD.gn b/components/collaboration/internal/BUILD.gn index 4c286cc..4a4e51e 100644 --- a/components/collaboration/internal/BUILD.gn +++ b/components/collaboration/internal/BUILD.gn
@@ -52,8 +52,10 @@ deps += [ ":core_jni_headers", + "//components/collaboration/public:conversion_utils", "//components/collaboration/public:core_jni_headers", "//components/data_sharing/public:android_utils", + "//components/saved_tab_groups/public:conversion_utils", ] } } @@ -100,8 +102,10 @@ "//components/collaboration/public:messaging_public", "//components/data_sharing/public", "//components/saved_tab_groups/public", + "//components/strings", "//components/url_formatter", "//google_apis", + "//ui/base", ] if (is_android) { @@ -228,6 +232,7 @@ "//components/collaboration/public:java", "//components/data_sharing/public:public_java", "//third_party/jni_zero:jni_zero_java", + "//url:url_java", ] }
diff --git a/components/collaboration/internal/android/collaboration_service_android.cc b/components/collaboration/internal/android/collaboration_service_android.cc index 49e72cf..ceef0f68 100644 --- a/components/collaboration/internal/android/collaboration_service_android.cc +++ b/components/collaboration/internal/android/collaboration_service_android.cc
@@ -9,8 +9,12 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "components/collaboration/internal/core_jni_headers/CollaborationServiceImpl_jni.h" +#include "components/collaboration/public/android/conversion_utils.h" +#include "components/collaboration/public/collaboration_controller_delegate.h" #include "components/collaboration/public/collaboration_service.h" #include "components/data_sharing/public/android/conversion_utils.h" +#include "components/saved_tab_groups/public/android/tab_group_sync_conversions_bridge.h" +#include "url/android/gurl_android.h" // Must come after all headers that specialize FromJniType() / ToJniType(). #include "components/collaboration/public/core_jni_headers/ServiceStatus_jni.h" @@ -70,6 +74,28 @@ return collaboration_service_->IsEmptyService(); } +void CollaborationServiceAndroid::StartJoinFlow( + JNIEnv* env, + jlong delegateNativePtr, + const JavaParamRef<jobject>& j_url) { + collaboration_service_->StartJoinFlow( + conversion::GetDelegateUniquePtrFromJava(delegateNativePtr), + url::GURLAndroid::ToNativeGURL(env, j_url)); +} + +void CollaborationServiceAndroid::StartShareOrManageFlow( + JNIEnv* env, + jlong delegateNativePtr, + const JavaParamRef<jstring>& j_sync_group_id) { + std::string sync_group_id_str = + base::android::ConvertJavaStringToUTF8(env, j_sync_group_id); + tab_groups::EitherGroupID either_id = + base::Uuid::ParseLowercase(sync_group_id_str); + + collaboration_service_->StartShareOrManageFlow( + conversion::GetDelegateUniquePtrFromJava(delegateNativePtr), either_id); +} + ScopedJavaLocalRef<jobject> CollaborationServiceAndroid::GetServiceStatus( JNIEnv* env) { ServiceStatus status = collaboration_service_->GetServiceStatus();
diff --git a/components/collaboration/internal/android/collaboration_service_android.h b/components/collaboration/internal/android/collaboration_service_android.h index c9f263c..09c4adf 100644 --- a/components/collaboration/internal/android/collaboration_service_android.h +++ b/components/collaboration/internal/android/collaboration_service_android.h
@@ -23,6 +23,13 @@ // CollaborationService Java API methods, implemented by native service: bool IsEmptyService(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_caller); + void StartJoinFlow(JNIEnv* env, + jlong delegate, + const base::android::JavaParamRef<jobject>& j_url); + void StartShareOrManageFlow( + JNIEnv* env, + jlong delegate, + const base::android::JavaParamRef<jstring>& j_sync_group_id); base::android::ScopedJavaLocalRef<jobject> GetServiceStatus(JNIEnv* env); jint GetCurrentUserRoleForGroup( JNIEnv* env,
diff --git a/components/collaboration/internal/android/java/src/org/chromium/components/collaboration/CollaborationServiceImpl.java b/components/collaboration/internal/android/java/src/org/chromium/components/collaboration/CollaborationServiceImpl.java index 3a23e62f..c5f8958 100644 --- a/components/collaboration/internal/android/java/src/org/chromium/components/collaboration/CollaborationServiceImpl.java +++ b/components/collaboration/internal/android/java/src/org/chromium/components/collaboration/CollaborationServiceImpl.java
@@ -10,6 +10,7 @@ import org.chromium.components.data_sharing.GroupData; import org.chromium.components.data_sharing.member_role.MemberRole; +import org.chromium.url.GURL; /** * Java side of the JNI bridge between CollaborationServiceImpl in Java and C++. All method calls @@ -34,6 +35,17 @@ } @Override + public void startJoinFlow(CollaborationControllerDelegate delegate, GURL url) { + CollaborationServiceImplJni.get().startJoinFlow(mNativePtr, delegate.getNativePtr(), url); + } + + @Override + public void startShareOrManageFlow(CollaborationControllerDelegate delegate, String syncId) { + CollaborationServiceImplJni.get() + .startShareOrManageFlow(mNativePtr, delegate.getNativePtr(), syncId); + } + + @Override public ServiceStatus getServiceStatus() { return CollaborationServiceImplJni.get().getServiceStatus(mNativePtr); } @@ -59,6 +71,12 @@ boolean isEmptyService( long nativeCollaborationServiceAndroid, CollaborationServiceImpl caller); + void startJoinFlow( + long nativeCollaborationServiceAndroid, long delegateNativePtr, GURL url); + + void startShareOrManageFlow( + long nativeCollaborationServiceAndroid, long delegateNativePtr, String syncId); + ServiceStatus getServiceStatus(long nativeCollaborationServiceAndroid); int getCurrentUserRoleForGroup(
diff --git a/components/collaboration/internal/messaging/DEPS b/components/collaboration/internal/messaging/DEPS index 628470a..b3c6d1a6 100644 --- a/components/collaboration/internal/messaging/DEPS +++ b/components/collaboration/internal/messaging/DEPS
@@ -1,5 +1,7 @@ include_rules = [ + "+components/strings/grit/components_strings.h", "+components/tab_groups", "+components/url_formatter", "+google_apis/gaia/gaia_id.h", + "+ui/base/l10n", ]
diff --git a/components/collaboration/internal/messaging/messaging_backend_service_impl.cc b/components/collaboration/internal/messaging/messaging_backend_service_impl.cc index 1f990b1..809d9e89 100644 --- a/components/collaboration/internal/messaging/messaging_backend_service_impl.cc +++ b/components/collaboration/internal/messaging/messaging_backend_service_impl.cc
@@ -24,7 +24,9 @@ #include "components/data_sharing/public/group_data.h" #include "components/saved_tab_groups/public/saved_tab_group.h" #include "components/saved_tab_groups/public/types.h" +#include "components/strings/grit/components_strings.h" #include "components/url_formatter/elide_url.h" +#include "ui/base/l10n/l10n_util.h" namespace collaboration::messaging { namespace { @@ -860,6 +862,33 @@ return std::nullopt; } +int GetTitleStringRes(CollaborationEvent collaboration_event) { + switch (collaboration_event) { + case CollaborationEvent::TAB_ADDED: + return IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_ADDED; + case CollaborationEvent::TAB_REMOVED: + return IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_REMOVED; + case CollaborationEvent::TAB_UPDATED: + return IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_UPDATED; + case CollaborationEvent::TAB_GROUP_NAME_UPDATED: + return IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_NAME_UPDATED; + case CollaborationEvent::TAB_GROUP_COLOR_UPDATED: + return IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_COLOR_UPDATED; + case CollaborationEvent::COLLABORATION_MEMBER_ADDED: + return IDS_DATA_SHARING_RECENT_ACTIVITY_USER_JOINED_GROUP; + case CollaborationEvent::COLLABORATION_MEMBER_REMOVED: + return IDS_DATA_SHARING_RECENT_ACTIVITY_USER_LEFT_GROUP; + case CollaborationEvent::TAB_GROUP_ADDED: + case CollaborationEvent::TAB_GROUP_REMOVED: + case CollaborationEvent::COLLABORATION_ADDED: + case CollaborationEvent::COLLABORATION_REMOVED: + case CollaborationEvent::UNDEFINED: + CHECK(false) << "No string res for collaboration event " + << static_cast<size_t>(collaboration_event); + } + return 0; +} + std::optional<ActivityLogItem> MessagingBackendServiceImpl::ConvertMessageToActivityLogItem( const collaboration_pb::Message& message) { @@ -884,16 +913,17 @@ GetDisplayNameForUserInGroup(collaboration_group_id, *gaia_id, std::nullopt, message); if (user_name_for_display) { - item.user_display_name = *user_name_for_display; + item.title_text = l10n_util::GetStringFUTF16( + GetTitleStringRes(item.collaboration_event), + base::UTF8ToUTF16(*user_name_for_display)); } } // TODO(crbug.com/380517719): Compare GaiaId with current user in this // profile. - item.user_is_self = false; // By default, we use an empty description. This is special cased below. - item.description = u""; + item.description_text = u""; item.time_delta = base::Time::Now() - base::Time::FromTimeT(message.event_timestamp()); item.action = @@ -920,7 +950,7 @@ GURL url = GURL(*item.activity_metadata.tab_metadata->last_known_url); item.activity_metadata.triggering_user = group_member; - item.description = + item.description_text = url_formatter::FormatUrlForDisplayOmitSchemePathAndTrivialSubdomains( url); @@ -935,7 +965,7 @@ // Only tab group name changes have specialized description. if (message.event_type() == collaboration_pb::TAB_GROUP_NAME_UPDATED) { if (item.activity_metadata.tab_group_metadata->last_known_title) { - item.description = base::UTF8ToUTF16( + item.description_text = base::UTF8ToUTF16( *item.activity_metadata.tab_group_metadata->last_known_title); } } @@ -945,7 +975,7 @@ case MessageCategory::kCollaboration: item.activity_metadata.affected_user = group_member; if (group_member) { - item.description = base::UTF8ToUTF16(group_member->email); + item.description_text = base::UTF8ToUTF16(group_member->email); } break; default:
diff --git a/components/collaboration/internal/messaging/messaging_backend_service_impl_unittest.cc b/components/collaboration/internal/messaging/messaging_backend_service_impl_unittest.cc index 842ee14..c35d21f4 100644 --- a/components/collaboration/internal/messaging/messaging_backend_service_impl_unittest.cc +++ b/components/collaboration/internal/messaging/messaging_backend_service_impl_unittest.cc
@@ -596,11 +596,11 @@ // Use name from DB and no email. This is not intended to happen, because we // should always have the member data, but this tests that we still work // without it. - EXPECT_EQ("gaia_1 name", activity_log[0].user_display_name); - EXPECT_EQ(u"", activity_log[0].description); + EXPECT_EQ(u"gaia_1 name joined the group", activity_log[0].title_text); + EXPECT_EQ(u"", activity_log[0].description_text); // Use name and email from DataSharingService. - EXPECT_EQ("Given Name 2", activity_log[1].user_display_name); - EXPECT_EQ(u"gaia2@gmail.com", activity_log[1].description); + EXPECT_EQ(u"Given Name 2 left the group", activity_log[1].title_text); + EXPECT_EQ(u"gaia2@gmail.com", activity_log[1].description_text); // We should also fill in the MessageAttribution. EXPECT_EQ("gaia2@gmail.com", activity_log[1].activity_metadata.affected_user->email); @@ -718,7 +718,7 @@ ASSERT_EQ(2u, activity_log.size()); EXPECT_EQ(CollaborationEvent::TAB_GROUP_NAME_UPDATED, activity_log[0].collaboration_event); - EXPECT_EQ(tab_group.title(), activity_log[0].description); + EXPECT_EQ(tab_group.title(), activity_log[0].description_text); EXPECT_EQ(CollaborationEvent::TAB_GROUP_COLOR_UPDATED, activity_log[1].collaboration_event); } @@ -1026,8 +1026,8 @@ EXPECT_EQ(CollaborationEvent::TAB_ADDED, activity_log[0].collaboration_event); EXPECT_EQ(tab1->url().spec(), *activity_log[0].activity_metadata.tab_metadata->last_known_url); - EXPECT_EQ(u"example.com", activity_log[0].description); - EXPECT_EQ("Given Name 1", activity_log[0].user_display_name); + EXPECT_EQ(u"example.com", activity_log[0].description_text); + EXPECT_EQ(u"Given Name 1 added a tab", activity_log[0].title_text); EXPECT_EQ("gaia1@gmail.com", activity_log[0].activity_metadata.triggering_user->email); @@ -1036,8 +1036,8 @@ activity_log[1].collaboration_event); EXPECT_EQ(tab2->url().spec(), *activity_log[1].activity_metadata.tab_metadata->last_known_url); - EXPECT_EQ(u"example2.com", activity_log[1].description); - EXPECT_EQ("Given Name 2", activity_log[1].user_display_name); + EXPECT_EQ(u"example2.com", activity_log[1].description_text); + EXPECT_EQ(u"Given Name 2 changed a tab", activity_log[1].title_text); EXPECT_EQ("gaia2@gmail.com", activity_log[1].activity_metadata.triggering_user->email); @@ -1046,8 +1046,8 @@ activity_log[2].collaboration_event); EXPECT_EQ(tab3.url().spec(), *activity_log[2].activity_metadata.tab_metadata->last_known_url); - EXPECT_EQ(u"example3.com", activity_log[2].description); - EXPECT_EQ("Given Name 2", activity_log[2].user_display_name); + EXPECT_EQ(u"example3.com", activity_log[2].description_text); + EXPECT_EQ(u"Given Name 2 removed a tab", activity_log[2].title_text); EXPECT_EQ("gaia2@gmail.com", activity_log[2].activity_metadata.triggering_user->email); }
diff --git a/components/collaboration/public/BUILD.gn b/components/collaboration/public/BUILD.gn index d86a266..6ab003dbe 100644 --- a/components/collaboration/public/BUILD.gn +++ b/components/collaboration/public/BUILD.gn
@@ -95,6 +95,7 @@ "//components/tab_groups:tab_groups_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/jni_zero:jni_zero_java", + "//url:url_java", ] srcjar_deps = [ @@ -170,4 +171,16 @@ "//url:url_java", ] } + + static_library("conversion_utils") { + sources = [ + "android/conversion_utils.cc", + "android/conversion_utils.h", + ] + + deps = [ + ":public", + "//base", + ] + } }
diff --git a/components/collaboration/public/android/conversion_utils.cc b/components/collaboration/public/android/conversion_utils.cc new file mode 100644 index 0000000..39c6b2e --- /dev/null +++ b/components/collaboration/public/android/conversion_utils.cc
@@ -0,0 +1,46 @@ +// Copyright 2025 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/collaboration/public/android/conversion_utils.h" + +#include "base/memory/ptr_util.h" + +namespace collaboration::conversion { + +jlong GetJavaResultCallbackPtr( + CollaborationControllerDelegate::ResultCallback result) { + std::unique_ptr<CollaborationControllerDelegate::ResultCallback> + wrapped_callback = + std::make_unique<CollaborationControllerDelegate::ResultCallback>( + std::move(result)); + CHECK(wrapped_callback.get()); + jlong j_native_ptr = reinterpret_cast<jlong>(wrapped_callback.get()); + wrapped_callback.release(); + + return j_native_ptr; +} + +std::unique_ptr<CollaborationControllerDelegate::ResultCallback> +GetNativeResultCallbackFromJava(jlong callback) { + return base::WrapUnique( + reinterpret_cast<CollaborationControllerDelegate::ResultCallback*>( + callback)); +} + +jlong GetJavaDelegateUniquePtr( + std::unique_ptr<CollaborationControllerDelegate> delegate) { + CollaborationControllerDelegate* delegate_ptr = delegate.get(); + long java_ptr = reinterpret_cast<jlong>(delegate_ptr); + delegate.release(); + + return java_ptr; +} + +std::unique_ptr<CollaborationControllerDelegate> GetDelegateUniquePtrFromJava( + jlong java_ptr) { + return base::WrapUnique( + reinterpret_cast<CollaborationControllerDelegate*>(java_ptr)); +} + +} // namespace collaboration::conversion
diff --git a/components/collaboration/public/android/conversion_utils.h b/components/collaboration/public/android/conversion_utils.h new file mode 100644 index 0000000..72011de --- /dev/null +++ b/components/collaboration/public/android/conversion_utils.h
@@ -0,0 +1,34 @@ +// Copyright 2025 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_COLLABORATION_PUBLIC_ANDROID_CONVERSION_UTILS_H_ +#define COMPONENTS_COLLABORATION_PUBLIC_ANDROID_CONVERSION_UTILS_H_ + +#include "base/android/jni_android.h" +#include "components/collaboration/public/collaboration_controller_delegate.h" + +namespace collaboration::conversion { + +// Converts a CollaborationControllerDelegate::ResultCallback to a Java readable +// long. +jlong GetJavaResultCallbackPtr( + CollaborationControllerDelegate::ResultCallback result); + +// Convers a Java long obtained from GetJavaResultCallbackPtr() back into a +// ResultCallback. +std::unique_ptr<CollaborationControllerDelegate::ResultCallback> +GetNativeResultCallbackFromJava(jlong callback); + +// Converts a unique CollaborationControllerDelegate to a Java readable long. +jlong GetJavaDelegateUniquePtr( + std::unique_ptr<CollaborationControllerDelegate> delegate); + +// Converts a Java long obtained from GetJavaDelegateUniquePtr() back into a +// unique CollaborationControllerDelegate. +std::unique_ptr<CollaborationControllerDelegate> GetDelegateUniquePtrFromJava( + jlong java_ptr); + +} // namespace collaboration::conversion + +#endif // COMPONENTS_COLLABORATION_PUBLIC_ANDROID_CONVERSION_UTILS_H_
diff --git a/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationControllerDelegate.java b/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationControllerDelegate.java index a845e47b..d7227ac 100644 --- a/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationControllerDelegate.java +++ b/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationControllerDelegate.java
@@ -5,4 +5,12 @@ package org.chromium.components.collaboration; /** An interface to manage collaboration flow UI screens. */ -public interface CollaborationControllerDelegate {} +public interface CollaborationControllerDelegate { + /** + * This method is called exactly once, and the service takes ownership of the native and java + * object after this call. + * + * @return The native pointer of the current delegate. + */ + long getNativePtr(); +}
diff --git a/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationService.java b/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationService.java index c8d8acd..f36d6f7 100644 --- a/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationService.java +++ b/components/collaboration/public/android/java/src/org/chromium/components/collaboration/CollaborationService.java
@@ -10,6 +10,7 @@ import org.chromium.components.data_sharing.GroupData; import org.chromium.components.data_sharing.member_role.MemberRole; +import org.chromium.url.GURL; /** * CollaborationService is the core class for managing collaboration group flows. It represents a @@ -26,6 +27,22 @@ @VisibleForTesting boolean isEmptyService(); + /** + * Starts a new collaboration join flow. + * + * @param delegate The delegate to perform action on the Android UI. + * @param url The URL of the join request. + */ + void startJoinFlow(CollaborationControllerDelegate delegate, GURL url); + + /** + * Starts a new collaboration share or manage flow. + * + * @param delegate The delegate to perform action on the Android UI. + * @param either_id The ID to identify a tab group. + */ + void startShareOrManageFlow(CollaborationControllerDelegate delegate, String syncId); + /** Returns the current {@link ServiceStatus} of the service. */ @NonNull ServiceStatus getServiceStatus();
diff --git a/components/collaboration/public/collaboration_service.h b/components/collaboration/public/collaboration_service.h index 7fbcf5b..81d8973d1 100644 --- a/components/collaboration/public/collaboration_service.h +++ b/components/collaboration/public/collaboration_service.h
@@ -70,9 +70,9 @@ std::unique_ptr<CollaborationControllerDelegate> delegate, const GURL& url) = 0; - // Starts a new share flow. This will cancel all existing ongoing join and - // share flows in the same browser instance. - // Note: EitherGroupID is either a local tab group id or a sync id. + // Starts a new share or manage flow. This will cancel all existing ongoing + // flows in the same browser instance. Note: EitherGroupID is either a local + // tab group id or a sync id. virtual void StartShareOrManageFlow( std::unique_ptr<CollaborationControllerDelegate> delegate, const tab_groups::EitherGroupID& either_id) = 0;
diff --git a/components/collaboration_strings.grdp b/components/collaboration_strings.grdp index 127f3f0..ff96f97 100644 --- a/components/collaboration_strings.grdp +++ b/components/collaboration_strings.grdp
@@ -2,12 +2,14 @@ <grit-part> <!-- Data Sharing --> <!-- Error Messages --> - <message name ="IDS_COLLABORATION_SOMETHING_WENT_WRONG_HEADER" desc="The header of the error dialog something went wrong." formatter_data="android_java"> - Something went wrong. - </message> - <message name ="IDS_COLLABORATION_SOMETHING_WENT_WRONG_BODY" desc="The body of of the error dialog something went wrong." formatter_data="android_java"> - There was an error. Try again. - </message> + <if expr="is_android"> + <message name ="IDS_COLLABORATION_SOMETHING_WENT_WRONG_HEADER" desc="The header of the error dialog something went wrong." formatter_data="android_java"> + Something went wrong. + </message> + <message name ="IDS_COLLABORATION_SOMETHING_WENT_WRONG_BODY" desc="The body of of the error dialog something went wrong." formatter_data="android_java"> + There was an error. Try again. + </message> + </if> <!-- Error Messages --> <!-- /Data Sharing --> @@ -16,25 +18,25 @@ You </message> <message name="IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_ADDED" desc="Text on a recent activity bottom sheet row that says user added a tab." formatter_data="android_java"> - <ph name="USER_DISPLAY_NAME">%1$s<ex>User 1</ex></ph> added a tab + <ph name="USER_DISPLAY_NAME">$1<ex>User 1</ex></ph> added a tab </message> <message name="IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_REMOVED" desc="Text on a recent activity bottom sheet row that says user removed a tab." formatter_data="android_java"> - <ph name="USER_DISPLAY_NAME">%1$s<ex>User 1</ex></ph> removed a tab + <ph name="USER_DISPLAY_NAME">$1<ex>User 1</ex></ph> removed a tab </message> <message name="IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_UPDATED" desc="Text on a recent activity bottom sheet row that says user updated a tab." formatter_data="android_java"> - <ph name="USER_DISPLAY_NAME">%1$s<ex>User 1</ex></ph> changed a tab + <ph name="USER_DISPLAY_NAME">$1<ex>User 1</ex></ph> changed a tab </message> <message name="IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_NAME_UPDATED" desc="Text on a recent activity bottom sheet row that says user updated the tab group name." formatter_data="android_java"> - <ph name="USER_DISPLAY_NAME">%1$s<ex>User 1</ex></ph> changed the group name + <ph name="USER_DISPLAY_NAME">$1<ex>User 1</ex></ph> changed the group name </message> <message name="IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_COLOR_UPDATED" desc="Text on a recent activity bottom sheet row that says user updated the tab group color." formatter_data="android_java"> - <ph name="USER_DISPLAY_NAME">%1$s<ex>User 1</ex></ph> changed the group color + <ph name="USER_DISPLAY_NAME">$1<ex>User 1</ex></ph> changed the group color </message> <message name="IDS_DATA_SHARING_RECENT_ACTIVITY_USER_JOINED_GROUP" desc="Text on a recent activity bottom sheet row that says user joined the group." formatter_data="android_java"> - <ph name="USER_DISPLAY_NAME">%1$s<ex>User 1</ex></ph> joined the group + <ph name="USER_DISPLAY_NAME">$1<ex>User 1</ex></ph> joined the group </message> <message name="IDS_DATA_SHARING_RECENT_ACTIVITY_USER_LEFT_GROUP" desc="Text on a recent activity bottom sheet row that says user left the group." formatter_data="android_java"> - <ph name="USER_DISPLAY_NAME">%1$s<ex>User 1</ex></ph> left the group + <ph name="USER_DISPLAY_NAME">$1<ex>User 1</ex></ph> left the group </message> <!-- Recent Activity -->
diff --git a/components/collaboration_strings_grdp/DIR_METADATA b/components/collaboration_strings_grdp/DIR_METADATA new file mode 100644 index 0000000..c9d4fb8b --- /dev/null +++ b/components/collaboration_strings_grdp/DIR_METADATA
@@ -0,0 +1 @@ +mixins: "//components/collaboration/COMMON_METADATA"
diff --git a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_ADDED.png.sha1 b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_ADDED.png.sha1 index 70d4b4b1..c7e1730 100644 --- a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_ADDED.png.sha1 +++ b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_ADDED.png.sha1
@@ -1 +1 @@ -7fd700f84f4130001875f871252e64e658127907 \ No newline at end of file +28da08be68a99eeb2b31fe965589af852d42c81f \ No newline at end of file
diff --git a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_COLOR_UPDATED.png.sha1 b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_COLOR_UPDATED.png.sha1 index 1d9b573..b6017a6 100644 --- a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_COLOR_UPDATED.png.sha1 +++ b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_COLOR_UPDATED.png.sha1
@@ -1 +1 @@ -86b5d306b7fab51bde0da6f8b244890e425dc1c2 \ No newline at end of file +0b228f6921882717770034fe1171740796958df2 \ No newline at end of file
diff --git a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_NAME_UPDATED.png.sha1 b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_NAME_UPDATED.png.sha1 index 1d9b573..b6017a6 100644 --- a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_NAME_UPDATED.png.sha1 +++ b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_GROUP_NAME_UPDATED.png.sha1
@@ -1 +1 @@ -86b5d306b7fab51bde0da6f8b244890e425dc1c2 \ No newline at end of file +0b228f6921882717770034fe1171740796958df2 \ No newline at end of file
diff --git a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_REMOVED.png.sha1 b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_REMOVED.png.sha1 index 70d4b4b1..c7e1730 100644 --- a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_REMOVED.png.sha1 +++ b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_REMOVED.png.sha1
@@ -1 +1 @@ -7fd700f84f4130001875f871252e64e658127907 \ No newline at end of file +28da08be68a99eeb2b31fe965589af852d42c81f \ No newline at end of file
diff --git a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_UPDATED.png.sha1 b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_UPDATED.png.sha1 index 70d4b4b1..c7e1730 100644 --- a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_UPDATED.png.sha1 +++ b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_TAB_UPDATED.png.sha1
@@ -1 +1 @@ -7fd700f84f4130001875f871252e64e658127907 \ No newline at end of file +28da08be68a99eeb2b31fe965589af852d42c81f \ No newline at end of file
diff --git a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_JOINED_GROUP.png.sha1 b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_JOINED_GROUP.png.sha1 index 1d9b573..c7e1730 100644 --- a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_JOINED_GROUP.png.sha1 +++ b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_JOINED_GROUP.png.sha1
@@ -1 +1 @@ -86b5d306b7fab51bde0da6f8b244890e425dc1c2 \ No newline at end of file +28da08be68a99eeb2b31fe965589af852d42c81f \ No newline at end of file
diff --git a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_LEFT_GROUP.png.sha1 b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_LEFT_GROUP.png.sha1 index 1d9b573..b6017a6 100644 --- a/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_LEFT_GROUP.png.sha1 +++ b/components/collaboration_strings_grdp/IDS_DATA_SHARING_RECENT_ACTIVITY_USER_LEFT_GROUP.png.sha1
@@ -1 +1 @@ -86b5d306b7fab51bde0da6f8b244890e425dc1c2 \ No newline at end of file +0b228f6921882717770034fe1171740796958df2 \ No newline at end of file
diff --git a/components/collaboration_strings_grdp/OWNERS b/components/collaboration_strings_grdp/OWNERS new file mode 100644 index 0000000..24b55dd --- /dev/null +++ b/components/collaboration_strings_grdp/OWNERS
@@ -0,0 +1 @@ +file://components/collaboration/OWNERS
diff --git a/components/collaboration_strings_grdp/README.md b/components/collaboration_strings_grdp/README.md new file mode 100644 index 0000000..119d8b9 --- /dev/null +++ b/components/collaboration_strings_grdp/README.md
@@ -0,0 +1,5 @@ +This directory of image SHA-1 hashes is used to improve translations of UI +strings through context images for translators. + +See also: [Chrome Translation Screenshots - Instructions & FAQ +](https://docs.google.com/document/d/1nwYWDny20icMSpLUuV_LgrlbWKrYpbXOERUIZNH636o/edit#heading=h.2t7lc4cxo2au)
diff --git a/components/components_strings.grd b/components/components_strings.grd index 16d9fd9..3f6b44c 100644 --- a/components/components_strings.grd +++ b/components/components_strings.grd
@@ -341,9 +341,9 @@ <part file="user_education_strings.grdp" /> <part file="version_ui_strings.grdp" /> <part file="webapps_strings.grdp" /> + <part file="collaboration_strings.grdp" /> <if expr="is_android"> <part file="android_system_error_page_strings.grdp" /> - <part file="collaboration_strings.grdp" /> <part file="external_intents_strings.grdp" /> <part file="facilitated_payments_strings.grdp" /> </if>
diff --git a/components/data_sharing/internal/data_sharing_service_impl.cc b/components/data_sharing/internal/data_sharing_service_impl.cc index c41c66b..631c5f2 100644 --- a/components/data_sharing/internal/data_sharing_service_impl.cc +++ b/components/data_sharing/internal/data_sharing_service_impl.cc
@@ -179,6 +179,16 @@ DataSharingServiceImpl::GetPossiblyRemovedGroupMember( const GroupId& group_id, const GaiaId& member_gaia_id) { + if (group_data_for_testing_.contains(group_id)) { + CHECK_IS_TEST(); + const auto& group = group_data_for_testing_[group_id]; + for (const auto& member : group.members) { + if (member.gaia_id == member_gaia_id) { + return GroupMemberPartialData::FromGroupMember(member); + } + } + } + if (!group_data_model_) { return std::nullopt; }
diff --git a/components/google/core/common/google_util.cc b/components/google/core/common/google_util.cc index cc05afba..b7252ed 100644 --- a/components/google/core/common/google_util.cc +++ b/components/google/core/common/google_util.cc
@@ -319,9 +319,8 @@ ".ytimg.com", }; const std::string host = url.host(); - for (size_t i = 0; i < std::size(kSuffixesToSetHeadersFor); ++i) { - if (base::EndsWith(host, kSuffixesToSetHeadersFor[i], - base::CompareCase::INSENSITIVE_ASCII)) { + for (auto* i : kSuffixesToSetHeadersFor) { + if (base::EndsWith(host, i, base::CompareCase::INSENSITIVE_ASCII)) { return true; } } @@ -330,8 +329,8 @@ static const char* kHostsToSetHeadersFor[] = { "googleweblight.com", }; - for (size_t i = 0; i < std::size(kHostsToSetHeadersFor); ++i) { - if (base::EqualsCaseInsensitiveASCII(host, kHostsToSetHeadersFor[i])) { + for (auto* i : kHostsToSetHeadersFor) { + if (base::EqualsCaseInsensitiveASCII(host, i)) { return true; } }
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc index fd2d4e27..f562168 100644 --- a/components/history/core/browser/history_backend.cc +++ b/components/history/core/browser/history_backend.cc
@@ -1753,6 +1753,13 @@ return result; } +bool HistoryBackend::GetIsUrlKnownToSync(URLID id, bool* is_known_to_sync) { + if (db_) { + return db_->GetIsUrlKnownToSync(id, is_known_to_sync); + } + return false; +} + bool HistoryBackend::GetForeignVisit(const std::string& originator_cache_guid, VisitID originator_visit_id, VisitRow* visit_row) {
diff --git a/components/history/core/browser/history_backend.h b/components/history/core/browser/history_backend.h index 9225694..e8f87b0 100644 --- a/components/history/core/browser/history_backend.h +++ b/components/history/core/browser/history_backend.h
@@ -663,6 +663,9 @@ QueryURLResult GetMostRecentVisitsForGurl(GURL url, int max_visits); + // Gets whether the URL is known to sync. + bool GetIsUrlKnownToSync(URLID id, bool* is_known_to_sync); + // Searches for a visit with the given `originator_visit_id` coming from // another device (identified by `originator_cache_guid`). If found, returns // true and writes the visit into `visit_row`; otherwise returns false.
diff --git a/components/history/core/browser/history_backend_unittest.cc b/components/history/core/browser/history_backend_unittest.cc index bcf8836..e4cfb10 100644 --- a/components/history/core/browser/history_backend_unittest.cc +++ b/components/history/core/browser/history_backend_unittest.cc
@@ -4865,6 +4865,34 @@ EXPECT_TRUE(added_visit.is_known_to_sync); } +TEST_F(HistoryBackendTest, GetIsUrlKnownToSync) { + // Visit a url multiple times for setup. + GURL url("http://www.google.com"); + std::vector<VisitInfo> visits_info; + visits_info.emplace_back(base::Time::Now() - base::Days(5), + ui::PAGE_TRANSITION_LINK); + visits_info.emplace_back(base::Time::Now() - base::Days(1), + ui::PAGE_TRANSITION_LINK); + visits_info.emplace_back(base::Time::Now(), ui::PAGE_TRANSITION_LINK); + AddVisits(url, visits_info, SOURCE_BROWSED); + + // Get visit and row info from database. + VisitVector visit_vector; + URLRow row; + URLID url_id = backend_->db()->GetRowForURL(url, &row); + ASSERT_TRUE(backend_->db()->GetVisitsForURL(url_id, &visit_vector)); + + // Verify that none of the visits are yet known to sync. + bool is_url_known_to_sync; + ASSERT_TRUE(backend_->GetIsUrlKnownToSync(url_id, &is_url_known_to_sync)); + EXPECT_FALSE(is_url_known_to_sync); + + // Mark the 2nd visit as known to sync and verify. + backend_->MarkVisitAsKnownToSync(visit_vector[1].visit_id); + ASSERT_TRUE(backend_->GetIsUrlKnownToSync(url_id, &is_url_known_to_sync)); + EXPECT_TRUE(is_url_known_to_sync); +} + #if BUILDFLAG(IS_IOS) TEST_F(HistoryBackendTest, UpdateVisitReferrerOpenerIDs_DoesNotDoubleCountVisitInSegments) {
diff --git a/components/history/core/browser/visit_database.cc b/components/history/core/browser/visit_database.cc index 44e834ed..7183fc9 100644 --- a/components/history/core/browser/visit_database.cc +++ b/components/history/core/browser/visit_database.cc
@@ -1194,6 +1194,16 @@ return domain_visits; } +bool VisitDatabase::GetIsUrlKnownToSync(URLID url_id, bool* is_known_to_sync) { + sql::Statement statement( + GetDB().GetCachedStatement(SQL_FROM_HERE, + "SELECT 1 FROM visits " + "WHERE url=? AND is_known_to_sync")); + statement.BindInt64(0, url_id); + *is_known_to_sync = statement.Step(); + return true; +} + bool VisitDatabase::MigrateVisitsWithoutDuration() { if (!GetDB().DoesTableExist("visits")) { NOTREACHED() << " Visits table should exist before migration";
diff --git a/components/history/core/browser/visit_database.h b/components/history/core/browser/visit_database.h index 75dbda30..05ce9d027 100644 --- a/components/history/core/browser/visit_database.h +++ b/components/history/core/browser/visit_database.h
@@ -279,6 +279,10 @@ base::Time begin_time, base::Time end_time); + // Gets whether the URL is known to sync. A URL is considered known to sync + // if there is at least one visit with the URL that is known to sync. + bool GetIsUrlKnownToSync(URLID url_id, bool* is_known_to_sync); + protected: // Returns the database for the functions in this interface. virtual sql::Database& GetDB() = 0;
diff --git a/components/history_embeddings/history_embeddings_service.cc b/components/history_embeddings/history_embeddings_service.cc index f4b8c77b..97d6d6a5 100644 --- a/components/history_embeddings/history_embeddings_service.cc +++ b/components/history_embeddings/history_embeddings_service.cc
@@ -22,6 +22,7 @@ #include "base/timer/elapsed_timer.h" #include "base/token.h" #include "base/uuid.h" +#include "components/history/core/browser/history_backend.h" #include "components/history/core/browser/history_types.h" #include "components/history/core/browser/url_database.h" #include "components/history/core/browser/url_row.h" @@ -95,6 +96,10 @@ // history_embeddings database went out of sync. It's theoretically // possible since operations across separate databases are not atomic. result.scored_url_rows.pop_back(); + } else { + history_backend->GetIsUrlKnownToSync( + result.scored_url_rows.back().row.id(), + &result.scored_url_rows.back().is_url_known_to_sync); } } }
diff --git a/components/history_embeddings/history_embeddings_service.h b/components/history_embeddings/history_embeddings_service.h index 227fd4f..4f517b4 100644 --- a/components/history_embeddings/history_embeddings_service.h +++ b/components/history_embeddings/history_embeddings_service.h
@@ -87,6 +87,7 @@ // Basic scoring and history data for this URL. ScoredUrl scored_url; history::URLRow row; + bool is_url_known_to_sync = false; // All passages and embeddings for this URL (i.e. not a partial set). UrlData passages_embeddings;
diff --git a/components/history_embeddings/history_embeddings_service_unittest.cc b/components/history_embeddings/history_embeddings_service_unittest.cc index b89bea1..d4cc186 100644 --- a/components/history_embeddings/history_embeddings_service_unittest.cc +++ b/components/history_embeddings/history_embeddings_service_unittest.cc
@@ -20,6 +20,8 @@ #include "base/test/test_future.h" #include "base/time/time.h" #include "base/token.h" +#include "components/history/core/browser/history_backend.h" +#include "components/history/core/browser/history_db_task.h" #include "components/history/core/browser/history_service.h" #include "components/history/core/browser/history_types.h" #include "components/history/core/test/history_service_test_util.h" @@ -995,4 +997,87 @@ } } +namespace { + +class AddSyncedVisitTask : public history::HistoryDBTask { + public: + AddSyncedVisitTask(base::RunLoop* run_loop, + const GURL& url, + const history::VisitRow& visit) + : run_loop_(run_loop), url_(url), visit_(visit) {} + + AddSyncedVisitTask(const AddSyncedVisitTask&) = delete; + AddSyncedVisitTask& operator=(const AddSyncedVisitTask&) = delete; + + ~AddSyncedVisitTask() override = default; + + bool RunOnDBThread(history::HistoryBackend* backend, + history::HistoryDatabase* db) override { + history::VisitID visit_id = backend->AddSyncedVisit( + url_, u"Title", /*hidden=*/false, visit_, std::nullopt, std::nullopt); + EXPECT_NE(visit_id, history::kInvalidVisitID); + LOG(ERROR) << "Added visit!"; + return true; + } + + void DoneRunOnMainThread() override { run_loop_->QuitWhenIdle(); } + + private: + raw_ptr<base::RunLoop> run_loop_; + + GURL url_; + history::VisitRow visit_; +}; + +} // namespace + +TEST_F(HistoryEmbeddingsServiceTest, SearchGetsIfUrlIsKnownToSync) { + AddTestHistoryPage("http://not-synced.com"); + AddTestHistoryPage("http://synced.com"); + + // Add a synced visit, as it would be created by HISTORY sync. The API to do + // this isn't exposed in HistoryService (only HistoryBackend). + { + history::VisitRow visit; + visit.visit_time = base::Time::Now() - base::Days(2); + visit.originator_cache_guid = "some_originator"; + visit.transition = ui::PageTransitionFromInt( + ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CHAIN_START | + ui::PAGE_TRANSITION_CHAIN_END); + visit.is_known_to_sync = true; + + base::RunLoop run_loop; + base::CancelableTaskTracker tracker; + history_service_->ScheduleDBTask( + FROM_HERE, + std::make_unique<AddSyncedVisitTask>(&run_loop, + GURL("http://synced.com"), visit), + &tracker); + run_loop.Run(); + } + + OnPassagesEmbeddingsComputed(UrlData(1, 1, base::Time::Now()), + {"test passage 1", "test passage 2"}, + {Embedding(std::vector<float>(768, 1.0f)), + Embedding(std::vector<float>(768, 1.0f))}, + ComputeEmbeddingsStatus::KSuccess); + OnPassagesEmbeddingsComputed(UrlData(2, 2, base::Time::Now()), + {"test passage 1", "test passage 2"}, + {Embedding(std::vector<float>(768, 0.9f)), + Embedding(std::vector<float>(768, 0.9f))}, + ComputeEmbeddingsStatus::KSuccess); + + base::test::TestFuture<SearchResult> future; + OverrideVisibilityScoresForTesting({{"my query", 0.99}}); + service_->Search(nullptr, "my query", {}, 3, /*skip_answering=*/false, + future.GetRepeatingCallback()); + SearchResult result = future.Take(); + + EXPECT_EQ(result.scored_url_rows.size(), 2u); + EXPECT_EQ(result.scored_url_rows[0].scored_url.url_id, 1); + EXPECT_EQ(result.scored_url_rows[0].is_url_known_to_sync, false); + EXPECT_EQ(result.scored_url_rows[1].scored_url.url_id, 2); + EXPECT_EQ(result.scored_url_rows[1].is_url_known_to_sync, true); +} + } // namespace history_embeddings
diff --git a/components/infobars/core/infobar_container.cc b/components/infobars/core/infobar_container.cc index 8d2087d..5db1954 100644 --- a/components/infobars/core/infobar_container.cc +++ b/components/infobars/core/infobar_container.cc
@@ -17,7 +17,7 @@ namespace infobars { -InfoBarContainer::Delegate::~Delegate() {} +InfoBarContainer::Delegate::~Delegate() = default; InfoBarContainer::InfoBarContainer(Delegate* delegate) : delegate_(delegate),
diff --git a/components/infobars/core/infobar_delegate.cc b/components/infobars/core/infobar_delegate.cc index 6d23770..61093a0 100644 --- a/components/infobars/core/infobar_delegate.cc +++ b/components/infobars/core/infobar_delegate.cc
@@ -20,15 +20,14 @@ const int InfoBarDelegate::kNoIconID = 0; -InfoBarDelegate::~InfoBarDelegate() {} +InfoBarDelegate::~InfoBarDelegate() = default; int InfoBarDelegate::GetIconId() const { return kNoIconID; } const gfx::VectorIcon& InfoBarDelegate::GetVectorIcon() const { - static gfx::VectorIcon empty_icon; - return empty_icon; + return gfx::VectorIcon::EmptyIcon(); } ui::ImageModel InfoBarDelegate::GetIcon() const {
diff --git a/components/infobars/core/infobar_manager.cc b/components/infobars/core/infobar_manager.cc index 30d3a5e..82f6f5ea 100644 --- a/components/infobars/core/infobar_manager.cc +++ b/components/infobars/core/infobar_manager.cc
@@ -34,7 +34,7 @@ // InfoBarManager::Observer --------------------------------------------------- -InfoBarManager::Observer::~Observer() {} +InfoBarManager::Observer::~Observer() = default; void InfoBarManager::Observer::OnInfoBarAdded(InfoBar* infobar) {}
diff --git a/components/live_caption/BUILD.gn b/components/live_caption/BUILD.gn index 770625c..58f97ed 100644 --- a/components/live_caption/BUILD.gn +++ b/components/live_caption/BUILD.gn
@@ -85,6 +85,7 @@ "//google_apis:google_apis", "//media", "//media/mojo/mojom", + "//net", "//services/data_decoder/public/cpp:cpp", "//services/data_decoder/public/mojom:mojom", "//services/network/public/cpp",
diff --git a/components/live_caption/DEPS b/components/live_caption/DEPS index 221c6da..21176265 100644 --- a/components/live_caption/DEPS +++ b/components/live_caption/DEPS
@@ -16,6 +16,7 @@ "+media", "+mojo/public", "+net/http/http_request_headers.h", + "+net/base/net_errors.h", "+services/data_decoder/public", "+services/network/public", "+testing/gmock",
diff --git a/components/live_caption/live_translate_controller.cc b/components/live_caption/live_translate_controller.cc index e10b7306..f61f6ce 100644 --- a/components/live_caption/live_translate_controller.cc +++ b/components/live_caption/live_translate_controller.cc
@@ -13,6 +13,7 @@ #include "base/values.h" #include "components/live_caption/pref_names.h" #include "components/live_caption/translation_dispatcher.h" +#include "components/live_caption/translation_util.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_service.h" @@ -51,11 +52,10 @@ speech::kEnglishLocaleNoCountry); } -void LiveTranslateController::GetTranslation( - const std::string& result, - std::string source_language, - std::string target_language, - OnTranslateEventCallback callback) { +void LiveTranslateController::GetTranslation(const std::string& result, + std::string source_language, + std::string target_language, + TranslateEventCallback callback) { translation_dispatcher_->GetTranslation(result, source_language, target_language, std::move(callback)); }
diff --git a/components/live_caption/live_translate_controller.h b/components/live_caption/live_translate_controller.h index f34968d..44aa683 100644 --- a/components/live_caption/live_translate_controller.h +++ b/components/live_caption/live_translate_controller.h
@@ -11,6 +11,7 @@ #include "base/memory/raw_ptr.h" #include "components/keyed_service/core/keyed_service.h" #include "components/live_caption/translation_dispatcher.h" +#include "components/live_caption/translation_util.h" #include "media/mojo/mojom/speech_recognition_result.h" #include "mojo/public/cpp/bindings/remote.h" @@ -27,8 +28,6 @@ namespace captions { -using OnTranslateEventCallback = base::OnceCallback<void(const std::string&)>; - /////////////////////////////////////////////////////////////////////////////// // Live Translate Controller // @@ -49,7 +48,7 @@ virtual void GetTranslation(const std::string& result, std::string source_language, std::string target_language, - OnTranslateEventCallback callback); + TranslateEventCallback callback); private: void OnLiveTranslateEnabledChanged();
diff --git a/components/live_caption/translation_dispatcher.cc b/components/live_caption/translation_dispatcher.cc index 2460441..c6adf15 100644 --- a/components/live_caption/translation_dispatcher.cc +++ b/components/live_caption/translation_dispatcher.cc
@@ -12,17 +12,23 @@ #include "base/json/json_reader.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/metrics_hashes.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" +#include "base/types/expected.h" #include "base/values.h" +#include "components/live_caption/translation_util.h" #include "components/soda/constants.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/storage_partition.h" #include "media/mojo/mojom/speech_recognition_result.h" #include "mojo/public/cpp/bindings/remote.h" +#include "net/base/net_errors.h" #include "net/http/http_request_headers.h" +#include "services/network/public/cpp/header_util.h" #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/mojom/network_context.mojom.h" +#include "services/network/public/mojom/url_response_head.mojom.h" #include "url/gurl.h" namespace captions { @@ -39,6 +45,8 @@ constexpr char kTranslateUrl[] = "https://translation.googleapis.com/language/translate/v2?key=%s"; constexpr char kUploadContentType[] = "application/json"; +constexpr char kHttpErrorMessageTemplate[] = + "Failed to recieve response, got errror: %s"; // Response constants. constexpr char kDataKey[] = "data"; @@ -55,7 +63,7 @@ void TranslationDispatcher::GetTranslation(const std::string& result, std::string source_language, std::string target_language, - OnTranslateEventCallback callback) { + TranslateEventCallback callback) { if (!url_loader_factory_.is_bound() || !url_loader_factory_.is_connected()) { ResetURLLoaderFactory(); } @@ -110,7 +118,6 @@ base::StringPrintf(kTranslateBodyRequestTemplate, result.c_str(), source_language.c_str(), target_language.c_str()), kUploadContentType); - url_loader_->SetAllowHttpErrorResults(true); // Unretained is safe because |this| owns |url_loader_|. url_loader_->DownloadToString( @@ -138,10 +145,34 @@ } void TranslationDispatcher::OnURLLoadComplete( - OnTranslateEventCallback callback, - std::unique_ptr<std::string> response_body) { - if (!response_body) { - LOG(ERROR) << "Error parsing response: reponse body null"; + TranslateEventCallback callback, + std::optional<std::string> response_body) { + // Check that the request succeeded. First with Network Errors... + if (static_cast<net::Error>(url_loader_->NetError()) != net::Error::OK) { + EmitError( + std::move(callback), + base::StringPrintf(kHttpErrorMessageTemplate, + net::ErrorToShortString(url_loader_->NetError()))); + return; + } + + // and then check HTTP errors. + if (url_loader_->ResponseInfo() && url_loader_->ResponseInfo()->headers && + !network::IsSuccessfulStatus( + url_loader_->ResponseInfo()->headers->response_code())) { + EmitError(std::move(callback), + base::StringPrintf( + kHttpErrorMessageTemplate, + base::NumberToString( + url_loader_->ResponseInfo()->headers->response_code()))); + return; + } + + // Somehow the request succeeded but the body is empty. + if (!response_body.has_value()) { + EmitError(std::move(callback), + "Error parsing response: Translation dispatcher recieved a 2XX " + "response, but the body was empty"); return; } @@ -152,45 +183,57 @@ weak_factory_.GetWeakPtr(), std::move(callback))); } +void TranslationDispatcher::EmitError(TranslateEventCallback callback, + const std::string& message) const { + std::move(callback).Run(base::unexpected<std::string>(message)); +} + void TranslationDispatcher::OnResponseJsonParsed( - OnTranslateEventCallback callback, + TranslateEventCallback callback, data_decoder::DataDecoder::ValueOrError result) { - std::string error = [&]() -> std::string { - if (!result.has_value()) { - return "Error parsing response: value null"; - } - - if (!result.value().is_dict()) { - return "Error parsing response: result value is not a dictionary"; - } - - const base::Value::Dict* data_dict = - result.value().GetDict().FindDict(kDataKey); - if (!data_dict) { - return "Error parsing response: dictionary not found"; - } - - const base::Value::List* translations_list = - data_dict->FindList(kTranslationsKey); - if (!translations_list || translations_list->empty()) { - return "Error parsing response: translations not found"; - } - - const base::Value::Dict* translated_text = - (*translations_list)[0].GetIfDict(); - if (!translated_text) { - return "Error parsing response: translated text not found"; - } - - if (const std::string* value = - translated_text->FindString(kTranslatedTextKey)) { - std::move(callback).Run(*value); - } - return std::string(); - }(); - if (!error.empty()) { - LOG(ERROR) << std::move(error); + if (!result.has_value()) { + EmitError(std::move(callback), "Error parsing response: value null"); + return; } + + if (!result.value().is_dict()) { + EmitError(std::move(callback), + "Error parsing response: result value is not a dictionary"); + return; + } + + const base::Value::Dict* data_dict = + result.value().GetDict().FindDict(kDataKey); + if (!data_dict) { + EmitError(std::move(callback), + "Error parsing response: dictionary not found"); + return; + } + + const base::Value::List* translations_list = + data_dict->FindList(kTranslationsKey); + if (!translations_list || translations_list->empty()) { + EmitError(std::move(callback), + "Error parsing response: translations not found"); + return; + } + + const base::Value::Dict* translated_text = + (*translations_list)[0].GetIfDict(); + if (!translated_text) { + EmitError(std::move(callback), + "Error parsing response: translated list entry not found"); + return; + } + + const std::string* value = translated_text->FindString(kTranslatedTextKey); + if (!value) { + EmitError(std::move(callback), + "Error parsing response: translated text not found"); + return; + } + + std::move(callback).Run(TranslateEvent(*value)); } } // namespace captions
diff --git a/components/live_caption/translation_dispatcher.h b/components/live_caption/translation_dispatcher.h index 26d0d92e..10d32a6 100644 --- a/components/live_caption/translation_dispatcher.h +++ b/components/live_caption/translation_dispatcher.h
@@ -10,6 +10,8 @@ #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/types/expected.h" +#include "components/live_caption/translation_util.h" #include "components/soda/constants.h" #include "media/mojo/mojom/speech_recognition_result.h" #include "mojo/public/cpp/bindings/remote.h" @@ -26,8 +28,6 @@ namespace captions { -using OnTranslateEventCallback = base::OnceCallback<void(const std::string&)>; - /////////////////////////////////////////////////////////////////////////////// // Live Translate Dispatcher // @@ -45,16 +45,19 @@ void GetTranslation(const std::string& result, std::string source_language, std::string target_language, - OnTranslateEventCallback callback); + TranslateEventCallback callback); private: void ResetURLLoaderFactory(); - void OnURLLoadComplete(OnTranslateEventCallback callback, - std::unique_ptr<std::string> response_body); + void OnURLLoadComplete(TranslateEventCallback callback, + std::optional<std::string> response_body); + + void EmitError(TranslateEventCallback callback, + const std::string& string) const; // Called when the data decoder service provides parsed JSON data for a server // response. - void OnResponseJsonParsed(OnTranslateEventCallback callback, + void OnResponseJsonParsed(TranslateEventCallback callback, data_decoder::DataDecoder::ValueOrError result); const std::string api_key_;
diff --git a/components/live_caption/translation_util.h b/components/live_caption/translation_util.h index 7e5f69c..2a22f28 100644 --- a/components/live_caption/translation_util.h +++ b/components/live_caption/translation_util.h
@@ -9,8 +9,14 @@ #include <unordered_map> #include <vector> +#include "base/functional/callback.h" +#include "base/types/expected.h" + namespace captions { +using TranslateEvent = base::expected<std::string, std::string>; +using TranslateEventCallback = base::OnceCallback<void(const TranslateEvent&)>; + // Split the transcription into sentences. Spaces are included in the preceding // sentence. std::vector<std::string> SplitSentences(const std::string& text,
diff --git a/components/omnibox/browser/autocomplete_controller.cc b/components/omnibox/browser/autocomplete_controller.cc index ec023580..ebe968f 100644 --- a/components/omnibox/browser/autocomplete_controller.cc +++ b/components/omnibox/browser/autocomplete_controller.cc
@@ -1646,7 +1646,7 @@ // Only add the keyword if the match does not have a duplicate keyword // with a more relevant match. if (!keywords.count(keyword) || - (kIsDesktop && match.type == AutocompleteMatchType::STARTER_PACK)) { + (kIsDesktop && AutocompleteMatch::IsFeaturedSearchType(match.type))) { keywords.insert(keyword); match.associated_keyword = std::make_unique<AutocompleteMatch>( keyword_provider_->CreateVerbatimMatch(match.fill_into_edit, @@ -2490,36 +2490,35 @@ void AutocompleteController::MaybeCleanSuggestionsForKeywordMode( const AutocompleteInput& input, AutocompleteResult* result) { - if (input.current_page_classification() == - metrics::OmniboxEventProto::NTP_REALBOX) { + if (!kIsDesktop || input.current_page_classification() == + metrics::OmniboxEventProto::NTP_REALBOX) { // Realbox doesn't support keyword mode yet, so keep original list intact. return; } - if (kIsDesktop && input.text().starts_with(u'@')) { - // When the input is '@' exactly, some special filtering rules are applied. - // Note: the rule preserving other matches with `associated_keyword` is - // not currently necessary, but is intended to make it easy to coexist - // with enterprise configured scopes when that feature is implemented. - if (input.text() == u"@") { - result->EraseMatchesWhere([](const AutocompleteMatch& match) { - return !(match.type == AutocompleteMatchType::STARTER_PACK || - match.contents == u"@" || match.associated_keyword); - }); - // Simple sort is needed to restore verbatim '@' search as top/default - // match because a different default, e.g. "@hill", might have previously - // occupied the top spot while '@' was demoted below others. - std::sort(result->begin(), result->end(), - AutocompleteMatch::MoreRelevant); - // Put first defaultable match in top position since relevance - // ranking alone doesn't guarantee it. - auto default_match = std::find_if( - result->begin(), result->end(), - [](const auto& m) { return m.allowed_to_be_default_match; }); - if (default_match != result->begin() && default_match != result->end()) { - std::rotate(result->begin(), default_match, default_match + 1); - } - } + if (input.GetFeaturedKeywordMode() == + AutocompleteInput::FeaturedKeywordMode::kExact) { + result->EraseMatchesWhere([](const AutocompleteMatch& match) { + // When the input is '@' exactly, keep only the trivial search, starter + // pack, and featured enterprise suggestions. + return match.contents != u"@" && !match.associated_keyword; + }); + // Simple sort is needed to restore verbatim '@' search as top/default + // match because a different default, e.g. "@hill", might have previously + // occupied the top spot while '@' was demoted below others. + std::sort(result->begin(), result->end(), AutocompleteMatch::MoreRelevant); + // Put first defaultable match in top position since relevance + // ranking alone doesn't guarantee it. + auto default_match = std::find_if( + result->begin(), result->end(), + [](const auto& m) { return m.allowed_to_be_default_match; }); + if (default_match != result->begin() && default_match != result->end()) { + std::rotate(result->begin(), default_match, default_match + 1); + } + } + + if (input.GetFeaturedKeywordMode() != + AutocompleteInput::FeaturedKeywordMode::kFalse) { // Intentionally avoid actions and remove button on first suggestion // which may interfere with keyword mode refresh. if (result->size() > 1 &&
diff --git a/components/omnibox/browser/autocomplete_input.cc b/components/omnibox/browser/autocomplete_input.cc index 6a60fe8a..c65fe91 100644 --- a/components/omnibox/browser/autocomplete_input.cc +++ b/components/omnibox/browser/autocomplete_input.cc
@@ -32,8 +32,8 @@ #include "url/url_util.h" #if BUILDFLAG(IS_CHROMEOS) -#include "chromeos/constants/url_constants.h" // nogncheck -#endif // BUILDFLAG(IS_CHROMEOS) +#include "chromeos/constants/url_constants.h" // nogncheck +#endif // BUILDFLAG(IS_CHROMEOS) namespace { @@ -64,7 +64,7 @@ for (const auto& term : base::SplitString(text, u" ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { const std::string term_utf8(base::UTF16ToUTF8(term)); - static const char* kSchemes[2] = { url::kHttpScheme, url::kHttpsScheme }; + static const char* kSchemes[2] = {url::kHttpScheme, url::kHttpsScheme}; for (const char* scheme : kSchemes) { const std::string prefix(scheme + separator); // Doing an ASCII comparison is okay because prefix is ASCII. @@ -329,8 +329,7 @@ metrics::OmniboxInputType http_type = Parse(http_scheme_prefix + text, desired_tld, scheme_classifier, &http_parts, &http_scheme, &http_canonicalized_url); - DCHECK_EQ(std::string(url::kHttpScheme), - base::UTF16ToUTF8(http_scheme)); + DCHECK_EQ(std::string(url::kHttpScheme), base::UTF16ToUTF8(http_scheme)); if ((http_type == metrics::OmniboxInputType::URL) && http_parts.username.is_nonempty() && @@ -578,9 +577,9 @@ &real_parts, nullptr, nullptr); if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) { if (real_parts.scheme.is_nonempty()) { - *scheme = url::Component( - after_scheme_and_colon + real_parts.scheme.begin, - real_parts.scheme.len); + *scheme = + url::Component(after_scheme_and_colon + real_parts.scheme.begin, + real_parts.scheme.len); } else { scheme->reset(); } @@ -726,6 +725,16 @@ return HasScheme(input, url::kHttpsScheme); } +// static +AutocompleteInput::FeaturedKeywordMode +AutocompleteInput::GetFeaturedKeywordMode(const std::u16string& text) { + if (text == u"@") + return FeaturedKeywordMode::kExact; + if (text.starts_with(u'@')) + return FeaturedKeywordMode::kPrefix; + return FeaturedKeywordMode::kFalse; +} + void AutocompleteInput::UpdateText(const std::u16string& text, size_t cursor_position, const url::Parsed& parts) { @@ -785,3 +794,8 @@ bool AutocompleteInput::InKeywordMode() const { return keyword_mode_entry_method_ != metrics::OmniboxEventProto::INVALID; } + +AutocompleteInput::FeaturedKeywordMode +AutocompleteInput::GetFeaturedKeywordMode() const { + return GetFeaturedKeywordMode(text_); +}
diff --git a/components/omnibox/browser/autocomplete_input.h b/components/omnibox/browser/autocomplete_input.h index 587078a2..e65d4f9 100644 --- a/components/omnibox/browser/autocomplete_input.h +++ b/components/omnibox/browser/autocomplete_input.h
@@ -136,6 +136,14 @@ // Returns whether |text| begins with "https:" or "view-source:https:". static bool HasHTTPSScheme(const std::u16string& text); + // Whether the text might be matching featured keyword suggestions. + enum class FeaturedKeywordMode { + kFalse, // `text_` doesn't start with '@'. + kPrefix, // `text_` starts with '@'. + kExact, // `text_` is exactly '@'. + }; + static FeaturedKeywordMode GetFeaturedKeywordMode(const std::u16string& text); + // User-provided text to be completed. const std::u16string& text() const { return text_; } @@ -324,6 +332,9 @@ // mode. bool InKeywordMode() const; + // Whether the input might be matching featured keyword suggestions. + FeaturedKeywordMode GetFeaturedKeywordMode() const; + private: friend class AutocompleteProviderTest;
diff --git a/components/omnibox/browser/autocomplete_input_unittest.cc b/components/omnibox/browser/autocomplete_input_unittest.cc index 9d545906..97db29dd 100644 --- a/components/omnibox/browser/autocomplete_input_unittest.cc +++ b/components/omnibox/browser/autocomplete_input_unittest.cc
@@ -320,10 +320,8 @@ for (size_t i = 0; i < std::size(input_cases); ++i) { SCOPED_TRACE(input_cases[i].input); Component scheme, host; - AutocompleteInput::ParseForEmphasizeComponents(input_cases[i].input, - TestSchemeClassifier(), - &scheme, - &host); + AutocompleteInput::ParseForEmphasizeComponents( + input_cases[i].input, TestSchemeClassifier(), &scheme, &host); EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); EXPECT_EQ(input_cases[i].scheme.len, scheme.len); EXPECT_EQ(input_cases[i].host.begin, host.begin); @@ -516,3 +514,24 @@ input.typed_url_had_http_scheme()); } } + +TEST(AutocompleteInputTest, GetFeaturedKeywordMode) { + struct TestData { + const std::u16string input; + AutocompleteInput::FeaturedKeywordMode expected_mode; + }; + + const TestData test_cases[] = { + {u"", AutocompleteInput::FeaturedKeywordMode::kFalse}, + {u"@", AutocompleteInput::FeaturedKeywordMode::kExact}, + {u"@x", AutocompleteInput::FeaturedKeywordMode::kPrefix}, + {u"x@", AutocompleteInput::FeaturedKeywordMode::kFalse}, + }; + for (const TestData& test_case : test_cases) { + AutocompleteInput input(test_case.input, std::u16string::npos, + metrics::OmniboxEventProto::OTHER, + TestSchemeClassifier(), + /*should_use_https_as_default_scheme=*/true); + EXPECT_EQ(input.GetFeaturedKeywordMode(), test_case.expected_mode); + } +}
diff --git a/components/omnibox/browser/autocomplete_match.cc b/components/omnibox/browser/autocomplete_match.cc index 79d93e31..a0ba2c7 100644 --- a/components/omnibox/browser/autocomplete_match.cc +++ b/components/omnibox/browser/autocomplete_match.cc
@@ -64,17 +64,6 @@ namespace { -#if (!BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_VR)) && !BUILDFLAG(IS_IOS) -// Used for `SEARCH_SUGGEST_TAIL` and `NULL_RESULT_MESSAGE` (e.g. starter pack) -// type suggestion icons. - -const gfx::VectorIcon& GetEmptyIcon() { - static const gfx::VectorIcon instance; - return instance; -} - -#endif - bool IsTrivialClassification(const ACMatchClassifications& classifications) { return classifications.empty() || ((classifications.size() == 1) && @@ -593,7 +582,7 @@ // Found), fallthrough to use the empty icon. switch (iph_type) { case IphType::kNone: - return GetEmptyIcon(); + return gfx::VectorIcon::EmptyIcon(); case IphType::kGemini: return omnibox::kSparkIcon; case IphType::kFeaturedEnterpriseSearch: @@ -601,7 +590,7 @@ case IphType::kHistoryEmbeddingsSettingsPromo: return omnibox::kSparkIcon; case IphType::kHistoryEmbeddingsDisclaimer: - return GetEmptyIcon(); + return gfx::VectorIcon::EmptyIcon(); case IphType::kHistoryScopePromo: return vector_icons::kHistoryChromeRefreshIcon; case IphType::kHistoryEmbeddingsScopePromo: @@ -610,7 +599,7 @@ case Type::SEARCH_SUGGEST_TAIL: case Type::HISTORY_EMBEDDINGS_ANSWER: - return GetEmptyIcon(); + return gfx::VectorIcon::EmptyIcon(); case Type::DOCUMENT_SUGGESTION: switch (document_type) {
diff --git a/components/omnibox/browser/autocomplete_result.cc b/components/omnibox/browser/autocomplete_result.cc index 9ca6f4b..b995848 100644 --- a/components/omnibox/browser/autocomplete_result.cc +++ b/components/omnibox/browser/autocomplete_result.cc
@@ -124,18 +124,18 @@ omnibox::kMaxZeroSuggestMatches, OmniboxFieldTrial::kMaxZeroSuggestMatchesParam, kDefaultMaxZeroSuggestMatches); - DCHECK(kMaxAutocompletePositionValue > field_trial_value); #if BUILDFLAG(IS_IOS) if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET) { field_trial_value = std::min(field_trial_value, kMaxZeroSuggestMatchesOnIPad); } #endif + DCHECK(kMaxAutocompletePositionValue > field_trial_value); return field_trial_value; } - // Otherwise, i.e. if no zero suggest specific limit has been specified or - // the input is not from omnibox focus, return the general max matches limit. + // Otherwise, i.e. if no zero suggest specific limit has been specified or the + // input is not from omnibox focus, return the general max matches limit. size_t field_trial_value = base::GetFieldTrialParamByFeatureAsInt( omnibox::kUIExperimentMaxAutocompleteMatches, OmniboxFieldTrial::kUIMaxAutocompleteMatchesParam, @@ -376,8 +376,8 @@ MergeSuggestionGroupsMap(omnibox::BuildDefaultGroupsForInput(input)); // Grouping requires all matches have a group ID. To keep providers 'dumb', - // they only assign IDs when their ID isn't obvious from the match type. - // Most matches will instead set IDs here to keep providers 'dumb' and the + // they only assign IDs when their ID isn't obvious from the match type. Most + // matches will instead set IDs here to keep providers 'dumb' and the // type->group mapping consistent between providers. if (use_grouping) { base::ranges::for_each(matches_, [&](auto& match) { @@ -394,9 +394,8 @@ [&](const auto& match) { return match.relevance == 0; }); } - // If at zero suggest or `kGroupingFrameworkForNonZPS` is enabled - // and the current input & platform are supported, delegate to the - // framework. + // If at zero suggest or `kGroupingFrameworkForNonZPS` is enabled and the + // current input & platform are supported, delegate to the framework. if (is_zero_suggest) { PSections sections; if constexpr (is_android) { @@ -614,7 +613,7 @@ // Platform rules: // Mobile: // - First position allow all types of OmniboxActionId (ACTION_IN_SUGGEST and - // ANSWER_ACTION are preferred over PEDAL) + // ANSWER_ACTION are preferred over PEDAL) // - Third slot permits only PEDALs or ANSWER_ACTION. // - Slots 4 and beyond only permit ANSWER_ACTION. // - TAB_SWITCH actions are not considered because they're never attached.
diff --git a/components/omnibox/browser/autocomplete_result.h b/components/omnibox/browser/autocomplete_result.h index 4648d009..fb78459 100644 --- a/components/omnibox/browser/autocomplete_result.h +++ b/components/omnibox/browser/autocomplete_result.h
@@ -434,8 +434,8 @@ void MergeMatchesByProvider(ACMatches* old_matches, const ACMatches& new_matches); - // Returns a tuple encompassing all attributes relevant to determining whether a match should - // be deduplicated with another match. + // Returns a tuple encompassing all attributes relevant to determining whether + // a match should be deduplicated with another match. static MatchDedupComparator GetMatchComparisonFields( const AutocompleteMatch& match);
diff --git a/components/omnibox/browser/featured_search_provider.cc b/components/omnibox/browser/featured_search_provider.cc index 42dcaa4..f351dd2c 100644 --- a/components/omnibox/browser/featured_search_provider.cc +++ b/components/omnibox/browser/featured_search_provider.cc
@@ -154,7 +154,7 @@ AddHistoryEmbeddingsScopePromoIphMatch(); } - if (input.focus_type() != metrics::OmniboxFocusType::INTERACTION_DEFAULT || + if (input.IsZeroSuggest() || (input.type() == metrics::OmniboxInputType::EMPTY)) { return; } @@ -182,12 +182,8 @@ void FeaturedSearchProvider::AddFeaturedKeywordMatches( const AutocompleteInput& input) { - // When the user's input begins with '@', we want to prioritize providing - // suggestions for all active starter pack search engines. - bool starts_with_starter_pack_symbol = base::StartsWith( - input.text(), u"@", base::CompareCase::INSENSITIVE_ASCII); - - if (starts_with_starter_pack_symbol) { + if (input.GetFeaturedKeywordMode() != + AutocompleteInput::FeaturedKeywordMode::kFalse) { TemplateURLService::TemplateURLVector matches; template_url_service_->AddMatchingKeywords(input.text(), false, &matches); for (TemplateURL* match : matches) { @@ -199,7 +195,6 @@ match->starter_pack_id() > TemplateURLStarterPackData::kTabs) { continue; } - AddStarterPackMatch(*match, input); } else if (match->featured_by_policy()) { AddFeaturedEnterpriseSearchMatch(*match, input);
diff --git a/components/omnibox/browser/history_url_provider.cc b/components/omnibox/browser/history_url_provider.cc index 6ae54f1..9ce8d2e 100644 --- a/components/omnibox/browser/history_url_provider.cc +++ b/components/omnibox/browser/history_url_provider.cc
@@ -446,8 +446,10 @@ // likely to be looking for a starer pack scope than a URL. However, // URLs containing '@' before the host, such as '@history.com', area valid // URLs and still needs to run autocompletion. - if (autocomplete_input.text().starts_with('@')) + if (autocomplete_input.GetFeaturedKeywordMode() != + AutocompleteInput::FeaturedKeywordMode::kFalse) { fixup_return.second = u"@" + fixup_return.second; + } url::Parsed parts; url_formatter::SegmentURL(fixup_return.second, &parts);
diff --git a/components/omnibox/browser/omnibox_edit_model.cc b/components/omnibox/browser/omnibox_edit_model.cc index c27bd7f5..5ee0679e 100644 --- a/components/omnibox/browser/omnibox_edit_model.cc +++ b/components/omnibox/browser/omnibox_edit_model.cc
@@ -1272,7 +1272,8 @@ char16_t ch) { #if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) // Only check for acceleration when the current input text is "@" exactly. - if (input_text.size() != 1 || !input_text.starts_with('@') || + if (AutocompleteInput::GetFeaturedKeywordMode(input_text) != + AutocompleteInput::FeaturedKeywordMode::kExact || !history_embeddings::GetFeatureParameters().at_keyword_acceleration) { return false; }
diff --git a/components/page_load_metrics/browser/observers/ad_metrics/ads_page_load_metrics_observer.h b/components/page_load_metrics/browser/observers/ad_metrics/ads_page_load_metrics_observer.h index e338109..2e0bc9a 100644 --- a/components/page_load_metrics/browser/observers/ad_metrics/ads_page_load_metrics_observer.h +++ b/components/page_load_metrics/browser/observers/ad_metrics/ads_page_load_metrics_observer.h
@@ -277,9 +277,7 @@ // Per-frame memory usage by V8 in bytes. Memory data is stored for each frame // on the page during the navigation. - std::unordered_map<content::FrameTreeNodeId, - uint64_t, - content::FrameTreeNodeId::Hasher> + std::unordered_map<content::FrameTreeNodeId, uint64_t> v8_current_memory_usage_map_; // Tracks page-level information for the navigation.
diff --git a/components/password_manager/ios/password_suggestion_helper_unittest.mm b/components/password_manager/ios/password_suggestion_helper_unittest.mm index c6d42219..062baca5 100644 --- a/components/password_manager/ios/password_suggestion_helper_unittest.mm +++ b/components/password_manager/ios/password_suggestion_helper_unittest.mm
@@ -17,6 +17,7 @@ #import "components/autofill/ios/browser/autofill_util.h" #import "components/autofill/ios/browser/form_suggestion.h" #import "components/autofill/ios/browser/form_suggestion_provider_query.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/common/javascript_feature_util.h" #import "components/password_manager/core/browser/features/password_features.h" #import "components/password_manager/core/browser/mock_password_form_cache.h" @@ -92,8 +93,8 @@ ContentWorldForAutofillJavascriptFeatures(); web_state_.SetWebFramesManager(content_world, std::move(frames_manager)); - autofill::AutofillDriverIOSFactory::CreateForWebState( - &web_state_, &autofill_client_, /*autofill_agent=*/nil); + autofill_client_ = std::make_unique<autofill::TestAutofillClientIOS>( + &web_state_, /*bridge=*/nil); IOSPasswordManagerDriverFactory::CreateForWebState(&web_state_, nil, &password_manager_); @@ -147,7 +148,7 @@ web::WebTaskEnvironment task_environment_; autofill::test::AutofillUnitTestEnvironment autofill_test_environment_; - autofill::TestAutofillClient autofill_client_; + std::unique_ptr<autofill::TestAutofillClientIOS> autofill_client_; web::FakeWebState web_state_; id delegate_; PasswordSuggestionHelper* helper_;
diff --git a/components/password_manager/ios/shared_password_controller.mm b/components/password_manager/ios/shared_password_controller.mm index 18b6748..867294b 100644 --- a/components/password_manager/ios/shared_password_controller.mm +++ b/components/password_manager/ios/shared_password_controller.mm
@@ -36,6 +36,7 @@ #import "components/autofill/core/common/password_generation_util.h" #import "components/autofill/core/common/signatures.h" #import "components/autofill/core/common/unique_ids.h" +#import "components/autofill/ios/browser/autofill_client_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_manager_observer_bridge.h" @@ -472,8 +473,11 @@ // form when Autofill across frames is enabled. // Split the browser form into renderer forms. + // The cast is safe: every AutofillClient on iOS is an AutofillClientIOS. const autofill::AutofillDriverRouter& router = - autofill::AutofillDriverIOSFactory::FromWebState(_webState)->router(); + static_cast<autofill::AutofillClientIOS&>(manager.client()) + .GetAutofillDriverFactory() + .router(); std::vector<FormData> renderer_forms = router.GetRendererForms(form_data); // Process predictions for each renderer form.
diff --git a/components/password_manager/ios/shared_password_controller_unittest.mm b/components/password_manager/ios/shared_password_controller_unittest.mm index 9379bbc..9ad0c3c7 100644 --- a/components/password_manager/ios/shared_password_controller_unittest.mm +++ b/components/password_manager/ios/shared_password_controller_unittest.mm
@@ -29,6 +29,7 @@ #import "components/autofill/ios/browser/form_suggestion.h" #import "components/autofill/ios/browser/form_suggestion_provider_query.h" #import "components/autofill/ios/browser/password_autofill_agent.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/browser/test_autofill_manager_injector.h" #import "components/autofill/ios/common/field_data_manager_factory_ios.h" #import "components/autofill/ios/form_util/child_frame_registrar.h" @@ -179,8 +180,8 @@ web_state_.SetWebFramesManager(content_world, std::move(web_frames_manager)); - AutofillDriverIOSFactory::CreateForWebState(&web_state_, &autofill_client_, - /*bridge=*/nil); + autofill_client_ = std::make_unique<autofill::TestAutofillClientIOS>( + &web_state_, /*bridge=*/nil); // The manager injector must be created before creating the controller to // make sure it can exchange the manager before the controller starts // observing it. @@ -242,7 +243,7 @@ base::test::TaskEnvironment task_environment_; autofill::test::AutofillUnitTestEnvironment autofill_test_environment_; - autofill::TestAutofillClient autofill_client_; + std::unique_ptr<autofill::TestAutofillClientIOS> autofill_client_; std::unique_ptr<TestAutofillManagerInjector<TestBrowserAutofillManager>> autofill_manager_injector_; web::FakeWebState web_state_; @@ -1268,8 +1269,8 @@ controller_.delegate = delegate_; - AutofillDriverIOSFactory::CreateForWebState(&web_state_, &autofill_client_, - /*bridge=*/nil); + autofill_client_ = std::make_unique<autofill::TestAutofillClientIOS>( + &web_state_, /*bridge=*/nil); web_state_.SetCurrentURL(GURL(kTestURL)); @@ -1290,7 +1291,7 @@ protected: base::test::TaskEnvironment task_environment_; - autofill::TestAutofillClient autofill_client_; + std::unique_ptr<autofill::TestAutofillClientIOS> autofill_client_; web::FakeWebState web_state_; raw_ptr<web::FakeWebFramesManager> web_frames_manager_; testing::StrictMock<MockPasswordManager> password_manager_;
diff --git a/components/permissions/permission_request_id.h b/components/permissions/permission_request_id.h index 9ad2ce0..661bd4d1 100644 --- a/components/permissions/permission_request_id.h +++ b/components/permissions/permission_request_id.h
@@ -62,10 +62,4 @@ } // namespace permissions -namespace std { -template <> -struct hash<permissions::PermissionRequestID::RequestLocalId> - : public permissions::PermissionRequestID::RequestLocalId::Hasher {}; -} // namespace std - #endif // COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_ID_H_
diff --git a/components/permissions/permissions_client.cc b/components/permissions/permissions_client.cc index 3676a19..01f2b68 100644 --- a/components/permissions/permissions_client.cc +++ b/components/permissions/permissions_client.cc
@@ -11,7 +11,7 @@ #include "content/public/browser/web_contents.h" #if !BUILDFLAG(IS_ANDROID) -#include "ui/gfx/paint_vector_icon.h" +#include "ui/gfx/vector_icon_types.h" #endif namespace permissions { @@ -65,7 +65,7 @@ #if BUILDFLAG(IS_ANDROID) return 0; #else - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); #endif }
diff --git a/components/permissions/request_type.cc b/components/permissions/request_type.cc index 1b7d23b6..314dbfc 100644 --- a/components/permissions/request_type.cc +++ b/components/permissions/request_type.cc
@@ -20,7 +20,6 @@ #else #include "components/permissions/vector_icons/vector_icons.h" #include "components/vector_icons/vector_icons.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" #endif // BUILDFLAG(IS_ANDROID) @@ -167,14 +166,14 @@ return vector_icons::kStorageAccessOffIcon; case RequestType::kIdentityProvider: // TODO(crbug.com/40252825): use a dedicated icon - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); case RequestType::kKeyboardLock: return vector_icons::kKeyboardLockOffIcon; case RequestType::kPointerLock: return vector_icons::kPointerLockOffIcon; case RequestType::kWebAppInstallation: // TODO(crbug.com/333795265): provide a dedicated icon. - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); default: NOTREACHED(); }
diff --git a/components/safe_browsing/content/browser/client_side_detection_service.cc b/components/safe_browsing/content/browser/client_side_detection_service.cc index ffa30946..dc1e7e02 100644 --- a/components/safe_browsing/content/browser/client_side_detection_service.cc +++ b/components/safe_browsing/content/browser/client_side_detection_service.cc
@@ -889,12 +889,16 @@ LogOnDeviceModelExecutionParse(true); - CHECK(session_); - // TODO: Currently, due to the lifetime of session and its deletion when the - // model execution finishes, this causes a crash. crbug.com/384774788 tracks - // the ergonomic approach to deleting the session, but we can call DeleteSoon - // for this session. - // session_.reset(); + // Because of the use of DeleteSoon below, we can't guarantee that session_ + // is still available when the callback is invoked. + if (session_) { + // Reset session immediately so that future inference is not affected by the + // old context. + // TODO(crbug.com/380928557): Call session_.reset() directly once + // crbug.com/384774788 is fixed. + content::GetUIThreadTaskRunner({})->DeleteSoon(FROM_HERE, + std::move(session_)); + } if (inquire_on_device_model_callback_) { std::move(inquire_on_device_model_callback_).Run(scam_detection_response);
diff --git a/components/safe_browsing/content/browser/password_protection/password_protection_service_unittest.cc b/components/safe_browsing/content/browser/password_protection/password_protection_service_unittest.cc index d7f75fa..76068e1 100644 --- a/components/safe_browsing/content/browser/password_protection/password_protection_service_unittest.cc +++ b/components/safe_browsing/content/browser/password_protection/password_protection_service_unittest.cc
@@ -56,6 +56,7 @@ #include "content/public/test/test_browser_context.h" #include "content/public/test/test_renderer_host.h" #include "content/public/test/web_contents_tester.h" +#include "google_apis/gaia/gaia_id.h" #include "mojo/public/cpp/base/proto_wrapper.h" #include "mojo/public/cpp/bindings/associated_receiver_set.h" #include "mojo/public/cpp/bindings/pending_receiver.h" @@ -1123,7 +1124,7 @@ AccountInfo account_info; account_info.account_id = CoreAccountId::FromGaiaId("gaia"); account_info.email = "email"; - account_info.gaia = "gaia"; + account_info.gaia = GaiaId("gaia"); account_info.hosted_domain = "example.com"; EXPECT_CALL(*password_protection_service_, GetAccountInfoForUsername(_)) .WillRepeatedly(Return(account_info)); @@ -1350,7 +1351,7 @@ AccountInfo account_info; account_info.account_id = CoreAccountId::FromGaiaId("gaia"); account_info.email = "email"; - account_info.gaia = "gaia"; + account_info.gaia = GaiaId("gaia"); EXPECT_CALL(*password_protection_service_, GetAccountInfoForUsername(_)) .WillRepeatedly(Return(account_info)); @@ -1495,7 +1496,7 @@ AccountInfo account_info; account_info.account_id = CoreAccountId::FromGaiaId("gaia"); account_info.email = "email"; - account_info.gaia = "gaia"; + account_info.gaia = GaiaId("gaia"); EXPECT_CALL(*password_protection_service_, GetAccountInfoForUsername(_)) .WillRepeatedly(Return(account_info));
diff --git a/components/safe_browsing/content/browser/threat_details.h b/components/safe_browsing/content/browser/threat_details.h index fbd5fad..1db43a9 100644 --- a/components/safe_browsing/content/browser/threat_details.h +++ b/components/safe_browsing/content/browser/threat_details.h
@@ -74,9 +74,7 @@ // Maps a FrameTreeNode ID of a frame to a set of child IDs. The child IDs are // the Element IDs of the top-level HTML Elements in this frame. using FrameTreeIdToChildIdsMap = - std::unordered_map<content::FrameTreeNodeId, - std::unordered_set<int>, - content::FrameTreeNodeId::Hasher>; + std::unordered_map<content::FrameTreeNodeId, std::unordered_set<int>>; // Callback used to notify a caller that ThreatDetails has finished creating and // sending a report.
diff --git a/components/safe_browsing/content/browser/triggers/trigger_manager.h b/components/safe_browsing/content/browser/triggers/trigger_manager.h index 964a94f1..9ba0b9a 100644 --- a/components/safe_browsing/content/browser/triggers/trigger_manager.h +++ b/components/safe_browsing/content/browser/triggers/trigger_manager.h
@@ -53,9 +53,8 @@ // Stores the data collectors that are active on each WebContents (ie: browser // tab). Keys are derived from WebContents* but should not be dereferenced. -using DataCollectorsMap = std::unordered_map<WebContentsKey, - DataCollectorsContainer, - typename WebContentsKey::Hasher>; +using DataCollectorsMap = + std::unordered_map<WebContentsKey, DataCollectorsContainer>; using SBErrorOptions = security_interstitials::BaseSafeBrowsingErrorUI::SBErrorDisplayOptions;
diff --git a/components/search/ntp_features.cc b/components/search/ntp_features.cc index d39cf3a..e700f86 100644 --- a/components/search/ntp_features.cc +++ b/components/search/ntp_features.cc
@@ -29,12 +29,6 @@ "ConfirmNtpSuggestionRemovals", base::FEATURE_DISABLED_BY_DEFAULT); -// If enabled, Chrome theme color will be set to match the NTP background -// on NTP Customize Chrome background change. -BASE_FEATURE(kCustomizeChromeColorExtraction, - "CustomizeChromeColorExtraction", - base::FEATURE_ENABLED_BY_DEFAULT); - // If enabled, shows an extension card within the Customize Chrome Side // Panel for access to the Chrome Web Store extensions. BASE_FEATURE(kCustomizeChromeSidePanelExtensionsCard,
diff --git a/components/search/ntp_features.h b/components/search/ntp_features.h index 1168a6a..2b229ab 100644 --- a/components/search/ntp_features.h +++ b/components/search/ntp_features.h
@@ -21,7 +21,6 @@ // the .cc file. BASE_DECLARE_FEATURE(kConfirmSuggestionRemovals); -BASE_DECLARE_FEATURE(kCustomizeChromeColorExtraction); BASE_DECLARE_FEATURE(kCustomizeChromeSidePanelExtensionsCard); BASE_DECLARE_FEATURE(kCustomizeChromeWallpaperSearch); BASE_DECLARE_FEATURE(kCustomizeChromeWallpaperSearchButton);
diff --git a/components/search_engines/enterprise/site_search_policy_handler.cc b/components/search_engines/enterprise/site_search_policy_handler.cc index 0e3d477..b8337012 100644 --- a/components/search_engines/enterprise/site_search_policy_handler.cc +++ b/components/search_engines/enterprise/site_search_policy_handler.cc
@@ -226,16 +226,16 @@ base::Value::List providers; for (const base::Value& item : policy_value->GetList()) { - const base::Value::Dict& policy_dict = item.GetDict(); - const std::string& shortcut = *policy_dict.FindString(kShortcut); - if (ignored_shortcuts_.find(shortcut) == ignored_shortcuts_.end()) { - providers.Append( - SiteSearchDictFromPolicyValue(policy_dict, /*featured=*/false)); - if (policy_dict.FindBool(kFeatured).value_or(false)) { - providers.Append(SiteSearchDictFromPolicyValue(policy_dict, - /*featured=*/true)); - } + const base::Value::Dict& policy_dict = item.GetDict(); + const std::string& shortcut = *policy_dict.FindString(kShortcut); + if (ignored_shortcuts_.find(shortcut) == ignored_shortcuts_.end()) { + providers.Append( + SiteSearchDictFromPolicyValue(policy_dict, /*featured=*/false)); + if (policy_dict.FindBool(kFeatured).value_or(false)) { + providers.Append(SiteSearchDictFromPolicyValue(policy_dict, + /*featured=*/true)); } + } } prefs->SetValue(EnterpriseSearchManager::kSiteSearchSettingsPrefName,
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc index eb0742c..1dcb12b3 100644 --- a/components/search_engines/template_url_service.cc +++ b/components/search_engines/template_url_service.cc
@@ -536,10 +536,10 @@ // separated by a comma ("@work, work"). The logic below hides the one // that doesn't start with the "@" symbol. // - // It also handles one corner case when the user explicitely created a - // site search engine with keyword "work", which overrides the one with - // the same keyword created by policy. In that case, we want to show both - // the Enterprise one with keyword "@work" and the user-defined one. + // It also handles one corner case when the user explicitly created a site + // search engine with keyword "work", which overrides the one with the + // same keyword created by policy. In that case, we want to show both the + // Enterprise one with keyword "@work" and the user-defined one. const TemplateURL* t_url_with_at = GetTemplateURLForKeyword(u"@" + t_url->keyword()); return t_url_with_at &&
diff --git a/components/segmentation_platform/internal/signals/history_delegate_impl.h b/components/segmentation_platform/internal/signals/history_delegate_impl.h index cf56ad6..de9bd723 100644 --- a/components/segmentation_platform/internal/signals/history_delegate_impl.h +++ b/components/segmentation_platform/internal/signals/history_delegate_impl.h
@@ -67,7 +67,7 @@ // List of URLs visited in the current session. // TODO(ssid): This list grows indefnitely, consider having a limit or LRU // cache. - std::unordered_set<UrlId, UrlId::Hasher> cached_history_urls_; + std::unordered_set<UrlId> cached_history_urls_; SEQUENCE_CHECKER(sequence_checker_); base::WeakPtrFactory<HistoryDelegateImpl> weak_factory_{this};
diff --git a/components/tracing/common/background_tracing_metrics_provider.cc b/components/tracing/common/background_tracing_metrics_provider.cc index 9c9012a..c77126cd 100644 --- a/components/tracing/common/background_tracing_metrics_provider.cc +++ b/components/tracing/common/background_tracing_metrics_provider.cc
@@ -93,11 +93,11 @@ system_profile.ParsePartialFromString(*serialized_system_profile); uma_proto->mutable_system_profile()->MergeFrom(system_profile); } - // Serialize the log on the background instead of on the main + // Serialize the log on a worker thread instead of on the main // thread. base::ThreadPool::PostTask( FROM_HERE, - {base::TaskPriority::BEST_EFFORT, + {base::TaskPriority::USER_VISIBLE, base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, std::move(serialize_log_callback) .Then(base::BindPostTask(
diff --git a/components/url_formatter/spoof_checks/common_words/common_words_util.cc b/components/url_formatter/spoof_checks/common_words/common_words_util.cc index 31e8253..fa1f0935 100644 --- a/components/url_formatter/spoof_checks/common_words/common_words_util.cc +++ b/components/url_formatter/spoof_checks/common_words/common_words_util.cc
@@ -10,9 +10,7 @@ #include "base/containers/span.h" #include "net/base/lookup_string_in_fixed_set.h" -namespace url_formatter { - -namespace common_words { +namespace url_formatter::common_words { namespace { @@ -35,6 +33,4 @@ g_dafsa_params = kDafsa; } -} // namespace common_words - -} // namespace url_formatter +} // namespace url_formatter::common_words
diff --git a/components/url_formatter/spoof_checks/skeleton_generator.cc b/components/url_formatter/spoof_checks/skeleton_generator.cc index 6bbdb275..88d0a6f 100644 --- a/components/url_formatter/spoof_checks/skeleton_generator.cc +++ b/components/url_formatter/spoof_checks/skeleton_generator.cc
@@ -316,7 +316,7 @@ // Thus, the number of skeleton strings in the queue item will always // correspond to the index of the input string processed so far. std::queue<QueueItem> q; - q.push(QueueItem()); + q.emplace(); while (!q.empty()) { QueueItem current = q.front(); @@ -335,7 +335,7 @@ // First, add the original character from input. char16_t c = input_buffer[current.size()]; QueueItem new_item1 = current; - new_item1.push_back(std::u16string(1, c)); + new_item1.emplace_back(1, c); q.push(new_item1); // Then, find all alternative characters for the current input character and
diff --git a/components/url_formatter/spoof_checks/top_domains/top_domain_state_generator.cc b/components/url_formatter/spoof_checks/top_domains/top_domain_state_generator.cc index b595884a..baae9120 100644 --- a/components/url_formatter/spoof_checks/top_domains/top_domain_state_generator.cc +++ b/components/url_formatter/spoof_checks/top_domains/top_domain_state_generator.cc
@@ -19,9 +19,7 @@ using net::huffman_trie::HuffmanRepresentationTable; using net::huffman_trie::TrieWriter; -namespace url_formatter { - -namespace top_domains { +namespace url_formatter::top_domains { namespace { @@ -163,6 +161,4 @@ return output; } -} // namespace top_domains - -} // namespace url_formatter +} // namespace url_formatter::top_domains
diff --git a/components/url_formatter/spoof_checks/top_domains/top_domain_util.cc b/components/url_formatter/spoof_checks/top_domains/top_domain_util.cc index 985d2d3..78b56fb 100644 --- a/components/url_formatter/spoof_checks/top_domains/top_domain_util.cc +++ b/components/url_formatter/spoof_checks/top_domains/top_domain_util.cc
@@ -7,9 +7,7 @@ #include "base/strings/string_util.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" -namespace url_formatter { - -namespace top_domains { +namespace url_formatter::top_domains { namespace { @@ -38,6 +36,4 @@ return out; } -} // namespace top_domains - -} // namespace url_formatter +} // namespace url_formatter::top_domains
diff --git a/components/url_formatter/spoof_checks/top_domains/trie_entry.cc b/components/url_formatter/spoof_checks/top_domains/trie_entry.cc index 853f8db..2b530bca 100644 --- a/components/url_formatter/spoof_checks/top_domains/trie_entry.cc +++ b/components/url_formatter/spoof_checks/top_domains/trie_entry.cc
@@ -11,9 +11,7 @@ #include "net/tools/huffman_trie/trie/trie_bit_buffer.h" #include "net/tools/huffman_trie/trie/trie_writer.h" -namespace url_formatter { - -namespace top_domains { +namespace url_formatter::top_domains { TopDomainTrieEntry::TopDomainTrieEntry( const net::huffman_trie::HuffmanRepresentationTable& huffman_table, @@ -65,6 +63,4 @@ return true; } -} // namespace top_domains - -} // namespace url_formatter +} // namespace url_formatter::top_domains
diff --git a/components/url_formatter/url_formatter.cc b/components/url_formatter/url_formatter.cc index 5e4f1321..ae21932 100644 --- a/components/url_formatter/url_formatter.cc +++ b/components/url_formatter/url_formatter.cc
@@ -122,20 +122,16 @@ if (component_text.length() == stripped_component_text.length() + kMobilePrefixLength + kWwwLength) { // Add www. and m. offsets. - offset_adjustments.push_back( - base::OffsetAdjuster::Adjustment(0, kWwwLength, 0)); - offset_adjustments.push_back( - base::OffsetAdjuster::Adjustment(0, kMobilePrefixLength, 0)); + offset_adjustments.emplace_back(0, kWwwLength, 0); + offset_adjustments.emplace_back(0, kMobilePrefixLength, 0); } else if (component_text.length() == stripped_component_text.length() + kWwwLength) { // Add www. offset. - offset_adjustments.push_back( - base::OffsetAdjuster::Adjustment(0, kWwwLength, 0)); + offset_adjustments.emplace_back(0, kWwwLength, 0); } else if (component_text.length() == stripped_component_text.length() + kMobilePrefixLength) { // Add m. offset - offset_adjustments.push_back( - base::OffsetAdjuster::Adjustment(0, kMobilePrefixLength, 0)); + offset_adjustments.emplace_back(0, kMobilePrefixLength, 0); } std::u16string unicode_result = IDNToUnicodeWithAdjustments(stripped_component_text, adjustments) @@ -358,8 +354,8 @@ size_t new_component_length = out16.length() - new_component_start; if (component_result.converted && adjustments) { - adjustments->push_back(base::OffsetAdjuster::Adjustment( - component_start, component_length, new_component_length)); + adjustments->emplace_back(component_start, component_length, + new_component_length); } // Need to add the dot we just found (if we found one). @@ -646,18 +642,18 @@ if (parsed.username.is_nonempty() && parsed.password.is_nonempty()) { // The seeming off-by-two is to account for the ':' after the username // and '@' after the password. - adjustments->push_back(base::OffsetAdjuster::Adjustment( + adjustments->emplace_back( static_cast<size_t>(parsed.username.begin), static_cast<size_t>(parsed.username.len + parsed.password.len + 2), - 0)); + 0); } else { const url::Component* nonempty_component = parsed.username.is_nonempty() ? &parsed.username : &parsed.password; // The seeming off-by-one is to account for the '@' after the // username/password. - adjustments->push_back(base::OffsetAdjuster::Adjustment( + adjustments->emplace_back( static_cast<size_t>(nonempty_component->begin), - static_cast<size_t>(nonempty_component->len + 1), 0)); + static_cast<size_t>(nonempty_component->len + 1), 0); } } } else { @@ -712,15 +708,13 @@ trimmed_length += parsed.ref.len + 1; } - adjustments->push_back( - base::OffsetAdjuster::Adjustment(parsed.path.begin, trimmed_length, 0)); + adjustments->emplace_back(parsed.path.begin, trimmed_length, 0); } else if ((format_types & kFormatUrlOmitTrailingSlashOnBareHostname) && CanStripTrailingSlash(url)) { // Omit the path, which is a single trailing slash. There's no query or ref. if (parsed.path.is_nonempty()) { - adjustments->push_back(base::OffsetAdjuster::Adjustment( - parsed.path.begin, parsed.path.len, 0)); + adjustments->emplace_back(parsed.path.begin, parsed.path.len, 0); } } else { // Append the formatted path, query, and ref.
diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc index 5cdfae1..9d187ce 100644 --- a/components/url_formatter/url_formatter_unittest.cc +++ b/components/url_formatter/url_formatter_unittest.cc
@@ -431,13 +431,13 @@ }); // clang-format on - for (size_t i = 0; i < std::size(tests); ++i) { + for (const auto& test : tests) { size_t prefix_len; std::u16string formatted = - FormatUrl(GURL(tests[i].input), tests[i].format_types, - tests[i].escape_rules, nullptr, &prefix_len, nullptr); - EXPECT_EQ(WideToUTF16(tests[i].output), formatted) << tests[i].description; - EXPECT_EQ(tests[i].prefix_len, prefix_len) << tests[i].description; + FormatUrl(GURL(test.input), test.format_types, test.escape_rules, + nullptr, &prefix_len, nullptr); + EXPECT_EQ(WideToUTF16(test.output), formatted) << test.description; + EXPECT_EQ(test.prefix_len, prefix_len) << test.description; } }
diff --git a/components/vector_icons/aggregate_vector_icons.py b/components/vector_icons/aggregate_vector_icons.py index 3e5a94a7..87d7eaf1 100644 --- a/components/vector_icons/aggregate_vector_icons.py +++ b/components/vector_icons/aggregate_vector_icons.py
@@ -182,7 +182,7 @@ output_cc.write("VECTOR_ICON_REP_TEMPLATE({}, {})\n".format( icon_path_name, vector_commands)) icon_representation_strings.append( - "{{{0}, std::size({0})}}".format(icon_path_name)) + "{{{0}}}".format(icon_path_name)) # Another temporary variable kFooBarRepList is used to create all the # VectorIconReps inline, with a pointer to it in the final VectorIcon.
diff --git a/components/webdata/common/web_data_request_manager.cc b/components/webdata/common/web_data_request_manager.cc index 25a0e4b..9ea3732 100644 --- a/components/webdata/common/web_data_request_manager.cc +++ b/components/webdata/common/web_data_request_manager.cc
@@ -115,8 +115,8 @@ WebDataRequestManager::~WebDataRequestManager() { base::AutoLock l(pending_lock_); - for (auto i = pending_requests_.begin(); i != pending_requests_.end(); ++i) { - i->second->MarkAsInactive(); + for (auto& pending_request : pending_requests_) { + pending_request.second->MarkAsInactive(); } pending_requests_.clear(); }
diff --git a/components/webdata/common/web_database_service.cc b/components/webdata/common/web_database_service.cc index 54249d32..90b56352 100644 --- a/components/webdata/common/web_database_service.cc +++ b/components/webdata/common/web_database_service.cc
@@ -39,7 +39,8 @@ class WebDatabaseService::BackendDelegate : public WebDatabaseBackend::Delegate { public: - BackendDelegate(const base::WeakPtr<WebDatabaseService>& web_database_service) + explicit BackendDelegate( + const base::WeakPtr<WebDatabaseService>& web_database_service) : web_database_service_(web_database_service), callback_task_runner_(base::SequencedTaskRunner::GetCurrentDefault()) {}
diff --git a/components/webxr/xr_test_hook_wrapper.cc b/components/webxr/xr_test_hook_wrapper.cc index 4f540c3..4e6b03c 100644 --- a/components/webxr/xr_test_hook_wrapper.cc +++ b/components/webxr/xr_test_hook_wrapper.cc
@@ -2,11 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/342213636): Remove this and spanify to fix the errors. -#pragma allow_unsafe_buffers -#endif - #include "components/webxr/xr_test_hook_wrapper.h" #include "base/task/single_thread_task_runner.h" @@ -36,7 +31,7 @@ device::PoseFrameData ret = {}; ret.is_valid = !!pose->device_to_origin; if (ret.is_valid) { - pose->device_to_origin->GetColMajorF(ret.device_to_origin); + pose->device_to_origin->GetColMajorF(ret.device_to_origin.data()); } return ret;
diff --git a/content/browser/back_forward_cache_browsertest.cc b/content/browser/back_forward_cache_browsertest.cc index dacaf31..f1d1b46 100644 --- a/content/browser/back_forward_cache_browsertest.cc +++ b/content/browser/back_forward_cache_browsertest.cc
@@ -893,8 +893,9 @@ FrameTreeNode* root = web_contents()->GetPrimaryFrameTree().root(); base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, base::BindLambdaForTesting([&]() { - root->navigator().BeforeUnloadCompleted(root, true /* proceed */, - base::TimeTicks::Now()); + root->navigator().BeforeUnloadCompleted( + root, /*proceed=*/true, base::TimeTicks::Now(), + /*for_legacy=*/false, /*showed_dialog=*/false); })); // 7) Evict entry B. This will post a task (task #3) to restart the navigation
diff --git a/content/browser/browsing_topics/browsing_topics_url_loader_interceptor.cc b/content/browser/browsing_topics/browsing_topics_url_loader_interceptor.cc index e9c75fb..db6189f 100644 --- a/content/browser/browsing_topics/browsing_topics_url_loader_interceptor.cc +++ b/content/browser/browsing_topics/browsing_topics_url_loader_interceptor.cc
@@ -4,6 +4,7 @@ #include "content/browser/browsing_topics/browsing_topics_url_loader_interceptor.h" +#include "components/browsing_topics/common/common_types.h" #include "content/browser/browsing_topics/header_util.h" #include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/public/browser/content_browser_client.h" @@ -170,7 +171,9 @@ std::vector<blink::mojom::EpochTopicPtr> topics; topics_eligible_ = GetContentClient()->browser()->HandleTopicsWebApi( origin, request_initiator_frame->GetMainFrame(), - browsing_topics::ApiCallerSource::kFetch, + resource_request_->is_fetch_like_api + ? browsing_topics::ApiCallerSource::kFetch + : browsing_topics::ApiCallerSource::kImgAttribute, /*get_topics=*/true, /*observe=*/false, topics); @@ -200,9 +203,11 @@ return; } - HandleTopicsEligibleResponse(head->parsed_headers, - url::Origin::Create(url_), *rfh, - browsing_topics::ApiCallerSource::kFetch); + HandleTopicsEligibleResponse( + head->parsed_headers, url::Origin::Create(url_), *rfh, + resource_request_->is_fetch_like_api + ? browsing_topics::ApiCallerSource::kFetch + : browsing_topics::ApiCallerSource::kImgAttribute); topics_eligible_ = false; }
diff --git a/content/browser/browsing_topics/header_util.cc b/content/browser/browsing_topics/header_util.cc index 6e59fdd..c93244d 100644 --- a/content/browser/browsing_topics/header_util.cc +++ b/content/browser/browsing_topics/header_util.cc
@@ -5,6 +5,7 @@ #include "content/browser/browsing_topics/header_util.h" #include "base/strings/strcat.h" +#include "components/browsing_topics/common/common_types.h" #include "components/browsing_topics/common/semantic_tree.h" #include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/public/browser/content_browser_client.h" @@ -148,7 +149,8 @@ RenderFrameHost& request_initiator_frame, browsing_topics::ApiCallerSource caller_source) { DCHECK(caller_source == browsing_topics::ApiCallerSource::kFetch || - caller_source == browsing_topics::ApiCallerSource::kIframeAttribute); + caller_source == browsing_topics::ApiCallerSource::kIframeAttribute || + caller_source == browsing_topics::ApiCallerSource::kImgAttribute); if (!parsed_headers || !parsed_headers->observe_browsing_topics) { return;
diff --git a/content/browser/download/save_file_manager.h b/content/browser/download/save_file_manager.h index b487d4f2..9b6e7be 100644 --- a/content/browser/download/save_file_manager.h +++ b/content/browser/download/save_file_manager.h
@@ -234,21 +234,16 @@ void ClearURLLoader(SaveItemId save_item_id); // A map from save_item_id into SaveFiles. - std::unordered_map<SaveItemId, std::unique_ptr<SaveFile>, SaveItemId::Hasher> - save_file_map_; + std::unordered_map<SaveItemId, std::unique_ptr<SaveFile>> save_file_map_; // Tracks which SavePackage to send data to, called only on UI thread. // SavePackageMap maps save item ids to their SavePackage. - std::unordered_map<SaveItemId, - raw_ptr<SavePackage, CtnExperimental>, - SaveItemId::Hasher> + std::unordered_map<SaveItemId, raw_ptr<SavePackage, CtnExperimental>> packages_; // The helper object doing the actual download. Should be accessed on the UI // thread. - std::unordered_map<SaveItemId, - std::unique_ptr<SimpleURLLoaderHelper>, - SaveItemId::Hasher> + std::unordered_map<SaveItemId, std::unique_ptr<SimpleURLLoaderHelper>> url_loader_helpers_; };
diff --git a/content/browser/download/save_package.h b/content/browser/download/save_package.h index ec78cc2..fc52c8e 100644 --- a/content/browser/download/save_package.h +++ b/content/browser/download/save_package.h
@@ -155,8 +155,8 @@ FRIEND_TEST_ALL_PREFIXES(SavePackageBrowserTest, DownloadItemDestroyed); // Map from SaveItem::id() (aka save_item_id) into a SaveItem. - using SaveItemIdMap = std:: - unordered_map<SaveItemId, std::unique_ptr<SaveItem>, SaveItemId::Hasher>; + using SaveItemIdMap = + std::unordered_map<SaveItemId, std::unique_ptr<SaveItem>>; using FileNameSet = std::set<base::FilePath::StringType, bool (*)(base::FilePath::StringPieceType, @@ -378,9 +378,7 @@ // GetSerializedHtmlWithLocalLinksResponse) to the right SaveItem. // Note that |frame_tree_node_id_to_save_item_| does NOT own SaveItems - they // remain owned by waiting_item_queue_, in_progress_items_, etc. - std::unordered_map<FrameTreeNodeId, - raw_ptr<SaveItem, CtnExperimental>, - FrameTreeNodeId::Hasher> + std::unordered_map<FrameTreeNodeId, raw_ptr<SaveItem, CtnExperimental>> frame_tree_node_id_to_save_item_; // Used to limit which local paths get exposed to which frames @@ -389,8 +387,7 @@ // SaveItems - they remain owned by waiting_item_queue_, in_progress_items_, // etc. std::unordered_map<FrameTreeNodeId, - std::vector<raw_ptr<SaveItem, VectorExperimental>>, - FrameTreeNodeId::Hasher> + std::vector<raw_ptr<SaveItem, VectorExperimental>>> frame_tree_node_id_to_contained_save_items_; // Number of frames that we still need to get a response from.
diff --git a/content/browser/download/save_types.h b/content/browser/download/save_types.h index f39791a..da246fc 100644 --- a/content/browser/download/save_types.h +++ b/content/browser/download/save_types.h
@@ -25,8 +25,7 @@ using SaveItemId = base::IdType32<SaveItem>; // Map from save_item_id into final file path. -using FinalNamesMap = - std::unordered_map<SaveItemId, base::FilePath, SaveItemId::Hasher>; +using FinalNamesMap = std::unordered_map<SaveItemId, base::FilePath>; // This structure is used to handle and deliver some info // when processing each save item job.
diff --git a/content/browser/renderer_host/browsing_context_state.h b/content/browser/renderer_host/browsing_context_state.h index 8d2fc1cc..f44cd4b1 100644 --- a/content/browser/renderer_host/browsing_context_state.h +++ b/content/browser/renderer_host/browsing_context_state.h
@@ -76,8 +76,7 @@ public: using RenderFrameProxyHostMap = std::unordered_map<SiteInstanceGroupId, - std::unique_ptr<RenderFrameProxyHost>, - SiteInstanceGroupId::Hasher>; + std::unique_ptr<RenderFrameProxyHost>>; // Currently `browsing_instance_id` and `coop_related_group_id` will be null // iff the legacy mode is enabled, as the legacy mode BrowsingContextState is
diff --git a/content/browser/renderer_host/frame_tree.h b/content/browser/renderer_host/frame_tree.h index 6b8eb08f..0765e42 100644 --- a/content/browser/renderer_host/frame_tree.h +++ b/content/browser/renderer_host/frame_tree.h
@@ -608,9 +608,8 @@ // A map to store RenderViewHosts, keyed by SiteInstanceGroup ID. // This map does not cover all RenderViewHosts in a FrameTree. See // `speculative_render_view_host_`. - using RenderViewHostMap = std::unordered_map<RenderViewHostMapId, - RenderViewHostImpl*, - RenderViewHostMapId::Hasher>; + using RenderViewHostMap = + std::unordered_map<RenderViewHostMapId, RenderViewHostImpl*>; // Map of RenderViewHostMapId to RenderViewHost. This allows us to look up the // RenderViewHost for a given SiteInstance when creating RenderFrameHosts. // Each RenderViewHost maintains a refcount and is deleted when there are no
diff --git a/content/browser/renderer_host/frame_tree_node.cc b/content/browser/renderer_host/frame_tree_node.cc index 378b78e..25db812f 100644 --- a/content/browser/renderer_host/frame_tree_node.cc +++ b/content/browser/renderer_host/frame_tree_node.cc
@@ -49,8 +49,7 @@ // This is a global map between frame_tree_node_ids and pointers to // FrameTreeNodes. -using FrameTreeNodeIdMap = std:: - unordered_map<FrameTreeNodeId, FrameTreeNode*, FrameTreeNodeId::Hasher>; +using FrameTreeNodeIdMap = std::unordered_map<FrameTreeNodeId, FrameTreeNode*>; base::LazyInstance<FrameTreeNodeIdMap>::DestructorAtExit g_frame_tree_node_id_map = LAZY_INSTANCE_INITIALIZER;
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc index cc3a158..5a95c24 100644 --- a/content/browser/renderer_host/navigation_request.cc +++ b/content/browser/renderer_host/navigation_request.cc
@@ -2241,6 +2241,7 @@ common_params_->url.spec(), "Net Error Code", net_error_); MaybeRecordTraceEventsAndHistograms(); } + MaybeRecordNavigationStartAdjustments(); // Abandon the prerender host reserved for activation if it exists. if (IsPrerenderedPageActivation()) { @@ -2416,6 +2417,20 @@ BeginNavigationImpl(); } +void NavigationRequest::UpdateNavigationStartTime(const base::TimeTicks& time, + bool for_legacy, + bool showed_dialog) { + // Should be called at most once per NavigationRequest. + CHECK(original_navigation_start_.is_null()); + + // Track the adjustment details for https://crbug.com/385170155. + original_navigation_start_ = common_params_->navigation_start; + navigation_start_adjustment_for_legacy_ = for_legacy; + beforeunload_dialog_shown_ = showed_dialog; + + common_params_->navigation_start = time; +} + bool NavigationRequest::MaybeStartPrerenderingActivationChecks() { // Find an available prerendered page for this request. If it's found, this // request may activate it instead of loading a page via network. @@ -11032,6 +11047,85 @@ #undef MAYBE_RECORD_TRACE_AND_HISTOGRAM1 } +void NavigationRequest::MaybeRecordNavigationStartAdjustments() { + // Only record metrics if we have a navigation start time. + if (common_params().navigation_start.is_null()) { + return; + } + + // Some navigations do not adjust the start time, in which case + // `original_navigation_start_` is left as null. + if (original_navigation_start_.is_null()) { + base::UmaHistogramEnumeration("Navigation.StartAdjustment", + NavigationStartAdjustmentType::kNone); + return; + } + + // Compute the adjustment made and what percentage of the total navigation + // time it includes (approximating now as the end of the navigation). + base::TimeDelta adjustment = + common_params().navigation_start - original_navigation_start_; + base::TimeDelta original_start_to_finish = + base::TimeTicks::Now() - original_navigation_start_; + // Note that in unit tests, all timestamps can be the same. Skip recording + // duration metrics if no time has elapsed during the navigation. + if (original_start_to_finish.is_zero()) { + return; + } + + // Report the adjustment in UMA metrics specific to the case that occurred. + NavigationStartAdjustmentType adjustment_type = + NavigationStartAdjustmentType::kNone; + std::string histogram_name = "Navigation.StartAdjustment"; + if (navigation_start_adjustment_for_legacy_) { + // No beforeunload handlers actually run in legacy mode. + CHECK(!beforeunload_dialog_shown_); + adjustment_type = NavigationStartAdjustmentType::kLegacyPostTask; + histogram_name += ".LegacyPostTask"; + } else if (!beforeunload_dialog_shown_) { + adjustment_type = NavigationStartAdjustmentType::kBeforeUnloadHandlers; + histogram_name += ".BeforeUnloadHandlers"; + } else { + adjustment_type = NavigationStartAdjustmentType::kBeforeUnloadDialog; + histogram_name += ".BeforeUnloadDialog"; + } + base::UmaHistogramEnumeration("Navigation.StartAdjustment", adjustment_type); + + // It is currently possible for the adjustment to be negative, due to a bug + // where the updated start time from an earlier navigation is applied to the + // current NavigationRequest. See https://crbug.com/385170155. + if (adjustment.is_negative()) { + // In this case, report the absolute value of the adjustment in a different + // per-type metric, without reporting the (ill-defined) percentage or trying + // to create a trace event. + histogram_name += ".Negative"; + base::UmaHistogramTimes(histogram_name, adjustment.magnitude()); + return; + } + + // The duration of the navigation should never be negative. For now, return + // early if that happens, after reporting a DumpWithoutCrashing. Upgrade this + // to a CHECK failure if no reports are received by M135. + if (original_start_to_finish.is_negative()) { + NOTREACHED(base::NotFatalUntil::M135) << original_start_to_finish; + return; + } + + base::UmaHistogramTimes(histogram_name, adjustment); + size_t percentage = 100 * adjustment / original_start_to_finish; + base::UmaHistogramPercentage(histogram_name + ".Percentage", percentage); + + // Show trace events indicating where the adjustment occurred in time. + const auto trace_id = TRACE_ID_WITH_SCOPE("NavigationStartAdjustment", + TRACE_ID_LOCAL(navigation_id_)); + TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP1( + "navigation", "NavigationStartAdjustment", trace_id, + original_navigation_start_, "Percentage", percentage); + TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( + "navigation", "NavigationStartAdjustment", trace_id, + common_params().navigation_start); +} + void NavigationRequest::SanitizeDocumentIsolationPolicyHeader() { if (!response_head_) { return;
diff --git a/content/browser/renderer_host/navigation_request.h b/content/browser/renderer_host/navigation_request.h index ca67aa8c..a17ca3b 100644 --- a/content/browser/renderer_host/navigation_request.h +++ b/content/browser/renderer_host/navigation_request.h
@@ -481,10 +481,30 @@ return *commit_params_; } - // Updates the navigation start time. - void set_navigation_start_time(const base::TimeTicks& time) { - common_params_->navigation_start = time; - } + // This describes the cases where the navigation start time is adjusted to be + // later in time, after BeforeUnloadCompleted. This enum is used in UMA + // histograms, so existing values should be neither reordered nor removed. + enum class NavigationStartAdjustmentType { + // No adjustment to the navigation start time was made. + kNone = 0, + // The start time was adjusted so that the navigation could proceed via a + // posted task, even though there were no beforeunload handlers registered. + kLegacyPostTask = 1, + // The start time was adjusted because beforeunload handlers ran, but no + // dialog was displayed to the user. + kBeforeUnloadHandlers = 2, + // The start time was adjusted because a beforeunload dialog was shown. + kBeforeUnloadDialog = 3, + kMaxValue = kBeforeUnloadDialog, + }; + + // Updates the navigation start time, after beforeunload has completed. + // `for_legacy` indicates that the navigation proceeded in a separate task for + // legacy reasons, without running beforeunload handlers. `showed_dialog` + // indicates whether the beforeunload handlers actually displayed a dialog. + void UpdateNavigationStartTime(const base::TimeTicks& time, + bool for_legacy, + bool showed_dialog); void set_is_cross_site_cross_browsing_context_group( bool is_cross_site_cross_browsing_context_group) { @@ -2096,6 +2116,11 @@ void MaybeRecordTraceEventsAndHistograms(); + // Records how much the navigation start time was adjusted for beforeunload + // handlers, for various scenarios (legacy, beforeunload handlers only, and + // beforeunload dialogs). See https://crbug.com/385170155. + void MaybeRecordNavigationStartAdjustments(); + void ResetViewTransitionState(); // This check is to prevent a race condition where a parent fenced frame @@ -2371,6 +2396,18 @@ // Timing information of loading for the navigation. Used for recording UMAs. NavigationHandleTiming navigation_handle_timing_; + // The original value of navigation start for a given navigation, before any + // adjustment is made to avoid counting beforeunload dialogs. This is null + // (i.e., `TimeTicks()`) unless an adjustment was made. + base::TimeTicks original_navigation_start_; + + // Tracks whether an adjustment to the navigation start time was done for + // legacy PostTask reasons rather than for running a beforeunload handler. + bool navigation_start_adjustment_for_legacy_ = false; + + // Tracks whether a beforeunload dialog was shown as part of this navigation. + bool beforeunload_dialog_shown_ = false; + // The time this navigation was ready to commit. base::TimeTicks ready_to_commit_time_;
diff --git a/content/browser/renderer_host/navigator.cc b/content/browser/renderer_host/navigator.cc index bc6d0bae..e1816f1 100644 --- a/content/browser/renderer_host/navigator.cc +++ b/content/browser/renderer_host/navigator.cc
@@ -1123,7 +1123,9 @@ void Navigator::BeforeUnloadCompleted(FrameTreeNode* frame_tree_node, bool proceed, - const base::TimeTicks& proceed_time) { + const base::TimeTicks& proceed_time, + bool for_legacy, + bool showed_dialog) { DCHECK(frame_tree_node); NavigationRequest* navigation_request = frame_tree_node->navigation_request(); @@ -1157,7 +1159,8 @@ // Update the navigation start: it should be when it was determined that the // navigation will proceed. - navigation_request->set_navigation_start_time(proceed_time); + navigation_request->UpdateNavigationStartTime(proceed_time, for_legacy, + showed_dialog); DCHECK_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, navigation_request->state());
diff --git a/content/browser/renderer_host/navigator.h b/content/browser/renderer_host/navigator.h index 22051fa..5db1e21ef 100644 --- a/content/browser/renderer_host/navigator.h +++ b/content/browser/renderer_host/navigator.h
@@ -177,12 +177,16 @@ std::nullopt); // Called after BeforeUnloadCompleted callback is invoked from the renderer. - // If |frame_tree_node| has a NavigationRequest waiting for the renderer + // If `frame_tree_node` has a NavigationRequest waiting for the renderer // response, then the request is either started or canceled, depending on the - // value of |proceed|. + // value of `proceed`. If `for_legacy` is true, then this beforeunload flow + // was only used to post a task and no beforeunload handlers were run. If + // `showed_dialog` is true, then a beforeunload dialog was displayed. void BeforeUnloadCompleted(FrameTreeNode* frame_tree_node, bool proceed, - const base::TimeTicks& proceed_time); + const base::TimeTicks& proceed_time, + bool for_legacy, + bool showed_dialog); // Used to start a new renderer-initiated navigation, following a // BeginNavigation IPC from the renderer.
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index ea77770f..61e054b 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -6235,6 +6235,8 @@ send_before_unload_start_time_, for_legacy); } + bool showed_dialog = has_shown_beforeunload_dialog_; + // Resets beforeunload waiting state. is_waiting_for_beforeunload_completion_ = false; has_shown_beforeunload_dialog_ = false; @@ -6249,7 +6251,8 @@ base::OnceClosure task = base::BindOnce( [](base::WeakPtr<RenderFrameHostImpl> self, const base::TimeTicks& before_unload_end_time, bool proceed, - bool unload_ack_is_for_navigation) { + bool unload_ack_is_for_navigation, bool for_legacy, + bool showed_dialog) { if (!self) return; FrameTreeNode* frame = self->frame_tree_node(); @@ -6258,7 +6261,8 @@ // RenderFrameHostManager which handles closing. if (unload_ack_is_for_navigation) { frame->navigator().BeforeUnloadCompleted(frame, proceed, - before_unload_end_time); + before_unload_end_time, + for_legacy, showed_dialog); } else { frame->render_manager()->BeforeUnloadCompleted(proceed); } @@ -6269,7 +6273,7 @@ // which is tricky. weak_ptr_factory_.GetWeakPtr(), before_unload_end_time - browser_to_renderer_ipc_time_delta, proceed, - unload_ack_is_for_navigation_); + unload_ack_is_for_navigation_, for_legacy, showed_dialog); if (is_frame_being_destroyed) { DCHECK(proceed);
diff --git a/content/browser/renderer_host/render_frame_host_impl_browsertest.cc b/content/browser/renderer_host/render_frame_host_impl_browsertest.cc index 8eb9c811..16399d6 100644 --- a/content/browser/renderer_host/render_frame_host_impl_browsertest.cc +++ b/content/browser/renderer_host/render_frame_host_impl_browsertest.cc
@@ -217,6 +217,9 @@ class RenderFrameHostImplBrowserTest : public ContentBrowserTest { public: using LifecycleStateImpl = RenderFrameHostImpl::LifecycleStateImpl; + using NavigationStartAdjustmentType = + NavigationRequest::NavigationStartAdjustmentType; + RenderFrameHostImplBrowserTest() : https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} ~RenderFrameHostImplBrowserTest() override = default; @@ -743,8 +746,13 @@ TestJavaScriptDialogManager dialog_manager; web_contents()->SetDelegate(&dialog_manager); - EXPECT_TRUE(NavigateToURL( - shell(), GetTestUrl("render_frame_host", "beforeunload.html"))); + { + base::HistogramTester histogram_tester; + EXPECT_TRUE(NavigateToURL( + shell(), GetTestUrl("render_frame_host", "beforeunload.html"))); + histogram_tester.ExpectUniqueSample( + "Navigation.StartAdjustment", NavigationStartAdjustmentType::kNone, 1); + } // Disable the hang monitor, otherwise there will be a race between the // beforeunload dialog and the beforeunload hang timer. web_contents() @@ -753,8 +761,18 @@ // Reload. There should be no beforeunload dialog because there was no gesture // on the page. If there was, this WaitForLoadStop call will hang. - web_contents()->GetController().Reload(ReloadType::NORMAL, false); - EXPECT_TRUE(WaitForLoadStop(web_contents())); + { + base::HistogramTester histogram_tester; + web_contents()->GetController().Reload(ReloadType::NORMAL, false); + EXPECT_TRUE(WaitForLoadStop(web_contents())); + histogram_tester.ExpectUniqueSample( + "Navigation.StartAdjustment", + NavigationStartAdjustmentType::kBeforeUnloadHandlers, 1); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.BeforeUnloadHandlers", 1); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.BeforeUnloadHandlers.Percentage", 1); + } // Give the page a user gesture and try reloading again. This time there // should be a dialog. If there is no dialog, the call to Wait will hang. @@ -762,12 +780,22 @@ ->GetPrimaryMainFrame() ->ExecuteJavaScriptWithUserGestureForTests( std::u16string(), base::NullCallback(), ISOLATED_WORLD_ID_GLOBAL); - web_contents()->GetController().Reload(ReloadType::NORMAL, false); - dialog_manager.Wait(); + { + base::HistogramTester histogram_tester; + web_contents()->GetController().Reload(ReloadType::NORMAL, false); + dialog_manager.Wait(); - // Answer the dialog. - dialog_manager.Run(true, std::u16string()); - EXPECT_TRUE(WaitForLoadStop(web_contents())); + // Answer the dialog. + dialog_manager.Run(true, std::u16string()); + EXPECT_TRUE(WaitForLoadStop(web_contents())); + histogram_tester.ExpectUniqueSample( + "Navigation.StartAdjustment", + NavigationStartAdjustmentType::kBeforeUnloadDialog, 1); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.BeforeUnloadDialog", 1); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.BeforeUnloadDialog.Percentage", 1); + } // The reload should have cleared the user gesture bit, so upon leaving again // there should be no beforeunload dialog. @@ -2139,12 +2167,53 @@ ->GetHasPostData()); // Reload and verify the form was submitted. - web_contents()->GetController().Reload(ReloadType::NORMAL, false); - EXPECT_TRUE(WaitForLoadStop(web_contents())); + { + base::HistogramTester histogram_tester; + web_contents()->GetController().Reload(ReloadType::NORMAL, false); + EXPECT_TRUE(WaitForLoadStop(web_contents())); + + // This browser-initiated reload adjusts navigation start time for a legacy + // PostTask, without any beforeunload handlers present. + histogram_tester.ExpectUniqueSample( + "Navigation.StartAdjustment", + NavigationStartAdjustmentType::kLegacyPostTask, 1); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.LegacyPostTask", 1); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.LegacyPostTask.Percentage", 1); + } EXPECT_EQ("text=&select=a", base::UTF16ToASCII(web_contents()->GetTitle())); CHECK_EQ(2, post_counter); } +// Tests navigation metrics for back to back reloads, without waiting for the +// first reload to complete. This currently incorrectly creates a negative +// adjustment to the start time, because a posted task from the first navigation +// updates the start time of the second navigation (after the first is +// canceled). See https://crbug.com/385170155. +IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, BackToBackReloads) { + EXPECT_TRUE( + NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); + + base::HistogramTester histogram_tester; + web_contents()->GetController().Reload(ReloadType::NORMAL, false); + web_contents()->GetController().Reload(ReloadType::NORMAL, false); + EXPECT_TRUE(WaitForLoadStop(web_contents())); + + // The negative adjustment counts as a legacy post task case, but its time + // should show up in a separate negative time bucket, without a corresponding + // percentage value. + histogram_tester.ExpectUniqueSample( + "Navigation.StartAdjustment", + NavigationStartAdjustmentType::kLegacyPostTask, 1); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.LegacyPostTask.Negative", 1); + histogram_tester.ExpectTotalCount("Navigation.StartAdjustment.LegacyPostTask", + 0); + histogram_tester.ExpectTotalCount( + "Navigation.StartAdjustment.LegacyPostTask.Percentage", 0); +} + namespace { class NavigationHandleGrabber : public WebContentsObserver {
diff --git a/content/browser/renderer_host/stored_page.h b/content/browser/renderer_host/stored_page.h index 2e75dfd5..b8e476e 100644 --- a/content/browser/renderer_host/stored_page.h +++ b/content/browser/renderer_host/stored_page.h
@@ -31,8 +31,7 @@ public: using RenderFrameProxyHostMap = std::unordered_map<SiteInstanceGroupId, - std::unique_ptr<RenderFrameProxyHost>, - SiteInstanceGroupId::Hasher>; + std::unique_ptr<RenderFrameProxyHost>>; using RenderViewHostImplSafeRefSet = std::set<base::SafeRef<RenderViewHostImpl>>;
diff --git a/content/browser/webui/web_ui_mojo_browsertest.cc b/content/browser/webui/web_ui_mojo_browsertest.cc index 9b9c7c8..6a5858f6 100644 --- a/content/browser/webui/web_ui_mojo_browsertest.cc +++ b/content/browser/webui/web_ui_mojo_browsertest.cc
@@ -50,47 +50,12 @@ #include "mojo/public/cpp/bindings/receiver.h" #include "third_party/blink/public/common/chrome_debug_urls.h" -#if BUILDFLAG(IS_CHROMEOS) -#include "content/test/data/web_ui_test.test-mojom.h" -#include "content/test/data/web_ui_test_types.test-mojom.h" -#endif - namespace content { namespace { -const char kMojoWebUiHost[] = "mojo-web-ui"; const char kMojoWebUiTsHost[] = "mojo-web-ui-ts"; const char kDummyWebUiHost[] = "dummy-web-ui"; -#if BUILDFLAG(IS_CHROMEOS) -class WebUIMojoTestCacheImpl : public mojom::WebUIMojoTestCache { - public: - explicit WebUIMojoTestCacheImpl( - mojo::PendingReceiver<mojom::WebUIMojoTestCache> receiver) - : receiver_(this, std::move(receiver)) {} - - ~WebUIMojoTestCacheImpl() override = default; - - // mojom::WebUIMojoTestCache overrides: - void Put(const GURL& url, const std::string& contents) override { - cache_[url] = contents; - } - - void GetAll(GetAllCallback callback) override { - std::vector<mojom::CacheItemPtr> items; - for (const auto& entry : cache_) - items.push_back(mojom::CacheItem::New(entry.first, entry.second)); - std::move(callback).Run(std::move(items)); - } - - private: - mojo::Receiver<mojom::WebUIMojoTestCache> receiver_; - std::map<GURL, std::string> cache_; -}; -#endif - -// Duplicate for the TypeScript version of the test. We can't re-use because -// the TS interface has to be named differently to avoid conflicting symbols. class WebUITsMojoTestCacheImpl : public mojom::WebUITsMojoTestCache { public: explicit WebUITsMojoTestCacheImpl( @@ -161,18 +126,6 @@ {BindingsPolicyValue::kMojoWebUi})) : WebUIController(web_ui) { web_ui->SetBindings(bindings); -#if BUILDFLAG(IS_CHROMEOS) - { - WebUIDataSource* data_source = WebUIDataSource::CreateAndAdd( - web_ui->GetWebContents()->GetBrowserContext(), kMojoWebUiHost); - data_source->OverrideContentSecurityPolicy( - network::mojom::CSPDirectiveName::ScriptSrc, - "script-src chrome://resources 'self' 'unsafe-eval';"); - data_source->DisableTrustedTypesCSP(); - data_source->AddResourcePaths(kWebUiMojoTestResources); - data_source->AddResourcePath("", IDR_WEB_UI_MOJO_HTML); - } -#endif { WebUIDataSource* data_source = WebUIDataSource::CreateAndAdd( web_ui->GetWebContents()->GetBrowserContext(), kMojoWebUiTsHost); @@ -199,35 +152,20 @@ TestWebUIController& operator=(const TestWebUIController&) = delete; protected: -#if BUILDFLAG(IS_CHROMEOS) - std::unique_ptr<WebUIMojoTestCacheImpl> cache_; -#endif std::unique_ptr<WebUITsMojoTestCacheImpl> ts_cache_; }; -// TestWebUIController that can bind a WebUIMojoTestCache or -// WebUITsMojoTestCache interface when requested by the page. Uses asserts to -// ensure only one of the two is created for each test. +// TestWebUIController that can bind a WebUITsMojoTestCache interface when +// requested by the page. class CacheTestWebUIController : public TestWebUIController { public: explicit CacheTestWebUIController(WebUI* web_ui) : TestWebUIController(web_ui) {} ~CacheTestWebUIController() override = default; -#if BUILDFLAG(IS_CHROMEOS) - void BindInterface( - mojo::PendingReceiver<mojom::WebUIMojoTestCache> receiver) { - cache_ = std::make_unique<WebUIMojoTestCacheImpl>(std::move(receiver)); - ASSERT_FALSE(ts_cache_); - } -#endif - void BindInterface( mojo::PendingReceiver<mojom::WebUITsMojoTestCache> receiver) { ts_cache_ = std::make_unique<WebUITsMojoTestCacheImpl>(std::move(receiver)); -#if BUILDFLAG(IS_CHROMEOS) - ASSERT_FALSE(cache_); -#endif } WEB_UI_CONTROLLER_TYPE_DECL(); @@ -317,17 +255,12 @@ void RegisterBrowserInterfaceBindersForFrame( RenderFrameHost* render_frame_host, mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override { -#if BUILDFLAG(IS_CHROMEOS) - RegisterWebUIControllerInterfaceBinder<mojom::WebUIMojoTestCache, - CacheTestWebUIController>(map); -#endif RegisterWebUIControllerInterfaceBinder<mojom::WebUITsMojoTestCache, CacheTestWebUIController>(map); } }; -class WebUIMojoTest : public ContentBrowserTest, - public testing::WithParamInterface<bool> { +class WebUIMojoTest : public ContentBrowserTest { public: WebUIMojoTest() = default; @@ -350,9 +283,7 @@ } protected: - std::string GetMojoWebUiHost() { - return std::string(GetParam() ? kMojoWebUiTsHost : kMojoWebUiHost); - } + std::string GetMojoWebUiHost() { return kMojoWebUiTsHost; } void SetUpOnMainThread() override { client_ = std::make_unique<TestWebUIContentBrowserClient>(); @@ -367,14 +298,6 @@ std::unique_ptr<TestWebUIContentBrowserClient> client_; }; -// Test both JS and TS on Ash, since Ash widely uses both types of WebUI -// bindings. Test TS only on other platforms. -#if BUILDFLAG(IS_CHROMEOS) -INSTANTIATE_TEST_SUITE_P(All, WebUIMojoTest, testing::Bool()); -#else -INSTANTIATE_TEST_SUITE_P(All, WebUIMojoTest, testing::Values(true)); -#endif - #if BUILDFLAG(IS_LINUX) // TODO(crbug.com/353502934): This test became flaky on Linux TSan builds since // 2024-07-16. @@ -384,7 +307,7 @@ #endif // Loads a WebUI page that contains Mojo JS bindings and verifies a message // round-trip between the page and the browser. -IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_EndToEndCommunication) { +IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndCommunication) { // Load a dummy page in the initial RenderFrameHost. The initial // RenderFrameHost is created by the test harness prior to installing // TestWebUIContentBrowserClient in WebUIMojoTest::SetUpOnMainThread(). If we @@ -438,7 +361,7 @@ #else #define MAYBE_NativeMojoAvailable NativeMojoAvailable #endif -IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_NativeMojoAvailable) { +IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_NativeMojoAvailable) { // Mojo bindings should be enabled. NavigateWithNewWebUI("web_ui_mojo_native.html"); EXPECT_TRUE(RunBoolFunction("isNativeMojoAvailable()")); @@ -466,7 +389,7 @@ #else #define MAYBE_ChromeSendAvailable ChromeSendAvailable #endif -IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_ChromeSendAvailable) { +IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_ChromeSendAvailable) { // chrome.send is not available on mojo-only WebUIs. NavigateWithNewWebUI("web_ui_mojo_native.html"); EXPECT_FALSE(RunBoolFunction("isChromeSendAvailable()")); @@ -488,7 +411,7 @@ EXPECT_FALSE(RunBoolFunction("isChromeSendAvailable()")); } -IN_PROC_BROWSER_TEST_P(WebUIMojoTest, ChromeSendAvailable_AfterCrash) { +IN_PROC_BROWSER_TEST_F(WebUIMojoTest, ChromeSendAvailable_AfterCrash) { GURL test_url(GetWebUIURL(GetMojoWebUiHost() + "/web_ui_mojo_native.html?webui_bindings"));
diff --git a/content/browser/xr/webxr_internals/webxr_internals_ui.cc b/content/browser/xr/webxr_internals/webxr_internals_ui.cc index 9931eb1..6082c596 100644 --- a/content/browser/xr/webxr_internals/webxr_internals_ui.cc +++ b/content/browser/xr/webxr_internals/webxr_internals_ui.cc
@@ -2,11 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/342213636): Remove this and spanify to fix the errors. -#pragma allow_unsafe_buffers -#endif - #include "content/browser/xr/webxr_internals/webxr_internals_ui.h" #include "base/feature_list.h"
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc index 02dc9e5..0167780 100644 --- a/content/child/runtime_features.cc +++ b/content/child/runtime_features.cc
@@ -395,6 +395,9 @@ kSetOnlyIfOverridden}, {"TopicsDocumentAPI", raw_ref(features::kPrivacySandboxAdsAPIsM1Override)}, + {"TopicsImgAPI", raw_ref(features::kPrivacySandboxAdsAPIsOverride), + kSetOnlyIfOverridden}, + {"TopicsImgAPI", raw_ref(features::kPrivacySandboxAdsAPIsM1Override)}, {"TouchTextEditingRedesign", raw_ref(features::kTouchTextEditingRedesign)}, {"TrustedTypesFromLiteral", @@ -583,6 +586,7 @@ << blink::features::kBrowsingTopics.name << " in addition."; WebRuntimeFeatures::EnableTopicsAPI(false); WebRuntimeFeatures::EnableTopicsDocumentAPI(false); + WebRuntimeFeatures::EnableTopicsImgAPI(false); } else { if (!base::FeatureList::IsEnabled( blink::features::kBrowsingTopicsDocumentAPI)) {
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java b/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java index 7a2f13a..a06a1ee 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java
@@ -107,12 +107,13 @@ import org.junit.Test; import org.junit.runner.RunWith; -import org.chromium.base.FeatureList; import org.chromium.base.ThreadUtils; import org.chromium.base.test.util.Criteria; import org.chromium.base.test.util.CriteriaHelper; import org.chromium.base.test.util.DisableIf; import org.chromium.base.test.util.DisabledTest; +import org.chromium.base.test.util.Features.DisableFeatures; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.base.test.util.HistogramWatcher; import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.TestAnimations; @@ -123,7 +124,6 @@ import org.chromium.ui.base.DeviceFormFactor; import org.chromium.ui.test.util.DeviceRestriction; -import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -171,12 +171,6 @@ private static final String FOCUSING_ERROR = "Expected focus to be on a different node than it is."; - // ContentFeatureList maps used for various tests. - private static final Map<String, Boolean> INCLUDE_LONG_CLICK_ENABLED = - Map.of(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION, true); - private static final Map<String, Boolean> INCLUDE_LONG_CLICK_DISABLED = - Map.of(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION, false); - // Constant values for unit tests private static final int UNSUPPRESSED_EXPECTED_COUNT = 15; @@ -2028,11 +2022,10 @@ /** Test that ACTION_LONG_CLICK is included when experiment is running. */ @Test @SmallTest + @EnableFeatures(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION) public void testNodeInfo_Actions_longClickIncluded() throws Throwable { setupTestWithHTML("<p id='id1'>Example</p>"); - FeatureList.setTestFeatures(INCLUDE_LONG_CLICK_ENABLED); - int vvId = waitForNodeMatching(sViewIdResourceNameMatcher, "id1"); mNodeInfo = createAccessibilityNodeInfo(vvId); Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo); @@ -2043,11 +2036,10 @@ /** Test that ACTION_LONG_CLICK is excluded when experiment is paused. */ @Test @SmallTest + @DisableFeatures(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION) public void testNodeInfo_Actions_longClickExcluded() throws Throwable { setupTestWithHTML("<p id='id1'>Example</p>"); - FeatureList.setTestFeatures(INCLUDE_LONG_CLICK_DISABLED); - int vvId = waitForNodeMatching(sViewIdResourceNameMatcher, "id1"); mNodeInfo = createAccessibilityNodeInfo(vvId); Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java index b367751de..c28288d 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java
@@ -14,22 +14,20 @@ import androidx.test.filters.SmallTest; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.chromium.base.FeatureList; import org.chromium.base.test.util.Batch; import org.chromium.base.test.util.Feature; +import org.chromium.base.test.util.Features.DisableFeatures; import org.chromium.blink_public.common.BlinkFeatures; import org.chromium.content_public.browser.test.ContentJUnit4ClassRunner; import org.chromium.content_public.browser.test.util.TestInputMethodManagerWrapper; -import java.util.Map; - /** Test for {@link CursorAnchorInfoController}. */ @RunWith(ContentJUnit4ClassRunner.class) @Batch(Batch.UNIT_TESTS) +@DisableFeatures(BlinkFeatures.CURSOR_ANCHOR_INFO_MOJO_PIPE) public class CursorAnchorInfoControllerTest { private static final class TestViewDelegate implements CursorAnchorInfoController.ViewDelegate { public int locationX; @@ -144,13 +142,6 @@ } } - @Before - public void setUp() { - // Cannot access native features exposed to Java in tests without native initialization. - // Instead, assign a test value to the feature. - FeatureList.setTestFeatures(Map.of(BlinkFeatures.CURSOR_ANCHOR_INFO_MOJO_PIPE, false)); - } - @Test @SmallTest @Feature({"Input-Text-IME"})
diff --git a/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java b/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java index 1a5db9d7..90746ea 100644 --- a/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java +++ b/content/public/android/junit/src/org/chromium/content/browser/BindingManagerTest.java
@@ -24,7 +24,6 @@ import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowLooper; -import org.chromium.base.FeatureList; import org.chromium.base.process_launcher.ChildProcessConnection; import org.chromium.base.process_launcher.TestChildProcessConnection; import org.chromium.base.test.BaseRobolectricTestRunner; @@ -87,7 +86,6 @@ @After public void tearDown() { LauncherThread.setLauncherThreadAsLauncherThread(); - FeatureList.setTestValues(null); } private void setupBindingType(boolean useNotPerceptibleBinding) {
diff --git a/content/public/browser/permission_controller.h b/content/public/browser/permission_controller.h index e98dd99..014b4041 100644 --- a/content/public/browser/permission_controller.h +++ b/content/public/browser/permission_controller.h
@@ -145,17 +145,4 @@ } // namespace content -namespace std { - -template <> -struct hash<content::PermissionController::SubscriptionId> { - std::size_t operator()( - const content::PermissionController::SubscriptionId& v) const { - content::PermissionController::SubscriptionId::Hasher hasher; - return hasher(v); - } -}; - -} // namespace std - #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_CONTROLLER_H_
diff --git a/content/public/test/test_utils.cc b/content/public/test/test_utils.cc index 8fc4cb23..8392d18 100644 --- a/content/public/test/test_utils.cc +++ b/content/public/test/test_utils.cc
@@ -48,6 +48,29 @@ #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h" #include "url/url_util.h" +#if BUILDFLAG(IS_ANDROID) +#include "cc/slim/layer_tree.h" +#include "content/browser/renderer_host/compositor_impl_android.h" +#include "ui/android/window_android.h" +#include "ui/android/window_android_compositor.h" +#endif // BUILDFLAG(IS_ANDROID) + +#if BUILDFLAG(IS_IOS) +#include "content/browser/renderer_host/browser_compositor_ios.h" +#include "content/browser/renderer_host/test_render_widget_host_view_ios_factory.h" +#endif // BUILDFLAG(IS_IOS) + +#if BUILDFLAG(IS_MAC) +#include "content/browser/renderer_host/browser_compositor_view_mac.h" +#include "content/browser/renderer_host/test_render_widget_host_view_mac_factory.h" +#include "ui/compositor/compositor.h" +#endif // BUILDFLAG(IS_MAC) + +#if defined(USE_AURA) +#include "content/browser/renderer_host/render_widget_host_view_aura.h" +#include "ui/compositor/compositor.h" +#endif // defined(USE_AURA) + namespace content { namespace { @@ -592,4 +615,70 @@ SetBrowserClientForTesting(old_client_); } +void WaitForBrowserCompositorFramePresented(WebContents* web_contents) { +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_IOS) && \ + !defined(USE_AURA) + NOTREACHED(); +#else + base::RunLoop run_loop; + auto callback = base::BindOnce( + [](base::RepeatingClosure cb, + const viz::FrameTimingDetails& frame_timing_details) { + std::move(cb).Run(); + }, + run_loop.QuitClosure()); +#if BUILDFLAG(IS_ANDROID) + ui::WindowAndroidCompositor* compositor = + web_contents->GetNativeView()->GetWindowAndroid()->GetCompositor(); + compositor->PostRequestSuccessfulPresentationTimeForNextFrame( + std::move(callback)); +#elif BUILDFLAG(IS_MAC) + auto* browser_compositor = GetBrowserCompositorMacForTesting( + web_contents->GetRenderWidgetHostView()); + browser_compositor->GetCompositor() + ->RequestSuccessfulPresentationTimeForNextFrame(std::move(callback)); +#elif BUILDFLAG(IS_IOS) + auto* browser_compositor = GetBrowserCompositorIOSForTesting( + web_contents->GetRenderWidgetHostView()); + browser_compositor->GetCompositor() + ->RequestSuccessfulPresentationTimeForNextFrame(std::move(callback)); +#elif defined(USE_AURA) + auto* compositor = static_cast<RenderWidgetHostViewAura*>( + web_contents->GetRenderWidgetHostView()) + ->GetCompositor(); + compositor->RequestSuccessfulPresentationTimeForNextFrame( + std::move(callback)); +#endif + run_loop.Run(); +#endif +} + +void ForceNewCompositorFrameFromBrowser(WebContents* web_contents) { +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_IOS) && \ + !defined(USE_AURA) + NOTREACHED(); +#endif + +#if BUILDFLAG(IS_ANDROID) + ui::WindowAndroid* window = web_contents->GetTopLevelNativeWindow(); + ui::WindowAndroidCompositor* compositor = window->GetCompositor(); + cc::slim::LayerTree* layer_tree = + static_cast<CompositorImpl*>(compositor)->GetLayerTreeForTesting(); + layer_tree->SetNeedsRedrawForTesting(); +#elif BUILDFLAG(IS_MAC) + auto* browser_compositor = GetBrowserCompositorMacForTesting( + web_contents->GetRenderWidgetHostView()); + browser_compositor->GetCompositor()->ScheduleFullRedraw(); +#elif BUILDFLAG(IS_IOS) + auto* browser_compositor = GetBrowserCompositorIOSForTesting( + web_contents->GetRenderWidgetHostView()); + browser_compositor->GetCompositor()->ScheduleFullRedraw(); +#elif defined(USE_AURA) + auto* compositor = static_cast<RenderWidgetHostViewAura*>( + web_contents->GetRenderWidgetHostView()) + ->GetCompositor(); + compositor->ScheduleFullRedraw(); +#endif +} + } // namespace content
diff --git a/content/public/test/test_utils.h b/content/public/test/test_utils.h index 409da0b0..b6af0745 100644 --- a/content/public/test/test_utils.h +++ b/content/public/test/test_utils.h
@@ -467,6 +467,15 @@ const raw_ptr<ContentBrowserClient> old_client_; }; +// Blocks the current execution until the frame submitted via the browser's +// compositor is presented on the screen. +void WaitForBrowserCompositorFramePresented(WebContents* web_contents); + +// Forces the browser to submit a compositor frame, even if nothing has changed +// in the viewport. Use `WaitForBrowserCompositorFramePresented()` to wait for +// the frame's presentation. +void ForceNewCompositorFrameFromBrowser(WebContents* web_contents); + } // namespace content #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_
diff --git a/content/services/auction_worklet/trusted_signals_request_manager.cc b/content/services/auction_worklet/trusted_signals_request_manager.cc index bca20788..0546f38 100644 --- a/content/services/auction_worklet/trusted_signals_request_manager.cc +++ b/content/services/auction_worklet/trusted_signals_request_manager.cc
@@ -21,9 +21,11 @@ #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_refptr.h" +#include "base/metrics/histogram_functions.h" #include "base/notreached.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" +#include "base/timer/elapsed_timer.h" #include "base/timer/timer.h" #include "content/common/content_export.h" #include "content/services/auction_worklet/auction_v8_helper.h" @@ -525,6 +527,8 @@ return; } + base::ElapsedTimer compute_batch_cost; + std::unique_ptr<TrustedSignalsUrlBuilder> url_builder; bool split_fetch = base::FeatureList::IsEnabled( blink::features::kFledgeSplitTrustedSignalsFetchingURL); @@ -550,6 +554,12 @@ IssueRequests(*url_builder.get()); queued_requests_.clear(); + base::UmaHistogramMicrosecondsTimes( + type_ == Type::kBiddingSignals + ? "Ads.InterestGroup.Auction.TrustedBidderBatchCompute" + : "Ads.InterestGroup.Auction.TrustedSellerBatchCompute", + compute_batch_cost.Elapsed()); + return; }
diff --git a/content/services/auction_worklet/trusted_signals_request_manager_unittest.cc b/content/services/auction_worklet/trusted_signals_request_manager_unittest.cc index 0093eda..2ed819a 100644 --- a/content/services/auction_worklet/trusted_signals_request_manager_unittest.cc +++ b/content/services/auction_worklet/trusted_signals_request_manager_unittest.cc
@@ -22,6 +22,7 @@ #include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h" #include "base/test/bind.h" +#include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "components/cbor/reader.h" @@ -640,6 +641,8 @@ } TEST_F(TrustedSignalsRequestManagerTest, BiddingSignalsOneRequest) { + base::HistogramTester histogram_tester; + const std::vector<std::string> kKeys{"key2", "key1"}; scoped_refptr<TrustedSignals::Result> signals = FetchBiddingSignalsWithResponse( @@ -669,9 +672,16 @@ "&keys=key1,key2&interestGroupNames=name1" "&trusted_bidding_signals_slot_size_param=foo", "Completion Status: net::OK")); + // Measured time for URL computation is zero since this is using MOCK_TIME + // and nothing advances it during straight computation. + histogram_tester.ExpectUniqueTimeSample( + "Ads.InterestGroup.Auction.TrustedBidderBatchCompute", base::TimeDelta(), + /*expected_bucket_count=*/1); } TEST_F(TrustedSignalsRequestManagerTest, ScoringSignalsOneRequest) { + base::HistogramTester histogram_tester; + const GURL kRenderUrl = GURL("https://foo.test/"); const std::vector<std::string> kAdComponentRenderUrls{ "https://foosub.test/", "https://barsub.test/", "https://bazsub.test/"}; @@ -693,6 +703,12 @@ R"("adComponentRenderUrls":{"https://foosub.test/":2,)" R"("https://barsub.test/":[3],"https://bazsub.test/":"4"}})", ExtractScoringSignals(signals.get(), kRenderUrl, kAdComponentRenderUrls)); + + // Measured time for URL computation is zero since this is using MOCK_TIME + // and nothing advances it during straight computation. + histogram_tester.ExpectUniqueTimeSample( + "Ads.InterestGroup.Auction.TrustedSellerBatchCompute", base::TimeDelta(), + /*expected_bucket_count=*/1); } TEST_F(TrustedSignalsRequestManagerTest, BiddingSignalsSequentialRequests) {
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 6425e4e..a84e11d1 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -546,6 +546,7 @@ ":content_test_mojo_bindings", ":web_ui_mojo_test_resources", "//cc:test_support", + "//cc/slim", "//components/attribution_reporting:data_host_mojom", "//components/attribution_reporting:mojom", "//components/attribution_reporting:source_type_mojom", @@ -662,6 +663,7 @@ "//content/shell:android_shell_descriptors", "//mojo/public/java/system:native_support", "//testing/android/native_test:native_browser_test_support", + "//ui/android:android", ] } else { sources += [ @@ -689,10 +691,6 @@ } } - if (is_chromeos) { - deps += [ ":web_ui_test_mojo_bindings" ] - } - # HID support is not available without udev. is_linux_without_udev = (is_linux || is_chromeos) && !use_udev if (!is_linux_without_udev && !is_android) { @@ -1064,7 +1062,6 @@ "//base/test:test_config", "//base/test:test_support", "//build:chromeos_buildflags", - "//cc/slim", "//components/input", "//components/network_session_configurator/common:common", "//components/services/storage:storage", @@ -1083,10 +1080,7 @@ ] if (is_android) { - deps += [ - "//content/public/app", - "//ui/android:android", - ] + deps += [ "//content/public/app" ] } else { deps += [ "//content/public/browser" ] } @@ -1122,25 +1116,6 @@ ] } -# Testing JS bindings only on Ash, since they are primarily used there and -# because this test relies on the URL WebUI mojo bindings, which are -# TypeScript only on other platforms. -if (is_chromeos) { - mojom("web_ui_test_mojo_bindings") { - testonly = true - sources = [ - "data/web_ui_test.test-mojom", - "data/web_ui_test_types.test-mojom", - ] - public_deps = [ "//url/mojom:url_mojom_gurl" ] - webui_module_path = "/content/test/data" - - # Generate WebUI bindings in JavaScript instead of TypeScript. This is - # necessary since this target is intentionally testing JS WebUI bindings. - generate_webui_js_bindings = true - } -} - mojom("web_ui_managed_interface_tests_bindings") { testonly = true sources = [ "data/web_ui_managed_interface_test.test-mojom" ] @@ -1148,22 +1123,6 @@ webui_module_path = "/content/test/data" } -# Closure compilation is only used on Ash. See below for TypeScript targets -# which are used across platforms. -if (is_chromeos) { - js_library("web_ui_mojo_test_js") { - sources = [ "data/web_ui_mojo_test.js" ] - deps = [ ":web_ui_test_mojo_bindings_webui_js" ] - } - - # NOTE: Building this target serves as a compile test for type-checking of - # WebUI JS that consumes generated Mojom JS bindings. - js_type_check("web_ui_mojo_test_js_type_check") { - deps = [ ":web_ui_mojo_test_js" ] - closure_flags = default_closure_args + mojom_js_args - } -} - # Test cross target mojo typemapping. mojom("web_ui_ts_test_other_mojo_bindings") { testonly = true @@ -1986,10 +1945,6 @@ ] } - if (is_chromeos) { - deps += [ ":web_ui_test_mojo_bindings" ] - } - if (enable_plugins) { sources += [ "../browser/plugin_service_impl_browsertest.cc" ] } @@ -2143,10 +2098,7 @@ } if (is_chromeos) { - deps += [ - ":web_ui_mojo_test_js_type_check", - "//chromeos/ash/components/assistant:buildflags", - ] + deps += [ "//chromeos/ash/components/assistant:buildflags" ] } if (is_android) { @@ -2412,10 +2364,6 @@ "web_ui_mojo_test_resources.pak", ] deps = [ ":web_ui_mojo_test_build_ts" ] - - if (is_chromeos) { - deps += [ ":web_ui_test_mojo_bindings_js__generator" ] - } } static_library("run_all_unittests") {
diff --git a/content/test/content_browser_test_utils_internal.cc b/content/test/content_browser_test_utils_internal.cc index 96e253c4..6ff49e88e 100644 --- a/content/test/content_browser_test_utils_internal.cc +++ b/content/test/content_browser_test_utils_internal.cc
@@ -52,27 +52,6 @@ #include "net/test/embedded_test_server/request_handler_util.h" #include "third_party/blink/public/common/frame/frame_visual_properties.h" -#if BUILDFLAG(IS_ANDROID) -#include "cc/slim/layer_tree.h" -#include "content/browser/renderer_host/compositor_impl_android.h" -#include "ui/android/window_android.h" -#include "ui/android/window_android_compositor.h" -#endif // BUILDFLAG(IS_ANDROID) - -#if BUILDFLAG(IS_MAC) -#include "content/browser/renderer_host/browser_compositor_view_mac.h" -#include "content/browser/renderer_host/test_render_widget_host_view_mac_factory.h" -#endif // BUILDFLAG(IS_MAC) - -#if BUILDFLAG(IS_IOS) -#include "content/browser/renderer_host/browser_compositor_ios.h" -#include "content/browser/renderer_host/test_render_widget_host_view_ios_factory.h" -#endif // BUILDFLAG(IS_IOS) - -#if defined(USE_AURA) -#include "content/browser/renderer_host/render_widget_host_view_aura.h" -#endif // defined(USE_AURA) - namespace content { bool NavigateFrameToURL(FrameTreeNode* node, const GURL& url) { @@ -1169,67 +1148,6 @@ CHECK(future.Wait()); } -void WaitForBrowserCompositorFramePresented(WebContents* web_contents) { -#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_IOS) && \ - !defined(USE_AURA) - NOTREACHED(); -#else - base::RunLoop run_loop; - auto callback = base::BindOnce( - [](base::RepeatingClosure cb, - const viz::FrameTimingDetails& frame_timing_details) { - std::move(cb).Run(); - }, - run_loop.QuitClosure()); -#if BUILDFLAG(IS_ANDROID) - ui::WindowAndroidCompositor* compositor = - web_contents->GetNativeView()->GetWindowAndroid()->GetCompositor(); - compositor->PostRequestSuccessfulPresentationTimeForNextFrame( - std::move(callback)); -#elif BUILDFLAG(IS_MAC) - auto* browser_compositor = GetBrowserCompositorMacForTesting( - web_contents->GetRenderWidgetHostView()); - browser_compositor->GetCompositor() - ->RequestSuccessfulPresentationTimeForNextFrame(std::move(callback)); -#elif BUILDFLAG(IS_IOS) - auto* browser_compositor = GetBrowserCompositorIOSForTesting( - web_contents->GetRenderWidgetHostView()); - browser_compositor->GetCompositor() - ->RequestSuccessfulPresentationTimeForNextFrame(std::move(callback)); -#elif defined(USE_AURA) - auto* compositor = static_cast<RenderWidgetHostViewAura*>( - web_contents->GetRenderWidgetHostView()) - ->GetCompositor(); - compositor->RequestSuccessfulPresentationTimeForNextFrame( - std::move(callback)); -#endif - run_loop.Run(); -#endif -} - -void ForceNewCompositorFrameFromBrowser(WebContents* web_contents) { -#if BUILDFLAG(IS_ANDROID) - ui::WindowAndroid* window = web_contents->GetTopLevelNativeWindow(); - ui::WindowAndroidCompositor* compositor = window->GetCompositor(); - cc::slim::LayerTree* layer_tree = - static_cast<CompositorImpl*>(compositor)->GetLayerTreeForTesting(); - layer_tree->SetNeedsRedrawForTesting(); -#elif BUILDFLAG(IS_MAC) - auto* browser_compositor = GetBrowserCompositorMacForTesting( - web_contents->GetRenderWidgetHostView()); - browser_compositor->GetCompositor()->ScheduleFullRedraw(); -#elif BUILDFLAG(IS_IOS) - auto* browser_compositor = GetBrowserCompositorIOSForTesting( - web_contents->GetRenderWidgetHostView()); - browser_compositor->GetCompositor()->ScheduleFullRedraw(); -#elif defined(USE_AURA) - auto* compositor = static_cast<RenderWidgetHostViewAura*>( - web_contents->GetRenderWidgetHostView()) - ->GetCompositor(); - compositor->ScheduleFullRedraw(); -#endif -} - namespace { // Helper to return a 200 OK non-cacheable response for a first request, and
diff --git a/content/test/content_browser_test_utils_internal.h b/content/test/content_browser_test_utils_internal.h index 62249e3..0b5d335 100644 --- a/content/test/content_browser_test_utils_internal.h +++ b/content/test/content_browser_test_utils_internal.h
@@ -828,15 +828,6 @@ // against its view. void WaitForCopyableViewInFrame(RenderFrameHost* render_frame_host); -// Blocks the current execution until the frame submitted via the browser's -// compositor is presented on the screen. -void WaitForBrowserCompositorFramePresented(WebContents* web_contents); - -// Forces the browser to submit a compositor frame, even if nothing has changed -// in the viewport. Use `WaitForBrowserCompositorFramePresented()` to wait for -// the frame's presentation. -void ForceNewCompositorFrameFromBrowser(WebContents* web_contents); - // Sets up a /redirect-on-second-navigation?url endpoint on the provided // `server`, which will return a 200 OK response for the first request, and // redirect the second request to `url` provided in the query param. This should
diff --git a/content/test/content_test_bundle_data.filelist b/content/test/content_test_bundle_data.filelist index 288cbad8..0eab95a 100644 --- a/content/test/content_test_bundle_data.filelist +++ b/content/test/content_test_bundle_data.filelist
@@ -8204,16 +8204,12 @@ data/web_ui_mojo_conformance_test.ts data/web_ui_mojo_native.html data/web_ui_mojo_native.js -data/web_ui_mojo_test.html -data/web_ui_mojo_test.js data/web_ui_mojo_ts_test.html data/web_ui_mojo_ts_test.ts data/web_ui_mojo_ts_test_converters.ts data/web_ui_mojo_ts_test_mapped_types.ts data/web_ui_mojo_ts_test_other_mapped_types.ts data/web_ui_shared_worker.js -data/web_ui_test.test-mojom -data/web_ui_test_types.test-mojom data/web_ui_ts_test.test-mojom data/web_ui_ts_test_other_types.test-mojom data/web_ui_ts_test_types.test-mojom
diff --git a/content/test/data/web_ui_mojo_test.html b/content/test/data/web_ui_mojo_test.html deleted file mode 100644 index 119c588..0000000 --- a/content/test/data/web_ui_mojo_test.html +++ /dev/null
@@ -1,8 +0,0 @@ -<html> -<head> - <script src="web_ui_mojo_test.js" type="module"></script> -</head> -<body> - x -</body> -</html>
diff --git a/content/test/data/web_ui_mojo_test.js b/content/test/data/web_ui_mojo_test.js deleted file mode 100644 index 15b5094..0000000 --- a/content/test/data/web_ui_mojo_test.js +++ /dev/null
@@ -1,46 +0,0 @@ -// Copyright 2020 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import {WebUIMojoTestCache} from './content/test/data/web_ui_test.test-mojom-webui.js'; - -/** @type {{send: function(*)}} */ -Window.prototype.domAutomationController; - -const TEST_DATA = [ - { url: 'https://google.com/', contents: 'i am in fact feeling lucky' }, - { url: 'https://youtube.com/', contents: 'probably cat videos?' }, - { url: 'https://example.com/', contents: 'internets wow' }, -]; - -async function doTest() { - const cache = WebUIMojoTestCache.getRemote(); - for (const entry of TEST_DATA) { - cache.put({ url: entry.url }, entry.contents); - } - - const {items} = await cache.getAll(); - if (items.length != TEST_DATA.length) { - return false; - } - - const entries = {}; - for (const item of items) { - entries[item.url.url] = item.contents; - } - - for (const entry of TEST_DATA) { - if (!(entry.url in entries)) { - return false; - } - if (entries[entry.url] != entry.contents) { - return false; - } - } - - return true; -} - -window.runTest = async function() { - return doTest(); -}
diff --git a/content/test/data/web_ui_test.test-mojom b/content/test/data/web_ui_test.test-mojom deleted file mode 100644 index bc78e4f3..0000000 --- a/content/test/data/web_ui_test.test-mojom +++ /dev/null
@@ -1,13 +0,0 @@ -// Copyright 2020 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module content.mojom; - -import "content/test/data/web_ui_test_types.test-mojom"; -import "url/mojom/url.mojom"; - -interface WebUIMojoTestCache { - Put(url.mojom.Url url, string contents); - GetAll() => (array<CacheItem> items); -};
diff --git a/content/test/data/web_ui_test_types.test-mojom b/content/test/data/web_ui_test_types.test-mojom deleted file mode 100644 index 3dccacd..0000000 --- a/content/test/data/web_ui_test_types.test-mojom +++ /dev/null
@@ -1,16 +0,0 @@ -// Copyright 2020 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module content.mojom; - -import "url/mojom/url.mojom"; - -// This struct is imported by web_ui_test.test-mojom and is used to provide -// test coverage of non-shared WebUI mojom JS modules importing other -// non-shared WebUI mojom JS modules. -struct CacheItem { - url.mojom.Url url; - string contents; -}; -
diff --git a/content/test/web_ui_mojo_test_resources.grd b/content/test/web_ui_mojo_test_resources.grd index 7f07dd3..9adc490 100644 --- a/content/test/web_ui_mojo_test_resources.grd +++ b/content/test/web_ui_mojo_test_resources.grd
@@ -17,18 +17,10 @@ <include name="IDR_WEB_UI_MANAGED_INTERFACE_TEST_HTML" file="data/web_ui_managed_interface_test.html" type="BINDATA" resource_path="web_ui_managed_interface_test.html" /> <include name="IDR_WEB_UI_MANAGED_INTERFACE_TEST_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_managed_interface_test.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_managed_interface_test.js" /> <include name="IDR_WEB_UI_MANAGED_INTERFACE_TEST_TEST_MOJOM_WEBUI_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_managed_interface_test.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_managed_interface_test.test-mojom-webui.js" /> - <if expr="is_chromeos"> - <include name="IDR_WEB_UI_MOJO_HTML" file="data/web_ui_mojo_test.html" type="BINDATA" /> - <include name="IDR_WEB_UI_MOJO_JS" file="data/web_ui_mojo_test.js" type="BINDATA" resource_path="web_ui_mojo_test.js" /> - </if> <include name="IDR_WEB_UI_MOJO_TS_HTML" file="data/web_ui_mojo_ts_test.html" type="BINDATA" /> <include name="IDR_WEB_UI_MOJO_TS_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_mojo_ts_test.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_mojo_ts_test.js" /> <include name="IDR_WEB_UI_MOJO_NATIVE_HTML" file="data/web_ui_mojo_native.html" type="BINDATA" resource_path="web_ui_mojo_native.html" /> <include name="IDR_WEB_UI_MOJO_NATIVE_JS" file="data/web_ui_mojo_native.js" type="BINDATA" resource_path="web_ui_mojo_native.js" /> - <if expr="is_chromeos"> - <include name="IDR_WEB_UI_TEST_MOJOM_JS" file="${root_gen_dir}/mojom-webui/content/test/data/web_ui_test.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="content/test/data/web_ui_test.test-mojom-webui.js" /> - <include name="IDR_WEB_UI_TEST_TYPES_MOJOM_JS" file="${root_gen_dir}/mojom-webui/content/test/data/web_ui_test_types.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="content/test/data/web_ui_test_types.test-mojom-webui.js" /> - </if> <include name="IDR_WEB_UI_TS_TEST_MOJOM_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_ts_test.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_ts_test.test-mojom-webui.js" /> <include name="IDR_WEB_UI_TS_TEST_MOJOM_CONVERTER_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_ts_test.test-mojom-converters.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_ts_test.test-mojom-converters.js" /> <include name="IDR_WEB_UI_TS_TEST_MOJOM_OTHER_TYPES_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_ts_test_other_types.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_ts_test_other_types.test-mojom-webui.js" />
diff --git a/device/vr/test/test_hook.h b/device/vr/test/test_hook.h index 846525e..964a3fc 100644 --- a/device/vr/test/test_hook.h +++ b/device/vr/test/test_hook.h
@@ -2,11 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifdef UNSAFE_BUFFERS_BUILD -// TODO(crbug.com/351564777): Remove this and convert code to safer constructs. -#pragma allow_unsafe_buffers -#endif - #ifndef DEVICE_VR_TEST_TEST_HOOK_H_ #define DEVICE_VR_TEST_TEST_HOOK_H_ @@ -89,14 +84,16 @@ }; struct PoseFrameData { - float device_to_origin[16]; + std::array<float, 16> device_to_origin; bool is_valid; }; struct DeviceConfig { float interpupillary_distance; - float viewport_left[4]; // raw projection left {left, right, top, bottom} - float viewport_right[4]; // raw projection right {left, right, top, bottom} + std::array<float, 4> + viewport_left; // raw projection left {left, right, top, bottom} + std::array<float, 4> + viewport_right; // raw projection right {left, right, top, bottom} }; struct ControllerAxisData { @@ -140,10 +137,10 @@ uint64_t buttons_pressed = 0; uint64_t buttons_touched = 0; uint64_t supported_buttons = 0; - ControllerAxisData axis_data[kMaxNumAxes]; + std::array<ControllerAxisData, kMaxNumAxes> axis_data; PoseFrameData pose_data = {}; ControllerRole role = kControllerRoleInvalid; - XRHandJointData hand_data[kNumJointsForTest]; + std::array<XRHandJointData, kNumJointsForTest> hand_data; bool has_hand_data = false; bool is_valid = false; @@ -159,7 +156,7 @@ // we're given data in column-major order. Construct in column-major order and // transpose since it looks cleaner than manually transposing the arguments // passed to the constructor. - float* t = data.device_to_origin; + auto& t = data.device_to_origin; return gfx::Transform::ColMajor(t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]);
diff --git a/docs/website b/docs/website index 35124db..adc6178 160000 --- a/docs/website +++ b/docs/website
@@ -1 +1 @@ -Subproject commit 35124dbd52018ec09acadfbf61b18d5ca4d4b067 +Subproject commit adc61787dec31973d464788e4ea78d99320b7474
diff --git a/docs/workflow/debugging-with-swarming.md b/docs/workflow/debugging-with-swarming.md index c1ce34a540..7d03706 100644 --- a/docs/workflow/debugging-with-swarming.md +++ b/docs/workflow/debugging-with-swarming.md
@@ -1,8 +1,11 @@ # Debugging with Swarming This document outlines how to debug a test failure on a specific builder -configuration without needing to repeatedly upload new CL revisions or do CQ dry -runs. +configuration on Swarming using the [UTR tool](../../tools/utr/README.md) +without needing to repeatedly upload new CL revisions or do CQ dry runs. This +tool will automatically handle steps like replicating the right GN args, +building & uploading the test isolate, triggering & collecting the swarming test +tasks. [TOC] @@ -18,7 +21,9 @@ they link against or support data. An isolate can be thought of like a tarball, but held by the CAS server and identified by a digest of its contents. The isolate also includes the command(s) to run, which is why the command is -specified when building the isolate, not when executing it. +specified when building the isolate, not when executing it. See the +[infra glossay](../infra/glossary.md) for the definitions of these terms and +more. Normally, when you do a CQ dry run, something like this happens: @@ -54,204 +59,23 @@ use_swarming_to_run(type, isolate) ``` -## The easy way - -A lot of the steps described in this doc have been bundled up into 2 -tools. Before using either of these you will need to -[authenticate](#authenticating). - -### run-swarmed.py - -A lot of the logic below is wrapped up in `tools/run-swarmed.py`, which you can run -like this: - -``` -$ tools/run-swarmed.py $outdir $target [-- --gtest_filter=...] -``` - -See the `--help` option of `run-swarmed.py` for more details about that script. -Many flags are converted into dimensions to pass to `mb.py`; see -[Bot selection criteria](#bot-selection-criteria) for possible values. (Most -dimensions have the same name as the flag, but `--swarming-os` is just the `os` -dimension.) - -Note you might need `--swarming-os Ubuntu-14.04` if you get an error like, -`UnboundLocalError: local variable 'dbus_pid' referenced before assignment`. - -Web tests can be also run on swarmed. However: -- the only supported output folders are `Debug` and `Release` -- `--no-test-flags` must be specified. - -For example, you can run all Web Platform Tests inside `<some-wpt-folder>` like this: -``` -$ autoninja -C out/Release blink_tests -$ tools/run-swarmed.py --no-test-flags out/Release blink_wpt_tests <some-wpt-folder> -``` - -### mb.py run - -Similar to `tools/run-swarmed.py`, `mb.py run` bundles much of the logic into a -single command line. Unlike `tools/run-swarmed.py`, `mb.py run` allows the user -to specify extra arguments to pass to the test, but has a messier command line. - -To use it, run: -``` -$ tools/mb/mb.py run \ - -s --no-default-dimensions \ - -d pool $pool \ - $criteria \ - $outdir $target \ - -- $extra_args -``` - ## A concrete example -Here's how to run `chrome_public_test_apk` on a bot with a Nexus 5 running KitKat. +Here's how to run `chrome_public_unit_test_apk` on Android devices. By using the +config of the `android-arm64-rel` trybot, we can run it on Pixel 3 XLs running +Android Pie. ```sh -$ tools/mb/mb.py run \ - -s --no-default-dimensions \ - -d pool chromium.tests \ - -d device_os_type userdebug -d device_os KTU84P -d device_type hammerhead \ - out/Android-arm-dbg chrome_public_test_apk +$ vpython3 tools/utr \ + -p chromium \ + -B try \ + -b android-arm64-rel \ + -t "chrome_public_unit_test_apk on Android device Pixel 3 XL" \ + compile-and-test ``` -This assumes you have an `out/Android-arm-dbg/args.gn` like - -``` -ffmpeg_branding = "Chrome" -is_component_build = false -is_debug = true -proprietary_codecs = true -strip_absolute_paths_from_debug_symbols = true -symbol_level = 1 -system_webview_package_name = "com.google.android.webview" -target_os = "android" -use_remoteexec = true -``` - -## Bot selection criteria - -The examples in this doc use `$criteria`. To figure out what values to use, you -can go to an existing swarming run -([recent tasks page](https://chromium-swarm.appspot.com/tasklist)) and -look at the `Dimensions` section. Each of these becomes a `-d dimension_name -dimension_value` in your `$criteria`. Click on `bots` (or go -[here](https://chromium-swarm.appspot.com/botlist)) to be taken to a UI that -allows you to try out the criteria interactively, so that you can be sure that -there are bots matching your criteria. Sometimes the web page shows a -human-friendly name rather than the name required on the commandline. [This -file](https://cs.chromium.org/chromium/infra/luci/appengine/swarming/ui2/modules/alias.js) -contains the mapping to human-friendly names. You can test your commandline by -entering `dimension_name:dimension_value` in the interactive UI. - -## Building an isolate - -At the moment, you can only build an isolate locally, like so (commands you type -begin with `$`): - -``` -$ tools/mb/mb.py isolate //$outdir $target -``` - -This will produce some files in $outdir. The most pertinent two are -`$outdir/$target.isolate` and `$outdir/target.isolated`. If you've already built -$target, you can save some CPU time and run `tools/mb/mb.py` with `--no-build`: - -``` -$ tools/mb/mb.py isolate --no-build //$outdir $target -``` - -Support for building an isolate using swarming, which would allow you to build -for a platform you can't build for locally, does not yet exist. - -## Authenticating - -You may need to log in to `https://chromium-swarm.appspot.com` to do this - -``` -$ tools/luci-go/isolate login -``` - -Use your google.com account for this. On Windows the command would be: - -``` -$ tools\luci-go\isolate.exe login -``` - -## Uploading an isolate - -You can then upload the resulting isolate to the CAS server: - -``` -$ tools/luci-go/isolate archive \ - -cas-instance chromium-swarm \ - -i $outdir/$target.isolate \ - -dump-json $outdir/$target.archive.json -``` - -The archive json looks like this: - -``` -{ - "unit_tests": "5bee0815d2ddd2b876b49d4cce8aaa23de8a6f9e2dbf134ec409fbdc224e8c64/398" -} -``` - -Do not ctrl-c it after it does this, even if it seems to be hanging for a -minute - just let it finish. - -## Running an isolate - -Now that the isolate is on the CAS server with digest `$digest` from the -previous step, you can run on bots of your choice: - -``` -$ tools/luci-go/swarming trigger \ - -server https://chromium-swarm.appspot.com \ - -dimension pool=$pool \ - $criteria \ - -digest $digest -``` - -There are two more things you need to fill in here. The first is the pool name; -you should pick "chromium.tests" unless you know otherwise. The pool is the -collection of hosts from which swarming will try to pick bots to run your tasks. - -The second is the criteria, which is how you specify which bot(s) you want your -task scheduled on. These are specified via "dimensions", which are specified -with `-dimension key=val`. In fact, the `-dimension pool=$pool` in the -command above is selecting based on the "pool" dimension. There are a lot of -possible dimensions; one useful one is "os", like `-dimension os=Linux`. Examples of -other dimensions include: - -* `-dimension os=Mac10.13.6` to select a specific OS version -* `-dimension device_type="Pixel 3"` to select a specific Android device type -* `-dimension gpu=8086:1912` to select a specific GPU - -The [swarming bot list] allows you to see all the dimensions and the values they -can take on. - -And you can pass shard number via env flags, e.g. - -* `-env GTEST_SHARD_INDEX=0` to specify which shard to run. -* `-env GTEST_TOTAL_SHARDS=1` to specify total number of shards. - -If you need to pass additional arguments to the test, simply add -`-- $extra_args` to the end of the `swarming trigger` command line - anything -after the `--` will be passed directly to the test. - -When you invoke `swarming trigger`, it will emit a piece of information: a -command you can run to collect the results of that task. For example: - -``` -To collect results use: - swarming collect -server https://chromium-swarm.appspot.com 4a0e739053fddd10 -``` - -The 'collect' command given there will block until the task is complete, then -produce the task's results, or you can load that URL and watch the task's -progress. +You can find the UTR invocation for any test on the build UI under the step's +"reproduction instructions" (displayed by clicking the page icon in the UI). ## Other notes
diff --git a/gpu/command_buffer/service/shared_image/ozone_image_backing.cc b/gpu/command_buffer/service/shared_image/ozone_image_backing.cc index 578e842c..4ef5315a 100644 --- a/gpu/command_buffer/service/shared_image/ozone_image_backing.cc +++ b/gpu/command_buffer/service/shared_image/ozone_image_backing.cc
@@ -156,6 +156,9 @@ wgpu::BackendType backend_type, std::vector<wgpu::TextureFormat> view_formats, scoped_refptr<SharedContextState> context_state) { + // Creating a representation in GPU is not allowed when usage is CPU only. + CHECK(!(usage().Has(SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE))); + #if BUILDFLAG(USE_DAWN) wgpu::TextureFormat webgpu_format = ToDawnFormat(format()); if (webgpu_format == wgpu::TextureFormat::Undefined) { @@ -177,6 +180,9 @@ scoped_refptr<SharedContextState> context_state) { CHECK(context_state); CHECK(context_state->IsGraphiteDawn()); + // Creating a representation in GPU is not allowed when usage is CPU only. + CHECK(!(usage().Has(SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE))); + #if BUILDFLAG(SKIA_USE_DAWN) auto device = context_state->dawn_context_provider()->GetDevice(); auto backend_type = context_state->dawn_context_provider()->backend_type(); @@ -283,6 +289,9 @@ std::unique_ptr<GLTexturePassthroughImageRepresentation> OzoneImageBacking::ProduceGLTexturePassthrough(SharedImageManager* manager, MemoryTypeTracker* tracker) { + // Creating a representation in GPU is not allowed when usage is CPU only. + CHECK(!(usage().Has(SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE))); + auto texture_holder = RetainGLTexturePerContextCache(); if (!texture_holder) { return nullptr; @@ -301,6 +310,9 @@ SharedImageManager* manager, MemoryTypeTracker* tracker, scoped_refptr<SharedContextState> context_state) { + // Creating a representation in GPU is not allowed when usage is CPU only. + CHECK(!(usage().Has(SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE))); + if (context_state->GrContextIsGL()) { auto gl_representation = ProduceGLTexturePassthrough(manager, tracker); if (!gl_representation) { @@ -372,6 +384,9 @@ std::unique_ptr<OverlayImageRepresentation> OzoneImageBacking::ProduceOverlay( SharedImageManager* manager, MemoryTypeTracker* tracker) { + // Creating a representation in GPU is not allowed when usage is CPU only. + CHECK(!(usage().Has(SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE))); + return std::make_unique<OverlayOzoneImageRepresentation>(manager, this, tracker); } @@ -389,17 +404,18 @@ scoped_refptr<gfx::NativePixmap> pixmap, const GpuDriverBugWorkarounds& workarounds, std::optional<gfx::BufferUsage> buffer_usage) - : ClearTrackingSharedImageBacking(mailbox, - format, - size, - color_space, - surface_origin, - alpha_type, - usage, - std::move(debug_label), - GetPixmapSizeInBytes(*pixmap), - false, - std::move(buffer_usage)), + : ClearTrackingSharedImageBacking( + mailbox, + format, + size, + color_space, + surface_origin, + alpha_type, + usage, + std::move(debug_label), + pixmap ? GetPixmapSizeInBytes(*pixmap) : 0, + false, + std::move(buffer_usage)), pixmap_(std::move(pixmap)), context_state_(std::move(context_state)), workarounds_(workarounds), @@ -451,6 +467,9 @@ gpu::VulkanDeviceQueue* vulkan_device_queue, gpu::VulkanImplementation& vulkan_impl, bool needs_detiling) { + // Creating a representation in GPU is not allowed when usage is CPU only. + CHECK(!(usage().Has(SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE))); + viz::SharedImageFormat image_format = format(); gfx::Size image_size = size(); gfx::GpuMemoryBufferHandle gmb_handle = GetGpuMemoryBufferHandle();
diff --git a/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc b/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc index 48c672d..c935c4f 100644 --- a/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc +++ b/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc
@@ -71,7 +71,7 @@ SHARED_IMAGE_USAGE_HIGH_PERFORMANCE_GPU | SHARED_IMAGE_USAGE_CPU_UPLOAD | SHARED_IMAGE_USAGE_CPU_WRITE_ONLY | SHARED_IMAGE_USAGE_WEBGPU_STORAGE_TEXTURE | - SHARED_IMAGE_USAGE_PROTECTED_VIDEO; + SHARED_IMAGE_USAGE_PROTECTED_VIDEO | SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE; } // namespace @@ -194,14 +194,21 @@ gfx::GpuMemoryBufferHandle handle) { DCHECK_EQ(handle.type, gfx::NATIVE_PIXMAP); - ui::SurfaceFactoryOzone* surface_factory = - ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); - scoped_refptr<gfx::NativePixmap> pixmap = - surface_factory->CreateNativePixmapFromHandle( - kNullSurfaceHandle, size, ToBufferFormat(format), - std::move(handle.native_pixmap_handle)); - if (!pixmap) { - return nullptr; + scoped_refptr<gfx::NativePixmap> pixmap; + + // We do not create a native pixmap if the backing will be used only by the + // CPU. This is usually used for cases where clients needs MappableSI with a + // certain format which is not texturable but client wants to map the shared + // image in CPU for read/writes. + if (!usage.Has(SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE)) { + ui::SurfaceFactoryOzone* surface_factory = + ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); + pixmap = surface_factory->CreateNativePixmapFromHandle( + kNullSurfaceHandle, size, ToBufferFormat(format), + std::move(handle.native_pixmap_handle)); + if (!pixmap) { + return nullptr; + } } auto backing = std::make_unique<OzoneImageBacking>(
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd index ade4686a..0d22caf 100644 --- a/ios/chrome/app/strings/ios_strings.grd +++ b/ios/chrome/app/strings/ios_strings.grd
@@ -5227,6 +5227,15 @@ <message name="IDS_IOS_SET_UP_LIST_TRY_BUTTON_TEXT" desc="Button text next to a Set Up List item suggesting to the user to try the action."> Try </message> + <message name="IDS_IOS_SHARED_GROUP_ERROR_GOT_IT" desc="Title of the button to close the error message, letting the user notify Chrome of their understanding of the error message."> + Got it + </message> + <message name="IDS_IOS_SHARED_GROUP_ERROR_MESSAGE" desc="Title for a generic alert when an error happened."> + There was an error. Try again. + </message> + <message name="IDS_IOS_SHARED_GROUP_ERROR_TITLE" desc="Title for a generic alert when an error happened."> + Something went wrong + </message> <message name="IDS_IOS_SHARED_GROUP_SHARE_GROUP" desc="The Voice Over label for the button allowing the user to share a group."> Share group </message>
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_GOT_IT.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_GOT_IT.png.sha1 new file mode 100644 index 0000000..7b2be92 --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_GOT_IT.png.sha1
@@ -0,0 +1 @@ +12335f2f6ef3b51c2a909f1062048850d9f9943d \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_MESSAGE.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_MESSAGE.png.sha1 new file mode 100644 index 0000000..7b2be92 --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_MESSAGE.png.sha1
@@ -0,0 +1 @@ +12335f2f6ef3b51c2a909f1062048850d9f9943d \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_TITLE.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_TITLE.png.sha1 new file mode 100644 index 0000000..7b2be92 --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_SHARED_GROUP_ERROR_TITLE.png.sha1
@@ -0,0 +1 @@ +12335f2f6ef3b51c2a909f1062048850d9f9943d \ No newline at end of file
diff --git a/ios/chrome/browser/autofill/model/autofill_controller_unittest.mm b/ios/chrome/browser/autofill/model/autofill_controller_unittest.mm index d50afda..2f889fc 100644 --- a/ios/chrome/browser/autofill/model/autofill_controller_unittest.mm +++ b/ios/chrome/browser/autofill/model/autofill_controller_unittest.mm
@@ -40,6 +40,7 @@ #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_java_script_feature.h" #import "components/autofill/ios/browser/form_suggestion.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/browser/test_autofill_manager_injector.h" #import "components/autofill/ios/common/field_data_manager_factory_ios.h" #import "components/infobars/core/confirm_infobar_delegate.h" @@ -387,8 +388,9 @@ InfoBarManagerImpl::CreateForWebState(web_state()); infobars::InfoBarManager* infobar_manager = InfoBarManagerImpl::FromWebState(web_state()); - autofill_client_ = std::make_unique<ChromeAutofillClientIOS>( - profile_.get(), web_state(), infobar_manager, autofill_agent_); + autofill_client_ = + std::make_unique<WithFakedFromWebState<ChromeAutofillClientIOS>>( + profile_.get(), web_state(), infobar_manager, autofill_agent_); autofill_client_->GetPersonalDataManager() .address_data_manager()
diff --git a/ios/chrome/browser/autofill/model/autofill_tab_helper.mm b/ios/chrome/browser/autofill/model/autofill_tab_helper.mm index 1a72b90..9c1c31f 100644 --- a/ios/chrome/browser/autofill/model/autofill_tab_helper.mm +++ b/ios/chrome/browser/autofill/model/autofill_tab_helper.mm
@@ -58,8 +58,16 @@ infobars::InfoBarManager* infobar_manager = InfoBarManagerImpl::FromWebState(web_state); DCHECK(infobar_manager); + auto from_web_state_impl = + [](web::WebState* web_state) -> autofill::AutofillClientIOS* { + if (auto* ath = AutofillTabHelper::FromWebState(web_state)) { + return ath->autofill_client(); + } + return nullptr; + }; autofill_client_ = std::make_unique<autofill::ChromeAutofillClientIOS>( - profile_, web_state, infobar_manager, autofill_agent_); + from_web_state_impl, profile_, web_state, infobar_manager, + autofill_agent_); if (IsAutofillAcrossIframesEnabled()) { autofill::ChildFrameRegistrar::GetOrCreateForWebState(web_state)
diff --git a/ios/chrome/browser/autofill/model/bottom_sheet/BUILD.gn b/ios/chrome/browser/autofill/model/bottom_sheet/BUILD.gn index 518053b..e23b9b5 100644 --- a/ios/chrome/browser/autofill/model/bottom_sheet/BUILD.gn +++ b/ios/chrome/browser/autofill/model/bottom_sheet/BUILD.gn
@@ -51,6 +51,7 @@ "//base/test:test_support", "//components/autofill/core/common:test_support", "//components/autofill/ios/browser", + "//components/autofill/ios/browser:test_support", "//components/autofill/ios/form_util", "//components/infobars/core", "//components/password_manager/core/browser/features:password_features",
diff --git a/ios/chrome/browser/autofill/model/bottom_sheet/autofill_bottom_sheet_tab_helper_unittest.mm b/ios/chrome/browser/autofill/model/bottom_sheet/autofill_bottom_sheet_tab_helper_unittest.mm index c8440ed..8335b54 100644 --- a/ios/chrome/browser/autofill/model/bottom_sheet/autofill_bottom_sheet_tab_helper_unittest.mm +++ b/ios/chrome/browser/autofill/model/bottom_sheet/autofill_bottom_sheet_tab_helper_unittest.mm
@@ -8,6 +8,7 @@ #import "components/autofill/core/common/autofill_test_utils.h" #import "components/autofill/ios/browser/autofill_agent.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/infobars/core/infobar.h" #import "components/infobars/core/infobar_manager.h" #import "components/password_manager/core/browser/features/password_features.h" @@ -83,7 +84,8 @@ // // That's why we initialize it in the constructor but put it in the // declaration order above `web_state_`. - autofill_client_ = std::make_unique<autofill::ChromeAutofillClientIOS>( + autofill_client_ = std::make_unique< + autofill::WithFakedFromWebState<autofill::ChromeAutofillClientIOS>>( profile_.get(), web_state_.get(), infobar_manager, autofill_agent_); }
diff --git a/ios/chrome/browser/autofill/model/form_structure_browsertest.mm b/ios/chrome/browser/autofill/model/form_structure_browsertest.mm index a761081..e495140 100644 --- a/ios/chrome/browser/autofill/model/form_structure_browsertest.mm +++ b/ios/chrome/browser/autofill/model/form_structure_browsertest.mm
@@ -31,13 +31,13 @@ #import "components/autofill/ios/browser/autofill_driver_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_util.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/browser/test_autofill_manager_injector.h" #import "components/password_manager/core/browser/password_manager_test_utils.h" #import "components/password_manager/core/browser/password_store/mock_password_store_interface.h" #import "components/sync_user_events/fake_user_event_service.h" #import "ios/chrome/browser/autofill/model/address_normalizer_factory.h" #import "ios/chrome/browser/autofill/model/form_suggestion_controller.h" -#import "ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.h" #import "ios/chrome/browser/infobars/model/infobar_manager_impl.h" #import "ios/chrome/browser/passwords/model/ios_chrome_profile_password_store_factory.h" #import "ios/chrome/browser/passwords/model/password_controller.h" @@ -241,13 +241,8 @@ providers:@[ autofill_agent_ ]]; InfoBarManagerImpl::CreateForWebState(web_state()); - infobars::InfoBarManager* infobar_manager = - InfoBarManagerImpl::FromWebState(web_state()); - autofill_client_ = std::make_unique<ChromeAutofillClientIOS>( - profile_.get(), web_state(), infobar_manager, autofill_agent_); - - autofill::AutofillDriverIOSFactory::CreateForWebState( - web_state(), autofill_client_.get(), /*autofill_agent=*/autofill_agent_); + autofill_client_ = + std::make_unique<TestAutofillClientIOS>(web_state(), autofill_agent_); autofill_manager_injector_ = std::make_unique<TestAutofillManagerInjector<TestAutofillManager>>(
diff --git a/ios/chrome/browser/autofill/ui_bundled/authentication/card_unmask_authentication_coordinator.mm b/ios/chrome/browser/autofill/ui_bundled/authentication/card_unmask_authentication_coordinator.mm index 9f30e906..8e78bf42 100644 --- a/ios/chrome/browser/autofill/ui_bundled/authentication/card_unmask_authentication_coordinator.mm +++ b/ios/chrome/browser/autofill/ui_bundled/authentication/card_unmask_authentication_coordinator.mm
@@ -58,6 +58,8 @@ // TODO(crbug.com/333925306): Create a CVC input coordinator/mediator out of the // legacy CardUnmaskPromptViewBridge and move this function there. - (void)continueWithCvcAuth { + // TODO(crbug.com/40714201): Use AutofillClientIOS::FromWebState() so that + // tests can easily inject their AutofillClient. autofill::ChromeAutofillClientIOS* client = AutofillTabHelper::FromWebState( self.browser->GetWebStateList()->GetActiveWebState())
diff --git a/ios/chrome/browser/autofill/ui_bundled/authentication/otp_input_dialog_coordinator.mm b/ios/chrome/browser/autofill/ui_bundled/authentication/otp_input_dialog_coordinator.mm index 4bf5c64..7996c2fac 100644 --- a/ios/chrome/browser/autofill/ui_bundled/authentication/otp_input_dialog_coordinator.mm +++ b/ios/chrome/browser/autofill/ui_bundled/authentication/otp_input_dialog_coordinator.mm
@@ -49,6 +49,8 @@ browser:browser]; if (self) { _baseNavigationController = navigationController; + // TODO(crbug.com/40714201): Use AutofillClientIOS::FromWebState() so that + // tests can easily inject their AutofillClient. autofill::ChromeAutofillClientIOS* client = AutofillTabHelper::FromWebState( browser->GetWebStateList()->GetActiveWebState())
diff --git a/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.h b/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.h index 3038423c..887a05c 100644 --- a/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.h +++ b/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.h
@@ -26,6 +26,7 @@ #import "components/autofill/core/browser/ui/payments/card_unmask_prompt_options.h" #import "components/autofill/core/browser/webdata/autofill_webdata_service.h" #import "components/autofill/ios/browser/autofill_agent.h" +#import "components/autofill/ios/browser/autofill_client_ios.h" #import "components/autofill/ios/browser/autofill_client_ios_bridge.h" #import "components/infobars/core/infobar_manager.h" #import "components/plus_addresses/plus_address_types.h" @@ -49,9 +50,10 @@ enum class SuggestionType; // Chrome iOS implementation of AutofillClient. -class ChromeAutofillClientIOS : public AutofillClient { +class ChromeAutofillClientIOS : public AutofillClientIOS { public: ChromeAutofillClientIOS( + FromWebStateImpl from_web_state_impl, ProfileIOS* profile, web::WebState* web_state, infobars::InfoBarManager* infobar_manager, @@ -77,7 +79,6 @@ version_info::Channel GetChannel() const override; bool IsOffTheRecord() const override; scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override; - AutofillDriverFactory& GetAutofillDriverFactory() override; AutofillCrowdsourcingManager& GetCrowdsourcingManager() override; VotesUploader& GetVotesUploader() override; PersonalDataManager& GetPersonalDataManager() override; @@ -161,11 +162,10 @@ raw_ptr<PrefService> pref_service_; raw_ptr<syncer::SyncService> sync_service_; std::unique_ptr<AutofillCrowdsourcingManager> crowdsourcing_manager_; - std::unique_ptr<VotesUploader> votes_uploader_; + VotesUploader votes_uploader_{this}; raw_ptr<PersonalDataManager> personal_data_manager_; raw_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; raw_ptr<ProfileIOS> profile_; - raw_ptr<web::WebState> web_state_; __weak id<AutofillClientIOSBridge> bridge_; raw_ptr<signin::IdentityManager> identity_manager_; std::unique_ptr<FormDataImporter> form_data_importer_; @@ -181,7 +181,7 @@ // after all of the members passed into the constructor of // `payments_autofill_client_` are initialized, other than `this`. payments::IOSChromePaymentsAutofillClient payments_autofill_client_{ - this, web_state_, infobar_manager_, pref_service_}; + this, web_state(), infobar_manager_, pref_service_}; SingleFieldFillRouter single_field_fill_router_{ autocomplete_history_manager_, payments_autofill_client_.GetIbanManager(), payments_autofill_client_.GetMerchantPromoCodeManager()};
diff --git a/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.mm b/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.mm index a821bea..07302f0 100644 --- a/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.mm +++ b/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.mm
@@ -30,6 +30,7 @@ #import "components/autofill/core/browser/suggestions/suggestion_type.h" #import "components/autofill/core/common/autofill_features.h" #import "components/autofill/core/common/autofill_prefs.h" +#import "components/autofill/ios/browser/autofill_client_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_util.h" #import "components/infobars/core/infobar.h" @@ -81,26 +82,25 @@ namespace autofill { ChromeAutofillClientIOS::ChromeAutofillClientIOS( + FromWebStateImpl from_web_state_impl, ProfileIOS* profile, web::WebState* web_state, infobars::InfoBarManager* infobar_manager, id<AutofillClientIOSBridge, AutofillDriverIOSBridge> bridge) - : pref_service_(profile->GetPrefs()), + : AutofillClientIOS(from_web_state_impl, web_state, bridge), + pref_service_(profile->GetPrefs()), sync_service_(SyncServiceFactory::GetForProfile(profile)), personal_data_manager_(PersonalDataManagerFactory::GetForProfile( profile->GetOriginalProfile())), autocomplete_history_manager_( AutocompleteHistoryManagerFactory::GetForProfile(profile)), profile_(profile), - web_state_(web_state), bridge_(bridge), identity_manager_( IdentityManagerFactory::GetForProfile(profile->GetOriginalProfile())), infobar_manager_(infobar_manager), log_router_(AutofillLogRouterFactory::GetForProfile(profile_)), - ablation_study_(GetApplicationContext()->GetLocalState()) { - AutofillDriverIOSFactory::CreateForWebState(web_state, this, bridge); -} + ablation_study_(GetApplicationContext()->GetLocalState()) {} ChromeAutofillClientIOS::~ChromeAutofillClientIOS() { HideAutofillSuggestions(SuggestionHidingReason::kTabGone); @@ -124,17 +124,13 @@ } bool ChromeAutofillClientIOS::IsOffTheRecord() const { - return web_state_->GetBrowserState()->IsOffTheRecord(); + return web_state()->GetBrowserState()->IsOffTheRecord(); } scoped_refptr<network::SharedURLLoaderFactory> ChromeAutofillClientIOS::GetURLLoaderFactory() { return base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( - web_state_->GetBrowserState()->GetURLLoaderFactory()); -} - -AutofillDriverFactory& ChromeAutofillClientIOS::GetAutofillDriverFactory() { - return CHECK_DEREF(AutofillDriverIOSFactory::FromWebState(web_state_)); + web_state()->GetBrowserState()->GetURLLoaderFactory()); } AutofillCrowdsourcingManager& @@ -148,17 +144,7 @@ } VotesUploader& ChromeAutofillClientIOS::GetVotesUploader() { - if (!votes_uploader_) { - // We need to do lazy evaluation because AutofillDriverIOSFactory is created - // only after ChromeAutofillClientIOS. This is OK because only - // BrowserAutofillManager, which is owned by AutofillClientIOS and thus - // instantiated after AutofillDriverIOSFactory, calls GetVotesUploader(). - // - // TODO(crbug.com/355907668): Make AutofillDriverIOSFactory owned by - // ChromeAutofillClientIOS and initialize `votes_uploader_` non-lazily. - votes_uploader_ = std::make_unique<VotesUploader>(this); - } - return *votes_uploader_; + return votes_uploader_; } PersonalDataManager& ChromeAutofillClientIOS::GetPersonalDataManager() { @@ -237,7 +223,7 @@ const GURL& ChromeAutofillClientIOS::GetLastCommittedPrimaryMainFrameURL() const { - return web_state_->GetLastCommittedURL(); + return web_state()->GetLastCommittedURL(); } url::Origin ChromeAutofillClientIOS::GetLastCommittedPrimaryMainFrameOrigin() @@ -247,13 +233,13 @@ security_state::SecurityLevel ChromeAutofillClientIOS::GetSecurityLevelForUmaHistograms() { - return security_state::GetSecurityLevelForWebState(web_state_); + return security_state::GetSecurityLevelForWebState(web_state()); } const translate::LanguageState* ChromeAutofillClientIOS::GetLanguageState() { // TODO(crbug.com/41430413): iOS vs other platforms extracts language from // the top level frame vs whatever frame directly holds the form. - auto* translate_client = ChromeIOSTranslateClient::FromWebState(web_state_); + auto* translate_client = ChromeIOSTranslateClient::FromWebState(web_state()); if (translate_client) { auto* translate_manager = translate_client->GetTranslateManager(); if (translate_manager) @@ -263,7 +249,7 @@ } translate::TranslateDriver* ChromeAutofillClientIOS::GetTranslateDriver() { - auto* translate_client = ChromeIOSTranslateClient::FromWebState(web_state_); + auto* translate_client = ChromeIOSTranslateClient::FromWebState(web_state()); if (translate_client) { return translate_client->GetTranslateDriver(); } @@ -351,7 +337,7 @@ bool is_manual_fallback, PlusAddressCallback callback) { AutofillBottomSheetTabHelper* bottomSheetTabHelper = - AutofillBottomSheetTabHelper::FromWebState(web_state_); + AutofillBottomSheetTabHelper::FromWebState(web_state()); bottomSheetTabHelper->ShowPlusAddressesBottomSheet(std::move(callback)); } @@ -394,7 +380,7 @@ bool is_refill) {} bool ChromeAutofillClientIOS::IsContextSecure() const { - return IsContextSecureForWebState(web_state_); + return IsContextSecureForWebState(web_state()); } FormInteractionsFlowId @@ -470,7 +456,9 @@ // iframes is enabled. const auto GetRendererForm = [&]() -> std::optional<FormData> { const AutofillDriverRouter& router = - AutofillDriverIOSFactory::FromWebState(web_state_)->router(); + static_cast<AutofillClientIOS&>(manager.client()) + .GetAutofillDriverFactory() + .router(); std::vector<FormData> renderer_forms = router.GetRendererForms(form_data);
diff --git a/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios_unittest.mm b/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios_unittest.mm index 07d11e5..710b407 100644 --- a/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios_unittest.mm +++ b/ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios_unittest.mm
@@ -23,6 +23,7 @@ #import "components/autofill/ios/browser/autofill_agent.h" #import "components/autofill/ios/browser/autofill_driver_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/browser/test_autofill_manager_injector.h" #import "components/infobars/core/infobar_manager.h" #import "ios/chrome/browser/infobars/model/infobar_manager_impl.h" @@ -97,9 +98,10 @@ autofill_agent.snackbarHandler = mock_snackbar_handler_; InfoBarManagerImpl::CreateForWebState(web_state_.get()); - autofill_client_ = std::make_unique<ChromeAutofillClientIOS>( - profile_.get(), web_state_.get(), - InfoBarManagerImpl::FromWebState(web_state_.get()), autofill_agent); + autofill_client_ = + std::make_unique<WithFakedFromWebState<ChromeAutofillClientIOS>>( + profile_.get(), web_state_.get(), + InfoBarManagerImpl::FromWebState(web_state_.get()), autofill_agent); autofill_manager_injector_ = std::make_unique<TestAutofillManagerInjector<TestAutofillManager>>( web_state_.get());
diff --git a/ios/chrome/browser/autofill/ui_bundled/ios_chrome_payments_autofill_client_unittest.mm b/ios/chrome/browser/autofill/ui_bundled/ios_chrome_payments_autofill_client_unittest.mm index 28395828..e34f1be3 100644 --- a/ios/chrome/browser/autofill/ui_bundled/ios_chrome_payments_autofill_client_unittest.mm +++ b/ios/chrome/browser/autofill/ui_bundled/ios_chrome_payments_autofill_client_unittest.mm
@@ -15,6 +15,7 @@ #import "components/autofill/core/browser/ui/payments/virtual_card_enroll_ui_model.h" #import "components/autofill/core/common/autofill_payments_features.h" #import "components/autofill/ios/browser/autofill_agent.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "ios/chrome/browser/autofill/model/bottom_sheet/autofill_bottom_sheet_tab_helper.h" #import "ios/chrome/browser/autofill/ui_bundled/chrome_autofill_client_ios.h" #import "ios/chrome/browser/infobars/model/infobar_manager_impl.h" @@ -100,16 +101,17 @@ using ::testing::_; -class TestChromeAutofillClient : public ChromeAutofillClientIOS { +class TestChromeAutofillClient + : public WithFakedFromWebState<ChromeAutofillClientIOS> { public: explicit TestChromeAutofillClient(ProfileIOS* profile, web::WebState* web_state, infobars::InfoBarManager* infobar_manager, AutofillAgent* autofill_agent) - : ChromeAutofillClientIOS(profile, - web_state, - infobar_manager, - autofill_agent) { + : WithFakedFromWebState<ChromeAutofillClientIOS>(profile, + web_state, + infobar_manager, + autofill_agent) { autofill::CreditCard credit_card( base::Uuid::GenerateRandomV4().AsLowercaseString(), "https://www.example.test/");
diff --git a/ios/chrome/browser/autofill/ui_bundled/progress_dialog/autofill_progress_dialog_coordinator.mm b/ios/chrome/browser/autofill/ui_bundled/progress_dialog/autofill_progress_dialog_coordinator.mm index d5d39f1..9e06c2d0 100644 --- a/ios/chrome/browser/autofill/ui_bundled/progress_dialog/autofill_progress_dialog_coordinator.mm +++ b/ios/chrome/browser/autofill/ui_bundled/progress_dialog/autofill_progress_dialog_coordinator.mm
@@ -38,6 +38,8 @@ browser:(Browser*)browser { self = [super initWithBaseViewController:viewController browser:browser]; if (self) { + // TODO(crbug.com/40714201): Use AutofillClientIOS::FromWebState() so that + // tests can easily inject their AutofillClient. autofill::ChromeAutofillClientIOS* client = AutofillTabHelper::FromWebState( browser->GetWebStateList()->GetActiveWebState())
diff --git a/ios/chrome/browser/collaboration/model/BUILD.gn b/ios/chrome/browser/collaboration/model/BUILD.gn index 1c4d8f4..23a3f0d7 100644 --- a/ios/chrome/browser/collaboration/model/BUILD.gn +++ b/ios/chrome/browser/collaboration/model/BUILD.gn
@@ -11,10 +11,12 @@ "//base", "//components/collaboration/public", "//components/signin/public/identity_manager", + "//ios/chrome/app/strings", "//ios/chrome/browser/authentication/ui_bundled/signin:constants", "//ios/chrome/browser/saved_tab_groups/model", "//ios/chrome/browser/share_kit/model", "//ios/chrome/browser/share_kit/model:factory", + "//ios/chrome/browser/shared/coordinator/alert", "//ios/chrome/browser/shared/model/browser", "//ios/chrome/browser/shared/model/web_state_list", "//ios/chrome/browser/shared/public/commands",
diff --git a/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.h b/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.h index 2140a1c..eb3b06a 100644 --- a/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.h +++ b/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.h
@@ -9,6 +9,7 @@ #import "components/collaboration/public/collaboration_controller_delegate.h" +@class AlertCoordinator; class Browser; class ShareKitService; @@ -50,6 +51,7 @@ raw_ptr<Browser> browser_; __weak UIViewController* base_view_controller_; NSString* session_id_ = nil; + AlertCoordinator* alert_coordinator_ = nil; }; } // namespace collaboration
diff --git a/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.mm b/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.mm index b21bc13..2f7f688 100644 --- a/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.mm +++ b/ios/chrome/browser/collaboration/model/ios_collaboration_controller_delegate.mm
@@ -20,12 +20,15 @@ #import "ios/chrome/browser/share_kit/model/share_kit_service.h" #import "ios/chrome/browser/share_kit/model/share_kit_service_factory.h" #import "ios/chrome/browser/share_kit/model/share_kit_share_group_configuration.h" +#import "ios/chrome/browser/shared/coordinator/alert/alert_coordinator.h" #import "ios/chrome/browser/shared/model/browser/browser.h" #import "ios/chrome/browser/shared/model/web_state_list/tab_group.h" #import "ios/chrome/browser/shared/public/commands/application_commands.h" #import "ios/chrome/browser/shared/public/commands/command_dispatcher.h" #import "ios/chrome/browser/shared/public/commands/show_signin_command.h" #import "ios/chrome/browser/signin/model/identity_manager_factory.h" +#import "ios/chrome/grit/ios_strings.h" +#import "ui/base/l10n/l10n_util_mac.h" namespace collaboration { @@ -50,8 +53,32 @@ void IOSCollaborationControllerDelegate::ShowError(const ErrorInfo& error, ResultCallback result) { - std::move(result).Run(CollaborationControllerDelegate::Outcome::kSuccess); - // TODO(crbug.com/377306986): Implement this. + NSString* title = nil; + NSString* message = nil; + switch (error.type) { + case ErrorInfo::Type::kUnknown: + NOTREACHED(); + case ErrorInfo::Type::kGenericError: { + title = l10n_util::GetNSString(IDS_IOS_SHARED_GROUP_ERROR_TITLE); + message = l10n_util::GetNSString(IDS_IOS_SHARED_GROUP_ERROR_MESSAGE); + break; + } + } + + auto result_block = base::CallbackToBlock(std::move(result)); + alert_coordinator_ = + [[AlertCoordinator alloc] initWithBaseViewController:base_view_controller_ + browser:browser_ + title:title + message:message]; + [alert_coordinator_ + addItemWithTitle:l10n_util::GetNSString(IDS_IOS_SHARED_GROUP_ERROR_GOT_IT) + action:^{ + result_block( + CollaborationControllerDelegate::Outcome::kSuccess); + } + style:UIAlertActionStyleDefault]; + [alert_coordinator_ start]; } void IOSCollaborationControllerDelegate::Cancel(ResultCallback result) {
diff --git a/ios/chrome/browser/lens_overlay/coordinator/lens_omnibox_client.mm b/ios/chrome/browser/lens_overlay/coordinator/lens_omnibox_client.mm index 0282be4b..d97ebea 100644 --- a/ios/chrome/browser/lens_overlay/coordinator/lens_omnibox_client.mm +++ b/ios/chrome/browser/lens_overlay/coordinator/lens_omnibox_client.mm
@@ -179,8 +179,7 @@ } const gfx::VectorIcon& LensOmniboxClient::GetVectorIcon() const { - static const gfx::VectorIcon kEmptyVectorIcon = {}; - return kEmptyVectorIcon; + return gfx::VectorIcon::EmptyIcon(); } std::optional<lens::proto::LensOverlaySuggestInputs>
diff --git a/ios/chrome/browser/passwords/model/BUILD.gn b/ios/chrome/browser/passwords/model/BUILD.gn index 4d014df..73c8f82c 100644 --- a/ios/chrome/browser/passwords/model/BUILD.gn +++ b/ios/chrome/browser/passwords/model/BUILD.gn
@@ -261,6 +261,7 @@ "//components/affiliations/core/browser:test_support", "//components/autofill/core/common", "//components/autofill/ios/browser", + "//components/autofill/ios/browser:test_support", "//components/autofill/ios/browser:util", "//components/autofill/ios/common", "//components/autofill/ios/form_util",
diff --git a/ios/chrome/browser/passwords/model/password_controller_unittest.mm b/ios/chrome/browser/passwords/model/password_controller_unittest.mm index 7ec35f5..7539b2b2 100644 --- a/ios/chrome/browser/passwords/model/password_controller_unittest.mm +++ b/ios/chrome/browser/passwords/model/password_controller_unittest.mm
@@ -26,6 +26,7 @@ #import "components/autofill/core/common/password_form_fill_data.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/autofill/ios/browser/autofill_util.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/common/field_data_manager_factory_ios.h" #import "components/autofill/ios/form_util/form_activity_params.h" #import "components/autofill/ios/form_util/form_util_java_script_feature.h" @@ -259,8 +260,8 @@ // predictions on. PasswordFormManager::set_wait_for_server_predictions_for_filling(false); - autofill::AutofillDriverIOSFactory::CreateForWebState( - web_state(), &autofill_client_, /*bridge=*/nil); + autofill_client_ = std::make_unique<autofill::TestAutofillClientIOS>( + web_state(), /*bridge=*/nil); passwordController_ = CreatePasswordController( profile_->GetPrefs(), web_state(), store_.get(), &weak_client_); @@ -488,10 +489,8 @@ IOSChromeScopedTestingLocalState scoped_testing_local_state_; TestProfileManagerIOS profile_manager_; raw_ptr<ProfileIOS> profile_; - // `autofill_client_` mocks KeyedServices, which need to outlive the - // `BrowserAutofillManager` owned by frame (`web_state`). - autofill::TestAutofillClient autofill_client_; std::unique_ptr<web::WebState> web_state_; + std::unique_ptr<autofill::TestAutofillClientIOS> autofill_client_; // SuggestionController for testing. PasswordsTestSuggestionController* suggestionController_; @@ -1264,8 +1263,8 @@ web_state_.SetWebFramesManager(content_world, std::move(web_frames_manager)); - autofill::AutofillDriverIOSFactory::CreateForWebState( - &web_state_, &autofill_client_, /*bridge=*/nil); + autofill_client_ = std::make_unique<autofill::TestAutofillClientIOS>( + &web_state_, /*bridge=*/nil); passwordController_ = CreatePasswordController(&pref_service_, &web_state_, store_.get(), &weak_client_); @@ -1285,11 +1284,11 @@ sync_preferences::TestingPrefServiceSyncable pref_service_; std::unique_ptr<web::FakeBrowserState> browser_state_; - autofill::TestAutofillClient autofill_client_; + web::FakeWebState web_state_; + std::unique_ptr<autofill::TestAutofillClientIOS> autofill_client_; PasswordController* passwordController_; scoped_refptr<password_manager::MockPasswordStoreInterface> store_; raw_ptr<MockPasswordManagerClient> weak_client_; - web::FakeWebState web_state_; raw_ptr<web::FakeWebFramesManager> web_frames_manager_; };
diff --git a/ios/chrome/browser/settings/ui_bundled/settings_egtest.mm b/ios/chrome/browser/settings/ui_bundled/settings_egtest.mm index a93decb..beeaaf8 100644 --- a/ios/chrome/browser/settings/ui_bundled/settings_egtest.mm +++ b/ios/chrome/browser/settings/ui_bundled/settings_egtest.mm
@@ -284,7 +284,8 @@ // Tests that clearing the cookies through the UI does clear all of them. Use a // local server to navigate to a page that sets then tests a cookie, and then // clears the cookie and tests it is not set. -- (void)testClearCookies { +// TODO(crbug.com/384871835): Re-enable this test. +- (void)DISABLED_testClearCookies { // Set pref to the last hour. [ChromeEarlGrey setIntegerValue:static_cast<int>(browsing_data::TimePeriod::LAST_HOUR)
diff --git a/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios.zip.sha1 b/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios.zip.sha1 index 85bbc8f..a4f8bb9 100644 --- a/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios.zip.sha1 +++ b/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios.zip.sha1
@@ -1 +1 @@ -2fff3e552abbfa57144adfb6fe72dd7c9536ce40 \ No newline at end of file +4f21cca66ecf84a699987c32c09e3b642e46db11 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios_asan.zip.sha1 b/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios_asan.zip.sha1 index d8ff023..87438aa1 100644 --- a/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/ChromeExtensionKeychainInternal.framework.dSYM.ios_asan.zip.sha1
@@ -1 +1 @@ -cc4ece4b9d505dd59073f10d2cb87e485fee96f6 \ No newline at end of file +685708ae7ae689af397a411eb421074e5103dfac \ No newline at end of file
diff --git a/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios.zip.sha1 b/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios.zip.sha1 index daae991e..385ed43 100644 --- a/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios.zip.sha1 +++ b/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios.zip.sha1
@@ -1 +1 @@ -74a974f6c719e01cad522aef395170dd5366e8f8 \ No newline at end of file +48182fd456911c9e6a72e35398a60059ac6190f0 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios_asan.zip.sha1 b/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios_asan.zip.sha1 index 7288a1f..e740473 100644 --- a/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/ChromeInternal.framework.dSYM.ios_asan.zip.sha1
@@ -1 +1 @@ -9a4f996c73061dc5ce4b050d6dd234d449a738d5 \ No newline at end of file +49642fc5912895bbf559a50b8d8541274fdd268a \ No newline at end of file
diff --git a/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios.zip.sha1 b/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios.zip.sha1 index bf298a6..11f777a 100644 --- a/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios.zip.sha1 +++ b/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios.zip.sha1
@@ -1 +1 @@ -86fa8ee8aebf8cc1a4fd9cc8ef89a37dc7755bf5 \ No newline at end of file +8b74468850835eff0079ed605ec6ba5327f02636 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios_asan.zip.sha1 b/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios_asan.zip.sha1 index a85f4679..0ebc5f62 100644 --- a/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/ChromeSSOInternal.framework.dSYM.ios_asan.zip.sha1
@@ -1 +1 @@ -3dbb7f0be4837aaa0e063d7d093d5a9070bed7ab \ No newline at end of file +12a53e5f32ae82a60a6958c428adf7f334ddda49 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios.zip.sha1 index 6aa93e70..f1f5098 100644 --- a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -1e8d1ef94696b75d4a25e7104f7978a7690c6a7c \ No newline at end of file +d5abc901cc854538f1081cb836b4e465cfba3850 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios_asan.zip.sha1 b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios_asan.zip.sha1 index a88d3a0..7e3b231 100644 --- a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.ios_asan.zip.sha1
@@ -1 +1 @@ -410dcff642f852232598e67ac101689e9f84670b \ No newline at end of file +7b4fdd0171ba435aef10f24d3b00f66db64eff6b \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator.zip.sha1 index ab02fdc..8de898f 100644 --- a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -0f78f0df2af36e92866716d5b79d736a77b13c92 \ No newline at end of file +705c68be11243174a3165369c7837989643016c2 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator_asan.zip.sha1 b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator_asan.zip.sha1 index e7fc6330..6785613 100644 --- a/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator_asan.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_extension_keychain_internal_dynamic_framework.iossimulator_asan.zip.sha1
@@ -1 +1 @@ -536ebbb9b0987c6292c68973e42316d4ec41db6c \ No newline at end of file +ce799667b283595adf8fb416b5a54eea8285a124 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 index 253d7f3..1406a48 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -f120dfc6cce95327f6b7314ddad12c920ccaa376 \ No newline at end of file +448e8f89f8a0af7e951f4f0631262456d397063c \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios_asan.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios_asan.zip.sha1 index 7ccfd50..7e8bce8 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios_asan.zip.sha1
@@ -1 +1 @@ -8834dc502a1ec85284bbdb6c19281446ada58d2a \ No newline at end of file +230514beaacba8cf2952efd017dd5682faa0787e \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 index 8d15cdd9..cb59a33 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -7ea6100d192c10ad341f786a8ae90b61d2433226 \ No newline at end of file +1d653d991a8bdb078a72346808a6bf67c2442b38 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator_asan.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator_asan.zip.sha1 index 78ea3ef..8b93301f 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator_asan.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator_asan.zip.sha1
@@ -1 +1 @@ -0bd6019fa34d0e36769e19d94423506617ce5cc6 \ No newline at end of file +4a8ee768be6e4aefc5e7b6e784043da5db092eae \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 index 00101b68..cbd9b35 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -cd7177c87b176d30a898895539b38a5d2a08e6f9 \ No newline at end of file +8468f0dbc984b3254b3cfc3fa5c20ffb94cfb4b2 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios_asan.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios_asan.zip.sha1 index 52491e47..8333a21 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios_asan.zip.sha1
@@ -1 +1 @@ -76585b06517b047aefa34a94f1f7b47dc15ac5cd \ No newline at end of file +ed1fa89247319f81af2f5b748da26654909901ba \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 index 504246a..dd2d649d 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -1c6e328334815b65cb0334f4e86e1a80f63e0df3 \ No newline at end of file +2edb1ee98b4140d9f19ed230a7da2b66ed86e417 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator_asan.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator_asan.zip.sha1 index 0d63089..1ed3dae 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator_asan.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator_asan.zip.sha1
@@ -1 +1 @@ -292dedd02810f29cfb6435a97c4ec78635574854 \ No newline at end of file +d97c8666b0bd4166b0d91a7f139835416c4acff0 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.ios.zip.sha1 index 646e7bb..b615f3a 100644 --- a/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -e15d2af18e39c525700890a3a2f25b48691663ae \ No newline at end of file +2e25fcef6f3f4fddd72074d5f603da48684167da \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.iossimulator.zip.sha1 index 5e51b541..ac57f40 100644 --- a/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_test_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -7e85b06e33507d6e94c9deb644badfdaba895a63 \ No newline at end of file +f1867deb7563ccada2bd69ea7b6c2352329829bd \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 index 020de863..0a1b66b 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -af9b7198e026fb7da4ae1d4b590fb08b1bfb9cc3 \ No newline at end of file +3ad1597fe7c4474056435ef30aa111cc67fcca7d \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios_asan.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios_asan.zip.sha1 index d69d560..852790a 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios_asan.zip.sha1
@@ -1 +1 @@ -83f3d93a206d60314a87e7fcbfd306d163d33b5b \ No newline at end of file +2d51ecede73f9fb82ddf88e269af038b06a52562 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 index 044143a..bd4b32e 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -3e5c24e183e380fca7a66483299e544f49f0ae5d \ No newline at end of file +22d26d4cd0ecdd664c382c44cee8c2fab75ee7bf \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator_asan.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator_asan.zip.sha1 index b839639..bad9efab 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator_asan.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator_asan.zip.sha1
@@ -1 +1 @@ -54319e38c800d0776385124f9c698bb5185436a3 \ No newline at end of file +7906662d7a70e32ecdf970065af47060c27245ce \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 index 7679c02..8e2d14b 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -a0571b07cab4f81a3b3e29ec6ab6718f59c25189 \ No newline at end of file +227f9f51e88812446b1f1c8883a9a2019613b83c \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios_asan.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios_asan.zip.sha1 index 7c8ca02..a18d9dd2 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios_asan.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios_asan.zip.sha1
@@ -1 +1 @@ -590234608e423d23b027bbfd686cd563cea33b7c \ No newline at end of file +5d3d949cf6d431cce52fcbf9f54b48c69d9326df \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 index 8d201e40..28cec30 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -9b958c7909347b9d8e734f1356b9cff883dfe478 \ No newline at end of file +9a886d0810414575477db3fb70c272920c2b9c27 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator_asan.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator_asan.zip.sha1 index 6d06075..74f0daf 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator_asan.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator_asan.zip.sha1
@@ -1 +1 @@ -76d2c3fd5a4f1da366aefe9e8fa5518a84e13e6b \ No newline at end of file +e20dc7bad28bd45875252ea9ba0bd9aad8eb76a5 \ No newline at end of file
diff --git a/ios/web_view/internal/autofill/cwv_autofill_controller.mm b/ios/web_view/internal/autofill/cwv_autofill_controller.mm index ef844e2..7ed7c0e 100644 --- a/ios/web_view/internal/autofill/cwv_autofill_controller.mm +++ b/ios/web_view/internal/autofill/cwv_autofill_controller.mm
@@ -45,10 +45,12 @@ #import "ios/web_view/internal/autofill/web_view_autofill_log_router_factory.h" #import "ios/web_view/internal/autofill/web_view_personal_data_manager_factory.h" #import "ios/web_view/internal/autofill/web_view_strike_database_factory.h" +#import "ios/web_view/internal/cwv_web_view_internal.h" #import "ios/web_view/internal/passwords/cwv_password_internal.h" #import "ios/web_view/internal/signin/web_view_identity_manager_factory.h" #import "ios/web_view/internal/web_view_browser_state.h" #import "ios/web_view/public/cwv_autofill_controller_delegate.h" +#import "ios/web_view/public/cwv_web_view.h" #import "net/base/apple/url_conversions.h" using autofill::FieldRendererId; @@ -138,10 +140,18 @@ _formActivityObserverBridge = std::make_unique<autofill::FormActivityObserverBridge>(webState, self); - _autofillClient = - autofillClientForTest - ? std::move(autofillClientForTest) - : autofill::WebViewAutofillClientIOS::Create(_webState, self); + auto from_web_state_impl = + [](web::WebState* web_state) -> autofill::AutofillClientIOS* { + if (CWVWebView* web_view = [CWVWebView webViewForWebState:web_state]) { + CWVAutofillController* controller = web_view.autofillController; + return [controller autofillClient]; + } + return nullptr; + }; + _autofillClient = autofillClientForTest + ? std::move(autofillClientForTest) + : autofill::WebViewAutofillClientIOS::Create( + from_web_state_impl, _webState, self); _passwordManagerClient = std::move(passwordManagerClient); _passwordManagerClient->set_bridge(self); @@ -163,6 +173,10 @@ #pragma mark - Public Methods +- (autofill::WebViewAutofillClientIOS*)autofillClient { + return _autofillClient.get(); +} + - (void)clearFormWithName:(NSString*)formName fieldIdentifier:(NSString*)fieldIdentifier frameID:(NSString*)frameID
diff --git a/ios/web_view/internal/autofill/cwv_autofill_controller_internal.h b/ios/web_view/internal/autofill/cwv_autofill_controller_internal.h index 3525946..ba0990dd 100644 --- a/ios/web_view/internal/autofill/cwv_autofill_controller_internal.h +++ b/ios/web_view/internal/autofill/cwv_autofill_controller_internal.h
@@ -13,6 +13,7 @@ #import "components/password_manager/ios/shared_password_controller.h" #import "ios/web/public/web_state_observer_bridge.h" #import "ios/web_view/internal/autofill/cwv_autofill_client_ios_bridge.h" +#import "ios/web_view/internal/autofill/web_view_autofill_client_ios.h" #import "ios/web_view/internal/passwords/web_view_password_manager_client.h" #import "ios/web_view/public/cwv_autofill_controller.h" @@ -50,6 +51,9 @@ passwordManagerClient passwordController:(SharedPasswordController*)passwordController; +@property(nonatomic, readonly) + autofill::WebViewAutofillClientIOS* autofillClient; + @end NS_ASSUME_NONNULL_END
diff --git a/ios/web_view/internal/autofill/cwv_autofill_controller_unittest.mm b/ios/web_view/internal/autofill/cwv_autofill_controller_unittest.mm index 543eef9d..a4f4d934 100644 --- a/ios/web_view/internal/autofill/cwv_autofill_controller_unittest.mm +++ b/ios/web_view/internal/autofill/cwv_autofill_controller_unittest.mm
@@ -18,6 +18,7 @@ #import "components/autofill/ios/browser/autofill_java_script_feature.h" #import "components/autofill/ios/browser/fake_autofill_agent.h" #import "components/autofill/ios/browser/form_suggestion.h" +#import "components/autofill/ios/browser/test_autofill_client_ios.h" #import "components/autofill/ios/form_util/form_activity_params.h" #import "components/autofill/ios/form_util/form_activity_tab_helper.h" #import "components/autofill/ios/form_util/test_form_activity_tab_helper.h" @@ -106,7 +107,8 @@ &web_state_, password_controller_, password_manager.get()); password_manager_client_ = password_manager_client.get(); - auto autofill_client = std::make_unique<autofill::WebViewAutofillClientIOS>( + auto autofill_client = std::make_unique< + autofill::WithFakedFromWebState<autofill::WebViewAutofillClientIOS>>( &pref_service_, &personal_data_manager_, &autocomplete_history_manager_, &web_state_, /*bridge=*/nil, /*identity_manager=*/nullptr, &strike_database_, &sync_service_, /*log_router=*/nullptr);
diff --git a/ios/web_view/internal/autofill/web_view_autofill_client_ios.h b/ios/web_view/internal/autofill/web_view_autofill_client_ios.h index 6557461..9687d474 100644 --- a/ios/web_view/internal/autofill/web_view_autofill_client_ios.h +++ b/ios/web_view/internal/autofill/web_view_autofill_client_ios.h
@@ -20,6 +20,7 @@ #import "components/autofill/core/browser/single_field_fillers/autocomplete/autocomplete_history_manager.h" #import "components/autofill/core/browser/single_field_fillers/single_field_fill_router.h" #import "components/autofill/core/browser/strike_databases/strike_database.h" +#import "components/autofill/ios/browser/autofill_client_ios.h" #import "components/autofill/ios/browser/autofill_driver_ios_bridge.h" #import "components/autofill/ios/browser/autofill_driver_ios_factory.h" #import "components/prefs/pref_service.h" @@ -39,13 +40,15 @@ } // namespace payments // WebView implementation of AutofillClient. -class WebViewAutofillClientIOS : public AutofillClient { +class WebViewAutofillClientIOS : public AutofillClientIOS { public: static std::unique_ptr<WebViewAutofillClientIOS> Create( + FromWebStateImpl from_web_state_impl, web::WebState* web_state, id<CWVAutofillClientIOSBridge, AutofillDriverIOSBridge> bridge); WebViewAutofillClientIOS( + FromWebStateImpl from_web_state_impl, PrefService* pref_service, PersonalDataManager* personal_data_manager, AutocompleteHistoryManager* autocomplete_history_manager, @@ -66,7 +69,6 @@ const std::string& GetAppLocale() const override; bool IsOffTheRecord() const override; scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override; - AutofillDriverIOSFactory& GetAutofillDriverFactory() override; AutofillCrowdsourcingManager& GetCrowdsourcingManager() override; VotesUploader& GetVotesUploader() override; PersonalDataManager& GetPersonalDataManager() override; @@ -116,11 +118,10 @@ LogManager* GetCurrentLogManager() override; private: - web::WebState* web_state_; __weak id<CWVAutofillClientIOSBridge> bridge_; raw_ptr<PrefService> pref_service_; std::unique_ptr<AutofillCrowdsourcingManager> crowdsourcing_manager_; - std::unique_ptr<VotesUploader> votes_uploader_; + VotesUploader votes_uploader_{this}; PersonalDataManager* personal_data_manager_; AutocompleteHistoryManager* autocomplete_history_manager_; raw_ptr<signin::IdentityManager> identity_manager_; @@ -136,7 +137,7 @@ // after all of the members passed into the constructor of // `payments_autofill_client_` are initialized, other than `this`. payments::IOSWebViewPaymentsAutofillClient payments_autofill_client_{ - this, bridge_, web_state_}; + this, bridge_, web_state()}; SingleFieldFillRouter single_field_fill_router_{ autocomplete_history_manager_, payments_autofill_client_.GetIbanManager(), payments_autofill_client_.GetMerchantPromoCodeManager()};
diff --git a/ios/web_view/internal/autofill/web_view_autofill_client_ios.mm b/ios/web_view/internal/autofill/web_view_autofill_client_ios.mm index 17be06f5..c184e510 100644 --- a/ios/web_view/internal/autofill/web_view_autofill_client_ios.mm +++ b/ios/web_view/internal/autofill/web_view_autofill_client_ios.mm
@@ -38,12 +38,13 @@ // static std::unique_ptr<WebViewAutofillClientIOS> WebViewAutofillClientIOS::Create( + FromWebStateImpl from_web_state_impl, web::WebState* web_state, id<CWVAutofillClientIOSBridge, AutofillDriverIOSBridge> bridge) { auto* browser_state = ios_web_view::WebViewBrowserState::FromBrowserState( web_state->GetBrowserState()); return std::make_unique<autofill::WebViewAutofillClientIOS>( - browser_state->GetPrefs(), + from_web_state_impl, browser_state->GetPrefs(), ios_web_view::WebViewPersonalDataManagerFactory::GetForBrowserState( browser_state->GetRecordingBrowserState()), ios_web_view::WebViewAutocompleteHistoryManagerFactory:: @@ -60,6 +61,7 @@ } WebViewAutofillClientIOS::WebViewAutofillClientIOS( + FromWebStateImpl from_web_state_impl, PrefService* pref_service, PersonalDataManager* personal_data_manager, AutocompleteHistoryManager* autocomplete_history_manager, @@ -69,7 +71,7 @@ StrikeDatabase* strike_database, syncer::SyncService* sync_service, LogRouter* log_router) - : web_state_(web_state), + : AutofillClientIOS(from_web_state_impl, web_state, bridge), bridge_(bridge), pref_service_(pref_service), personal_data_manager_(personal_data_manager), @@ -77,19 +79,16 @@ identity_manager_(identity_manager), strike_database_(strike_database), sync_service_(sync_service), - log_router_(log_router) { - AutofillDriverIOSFactory::CreateForWebState(web_state, this, bridge); -} + log_router_(log_router) {} WebViewAutofillClientIOS::~WebViewAutofillClientIOS() { HideAutofillSuggestions(SuggestionHidingReason::kTabGone); - if (auto* factory = AutofillDriverIOSFactory::FromWebState(web_state_)) { - // Autofill expects that AutofillDrivers and their ownees are destroyed - // before the AutofillClient. It's not clear if that's the case on iOS - // WebView. As a temporary fix, we explicitly delete the drivers. - // TODO(crbug.com/380442588): Investigate and look for a better fix. - static_cast<web::WebStateObserver*>(factory)->WebStateDestroyed(web_state_); - } + // Autofill expects that AutofillDrivers and their ownees are destroyed + // before the AutofillClient. It's not clear if that's the case on iOS + // WebView. As a temporary fix, we explicitly delete the drivers. + // TODO(crbug.com/380442588): Investigate and look for a better fix. + static_cast<web::WebStateObserver&>(GetAutofillDriverFactory()) + .WebStateDestroyed(web_state()); } base::WeakPtr<AutofillClient> WebViewAutofillClientIOS::GetWeakPtr() { @@ -102,17 +101,13 @@ } bool WebViewAutofillClientIOS::IsOffTheRecord() const { - return web_state_->GetBrowserState()->IsOffTheRecord(); + return web_state()->GetBrowserState()->IsOffTheRecord(); } scoped_refptr<network::SharedURLLoaderFactory> WebViewAutofillClientIOS::GetURLLoaderFactory() { return base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( - web_state_->GetBrowserState()->GetURLLoaderFactory()); -} - -AutofillDriverIOSFactory& WebViewAutofillClientIOS::GetAutofillDriverFactory() { - return CHECK_DEREF(AutofillDriverIOSFactory::FromWebState(web_state_)); + web_state()->GetBrowserState()->GetURLLoaderFactory()); } AutofillCrowdsourcingManager& @@ -126,17 +121,7 @@ } VotesUploader& WebViewAutofillClientIOS::GetVotesUploader() { - if (!votes_uploader_) { - // We need to do lazy evaluation because AutofillDriverIOSFactory is created - // only after WebViewAutofillClientIOS. This is OK because only - // BrowserAutofillManager, which is owned by AutofillClientIOS and thus - // instantiated after AutofillDriverIOSFactory, calls GetVotesUploader(). - // - // TODO(crbug.com/355907668): Make AutofillDriverIOSFactory owned by - // WebViewAutofillClientIOS and initialize `votes_uploader_` non-lazily. - votes_uploader_ = std::make_unique<VotesUploader>(this); - } - return *votes_uploader_; + return votes_uploader_; } PersonalDataManager& WebViewAutofillClientIOS::GetPersonalDataManager() { @@ -202,7 +187,7 @@ const GURL& WebViewAutofillClientIOS::GetLastCommittedPrimaryMainFrameURL() const { - return web_state_->GetLastCommittedURL(); + return web_state()->GetLastCommittedURL(); } url::Origin WebViewAutofillClientIOS::GetLastCommittedPrimaryMainFrameOrigin() @@ -212,7 +197,7 @@ security_state::SecurityLevel WebViewAutofillClientIOS::GetSecurityLevelForUmaHistograms() { - return security_state::GetSecurityLevelForWebState(web_state_); + return security_state::GetSecurityLevelForWebState(web_state()); } const translate::LanguageState* WebViewAutofillClientIOS::GetLanguageState() { @@ -285,7 +270,7 @@ bool is_refill) {} bool WebViewAutofillClientIOS::IsContextSecure() const { - return IsContextSecureForWebState(web_state_); + return IsContextSecureForWebState(web_state()); } autofill::FormInteractionsFlowId
diff --git a/ios_internal b/ios_internal index 6102267..318acc7 160000 --- a/ios_internal +++ b/ios_internal
@@ -1 +1 @@ -Subproject commit 61022675d8772a34fc6bcc1c3b60908fc0ee6623 +Subproject commit 318acc714eeb02ac2fd443810f5143f4830ca6a4
diff --git a/media/capture/video/chromeos/camera_buffer_factory.cc b/media/capture/video/chromeos/camera_buffer_factory.cc index 87aebd0..9a39b06 100644 --- a/media/capture/video/chromeos/camera_buffer_factory.cc +++ b/media/capture/video/chromeos/camera_buffer_factory.cc
@@ -12,10 +12,6 @@ namespace media { -// Setting some default usage in order to get a mappable shared image. -constexpr auto si_usage = gpu::SHARED_IMAGE_USAGE_CPU_WRITE_ONLY | - gpu::SHARED_IMAGE_USAGE_DISPLAY_READ; - CameraBufferFactory::CameraBufferFactory() = default; CameraBufferFactory::~CameraBufferFactory() = default; @@ -68,9 +64,24 @@ return nullptr; } + // In the media capture process, the underlying GMB handle created via the + // below shared image is only used for CPU read/write. It is then later sent + // to the renderer which uses the handle to create a new shared image for + // drawing. Hence there is no need to create and hold a service side GMB + // handle/NativePixmap as a part of OzoneImageBacking created via below + // CreateSharedImage call. Creating and holding a NativePixmap via below + // CreateSharedImage call also fails for R8 format since it's not a + // texturable format for some devices. + // Hence we use the special usage flag SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE + // which instructs the service side code that a NativePixmap inside the + // SharedImage is not necessary for this use case. + // Note that we'll need to refine this if/when we want to send these + // SharedImages over to the renderer process when feasible (i.e., for non-R8 + // and/or for R8 on devices where it's texturable). auto shared_image = sii->CreateSharedImage( {viz::GetSharedImageFormat(format), size, color_space, - gpu::SharedImageUsageSet(si_usage), "CameraBufferFactory"}, + gpu::SharedImageUsageSet(gpu::SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE), + "CameraBufferFactory"}, gpu::kNullSurfaceHandle, usage); if (!shared_image) { LOG(ERROR) << "Failed to create a shared image."; @@ -91,9 +102,24 @@ return nullptr; } + // In the media capture process, the underlying GMB handle created via the + // below shared image is only used for CPU read/write. It is then later sent + // to the renderer which uses the handle to create a new shared image for + // drawing. Hence there is no need to create and hold a service side GMB + // handle/NativePixmap as a part of OzoneImageBacking created via below + // CreateSharedImage call. Creating and holding a NativePixmap via below + // CreateSharedImage call also fails for R8 format since it's not a + // texturable format for some devices. + // Hence we use the special usage flag SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE + // which instructs the service side code that a NativePixmap inside the + // SharedImage is not necessary for this use case. + // Note that we'll need to refine this if/when we want to send these + // SharedImages over to the renderer process when feasible (i.e., for non-R8 + // and/or for R8 on devices where it's texturable). auto shared_image = sii->CreateSharedImage( {viz::GetSharedImageFormat(format), size, color_space, - gpu::SharedImageUsageSet(si_usage), "CameraBufferFactory"}, + gpu::SharedImageUsageSet(gpu::SHARED_IMAGE_USAGE_CPU_ONLY_READ_WRITE), + "CameraBufferFactory"}, gpu::kNullSurfaceHandle, usage, std::move(buffer_handle)); if (!shared_image) { LOG(ERROR) << "Failed to create a shared image.";
diff --git a/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.cc b/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.cc index cb49360e..9dece58 100644 --- a/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.cc +++ b/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.cc
@@ -6,13 +6,15 @@ #include "base/check.h" #include "base/notreached.h" +#include "components/viz/common/resources/shared_image_format_utils.h" +#include "gpu/command_buffer/client/client_shared_image.h" #include "media/capture/video/chromeos/pixel_format_utils.h" #include "media/capture/video/video_capture_buffer_handle.h" #include "ui/gfx/geometry/size.h" namespace media { -GpuMemoryBufferTrackerCros::GpuMemoryBufferTrackerCros() : buffer_(nullptr) {} +GpuMemoryBufferTrackerCros::GpuMemoryBufferTrackerCros() = default; GpuMemoryBufferTrackerCros::~GpuMemoryBufferTrackerCros() = default; @@ -32,13 +34,9 @@ ? gfx::BufferUsage::CAMERA_AND_CPU_READ_WRITE : gfx::BufferUsage::VEA_READ_CAMERA_AND_CPU_READ_WRITE; - buffer_ = - buffer_factory_.CreateGpuMemoryBuffer(dimensions, *gfx_format, usage); - if (!buffer_) { - DLOG(ERROR) << "Failed to create GPU memory buffer"; - return false; - } - return true; + shared_image_ = + buffer_factory_.CreateSharedImage(dimensions, *gfx_format, usage); + return shared_image_ ? true : false; } bool GpuMemoryBufferTrackerCros::IsReusableForFormat( @@ -49,8 +47,8 @@ if (!gfx_format) { return false; } - return (*gfx_format == buffer_->GetFormat() && - dimensions == buffer_->GetSize()); + return (viz::GetSharedImageFormat(*gfx_format) == shared_image_->format() && + dimensions == shared_image_->size()); } std::unique_ptr<VideoCaptureBufferHandle> @@ -65,8 +63,8 @@ gfx::GpuMemoryBufferHandle GpuMemoryBufferTrackerCros::GetGpuMemoryBufferHandle() { - DCHECK(buffer_); - // Overriding the GpuMemoryBuffer id to an invalid id to avoid buffer + CHECK(shared_image_); + // Overriding the GpuMemoryBufferHandle id to an invalid id to avoid buffer // collision in GpuMemoryBufferFactoryNativePixmap when we pass the handle // to a different process. (crbug.com/993265) // @@ -75,7 +73,14 @@ // re-using a wrong pixmap handle in the cache. // // [1]: https://tinyurl.com/yymtv22y - gfx::GpuMemoryBufferHandle handle = buffer_->CloneHandle(); + // TODO(crbug.com/359601431): Remove this method once all + // GpuMemoryBufferTrackers are converted to use MappableSI. + // Note that the above case of buffer collision will not be an issue with use + // of MappableSI everywhere since it does not internally use or cache buffer + // ids to refer to underlying buffer. Instead all the shared images are + // referred to by mailboxes. + gfx::GpuMemoryBufferHandle handle = + shared_image_->CloneGpuMemoryBufferHandle(); handle.id = gfx::GpuMemoryBufferHandle::kInvalidId; return handle; } @@ -85,15 +90,14 @@ } uint32_t GpuMemoryBufferTrackerCros::GetMemorySizeInBytes() { - DCHECK(buffer_); - switch (buffer_->GetFormat()) { - case gfx::BufferFormat::YUV_420_BIPLANAR: - return buffer_->GetSize().width() * buffer_->GetSize().height() * 3 / 2; - case gfx::BufferFormat::R_8: - return buffer_->GetSize().width() * buffer_->GetSize().height(); - default: - NOTREACHED() << "Unsupported gfx buffer format"; + CHECK(shared_image_); + auto size = + shared_image_->format().EstimatedSizeInBytes(shared_image_->size()); + if ((shared_image_->format() != viz::MultiPlaneFormat::kNV12) && + (shared_image_->format() != viz::SinglePlaneFormat::kR_8)) { + NOTREACHED() << "Unsupported shared image format"; } + return size; } } // namespace media
diff --git a/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.h b/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.h index 58a6695b..603c191 100644 --- a/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.h +++ b/media/capture/video/chromeos/gpu_memory_buffer_tracker_cros.h
@@ -12,6 +12,10 @@ class Size; } // namespace gfx +namespace gpu { +class ClientSharedImage; +} + namespace media { // Tracker specifics for Chrome OS GpuMemoryBuffer. @@ -45,7 +49,7 @@ private: CameraBufferFactory buffer_factory_; - std::unique_ptr<gfx::GpuMemoryBuffer> buffer_; + scoped_refptr<gpu::ClientSharedImage> shared_image_; }; } // namespace media
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc index 0579a053..c937c8d5 100644 --- a/media/cdm/aes_decryptor.cc +++ b/media/cdm/aes_decryptor.cc
@@ -159,10 +159,10 @@ CHECK(input.decrypt_config()); if (input.decrypt_config()->encryption_scheme() == EncryptionScheme::kCenc) - return DecryptCencBuffer(input, key); + return DecryptCencBuffer(input, base::as_byte_span(key.key())); if (input.decrypt_config()->encryption_scheme() == EncryptionScheme::kCbcs) - return DecryptCbcsBuffer(input, key); + return DecryptCbcsBuffer(input, base::as_byte_span(key.key())); DVLOG(1) << "Only 'cenc' and 'cbcs' modes supported."; return nullptr;
diff --git a/media/cdm/cbcs_decryptor.cc b/media/cdm/cbcs_decryptor.cc index 206b3e6..69236c4 100644 --- a/media/cdm/cbcs_decryptor.cc +++ b/media/cdm/cbcs_decryptor.cc
@@ -19,7 +19,6 @@ #include "base/logging.h" #include "base/memory/scoped_refptr.h" #include "base/numerics/checked_math.h" -#include "crypto/symmetric_key.h" #include "media/base/decoder_buffer.h" #include "media/base/decrypt_config.h" #include "media/base/encryption_pattern.h" @@ -123,12 +122,6 @@ } // namespace -scoped_refptr<DecoderBuffer> DecryptCbcsBuffer( - const DecoderBuffer& input, - const crypto::SymmetricKey& key) { - return DecryptCbcsBuffer(input, base::as_byte_span(key.key())); -} - scoped_refptr<DecoderBuffer> DecryptCbcsBuffer(const DecoderBuffer& input, base::span<const uint8_t> key) { const size_t sample_size = input.size();
diff --git a/media/cdm/cbcs_decryptor.h b/media/cdm/cbcs_decryptor.h index 0aca4d4..6057bc5a 100644 --- a/media/cdm/cbcs_decryptor.h +++ b/media/cdm/cbcs_decryptor.h
@@ -9,10 +9,6 @@ #include "base/memory/scoped_refptr.h" #include "media/base/media_export.h" -namespace crypto { -class SymmetricKey; -} - namespace media { class DecoderBuffer; @@ -49,9 +45,6 @@ // |input|->DecryptConfig. The key size must be 128 bits. MEDIA_EXPORT scoped_refptr<DecoderBuffer> DecryptCbcsBuffer( const DecoderBuffer& input, - const crypto::SymmetricKey& key); -MEDIA_EXPORT scoped_refptr<DecoderBuffer> DecryptCbcsBuffer( - const DecoderBuffer& input, base::span<const uint8_t> key); } // namespace media
diff --git a/media/cdm/cbcs_decryptor_fuzzer.cc b/media/cdm/cbcs_decryptor_fuzzer.cc index ac720dc5..0ad1bcb1 100644 --- a/media/cdm/cbcs_decryptor_fuzzer.cc +++ b/media/cdm/cbcs_decryptor_fuzzer.cc
@@ -50,11 +50,6 @@ const uint8_t encryption_pattern = data[1]; data = data.subspan<2>(); - static std::unique_ptr<crypto::SymmetricKey> key = - crypto::SymmetricKey::Import( - crypto::SymmetricKey::AES, - std::string(std::begin(kKey), std::end(kKey))); - // |clear_bytes| is used to determine how much of the buffer is "clear". // Since the code checks SubsampleEntries, use |clear_bytes| as the actual // number of bytes clear, and the rest as encrypted. To avoid size_t problems, @@ -75,9 +70,8 @@ // Key_ID is never used. encrypted_buffer->set_decrypt_config(media::DecryptConfig::CreateCbcsConfig( - "key_id", std::string(std::begin(kIv), std::end(kIv)), subsamples, - pattern)); + "key_id", std::string(base::as_string_view(kIv)), subsamples, pattern)); - media::DecryptCbcsBuffer(*encrypted_buffer, *key); + media::DecryptCbcsBuffer(*encrypted_buffer, kKey); return 0; }
diff --git a/media/cdm/cenc_decryptor.cc b/media/cdm/cenc_decryptor.cc index ff103d2..a16d95cb8 100644 --- a/media/cdm/cenc_decryptor.cc +++ b/media/cdm/cenc_decryptor.cc
@@ -15,7 +15,6 @@ #include "base/containers/span.h" #include "base/logging.h" #include "crypto/aes_ctr.h" -#include "crypto/symmetric_key.h" #include "media/base/decoder_buffer.h" #include "media/base/decrypt_config.h" #include "media/base/subsample_entry.h" @@ -69,12 +68,6 @@ } // namespace -scoped_refptr<DecoderBuffer> DecryptCencBuffer( - const DecoderBuffer& input, - const crypto::SymmetricKey& wrapped_key) { - return DecryptCencBuffer(input, base::as_byte_span(wrapped_key.key())); -} - scoped_refptr<DecoderBuffer> DecryptCencBuffer(const DecoderBuffer& input, base::span<const uint8_t> key) { base::span<const uint8_t> sample = input;
diff --git a/media/cdm/cenc_decryptor.h b/media/cdm/cenc_decryptor.h index 447591e..7938b2d6 100644 --- a/media/cdm/cenc_decryptor.h +++ b/media/cdm/cenc_decryptor.h
@@ -9,10 +9,6 @@ #include "base/memory/scoped_refptr.h" #include "media/base/media_export.h" -namespace crypto { -class SymmetricKey; -} - namespace media { class DecoderBuffer; @@ -40,9 +36,6 @@ // |input|->DecryptConfig. The key size must be 128 bits. MEDIA_EXPORT scoped_refptr<DecoderBuffer> DecryptCencBuffer( const DecoderBuffer& input, - const crypto::SymmetricKey& key); -MEDIA_EXPORT scoped_refptr<DecoderBuffer> DecryptCencBuffer( - const DecoderBuffer& input, base::span<const uint8_t> key); } // namespace media
diff --git a/media/cdm/cenc_decryptor_fuzzer.cc b/media/cdm/cenc_decryptor_fuzzer.cc index d7a69faf..359b1c8 100644 --- a/media/cdm/cenc_decryptor_fuzzer.cc +++ b/media/cdm/cenc_decryptor_fuzzer.cc
@@ -14,7 +14,6 @@ #include "base/compiler_specific.h" #include "base/containers/span.h" #include "base/logging.h" -#include "crypto/symmetric_key.h" #include "media/base/decoder_buffer.h" #include "media/base/subsample_entry.h" @@ -48,11 +47,6 @@ const uint8_t clear_bytes = data[0]; data = data.subspan<1>(); - static std::unique_ptr<crypto::SymmetricKey> key = - crypto::SymmetricKey::Import( - crypto::SymmetricKey::AES, - std::string(std::begin(kKey), std::end(kKey))); - // |clear_bytes| is used to determine how much of the buffer is "clear". // Since the code checks SubsampleEntries, use |clear_bytes| as the actual // number of bytes clear, and the rest as encrypted. To avoid size_t problems, @@ -70,6 +64,6 @@ encrypted_buffer->set_decrypt_config(media::DecryptConfig::CreateCencConfig( "key_id", std::string(base::as_string_view(kIv)), subsamples)); - media::DecryptCencBuffer(*encrypted_buffer, *key); + media::DecryptCencBuffer(*encrypted_buffer, kKey); return 0; }
diff --git a/mojo/public/cpp/bindings/lib/buffer.cc b/mojo/public/cpp/bindings/lib/buffer.cc index 64056b6f..e9b54933 100644 --- a/mojo/public/cpp/bindings/lib/buffer.cc +++ b/mojo/public/cpp/bindings/lib/buffer.cc
@@ -73,7 +73,7 @@ uint32_t new_size; MojoResult rv = MojoAppendMessageData( message_.value(), static_cast<uint32_t>(additional_bytes), nullptr, 0, - nullptr, &data_, &new_size); + nullptr, &data_.AsEphemeralRawAddr(), &new_size); DCHECK_EQ(MOJO_RESULT_OK, rv); message_payload_size_ = new_cursor; size_ = new_size; @@ -100,7 +100,8 @@ uint32_t new_size = 0; MojoResult rv = MojoAppendMessageData( message_.value(), 0, reinterpret_cast<MojoHandle*>(handles->data()), - static_cast<uint32_t>(handles->size()), nullptr, &data_, &new_size); + static_cast<uint32_t>(handles->size()), nullptr, + &data_.AsEphemeralRawAddr(), &new_size); if (rv != MOJO_RESULT_OK) return false;
diff --git a/mojo/public/cpp/bindings/lib/buffer.h b/mojo/public/cpp/bindings/lib/buffer.h index bc5451b..eb12a32 100644 --- a/mojo/public/cpp/bindings/lib/buffer.h +++ b/mojo/public/cpp/bindings/lib/buffer.h
@@ -16,7 +16,7 @@ #include <vector> #include "base/component_export.h" -#include "base/memory/raw_ptr_exclusion.h" +#include "base/memory/raw_ptr.h" #include "mojo/public/cpp/system/handle.h" #include "mojo/public/cpp/system/message.h" @@ -124,9 +124,18 @@ // The storage location and capacity currently backing |message_|. Owned by // the message object internally, not by this Buffer. - // This field is not a raw_ptr<> because it was filtered by the rewriter for: - // #union, #addr-of - RAW_PTR_EXCLUSION void* data_ = nullptr; + // Dangling when running chromedriver_unittests on win-rel (this is not an + // exhaustive list of failures, just ones that provided an easy to view + // backtrace): + // FetchUrlTest.ConnectionClose + // FetchUrlTest.Http200 + // FetchUrlTest.HttpNon200 + // FetchUrlTest.NoServer + // TestHttpServerTest.ResourceNotFound + // TestHttpServerTest.SetDataForPath + // TestHttpServerTest.Start + // TODO: crbug.com/387315749 - Resolving dangling pointer + raw_ptr<void, DanglingUntriaged> data_ = nullptr; size_t size_ = 0; // The current write offset into |data_| if this Buffer is being used for
diff --git a/net/test/cert_builder.cc b/net/test/cert_builder.cc index a405245..39a9e321 100644 --- a/net/test/cert_builder.cc +++ b/net/test/cert_builder.cc
@@ -578,7 +578,20 @@ SetCrlDistributionPointUrls({url}); } +void CertBuilder::SetCrlDistributionPointUrl(const std::string_view& url) { + SetCrlDistributionPointUrls(std::vector<std::string>{std::string(url)}); +} + void CertBuilder::SetCrlDistributionPointUrls(const std::vector<GURL>& urls) { + std::vector<std::string> string_urls; + for (const auto& url : urls) { + string_urls.push_back(url.possibly_invalid_spec()); + } + SetCrlDistributionPointUrls(string_urls); +} + +void CertBuilder::SetCrlDistributionPointUrls( + const std::vector<std::string>& urls) { bssl::ScopedCBB cbb; ASSERT_TRUE(CBB_init(cbb.get(), 64)); CBB dps, dp, dp_name, dp_fullname; @@ -608,7 +621,7 @@ CBB dp_url; ASSERT_TRUE( CBB_add_asn1(&dp_fullname, &dp_url, CBS_ASN1_CONTEXT_SPECIFIC | 6)); - ASSERT_TRUE(CBBAddBytes(&dp_url, url.spec())); + ASSERT_TRUE(CBBAddBytes(&dp_url, url)); ASSERT_TRUE(CBB_flush(&dp_fullname)); }
diff --git a/net/test/cert_builder.h b/net/test/cert_builder.h index 591d9388..8c225ff 100644 --- a/net/test/cert_builder.h +++ b/net/test/cert_builder.h
@@ -188,10 +188,16 @@ // Sets a cRLDistributionPoints extension with a single DistributionPoint // with |url| in distributionPoint.fullName. void SetCrlDistributionPointUrl(const GURL& url); + // Same as |SetCrlDistributionPointUrl| above, but the inputs can be an + // arbitrary string. + void SetCrlDistributionPointUrl(const std::string_view& url); // Sets a cRLDistributionPoints extension with a single DistributionPoint // with |urls| in distributionPoints.fullName. void SetCrlDistributionPointUrls(const std::vector<GURL>& urls); + // Same as |SetCrlDistributionPointUrls| above, but the inputs can be + // arbitrary strings. + void SetCrlDistributionPointUrls(const std::vector<std::string>& urls); // Sets the issuer bytes that will be encoded into the generated certificate. // If this is not called, or |issuer_tlv| is empty, the subject field from
diff --git a/remoting/host/it2me/it2me_confirmation_dialog_chromeos.cc b/remoting/host/it2me/it2me_confirmation_dialog_chromeos.cc index ccc6ce48..e304c24 100644 --- a/remoting/host/it2me/it2me_confirmation_dialog_chromeos.cc +++ b/remoting/host/it2me/it2me_confirmation_dialog_chromeos.cc
@@ -18,7 +18,6 @@ #include "remoting/host/it2me/it2me_confirmation_dialog.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_types.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" #include "ui/message_center/message_center.h" #include "ui/message_center/public/cpp/notification.h" @@ -68,7 +67,7 @@ const gfx::VectorIcon& GetIcon() const { switch (style_) { case DialogStyle::kConsumer: - return gfx::kNoneIcon; + return gfx::VectorIcon::EmptyIcon(); case DialogStyle::kEnterprise: return chromeos::kEnterpriseIcon; }
diff --git a/services/on_device_model/ml/chrome_ml.cc b/services/on_device_model/ml/chrome_ml.cc index efc49d4ce..775cff5 100644 --- a/services/on_device_model/ml/chrome_ml.cc +++ b/services/on_device_model/ml/chrome_ml.cc
@@ -39,9 +39,10 @@ enum class GpuErrorReason { kOther = 0, kDxgiErrorDeviceHung = 1, - kDxgiErrorDeviceRemoved = 2, + kDeviceRemoved = 2, kDeviceCreationFailed = 3, - kMaxValue = kDeviceCreationFailed, + kOutOfMemory = 4, + kMaxValue = kOutOfMemory, }; void FatalGpuErrorFn(const char* msg) { @@ -50,10 +51,14 @@ GpuErrorReason error_reason = GpuErrorReason::kOther; if (msg_str.find("DXGI_ERROR_DEVICE_HUNG") != std::string::npos) { error_reason = GpuErrorReason::kDxgiErrorDeviceHung; - } else if (msg_str.find("DXGI_ERROR_DEVICE_REMOVED") != std::string::npos) { - error_reason = GpuErrorReason::kDxgiErrorDeviceRemoved; + } else if (msg_str.find("DXGI_ERROR_DEVICE_REMOVED") != std::string::npos || + msg_str.find("VK_ERROR_DEVICE_LOST") != std::string::npos) { + error_reason = GpuErrorReason::kDeviceRemoved; } else if (msg_str.find("Failed to create device") != std::string::npos) { error_reason = GpuErrorReason::kDeviceCreationFailed; + } else if (msg_str.find("VK_ERROR_OUT_OF_DEVICE_MEMORY") != + std::string::npos) { + error_reason = GpuErrorReason::kOutOfMemory; } base::UmaHistogramEnumeration("OnDeviceModel.GpuErrorReason", error_reason); if (error_reason == GpuErrorReason::kOther) {
diff --git a/testing/buildbot/chromium.perf.fyi.json b/testing/buildbot/chromium.perf.fyi.json index 64fd21f..feddde0 100644 --- a/testing/buildbot/chromium.perf.fyi.json +++ b/testing/buildbot/chromium.perf.fyi.json
@@ -310,7 +310,7 @@ "cpu": "arm64-64-Snapdragon(R)_X_Elite_-_X1E80100_-_Qualcomm(R)_Oryon(TM)_CPU", "os": "Windows-11", "pool": "chrome.tests.perf", - "synthetic_product_name": "Inspiron 14 Plus 7441 (Dell Inc.)" + "synthetic_product_name": "Latitude 7455 (Dell Inc.)" }, "expiration": 7200, "hard_timeout": 14400,
diff --git a/testing/libfuzzer/fuzzers/paint_vector_icon_fuzztest.cc b/testing/libfuzzer/fuzzers/paint_vector_icon_fuzztest.cc index 63be435..158c5f3 100644 --- a/testing/libfuzzer/fuzzers/paint_vector_icon_fuzztest.cc +++ b/testing/libfuzzer/fuzzers/paint_vector_icon_fuzztest.cc
@@ -112,7 +112,7 @@ // An icon can contain multiple representations. We do not fuzz the code // that chooses which representation to draw based on canvas size and scale, // and instead use a single representation. - gfx::VectorIconRep rep(path.data(), path.size()); + gfx::VectorIconRep rep{path}; gfx::VectorIcon icon(&rep, /*reps_size=*/1u, "icon"); constexpr float kImageScale = 1.f;
diff --git a/third_party/beto-core/BUILD.gn b/third_party/beto-core/BUILD.gn index 5ba1ed3..cd7ac92 100644 --- a/third_party/beto-core/BUILD.gn +++ b/third_party/beto-core/BUILD.gn
@@ -392,6 +392,9 @@ "//third_party/rust/itertools/v0_11:lib", "//third_party/rust/serde_json/v1:lib", ] + + # TODO(https://crbug.com/326247202): Fix unused imports and remove this flag. + rustflags = [ "-Aunused-imports" ] } rust_static_library("rand_ext") {
diff --git a/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom b/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom index 4ca47a15..1f4da82 100644 --- a/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom +++ b/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom
@@ -4619,6 +4619,7 @@ kInjectionMitigatedContextSubFrame = 5233, kInjectionMitigatedContextMainFrame = 5234, kCanvasTextDirectionConflict = 5235, + kTopicsAPIImg = 5236, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots. Also don't add extra
diff --git a/third_party/blink/renderer/core/html/forms/html_select_element.cc b/third_party/blink/renderer/core/html/forms/html_select_element.cc index 4a2b097..aa721745 100644 --- a/third_party/blink/renderer/core/html/forms/html_select_element.cc +++ b/third_party/blink/renderer/core/html/forms/html_select_element.cc
@@ -1117,14 +1117,23 @@ } bool HTMLSelectElement::IsInDialogMode() const { - return content_model_violations_count_ > 0U; + return RuntimeEnabledFeatures::CustomizableSelectEnabled() && + IsAppearanceBaseButton( + HTMLSelectElement::StyleUpdateBehavior::kDontUpdateStyle) && + content_model_violations_count_ > 0U; } void HTMLSelectElement::IncreaseContentModelViolationCount() { + CHECK(RuntimeEnabledFeatures::CustomizableSelectEnabled()); + DCHECK(IsAppearanceBaseButton( + HTMLSelectElement::StyleUpdateBehavior::kDontUpdateStyle)); ++content_model_violations_count_; } void HTMLSelectElement::DecreaseContentModelViolationCount() { + CHECK(RuntimeEnabledFeatures::CustomizableSelectEnabled()); + DCHECK(IsAppearanceBaseButton( + HTMLSelectElement::StyleUpdateBehavior::kDontUpdateStyle)); if (content_model_violations_count_ > 0U) { --content_model_violations_count_; }
diff --git a/third_party/blink/renderer/core/html/forms/select_type.cc b/third_party/blink/renderer/core/html/forms/select_type.cc index cff8725..1f12278 100644 --- a/third_party/blink/renderer/core/html/forms/select_type.cc +++ b/third_party/blink/renderer/core/html/forms/select_type.cc
@@ -123,18 +123,26 @@ // whether the popover is opened or closed. select->GetShadowRoot()->SetNeedsAssignmentRecalc(); // This is a CustomizableSelect popup. When it is shown, we should focus - // the selected option. - HTMLOptionElement* option_to_focus = select->SelectedOption(); - if (!option_to_focus || !option_to_focus->IsFocusable()) { - for (auto& option : select->GetOptionList()) { - if (option.IsFocusable()) { - option_to_focus = &option; - break; + // on the selected option or on the first focusable element if we're in + // dialog mode. + if (select->IsInDialogMode()) { + if (Element* control = + select->GetFocusDelegate(/*autofocus_only=*/false)) { + control->Focus(FocusParams(FocusTrigger::kScript)); + } + } else { + HTMLOptionElement* option_to_focus = select->SelectedOption(); + if (!option_to_focus || !option_to_focus->IsFocusable()) { + for (auto& option : select->GetOptionList()) { + if (option.IsFocusable()) { + option_to_focus = &option; + break; + } } } - } - if (option_to_focus) { - option_to_focus->Focus(FocusParams(FocusTrigger::kScript)); + if (option_to_focus) { + option_to_focus->Focus(FocusParams(FocusTrigger::kScript)); + } } if (AXObjectCache* cache = select->GetDocument().ExistingAXObjectCache()) {
diff --git a/third_party/blink/renderer/core/html/html_image_element.idl b/third_party/blink/renderer/core/html/html_image_element.idl index 2c4624c..15977fa 100644 --- a/third_party/blink/renderer/core/html/html_image_element.idl +++ b/third_party/blink/renderer/core/html/html_image_element.idl
@@ -63,6 +63,9 @@ [MeasureAs=HTMLImageElementY] readonly attribute long y; [CallWith=ScriptState, RaisesException] Promise<undefined> decode(); + + // Topics API (https://github.com/patcg-individual-drafts/topics) + [RuntimeEnabled=TopicsImgAPI, SecureContext, CEReactions, Reflect] attribute boolean browsingTopics; }; HTMLImageElement includes HTMLAttributionSrcElementUtils;
diff --git a/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc b/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc index 7a3f6ed..f9274f3 100644 --- a/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc +++ b/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
@@ -369,6 +369,11 @@ request->SetSharedStorageWritableOptedIn(true); } + if (browsing_topics_attr_set_) { + DCHECK(is_img); + request->SetBrowsingTopicsEligible(true); + } + return request; } @@ -451,6 +456,8 @@ attributionsrc_attr_set_ = true; } else if (Match(attribute_name, html_names::kSharedstoragewritableAttr)) { shared_storage_writable_opted_in_ = true; + } else if (Match(attribute_name, html_names::kBrowsingtopicsAttr)) { + browsing_topics_attr_set_ = true; } else if (use_data_src_attr_match_for_image_ && Match(attribute_name, html_names::kDataSrcAttr) && img_src_url_.IsNull()) { @@ -818,6 +825,7 @@ const HashSet<String>* disabled_image_types_; bool attributionsrc_attr_set_ = false; bool shared_storage_writable_opted_in_ = false; + bool browsing_topics_attr_set_ = false; std::optional<float> resource_width_; std::optional<float> resource_height_; features::LcppPreloadLazyLoadImageType preload_lazy_load_image_type_;
diff --git a/third_party/blink/renderer/core/html/parser/html_preload_scanner_test.cc b/third_party/blink/renderer/core/html/parser/html_preload_scanner_test.cc index a0df978..0e1fcfb 100644 --- a/third_party/blink/renderer/core/html/parser/html_preload_scanner_test.cc +++ b/third_party/blink/renderer/core/html/parser/html_preload_scanner_test.cc
@@ -130,6 +130,13 @@ bool expected_shared_storage_writable_opted_in; }; +struct BrowsingTopicsWritableTestCase { + bool use_secure_document_url; + const char* base_url; + const char* input_html; + bool expected_browsing_topics; +}; + class HTMLMockHTMLResourcePreloader : public ResourcePreloader { public: explicit HTMLMockHTMLResourcePreloader(const KURL& document_url) @@ -309,6 +316,16 @@ resource->GetResourceRequest().GetSharedStorageWritableOptedIn()); } + void BrowsingTopicsRequestVerification(Document* document, + bool expected_browsing_topics) { + ASSERT_TRUE(preload_request_.get()); + Resource* resource = preload_request_->Start(document); + ASSERT_TRUE(resource); + + EXPECT_EQ(expected_browsing_topics, + resource->GetResourceRequest().GetBrowsingTopics()); + } + protected: void Preload(std::unique_ptr<PreloadRequest> preload_request) override { preload_request_ = std::move(preload_request); @@ -546,6 +563,20 @@ &GetDocument(), test_case.expected_shared_storage_writable_opted_in); } + void Test(BrowsingTopicsWritableTestCase test_case) { + SCOPED_TRACE(base::StringPrintf("Use secure doc URL: %d; HTML: '%s'", + test_case.use_secure_document_url, + test_case.input_html)); + + HTMLMockHTMLResourcePreloader preloader(GetDocument().Url()); + KURL base_url(test_case.base_url); + scanner_->AppendToEnd(String(test_case.input_html)); + std::unique_ptr<PendingPreloadData> preload_data = scanner_->Scan(base_url); + preloader.TakePreloadData(std::move(preload_data)); + preloader.BrowsingTopicsRequestVerification( + &GetDocument(), test_case.expected_browsing_topics); + } + private: std::unique_ptr<HTMLPreloadScanner> scanner_; }; @@ -1990,4 +2021,42 @@ } } +TEST_F(HTMLPreloadScannerTest, testBrowsingTopics) { + WebRuntimeFeaturesBase::EnableTopicsAPI(true); + static constexpr bool kSecureDocumentUrl = true; + static constexpr bool kInsecureDocumentUrl = false; + + static constexpr char kSecureBaseURL[] = "https://example.test"; + static constexpr char kInsecureBaseURL[] = "http://example.test"; + + BrowsingTopicsWritableTestCase test_cases[] = { + // Insecure context + {kInsecureDocumentUrl, kSecureBaseURL, + "<img src='/image' browsingtopics>", + /*expected_browsing_topics=*/false}, + // No browsingtopics attribute + {kSecureDocumentUrl, kSecureBaseURL, "<img src='/image'>", + /*expected_browsing_topics=*/false}, + // Irrelevant element type + {kSecureDocumentUrl, kSecureBaseURL, + "<video poster='/image' browsingtopics>", + /*expected_browsing_topics=*/false}, + // Secure context, browsingtopics attribute + // Base (initial) URL does not affect SharedStorageWritable eligibility + {kSecureDocumentUrl, kInsecureBaseURL, + "<img src='/image' browsingtopics>", + /*expected_browsing_topics=*/true}, + // Secure context, browsingtopics attribute + {kSecureDocumentUrl, kSecureBaseURL, "<img src='/image' browsingtopics>", + /*expected_browsing_topics=*/true}, + }; + + for (const auto& test_case : test_cases) { + RunSetUp(kViewportDisabled, kPreloadEnabled, + network::mojom::ReferrerPolicy::kDefault, + /*use_secure_document_url=*/test_case.use_secure_document_url); + Test(test_case); + } +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/html/parser/preload_request.cc b/third_party/blink/renderer/core/html/parser/preload_request.cc index 2f5b013..848b9fd 100644 --- a/third_party/blink/renderer/core/html/parser/preload_request.cc +++ b/third_party/blink/renderer/core/html/parser/preload_request.cc
@@ -140,6 +140,12 @@ UseCounter::Count(document, WebFeature::kSharedStorageAPI_Image_Attribute); } + bool browsing_topics = + browsing_topics_eligible_ && RuntimeEnabledFeatures::TopicsAPIEnabled() && + document->domWindow()->IsSecureContext() && + !document->domWindow()->GetSecurityOrigin()->IsOpaque(); + resource_request.SetBrowsingTopics(browsing_topics); + ResourceLoaderOptions options(document->domWindow()->GetCurrentWorld()); options.initiator_info = initiator_info; FetchParameters params(std::move(resource_request), options);
diff --git a/third_party/blink/renderer/core/html/parser/preload_request.h b/third_party/blink/renderer/core/html/parser/preload_request.h index f195db6d..11bbb15f 100644 --- a/third_party/blink/renderer/core/html/parser/preload_request.h +++ b/third_party/blink/renderer/core/html/parser/preload_request.h
@@ -159,6 +159,14 @@ shared_storage_writable_opted_in_ = opted_in; } + // Set whether the preload request is eligible for the Browsing Topics API. + // + // See https://github.com/patcg-individual-drafts/topics/blob/main/README.md + // for the latest version of the Topics API explainer. + void SetBrowsingTopicsEligible(bool flag) { + browsing_topics_eligible_ = flag; + } + bool IsPotentiallyLCPElement() const { return is_potentially_lcp_element_; } bool IsPotentiallyLCPInfluencer() const { @@ -217,6 +225,7 @@ bool is_potentially_lcp_element_ = false; bool is_potentially_lcp_influencer_ = false; bool shared_storage_writable_opted_in_ = false; + bool browsing_topics_eligible_ = false; }; typedef Vector<std::unique_ptr<PreloadRequest>> PreloadRequestStream;
diff --git a/third_party/blink/renderer/core/loader/image_loader.cc b/third_party/blink/renderer/core/loader/image_loader.cc index 402a7c3b..1ca92c4 100644 --- a/third_party/blink/renderer/core/loader/image_loader.cc +++ b/third_party/blink/renderer/core/loader/image_loader.cc
@@ -507,6 +507,14 @@ !SecurityOrigin::Create(url)->IsOpaque(); resource_request.SetSharedStorageWritableOptedIn( shared_storage_writable_opted_in); + if (GetElement()->FastHasAttribute(html_names::kBrowsingtopicsAttr) && + RuntimeEnabledFeatures::TopicsAPIEnabled( + GetElement()->GetExecutionContext()) && + GetElement()->GetExecutionContext()->IsSecureContext()) { + resource_request.SetBrowsingTopics(true); + UseCounter::Count(document, mojom::blink::WebFeature::kTopicsAPIImg); + UseCounter::Count(document, mojom::blink::WebFeature::kTopicsAPIAll); + } } bool page_is_being_dismissed =
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 index 46d2097..96ab93d 100644 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -4297,6 +4297,14 @@ public: true, status: "stable", }, + { + // This feature allows calling the Topics API via an image + // attribute. + name: "TopicsImgAPI", + base_feature: "none", + public: true, + status: "experimental", + }, // This is a killswitch for the behavior where popover.showPopover() and // dialog.showModal() throw DOM exceptions if the document isn't active. // This landed in M132, and can be removed in M134.
diff --git a/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-default.tentative.https.sub.html b/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-default.tentative.https.sub.html index 8467ab6..f37a8972 100644 --- a/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-default.tentative.https.sub.html +++ b/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-default.tentative.https.sub.html
@@ -3,7 +3,9 @@ <script src=/resources/testharness.js></script> <script src=/resources/testharnessreport.js></script> <script src=/browsing-topics/resources/header-util.sub.js></script> + <script src=/browsing-topics/resources/load_img.sub.js></script> <script src=/browsing-topics/resources/permissions-policy-util.sub.js></script> + <script src=/common/utils.js></script> <script> 'use strict'; const header = 'Default permissions policy'; @@ -39,6 +41,18 @@ assert_equals(topics_header, EMPTY_TOPICS_HEADER); }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics fetch request.'); + promise_test(async t => { + let topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true); + assert_equals(topics_header, EMPTY_TOPICS_HEADER); + }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the same-origin topics img request.'); + + promise_test(async t => { + let topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/false); + assert_equals(topics_header, EMPTY_TOPICS_HEADER); + }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics img request.'); + async_test(t => { test_topics_iframe_navigation_header( t, /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true,
diff --git a/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-none.tentative.https.sub.html b/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-none.tentative.https.sub.html index 23bac438..1a3737c 100644 --- a/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-none.tentative.https.sub.html +++ b/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-none.tentative.https.sub.html
@@ -3,7 +3,9 @@ <script src=/resources/testharness.js></script> <script src=/resources/testharnessreport.js></script> <script src=/browsing-topics/resources/header-util.sub.js></script> + <script src=/browsing-topics/resources/load_img.sub.js></script> <script src=/browsing-topics/resources/permissions-policy-util.sub.js></script> + <script src=/common/utils.js></script> <script> 'use strict'; const header = 'permissions policy header browsing-topics=()'; @@ -44,6 +46,18 @@ assert_equals(topics_header, "NO_TOPICS_HEADER"); }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics fetch request.'); + promise_test(async t => { + let topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true); + assert_equals(topics_header, "NO_TOPICS_HEADER"); + }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the same-origin topics img request.'); + + promise_test(async t => { + let topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/false); + assert_equals(topics_header, "NO_TOPICS_HEADER"); + }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics img request.'); + async_test(t => { test_topics_iframe_navigation_header( t, /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true,
diff --git a/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-self.tentative.https.sub.html b/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-self.tentative.https.sub.html index 91ee4f0..3d0de47 100644 --- a/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-self.tentative.https.sub.html +++ b/third_party/blink/web_tests/external/wpt/browsing-topics/browsing-topics-permissions-policy-self.tentative.https.sub.html
@@ -3,7 +3,9 @@ <script src=/resources/testharness.js></script> <script src=/resources/testharnessreport.js></script> <script src=/browsing-topics/resources/header-util.sub.js></script> + <script src=/browsing-topics/resources/load_img.sub.js></script> <script src=/browsing-topics/resources/permissions-policy-util.sub.js></script> + <script src=/common/utils.js></script> <script> 'use strict'; const header = 'permissions policy header browsing-topics=(self)'; @@ -51,6 +53,18 @@ assert_equals(topics_header, "NO_TOPICS_HEADER"); }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the redirect of a topics fetch request, where the redirect has a cross-origin URL.'); + promise_test(async t => { + let topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true); + assert_equals(topics_header, EMPTY_TOPICS_HEADER); + }, header + 'allows the \'Sec-Browsing-Topics\' header to be sent for the same-origin topics img request.'); + + promise_test(async t => { + let topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/false); + assert_equals(topics_header, "NO_TOPICS_HEADER"); + }, header + 'disallows the \'Sec-Browsing-Topics\' header to be sent for the cross-origin topics img request.'); + async_test(t => { test_topics_iframe_navigation_header( t, /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true,
diff --git a/third_party/blink/web_tests/external/wpt/browsing-topics/img-topics-attribute.tentative.https.html b/third_party/blink/web_tests/external/wpt/browsing-topics/img-topics-attribute.tentative.https.html new file mode 100644 index 0000000..a87aea04 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/browsing-topics/img-topics-attribute.tentative.https.html
@@ -0,0 +1,23 @@ +<!doctype html> +<body> + <script src=/resources/testharness.js></script> + <script src=/resources/testharnessreport.js></script> + <script src=/common/utils.js></script> + <script src=/browsing-topics/resources/load_img.sub.js></script> + <script> + const EMPTY_TOPICS_HEADER = '();p=P0000000000000000000000000000000'; + + promise_test(async () => { + const topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/false, /*is_same_origin=*/true); + assert_equals(topics_header, 'NO_TOPICS_HEADER'); + }, 'test <img src=[url]></img>'); + promise_test(async () => { + const topics_header = await load_topics_image( + /*has_browsing_topics_attribute=*/true, /*is_same_origin=*/true); + assert_equals(topics_header, EMPTY_TOPICS_HEADER); + }, 'test <img browsingtopics src=[url]></img>'); + + </script> +</body> +
diff --git a/third_party/blink/web_tests/external/wpt/browsing-topics/resources/check-topics-request-header-in-img.py b/third_party/blink/web_tests/external/wpt/browsing-topics/resources/check-topics-request-header-in-img.py new file mode 100644 index 0000000..d5ab1ab --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/browsing-topics/resources/check-topics-request-header-in-img.py
@@ -0,0 +1,35 @@ +def main(request, response): + """ + This file is intended to be requested twice to verify that the correct headers + are included for images. + 1. Make an initial request for an img. The `sec-browsing-topics` header will + be stored for step 2. The request will be redirected to an image. + 2. Make a request with the query parameter set. The stashed header from the + first step will be returned in the response content. + + Parameters: + `token` should be a unique UUID request parameter for the duration of this + request. It will get stored in the server stash and will be used later in + a query request. + `query` should be a request parameter indicating the request would like + to know the last `sec-browsing-topics` header with that token. + """ + + token = request.GET.first(b"token", None) + is_query = request.GET.first(b"query", None) is not None + topics_header = request.headers.get(b"sec-browsing-topics", b"NO_TOPICS_HEADER") + + queried_topics_header = b"NO_PREVIOUS_REQUEST" + with request.server.stash.lock: + value = request.server.stash.take(token) + if value is not None: + queried_topics_header = value + if not is_query: + request.server.stash.put(token, topics_header) + + if is_query: + return (200, [(b"Access-Control-Allow-Origin", b"*")], queried_topics_header) + + headers = [(b"Location", "pixel.png"), + (b"Access-Control-Allow-Origin", b"*")] + return 301, headers, b""
diff --git a/third_party/blink/web_tests/external/wpt/browsing-topics/resources/load_img.sub.js b/third_party/blink/web_tests/external/wpt/browsing-topics/resources/load_img.sub.js new file mode 100644 index 0000000..35da085 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/browsing-topics/resources/load_img.sub.js
@@ -0,0 +1,39 @@ +// Poll the server for the test result. +async function get_stashed_topics_header(url) { + for (let i = 0; i < 30; ++i) { + const response = await fetch(url + '&query'); + let stashed_topics_header = await response.text(); + + if (!stashed_topics_header || (stashed_topics_header === 'NO_PREVIOUS_REQUEST')) { + await new Promise(resolve => step_timeout(resolve, 100)); + continue; + } + return stashed_topics_header; + } + assert_true(false, 'timeout'); +} + +// Load an image and poll for the topics header that +// check-topics-request-header-in-img.py should stash. +function load_topics_image(has_browsing_topics_attribute, is_same_origin) { + let stash_id = token(); + const sameOriginSrc = `/browsing-topics/resources/` + + `check-topics-request-header-in-img.py?token=${stash_id}`; + const crossOriginSrc = 'https://{{domains[www]}}:{{ports[https][0]}}' + + sameOriginSrc; + + const url = is_same_origin ? sameOriginSrc : crossOriginSrc + + let image = document.createElement('img'); + image.src = url; + + if (has_browsing_topics_attribute) { + image.browsingTopics = true; + } + + image.decode().then(() => { + document.body.appendChild(image); + }); + + return get_stashed_topics_header(url); +} \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/browsing-topics/resources/pixel.png b/third_party/blink/web_tests/external/wpt/browsing-topics/resources/pixel.png new file mode 100644 index 0000000..818c71d --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/browsing-topics/resources/pixel.png Binary files differ
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative.html b/third_party/blink/web_tests/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative.html new file mode 100644 index 0000000..b335db07 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative.html
@@ -0,0 +1,49 @@ + +<!DOCTYPE html> +<meta name="timeout" content="long"> +<link rel="help" href="http://crbug.com/374908738"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<style> + select, + select::picker(select) { + appearance: base-select; + } +</style> +<select id="target"> + <div></div> + <span></span> + <a id="interactive1" href="https://www.example.com/">Interactive element</a> + <option id="option1">Tiger</option> +</select> +<script> +const Enter = '\uE007'; +const Space = ' '; +const Tab = '\uE004'; + +promise_test(async (t) => { + assert_false( + target.matches(':open'), + 'The select should initially be closed.' + ); + + target.focus(); + assert_equals( + document.activeElement, + target, + 'The select should be focused.' + ); + + await test_driver.send_keys(document.activeElement, Space); + assert_equals( + document.activeElement, + interactive1, + 'The anchor should be focused.' + ); + await test_driver.send_keys(document.activeElement, Space); +}, 'In dialog mode the first focusable element should get focus.'); + +</script> +
diff --git a/third_party/blink/web_tests/virtual/customizable-select-disabled/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative-expected.txt b/third_party/blink/web_tests/virtual/customizable-select-disabled/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative-expected.txt new file mode 100644 index 0000000..bb56e6a3 --- /dev/null +++ b/third_party/blink/web_tests/virtual/customizable-select-disabled/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative-expected.txt
@@ -0,0 +1,5 @@ +This is a testharness.js-based test. +[FAIL] In dialog mode the first focusable element should get focus. + promise_test: Unhandled rejection with value: object "ReferenceError: interactive1 is not defined" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/select-parser-relaxation/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative-expected.txt b/third_party/blink/web_tests/virtual/select-parser-relaxation/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative-expected.txt new file mode 100644 index 0000000..494bf88 --- /dev/null +++ b/third_party/blink/web_tests/virtual/select-parser-relaxation/external/wpt/html/semantics/forms/the-select-element/customizable-select/select-dialog-mode-focus.tentative-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +[FAIL] In dialog mode the first focusable element should get focus. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt b/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt index fab3936..d2e582e 100644 --- a/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt +++ b/third_party/blink/web_tests/virtual/stable/webexposed/element-instance-property-listing-expected.txt
@@ -692,6 +692,7 @@ property alt property attributionSrc property border + property browsingTopics property complete property crossOrigin property currentSrc
diff --git a/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt index 608b51a5..d17468f 100644 --- a/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt +++ b/third_party/blink/web_tests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -3895,6 +3895,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -3925,6 +3926,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority @@ -5004,6 +5006,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -5034,6 +5037,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority
diff --git a/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt b/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt index 48c1126..7bd5528 100644 --- a/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt +++ b/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt
@@ -728,6 +728,7 @@ property alt property attributionSrc property border + property browsingTopics property complete property crossOrigin property currentSrc
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt index 4caa3060..7ae30781c 100644 --- a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt +++ b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
@@ -4329,6 +4329,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -4359,6 +4360,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority @@ -5484,6 +5486,7 @@ getter alt getter attributionSrc getter border + getter browsingTopics getter complete getter crossOrigin getter currentSrc @@ -5514,6 +5517,7 @@ setter alt setter attributionSrc setter border + setter browsingTopics setter crossOrigin setter decoding setter fetchPriority
diff --git a/third_party/boringssl/src b/third_party/boringssl/src index 8229027..04c1992 160000 --- a/third_party/boringssl/src +++ b/third_party/boringssl/src
@@ -1 +1 @@ -Subproject commit 822902749a5956bba09c7e9e451104e8a74f02c5 +Subproject commit 04c19925b088e8b884080ee6bd3d771d40e3c3a9
diff --git a/third_party/devtools-frontend/src b/third_party/devtools-frontend/src index 586fb9d..97928d6 160000 --- a/third_party/devtools-frontend/src +++ b/third_party/devtools-frontend/src
@@ -1 +1 @@ -Subproject commit 586fb9db396c599ab5549f869429f886c724a827 +Subproject commit 97928d6f6cccc7bd47fb2afe0d3ddeed9cc9ef2a
diff --git a/third_party/freetype/README.chromium b/third_party/freetype/README.chromium index 821608f1..cab0df61 100644 --- a/third_party/freetype/README.chromium +++ b/third_party/freetype/README.chromium
@@ -1,7 +1,7 @@ Name: FreeType URL: http://www.freetype.org/ -Version: VER-2-13-3-30-g10b3b14da -Revision: 10b3b14da2a60151dd9242364ad7a375d0d7590a +Version: VER-2-13-3-31-g64f8b7fbd +Revision: 64f8b7fbd029a8715e01ba58de5119666be56811 CPEPrefix: cpe:/a:freetype:freetype:2.13.3 License: FTL License File: src/docs/FTL.TXT
diff --git a/third_party/freetype/src b/third_party/freetype/src index 10b3b14..64f8b7fb 160000 --- a/third_party/freetype/src +++ b/third_party/freetype/src
@@ -1 +1 @@ -Subproject commit 10b3b14da2a60151dd9242364ad7a375d0d7590a +Subproject commit 64f8b7fbd029a8715e01ba58de5119666be56811
diff --git a/third_party/libaom/README.chromium b/third_party/libaom/README.chromium index 611e286..0882480f 100644 --- a/third_party/libaom/README.chromium +++ b/third_party/libaom/README.chromium
@@ -2,7 +2,7 @@ Short Name: libaom URL: https://aomedia.googlesource.com/aom/ Version: N/A -Revision: f74eae54f3beb6850c0a468091f4d0291b2d563c +Revision: 433be28b4f4f899f533991e2d2829dde0ab68406 CPEPrefix: cpe:/a:aomedia:aomedia:3.11.0 License: BSD-2-Clause, Patent License File: source/libaom/LICENSE, source/libaom/PATENTS
diff --git a/third_party/libaom/source/config/config/aom_version.h b/third_party/libaom/source/config/config/aom_version.h index 2c10020..929fd56 100644 --- a/third_party/libaom/source/config/config/aom_version.h +++ b/third_party/libaom/source/config/config/aom_version.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License @@ -14,9 +14,9 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 11 #define VERSION_PATCH 0 -#define VERSION_EXTRA "157-gf74eae54f3" +#define VERSION_EXTRA "160-g433be28b4f" #define VERSION_PACKED \ ((VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | (VERSION_PATCH)) -#define VERSION_STRING_NOSP "3.11.0-157-gf74eae54f3" -#define VERSION_STRING " 3.11.0-157-gf74eae54f3" +#define VERSION_STRING_NOSP "3.11.0-160-g433be28b4f" +#define VERSION_STRING " 3.11.0-160-g433be28b4f" #endif // AOM_VERSION_H_
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm index 7b8f05a7..3a2de77 100644 --- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm +++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm
@@ -1,5 +1,5 @@ ; -; Copyright (c) 2024, Alliance for Open Media. All rights reserved. +; Copyright (c) 2025, Alliance for Open Media. All rights reserved. ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.c b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.c index e46025b2..9b8f072 100644 --- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.c +++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h index 454d5ba..7372066 100644 --- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h +++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_dsp_rtcd.h index 719943c..6063970 100644 --- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_scale_rtcd.h b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_scale_rtcd.h index 3eaffa81..11acae6 100644 --- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/av1_rtcd.h b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/av1_rtcd.h index 2ab59dd..1d285133 100644 --- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/av1_rtcd.h +++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm index 2344225..d0ed90e 100644 --- a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm +++ b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm
@@ -1,5 +1,5 @@ ; -; Copyright (c) 2024, Alliance for Open Media. All rights reserved. +; Copyright (c) 2025, Alliance for Open Media. All rights reserved. ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.c b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.c index 8cec61e..cadbde5 100644 --- a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.c +++ b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h index 28c3ef6..4ac68e7f 100644 --- a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h +++ b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/linux/arm-neon/config/aom_dsp_rtcd.h index 4c90814..9b5513f 100644 --- a/third_party/libaom/source/config/linux/arm-neon/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/linux/arm-neon/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/aom_scale_rtcd.h b/third_party/libaom/source/config/linux/arm-neon/config/aom_scale_rtcd.h index 3eaffa81..11acae6 100644 --- a/third_party/libaom/source/config/linux/arm-neon/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/linux/arm-neon/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/av1_rtcd.h b/third_party/libaom/source/config/linux/arm-neon/config/av1_rtcd.h index 07a1799e..3c0c72f1 100644 --- a/third_party/libaom/source/config/linux/arm-neon/config/av1_rtcd.h +++ b/third_party/libaom/source/config/linux/arm-neon/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm/config/aom_config.asm b/third_party/libaom/source/config/linux/arm/config/aom_config.asm index bbc0dc3..f660a46 100644 --- a/third_party/libaom/source/config/linux/arm/config/aom_config.asm +++ b/third_party/libaom/source/config/linux/arm/config/aom_config.asm
@@ -1,5 +1,5 @@ ; -; Copyright (c) 2024, Alliance for Open Media. All rights reserved. +; Copyright (c) 2025, Alliance for Open Media. All rights reserved. ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm/config/aom_config.c b/third_party/libaom/source/config/linux/arm/config/aom_config.c index b72dad1..08ba95c 100644 --- a/third_party/libaom/source/config/linux/arm/config/aom_config.c +++ b/third_party/libaom/source/config/linux/arm/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm/config/aom_config.h b/third_party/libaom/source/config/linux/arm/config/aom_config.h index d93bbed..4bc4ef1 100644 --- a/third_party/libaom/source/config/linux/arm/config/aom_config.h +++ b/third_party/libaom/source/config/linux/arm/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/linux/arm/config/aom_dsp_rtcd.h index 7c25ac5c..580b40d 100644 --- a/third_party/libaom/source/config/linux/arm/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/linux/arm/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm/config/aom_scale_rtcd.h b/third_party/libaom/source/config/linux/arm/config/aom_scale_rtcd.h index 3eaffa81..11acae6 100644 --- a/third_party/libaom/source/config/linux/arm/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/linux/arm/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm/config/av1_rtcd.h b/third_party/libaom/source/config/linux/arm/config/av1_rtcd.h index d68fadb..9261c5a9 100644 --- a/third_party/libaom/source/config/linux/arm/config/av1_rtcd.h +++ b/third_party/libaom/source/config/linux/arm/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.asm b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.asm index e14be80..be2de79c7 100644 --- a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.asm +++ b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.asm
@@ -1,5 +1,5 @@ ; -; Copyright (c) 2024, Alliance for Open Media. All rights reserved. +; Copyright (c) 2025, Alliance for Open Media. All rights reserved. ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.c b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.c index 0c64e9e..560669e 100644 --- a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.c +++ b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.h b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.h index 6d4d3e2..861c2472 100644 --- a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.h +++ b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_dsp_rtcd.h index c951196..631cbde 100644 --- a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_scale_rtcd.h b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_scale_rtcd.h index 3eaffa81..11acae6 100644 --- a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/av1_rtcd.h b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/av1_rtcd.h index bf10119..1f281f9 100644 --- a/third_party/libaom/source/config/linux/arm64-cpu-detect/config/av1_rtcd.h +++ b/third_party/libaom/source/config/linux/arm64-cpu-detect/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/generic/config/aom_config.asm b/third_party/libaom/source/config/linux/generic/config/aom_config.asm index 31a80d0..b99c560 100644 --- a/third_party/libaom/source/config/linux/generic/config/aom_config.asm +++ b/third_party/libaom/source/config/linux/generic/config/aom_config.asm
@@ -1,5 +1,5 @@ ; -; Copyright (c) 2024, Alliance for Open Media. All rights reserved. +; Copyright (c) 2025, Alliance for Open Media. All rights reserved. ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/generic/config/aom_config.c b/third_party/libaom/source/config/linux/generic/config/aom_config.c index 41d33fe..e43ace4 100644 --- a/third_party/libaom/source/config/linux/generic/config/aom_config.c +++ b/third_party/libaom/source/config/linux/generic/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/generic/config/aom_config.h b/third_party/libaom/source/config/linux/generic/config/aom_config.h index c3c959aa..12f94ac 100644 --- a/third_party/libaom/source/config/linux/generic/config/aom_config.h +++ b/third_party/libaom/source/config/linux/generic/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/generic/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/linux/generic/config/aom_dsp_rtcd.h index b493878..768f5cc 100644 --- a/third_party/libaom/source/config/linux/generic/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/linux/generic/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/generic/config/aom_scale_rtcd.h b/third_party/libaom/source/config/linux/generic/config/aom_scale_rtcd.h index 0700a40..13c1216 100644 --- a/third_party/libaom/source/config/linux/generic/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/linux/generic/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/generic/config/av1_rtcd.h b/third_party/libaom/source/config/linux/generic/config/av1_rtcd.h index fb10146..fb56bcd 100644 --- a/third_party/libaom/source/config/linux/generic/config/av1_rtcd.h +++ b/third_party/libaom/source/config/linux/generic/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/ia32/config/aom_config.c b/third_party/libaom/source/config/linux/ia32/config/aom_config.c index 04a6632..a0f7608 100644 --- a/third_party/libaom/source/config/linux/ia32/config/aom_config.c +++ b/third_party/libaom/source/config/linux/ia32/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/ia32/config/aom_config.h b/third_party/libaom/source/config/linux/ia32/config/aom_config.h index bb7c685..1153334 100644 --- a/third_party/libaom/source/config/linux/ia32/config/aom_config.h +++ b/third_party/libaom/source/config/linux/ia32/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/ia32/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/linux/ia32/config/aom_dsp_rtcd.h index 81281dfa..479bfbd 100644 --- a/third_party/libaom/source/config/linux/ia32/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/linux/ia32/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/ia32/config/aom_scale_rtcd.h b/third_party/libaom/source/config/linux/ia32/config/aom_scale_rtcd.h index bc8f330d..cd32be6f 100644 --- a/third_party/libaom/source/config/linux/ia32/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/linux/ia32/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/ia32/config/av1_rtcd.h b/third_party/libaom/source/config/linux/ia32/config/av1_rtcd.h index bfd13d2..be56670f 100644 --- a/third_party/libaom/source/config/linux/ia32/config/av1_rtcd.h +++ b/third_party/libaom/source/config/linux/ia32/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/x64/config/aom_config.c b/third_party/libaom/source/config/linux/x64/config/aom_config.c index 0aaa84a..1d57413 100644 --- a/third_party/libaom/source/config/linux/x64/config/aom_config.c +++ b/third_party/libaom/source/config/linux/x64/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/x64/config/aom_config.h b/third_party/libaom/source/config/linux/x64/config/aom_config.h index 06d49d0..4b57129 100644 --- a/third_party/libaom/source/config/linux/x64/config/aom_config.h +++ b/third_party/libaom/source/config/linux/x64/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/x64/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/linux/x64/config/aom_dsp_rtcd.h index 9c7848a1..3eee5aa 100644 --- a/third_party/libaom/source/config/linux/x64/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/linux/x64/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/x64/config/aom_scale_rtcd.h b/third_party/libaom/source/config/linux/x64/config/aom_scale_rtcd.h index bc8f330d..cd32be6f 100644 --- a/third_party/libaom/source/config/linux/x64/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/linux/x64/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/linux/x64/config/av1_rtcd.h b/third_party/libaom/source/config/linux/x64/config/av1_rtcd.h index 8f16c5581..13bcdd2 100644 --- a/third_party/libaom/source/config/linux/x64/config/av1_rtcd.h +++ b/third_party/libaom/source/config/linux/x64/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.asm b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.asm index a63b267..e4f8f87 100644 --- a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.asm +++ b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.asm
@@ -1,5 +1,5 @@ ; -; Copyright (c) 2024, Alliance for Open Media. All rights reserved. +; Copyright (c) 2025, Alliance for Open Media. All rights reserved. ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.c b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.c index 49741e8..eb01a0b 100644 --- a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.c +++ b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.h b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.h index 7477cf3..00238b6 100644 --- a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.h +++ b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_dsp_rtcd.h index 8fe276a..4d38f2c86 100644 --- a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_scale_rtcd.h b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_scale_rtcd.h index 3eaffa81..11acae6 100644 --- a/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/win/arm64-cpu-detect/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/arm64-cpu-detect/config/av1_rtcd.h b/third_party/libaom/source/config/win/arm64-cpu-detect/config/av1_rtcd.h index 7f6909c4..d527b23 100644 --- a/third_party/libaom/source/config/win/arm64-cpu-detect/config/av1_rtcd.h +++ b/third_party/libaom/source/config/win/arm64-cpu-detect/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/ia32/config/aom_config.c b/third_party/libaom/source/config/win/ia32/config/aom_config.c index 04a6632..a0f7608 100644 --- a/third_party/libaom/source/config/win/ia32/config/aom_config.c +++ b/third_party/libaom/source/config/win/ia32/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/ia32/config/aom_config.h b/third_party/libaom/source/config/win/ia32/config/aom_config.h index e8890741..03c8ae4 100644 --- a/third_party/libaom/source/config/win/ia32/config/aom_config.h +++ b/third_party/libaom/source/config/win/ia32/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/ia32/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/win/ia32/config/aom_dsp_rtcd.h index 81281dfa..479bfbd 100644 --- a/third_party/libaom/source/config/win/ia32/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/win/ia32/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/ia32/config/aom_scale_rtcd.h b/third_party/libaom/source/config/win/ia32/config/aom_scale_rtcd.h index bc8f330d..cd32be6f 100644 --- a/third_party/libaom/source/config/win/ia32/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/win/ia32/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/ia32/config/av1_rtcd.h b/third_party/libaom/source/config/win/ia32/config/av1_rtcd.h index bfd13d2..be56670f 100644 --- a/third_party/libaom/source/config/win/ia32/config/av1_rtcd.h +++ b/third_party/libaom/source/config/win/ia32/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/x64/config/aom_config.c b/third_party/libaom/source/config/win/x64/config/aom_config.c index 0aaa84a..1d57413 100644 --- a/third_party/libaom/source/config/win/x64/config/aom_config.c +++ b/third_party/libaom/source/config/win/x64/config/aom_config.c
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/x64/config/aom_config.h b/third_party/libaom/source/config/win/x64/config/aom_config.h index 9431f9d..2072be2 100644 --- a/third_party/libaom/source/config/win/x64/config/aom_config.h +++ b/third_party/libaom/source/config/win/x64/config/aom_config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/x64/config/aom_dsp_rtcd.h b/third_party/libaom/source/config/win/x64/config/aom_dsp_rtcd.h index 9c7848a1..3eee5aa 100644 --- a/third_party/libaom/source/config/win/x64/config/aom_dsp_rtcd.h +++ b/third_party/libaom/source/config/win/x64/config/aom_dsp_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/x64/config/aom_scale_rtcd.h b/third_party/libaom/source/config/win/x64/config/aom_scale_rtcd.h index bc8f330d..cd32be6f 100644 --- a/third_party/libaom/source/config/win/x64/config/aom_scale_rtcd.h +++ b/third_party/libaom/source/config/win/x64/config/aom_scale_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/config/win/x64/config/av1_rtcd.h b/third_party/libaom/source/config/win/x64/config/av1_rtcd.h index 8f16c5581..13bcdd2 100644 --- a/third_party/libaom/source/config/win/x64/config/av1_rtcd.h +++ b/third_party/libaom/source/config/win/x64/config/av1_rtcd.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Alliance for Open Media. All rights reserved. + * Copyright (c) 2025, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
diff --git a/third_party/libaom/source/libaom b/third_party/libaom/source/libaom index f74eae5..433be28 160000 --- a/third_party/libaom/source/libaom +++ b/third_party/libaom/source/libaom
@@ -1 +1 @@ -Subproject commit f74eae54f3beb6850c0a468091f4d0291b2d563c +Subproject commit 433be28b4f4f899f533991e2d2829dde0ab68406
diff --git a/third_party/libc++/src b/third_party/libc++/src index b451193..80194f0 160000 --- a/third_party/libc++/src +++ b/third_party/libc++/src
@@ -1 +1 @@ -Subproject commit b4511937e4e55617e26ba3912e0dc169443e0c00 +Subproject commit 80194f087251d7ad235ffbf4c602786208bdb863
diff --git a/third_party/nearby/DIR_METADATA b/third_party/nearby/DIR_METADATA index d6d7997..3614fc9 100644 --- a/third_party/nearby/DIR_METADATA +++ b/third_party/nearby/DIR_METADATA
@@ -1,4 +1,9 @@ -buganizer { - component_id: 1131838 -} -team_email: "chromeos-cross-device-eng@google.com " +# Metadata information for this directory. +# +# For more information on DIR_METADATA files, see: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/README.md +# +# For the schema of this file, see Metadata message: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/proto/dir_metadata.proto + +mixins: "//chromeos/ash/services/nearby/COMMON_METADATA"
diff --git a/third_party/perfetto b/third_party/perfetto index fe572aa..16c0f5b 160000 --- a/third_party/perfetto +++ b/third_party/perfetto
@@ -1 +1 @@ -Subproject commit fe572aaa214487007138ea9a546692771bd6e25b +Subproject commit 16c0f5bc196947725c1f24ef519c0bdc47b6222f
diff --git a/third_party/skia b/third_party/skia index 65d7bff..fe8bac8 160000 --- a/third_party/skia +++ b/third_party/skia
@@ -1 +1 @@ -Subproject commit 65d7bff9d16aaec9c731c16cccfbca8303e60992 +Subproject commit fe8bac8f2251b50ce93a62d044495d36713bbbef
diff --git a/tools/gritsettings/resource_ids.spec b/tools/gritsettings/resource_ids.spec index 0bd0a5f..7a980ee 100644 --- a/tools/gritsettings/resource_ids.spec +++ b/tools/gritsettings/resource_ids.spec
@@ -428,6 +428,10 @@ "META": {"sizes": {"includes": [10]}}, "includes": [4080], }, + "<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/inspect/resources.grd": { + "META": {"sizes": {"includes": [5]}}, + "includes": [4085], + }, "<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/internal_debug_pages_disabled/resources.grd": { "META": {"sizes": {"includes": [10]}}, "includes": [4090],
diff --git a/tools/json_schema_compiler/test/idl_basics_expected.d.ts b/tools/json_schema_compiler/test/idl_basics_expected.d.ts index 1f3a4c0..800518e 100644 --- a/tools/json_schema_compiler/test/idl_basics_expected.d.ts +++ b/tools/json_schema_compiler/test/idl_basics_expected.d.ts
@@ -1,4 +1,4 @@ -// Copyright 2024 The Chromium Authors +// Copyright 2025 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/tools/json_schema_compiler/test/json_basics_expected.d.ts b/tools/json_schema_compiler/test/json_basics_expected.d.ts index e93f3fc..d374207 100644 --- a/tools/json_schema_compiler/test/json_basics_expected.d.ts +++ b/tools/json_schema_compiler/test/json_basics_expected.d.ts
@@ -1,4 +1,4 @@ -// Copyright 2024 The Chromium Authors +// Copyright 2025 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index fcd6a2f..b99b3b1 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -10952,6 +10952,7 @@ <int value="5233" label="InjectionMitigatedContextSubFrame"/> <int value="5234" label="InjectionMitigatedContextMainFrame"/> <int value="5235" label="CanvasTextDirectionConflict"/> + <int value="5236" label="TopicsAPIImg"/> </enum> <!-- LINT.ThenChange(//third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom:WebFeature) --> @@ -12157,8 +12158,9 @@ <enum name="GpuErrorReason"> <int value="0" label="Other"/> <int value="1" label="DXGI_ERROR_DEVICE_HUNG"/> - <int value="2" label="DXGI_ERROR_DEVICE_REMOVED"/> + <int value="2" label="DXGI_ERROR_DEVICE_REMOVED or VK_ERROR_DEVICE_LOST"/> <int value="3" label="Failed to create device."/> + <int value="4" label="VK_ERROR_OUT_OF_DEVICE_MEMORY"/> </enum> <enum name="GpuImageUsageState">
diff --git a/tools/metrics/histograms/metadata/android/enums.xml b/tools/metrics/histograms/metadata/android/enums.xml index d55523c..d7f9b26 100644 --- a/tools/metrics/histograms/metadata/android/enums.xml +++ b/tools/metrics/histograms/metadata/android/enums.xml
@@ -854,15 +854,12 @@ of the setWebContentsDebuggingEnabled value."/> </enum> -<enum name="DesktopWindowHeuristicResult"> +<enum name="DesktopWindowHeuristicResult2"> <int value="0" label="Invalid result."/> <int value="1" label="The app is in a desktop window."/> - <int value="2" label="The app is not in multi-window mode."/> - <int value="3" label="Navigation bar bottom insets are present."/> - <int value="4" - label="Caption bar insets hold an unexpected number of bounding rects."/> - <int value="5" label="Caption bar top insets are not present."/> - <int value="6" label="Caption bar bounding rect has an invalid height."/> + <int value="2" label="Caption bar top insets are not present."/> + <int value="3" label="Caption bar bounding rect has an invalid height."/> + <int value="4" label="Caption bar customizable space unavailable."/> </enum> <enum name="DesktopWindowModeState">
diff --git a/tools/metrics/histograms/metadata/android/histograms.xml b/tools/metrics/histograms/metadata/android/histograms.xml index 20722fa..72a6726 100644 --- a/tools/metrics/histograms/metadata/android/histograms.xml +++ b/tools/metrics/histograms/metadata/android/histograms.xml
@@ -1224,17 +1224,17 @@ </summary> </histogram> -<histogram name="Android.DesktopWindowHeuristicResult" - enum="DesktopWindowHeuristicResult" expires_after="2025-06-29"> - <owner>wenyufu@chromium.org</owner> +<histogram name="Android.DesktopWindowHeuristicResult2" + enum="DesktopWindowHeuristicResult2" expires_after="2025-07-02"> <owner>aishwaryarj@google.com</owner> + <owner>clank-large-form-factors@google.com</owner> <summary> Records the result of the heuristics used to determine whether the app is in a desktop window. The histogram will be emitted only if the result changed since the last time it was emitted. This is to avoid emitting noisy data, since we believe that most of the conditions in these heuristics are unlikely to change for a given OS/OEM across these checks that may be - relatively significantly larger in number. Android V+ only. + relatively significantly larger in number. </summary> </histogram>
diff --git a/tools/metrics/histograms/metadata/arc/histograms.xml b/tools/metrics/histograms/metadata/arc/histograms.xml index ada3262..383243d 100644 --- a/tools/metrics/histograms/metadata/arc/histograms.xml +++ b/tools/metrics/histograms/metadata/arc/histograms.xml
@@ -2370,7 +2370,7 @@ </histogram> <histogram name="Arc.UserInteraction" enum="ArcUserInteraction" - expires_after="2025-01-05"> + expires_after="2026-01-02"> <owner>jhorwich@chromium.org</owner> <owner>arc-core@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/autofill/histograms.xml b/tools/metrics/histograms/metadata/autofill/histograms.xml index ef31d15..e0f94d8 100644 --- a/tools/metrics/histograms/metadata/autofill/histograms.xml +++ b/tools/metrics/histograms/metadata/autofill/histograms.xml
@@ -2329,6 +2329,17 @@ </summary> </histogram> +<histogram name="Autofill.EditedAutofilledFieldAtSubmission.AddressOnTyping" + enum="AutofilledFieldUserEditingStatus" expires_after="2025-06-13"> + <owner>brunobraga@google.com</owner> + <owner>chrome-autofill-alerts@google.com</owner> + <summary> + Emitted on form submission, for each field where an autofill address + suggestion on typing is accepted, logs whether the filled value was changed + between acceptance and submission time. + </summary> +</histogram> + <histogram name="Autofill.EditedAutofilledFieldAtSubmission2.Aggregate" enum="AutofilledFieldUserEditingStatus" expires_after="2025-06-15"> <owner>koerber@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/bluetooth/OWNERS b/tools/metrics/histograms/metadata/bluetooth/OWNERS index c3e0122..c55d249 100644 --- a/tools/metrics/histograms/metadata/bluetooth/OWNERS +++ b/tools/metrics/histograms/metadata/bluetooth/OWNERS
@@ -1,5 +1,7 @@ per-file OWNERS=file://tools/metrics/histograms/metadata/METRIC_REVIEWER_OWNERS +# Prefer sending CLs to the owners listed below. +# Use chromium-metrics-reviews@google.com as a backup. chadduffin@chromium.org crisrael@google.com dclasson@google.com
diff --git a/tools/metrics/histograms/metadata/browsing_topics/enums.xml b/tools/metrics/histograms/metadata/browsing_topics/enums.xml index 0f0c1a3..58cb10c 100644 --- a/tools/metrics/histograms/metadata/browsing_topics/enums.xml +++ b/tools/metrics/histograms/metadata/browsing_topics/enums.xml
@@ -33,6 +33,8 @@ <int value="3" label="observe via fetch-like api"/> <int value="4" label="get via iframe attribute api"/> <int value="5" label="observe via iframe attribute api"/> + <int value="6" label="get via img attribute api"/> + <int value="7" label="observe via img attribute api"/> </enum> <enum name="BrowsingTopicsCalculatorResultStatus">
diff --git a/tools/metrics/histograms/metadata/cras/histograms.xml b/tools/metrics/histograms/metadata/cras/histograms.xml index 23a8aa8..50fa555 100644 --- a/tools/metrics/histograms/metadata/cras/histograms.xml +++ b/tools/metrics/histograms/metadata/cras/histograms.xml
@@ -758,7 +758,7 @@ </histogram> <histogram name="Cras.NoiseCancellationEnabledSource" - enum="AudioSettingsChangeSource" expires_after="2025-01-05"> + enum="AudioSettingsChangeSource" expires_after="2026-01-05"> <owner>gavinwill@chromium.org</owner> <owner>yuhsuan@chromium.org</owner> <owner>chromeos-audio@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/cross_device/DIR_METADATA b/tools/metrics/histograms/metadata/cross_device/DIR_METADATA new file mode 100644 index 0000000..0cb611e --- /dev/null +++ b/tools/metrics/histograms/metadata/cross_device/DIR_METADATA
@@ -0,0 +1,9 @@ +# Metadata information for this directory. +# +# For more information on DIR_METADATA files, see: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/README.md +# +# For the schema of this file, see Metadata message: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/proto/dir_metadata.proto + +mixins: "//chromeos/ash/components/multidevice/COMMON_METADATA"
diff --git a/tools/metrics/histograms/metadata/extensions/histograms.xml b/tools/metrics/histograms/metadata/extensions/histograms.xml index ddcc807..e35ab8b 100644 --- a/tools/metrics/histograms/metadata/extensions/histograms.xml +++ b/tools/metrics/histograms/metadata/extensions/histograms.xml
@@ -2066,7 +2066,7 @@ </histogram> <histogram name="Extensions.ExternalItemState2" enum="ExternalItemState" - expires_after="2025-01-01"> + expires_after="2025-12-01"> <owner>anunoy@chromium.org</owner> <owner>extensions-core@chromium.org</owner> <summary> @@ -4216,7 +4216,7 @@ </histogram> <histogram name="Extensions.NonWebStoreNewTabPageOverrides2" units="units" - expires_after="2025-01-01"> + expires_after="2025-12-01"> <owner>anunoy@chromium.org</owner> <owner>extensions-core@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/fastpair/DIR_METADATA b/tools/metrics/histograms/metadata/fastpair/DIR_METADATA new file mode 100644 index 0000000..0495dbc --- /dev/null +++ b/tools/metrics/histograms/metadata/fastpair/DIR_METADATA
@@ -0,0 +1,9 @@ +# Metadata information for this directory. +# +# For more information on DIR_METADATA files, see: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/README.md +# +# For the schema of this file, see Metadata message: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/proto/dir_metadata.proto + +mixins: "//ash/quick_pair/COMMON_METADATA"
diff --git a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml index 6b9bc97..6a52d517 100644 --- a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml +++ b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
@@ -223,6 +223,7 @@ <suffix name="chrome" label="Chrome Module"/> <suffix name="dev_ui" label="Developer UI Module"/> <suffix name="feedv2" label="Feed V2 Module"/> + <suffix name="google3" label="Google3 Module"/> <suffix name="image_editor" label="Image Editor Module"/> <suffix name="read_aloud_playback" label="Read Aloud Playback Module"/> <suffix name="stack_unwinder" label="Stack Unwinder Module"/>
diff --git a/tools/metrics/histograms/metadata/holding_space/histograms.xml b/tools/metrics/histograms/metadata/holding_space/histograms.xml index 1e44352..59ce430 100644 --- a/tools/metrics/histograms/metadata/holding_space/histograms.xml +++ b/tools/metrics/histograms/metadata/holding_space/histograms.xml
@@ -64,7 +64,7 @@ </variants> <histogram name="HoldingSpace.Animation.BubbleResize.Smoothness" units="%" - expires_after="2025-02-10"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -76,7 +76,7 @@ </histogram> <histogram name="HoldingSpace.Animation.PodResize.Smoothness" units="%" - expires_after="2025-02-10"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -88,7 +88,7 @@ </histogram> <histogram name="HoldingSpace.Downloads.Action.All" - enum="HoldingSpaceDownloadsAction" expires_after="2025-02-10"> + enum="HoldingSpaceDownloadsAction" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -98,7 +98,7 @@ </histogram> <histogram name="HoldingSpace.FileCreatedFromShowSaveFilePicker.Extension" - enum="HoldingSpaceExtension" expires_after="2025-02-10"> + enum="HoldingSpaceExtension" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -109,7 +109,7 @@ <histogram name="HoldingSpace.FileCreatedFromShowSaveFilePicker.FilePickerBindingContext" - enum="HoldingSpaceFilePickerBindingContext" expires_after="2025-02-10"> + enum="HoldingSpaceFilePickerBindingContext" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -120,7 +120,7 @@ </histogram> <histogram name="HoldingSpace.FilesAppChip.Action.All" - enum="HoldingSpaceFilesAppChipAction" expires_after="2025-02-10"> + enum="HoldingSpaceFilesAppChipAction" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -130,7 +130,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.All" enum="HoldingSpaceItemAction" - expires_after="2025-06-22"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -140,7 +140,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.Launch.Empty" - enum="HoldingSpaceItemType" expires_after="2025-02-10"> + enum="HoldingSpaceItemType" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -150,7 +150,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.Launch.Empty.Extension" - enum="HoldingSpaceExtension" expires_after="2025-02-10"> + enum="HoldingSpaceExtension" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -160,7 +160,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.Launch.Failure" - enum="HoldingSpaceItemType" expires_after="2025-02-10"> + enum="HoldingSpaceItemType" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -170,7 +170,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.Launch.Failure.Extension" - enum="HoldingSpaceExtension" expires_after="2025-02-10"> + enum="HoldingSpaceExtension" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -180,7 +180,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.Launch.Failure.Reason" - enum="HoldingSpaceItemLaunchFailureReason" expires_after="2025-02-10"> + enum="HoldingSpaceItemLaunchFailureReason" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -190,7 +190,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.{action}" enum="HoldingSpaceItemType" - expires_after="2025-06-22"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -201,7 +201,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.{action}.Extension" - enum="HoldingSpaceExtension" expires_after="2025-06-22"> + enum="HoldingSpaceExtension" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -212,7 +212,7 @@ </histogram> <histogram name="HoldingSpace.Item.Action.{action}.FileSystemType" - enum="HoldingSpaceFileSystemType" expires_after="2025-06-22"> + enum="HoldingSpaceFileSystemType" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -223,7 +223,7 @@ </histogram> <histogram name="HoldingSpace.Item.TotalCountV2.{type}" units="items" - expires_after="2025-06-22"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -236,7 +236,7 @@ <histogram name="HoldingSpace.Item.TotalCountV2.{type}.FileSystemType.{fs_type}" - units="items" expires_after="2025-06-08"> + units="items" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -250,7 +250,7 @@ </histogram> <histogram name="HoldingSpace.Item.VisibleCount.{type}" units="items" - expires_after="2025-06-22"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -262,7 +262,7 @@ <histogram name="HoldingSpace.Item.VisibleCount.{type}.FileSystemType.{fs_type}" - units="items" expires_after="2025-04-13"> + units="items" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -275,7 +275,7 @@ </histogram> <histogram name="HoldingSpace.Pod.Action.All" enum="HoldingSpacePodAction" - expires_after="2025-06-22"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -285,7 +285,7 @@ </histogram> <histogram name="HoldingSpace.Suggestions.Action.All" - enum="HoldingSpaceSuggestionsAction" expires_after="2025-02-10"> + enum="HoldingSpaceSuggestionsAction" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -295,7 +295,7 @@ </histogram> <histogram name="HoldingSpace.TimeFromFirstAvailabilityToFirstAdd" units="ms" - expires_after="2025-02-10"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -305,7 +305,7 @@ </histogram> <histogram name="HoldingSpace.TimeFromFirstAvailabilityToFirstEntry" units="ms" - expires_after="2025-02-10"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -315,7 +315,7 @@ </histogram> <histogram name="HoldingSpace.TimeFromFirstEntryToFirstPin" units="ms" - expires_after="2025-02-10"> + expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -326,7 +326,7 @@ </histogram> <histogram name="HoldingSpace.UserPreferences.PreviewsEnabled" - enum="BooleanEnabled" expires_after="2025-06-22"> + enum="BooleanEnabled" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary> @@ -336,7 +336,7 @@ </histogram> <histogram name="HoldingSpace.UserPreferences.SuggestionsExpanded" - enum="BooleanExpanded" expires_after="2025-06-22"> + enum="BooleanExpanded" expires_after="2025-08-01"> <owner>dmblack@google.com</owner> <owner>alexandrahill@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/ios/histograms.xml b/tools/metrics/histograms/metadata/ios/histograms.xml index 8d215e8..a0caf2c 100644 --- a/tools/metrics/histograms/metadata/ios/histograms.xml +++ b/tools/metrics/histograms/metadata/ios/histograms.xml
@@ -3495,7 +3495,7 @@ </histogram> <histogram name="IOS.PaymentsBottomSheet.AcceptAttempts.{Action}" units="count" - expires_after="2025-01-05"> + expires_after="2025-03-17"> <owner>vincb@google.com</owner> <owner>tmartino@chromium.org</owner> <owner>sugoi@chromium.org</owner> @@ -3508,8 +3508,8 @@ be handled yet. </summary> <token key="Action"> - <variant name=".Accept" summary="accept suggestion"/> - <variant name=".Dismiss" summary="dismiss without accepting suggestion"/> + <variant name="Accept" summary="accept suggestion"/> + <variant name="Dismiss" summary="dismiss without accepting suggestion"/> </token> </histogram>
diff --git a/tools/metrics/histograms/metadata/navigation/enums.xml b/tools/metrics/histograms/metadata/navigation/enums.xml index 656ca991..6ef84e6 100644 --- a/tools/metrics/histograms/metadata/navigation/enums.xml +++ b/tools/metrics/histograms/metadata/navigation/enums.xml
@@ -353,6 +353,13 @@ <int value="1" label="Requires dedicated process"/> </enum> +<enum name="NavigationStartAdjustmentType"> + <int value="0" label="No adjustment made"/> + <int value="1" label="Legacy PostTask without BeforeUnload"/> + <int value="2" label="BeforeUnload handlers without dialog"/> + <int value="3" label="BeforeUnload dialog shown"/> +</enum> + <enum name="NavigationSuddenTerminationDisabler"> <int value="0" label="Subframe-None"/> <int value="1" label="MainFrame-None"/>
diff --git a/tools/metrics/histograms/metadata/navigation/histograms.xml b/tools/metrics/histograms/metadata/navigation/histograms.xml index e6e4a459..73cfa20 100644 --- a/tools/metrics/histograms/metadata/navigation/histograms.xml +++ b/tools/metrics/histograms/metadata/navigation/histograms.xml
@@ -1044,7 +1044,7 @@ </histogram> <histogram name="Navigation.FencedFrameTopNavigation" - enum="FencedFrameNavigationState" expires_after="2025-02-10"> + enum="FencedFrameNavigationState" expires_after="2026-01-02"> <owner>lbrady@google.com</owner> <owner>shivanisha@chromium.org</owner> <owner>chrome-fenced-frames-core@google.com</owner> @@ -2057,6 +2057,122 @@ <token key="FrameType" variants="FrameTypes"/> </histogram> +<histogram name="Navigation.StartAdjustment" + enum="NavigationStartAdjustmentType" expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records whether an adjustment was made to the navigation start time, and + what the reason was if so. This metric is recorded each time a navigation + finishes. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.BeforeUnloadDialog" units="ms" + expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records how many milliseconds the navigation start time was delayed, in + cases where it was adjusted to after a beforeunload dialog was displayed. + See also Navigation.StartAdjustment.BeforeUnloadDialog.Percentage. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.BeforeUnloadDialog.Negative" + units="ms" expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records how many milliseconds the navigation start time was unexpectedly + moved earlier (due to a bug with updating the wrong NavigationRequest), in + cases where it was adjusted to after a beforeunload dialog was displayed. No + corresponding percentage is reported in these cases. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.BeforeUnloadDialog.Percentage" + units="%" expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records the percentage of navigation time that was ignored, in cases where + the start time was adjusted to after a beforeunload dialog was displayed. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.BeforeUnloadHandlers" units="ms" + expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records how many milliseconds the navigation start time was delayed, in + cases where it was adjusted to after beforeunload handlers ran, when no + dialog was displayed. See also + Navigation.StartAdjustment.BeforeUnloadHandlers.Percentage. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.BeforeUnloadHandlers.Negative" + units="ms" expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records how many milliseconds the navigation start time was unexpectedly + moved earlier (due to a bug with updating the wrong NavigationRequest), in + cases where it was adjusted to after beforeunload handlers ran, when no + dialog was displayed. No corresponding percentage is reported in these + cases. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.BeforeUnloadHandlers.Percentage" + units="%" expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records the percentage of navigation time that was ignored, in cases where + the start time was adjusted to after beforeunload handlers ran, when no + dialog was displayed. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.LegacyPostTask" units="ms" + expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records how many milliseconds the navigation start time was delayed, in + cases where it was adjusted to after a legacy PostTask was run, when no + beforeunload handlers were registered. See also + Navigation.StartAdjustment.LegacyPostTask.Percentage. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.LegacyPostTask.Negative" units="ms" + expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records how many milliseconds the navigation start time was unexpectedly + moved earlier (due to a bug with updating the wrong NavigationRequest), in + cases where it was adjusted to after a legacy PostTask was run, when no + beforeunload handlers were registered. No corresponding percentage is + reported in these cases. + </summary> +</histogram> + +<histogram name="Navigation.StartAdjustment.LegacyPostTask.Percentage" + units="%" expires_after="2026-01-03"> + <owner>creis@chromium.org</owner> + <owner>alexmos@chromium.org</owner> + <summary> + Records the percentage of navigation time that was ignored, in cases where + the start time was adjusted to after a legacy PostTask was run, when no + beforeunload handlers were registered. + </summary> +</histogram> + <histogram name="Navigation.StartToCommit" units="ms" expires_after="2025-06-01"> <owner>nasko@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/nearby/DIR_METADATA b/tools/metrics/histograms/metadata/nearby/DIR_METADATA new file mode 100644 index 0000000..3614fc9 --- /dev/null +++ b/tools/metrics/histograms/metadata/nearby/DIR_METADATA
@@ -0,0 +1,9 @@ +# Metadata information for this directory. +# +# For more information on DIR_METADATA files, see: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/README.md +# +# For the schema of this file, see Metadata message: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/proto/dir_metadata.proto + +mixins: "//chromeos/ash/services/nearby/COMMON_METADATA"
diff --git a/tools/metrics/histograms/metadata/new_tab_page/histograms.xml b/tools/metrics/histograms/metadata/new_tab_page/histograms.xml index e9ffd13..0ce3bd0 100644 --- a/tools/metrics/histograms/metadata/new_tab_page/histograms.xml +++ b/tools/metrics/histograms/metadata/new_tab_page/histograms.xml
@@ -241,7 +241,7 @@ </histogram> <histogram name="NewTabPage.CustomizeChromeBackgroundAction" - enum="NTPCustomizeChromeBackgroundAction" expires_after="2024-01-31"> + enum="NTPCustomizeChromeBackgroundAction" expires_after="2025-05-31"> <owner>pauladedeji@google.com</owner> <owner>tiborg@chromium.org</owner> <owner>chrome-desktop-ntp@google.com</owner> @@ -314,7 +314,7 @@ </histogram> <histogram name="NewTabPage.CustomizeLocalImageBackgroundAction" - enum="NTPCustomizeLocalImageBackgroundAction" expires_after="2024-01-31"> + enum="NTPCustomizeLocalImageBackgroundAction" expires_after="2025-05-31"> <owner>pauladedeji@google.com</owner> <owner>tiborg@chromium.org</owner> <owner>chrome-desktop-ntp@google.com</owner> @@ -1365,7 +1365,7 @@ </histogram> <histogram name="NewTabPage.TabResumption.Visit.ClickSource" - enum="NtpURLVisitAggregateTypes" expires_after="2025-01-05"> + enum="NtpURLVisitAggregateTypes" expires_after="2025-06-08"> <owner>mfacey@google.com</owner> <owner>romanarora@google.com</owner> <owner>chrome-desktop-ntp@google.com</owner> @@ -1389,7 +1389,7 @@ </histogram> <histogram name="NewTabPage.TabResumption.VisitRestoreIndex" units="index" - expires_after="2025-01-12"> + expires_after="2025-06-08"> <owner>mfacey@google.com</owner> <owner>romanarora@google.com</owner> <owner>chrome-desktop-ntp@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/others/histograms.xml b/tools/metrics/histograms/metadata/others/histograms.xml index 7bc9151..f1bd2b4 100644 --- a/tools/metrics/histograms/metadata/others/histograms.xml +++ b/tools/metrics/histograms/metadata/others/histograms.xml
@@ -1330,6 +1330,21 @@ </summary> </histogram> +<histogram name="Ads.InterestGroup.Auction.TrustedBidderBatchCompute" + units="microseconds" expires_after="2025-03-02"> + <owner>morlovich@google.com</owner> + <owner>privacy-sandbox-dev@chromium.org</owner> + <summary> + How long it takes to compute URL(s) for a batch of trusted bidding signals + fetches (using V1 protocol). + + Reported only on clients with high-resolution clocks. + + See https://github.com/WICG/turtledove/blob/main/FLEDGE.md for the latest + version of the FLEDGE explainer. + </summary> +</histogram> + <histogram name="Ads.InterestGroup.Auction.TrustedBidderSignalsOriginRelation" enum="BidderSignalsOriginRelation" expires_after="2025-05-10"> <owner>morlovich@chromium.org</owner> @@ -1343,6 +1358,21 @@ </summary> </histogram> +<histogram name="Ads.InterestGroup.Auction.TrustedSellerBatchCompute" + units="microseconds" expires_after="2025-03-02"> + <owner>morlovich@google.com</owner> + <owner>privacy-sandbox-dev@chromium.org</owner> + <summary> + How long it takes to compute URL(s) for a batch of trusted bidding signals + fetches (using V1 protocol). + + Reported only on clients with high-resolution clocks. + + See https://github.com/WICG/turtledove/blob/main/FLEDGE.md for the latest + version of the FLEDGE explainer. + </summary> +</histogram> + <histogram name="Ads.InterestGroup.Auction.TrustedSellerSignalsCrossOriginPermissionWait" units="ms" expires_after="2025-05-10">
diff --git a/tools/metrics/histograms/metadata/password/histograms.xml b/tools/metrics/histograms/metadata/password/histograms.xml index 57a4682..24099a9 100644 --- a/tools/metrics/histograms/metadata/password/histograms.xml +++ b/tools/metrics/histograms/metadata/password/histograms.xml
@@ -4738,7 +4738,7 @@ </histogram> <histogram name="PasswordProtection.CSDCacheContainsImages" - enum="BooleanPresent" expires_after="2025-02-10"> + enum="BooleanPresent" expires_after="2026-02-10"> <owner>andysjlim@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -4938,7 +4938,7 @@ </histogram> <histogram name="PasswordProtection.SuccessfulPhishingDetectionWithinTimeout" - enum="BooleanSuccess" expires_after="2025-02-10"> + enum="BooleanSuccess" expires_after="2026-02-10"> <owner>andysjlim@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary> @@ -4960,7 +4960,7 @@ </histogram> <histogram name="PasswordProtection.VisualFeatureExtractionDuration" units="ms" - expires_after="2025-02-10"> + expires_after="2026-02-10"> <owner>andysjlim@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/phonehub/DIR_METADATA b/tools/metrics/histograms/metadata/phonehub/DIR_METADATA new file mode 100644 index 0000000..66167f8 --- /dev/null +++ b/tools/metrics/histograms/metadata/phonehub/DIR_METADATA
@@ -0,0 +1,9 @@ +# Metadata information for this directory. +# +# For more information on DIR_METADATA files, see: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/README.md +# +# For the schema of this file, see Metadata message: +# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/proto/dir_metadata.proto + +mixins: "//chromeos/ash/components/phonehub/COMMON_METADATA"
diff --git a/tools/metrics/histograms/metadata/sb_client/histograms.xml b/tools/metrics/histograms/metadata/sb_client/histograms.xml index b220ed0..0ebbd8d 100644 --- a/tools/metrics/histograms/metadata/sb_client/histograms.xml +++ b/tools/metrics/histograms/metadata/sb_client/histograms.xml
@@ -608,7 +608,7 @@ </histogram> <histogram name="SBClientPhishing.CSDPhishingCachedDataAvailable" - enum="BooleanAvailable" expires_after="2025-02-10"> + enum="BooleanAvailable" expires_after="2026-02-10"> <owner>andysjlim@chromium.org</owner> <owner>chrome-counter-abuse-alerts@google.com</owner> <summary>
diff --git a/tools/perf/core/perf_data_generator.py b/tools/perf/core/perf_data_generator.py index d0d46e2..3a1cc2f 100755 --- a/tools/perf/core/perf_data_generator.py +++ b/tools/perf/core/perf_data_generator.py
@@ -293,7 +293,7 @@ 'pool': 'chrome.tests.perf', 'os': 'Windows-11', 'cpu': 'arm64-64-Snapdragon(R)_X_Elite_-_X1E80100_-_Qualcomm(R)_Oryon(TM)_CPU', - 'synthetic_product_name': 'Inspiron 14 Plus 7441 (Dell Inc.)' + 'synthetic_product_name': 'Latitude 7455 (Dell Inc.)' }, }, 'chromeos-kevin-builder-perf-fyi': {
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index e844e96..3f06b87 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 @@ "full_remote_path": "perfetto-luci-artifacts/79e2dcdef714a3d7f6e09a115cd9fba0c04c7689/linux-arm64/trace_processor_shell" }, "win": { - "hash": "d29819bf4ecb76e4dad3b025ab0cf8325007664b", - "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/win/a65d8d50d22863987cda7bb4d23d5effdceb4418/trace_processor_shell.exe" + "hash": "bf8b9be3b101f3bb51eb4f9442181e5214b477d4", + "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/win/38d6e838e2477a1aab2aa65edc52b727f50cb61d/trace_processor_shell.exe" }, "linux_arm": { "hash": "f92983e30310bbb0af7a96b2e23484a0e561de42", @@ -21,8 +21,8 @@ "full_remote_path": "perfetto-luci-artifacts/79e2dcdef714a3d7f6e09a115cd9fba0c04c7689/mac-arm64/trace_processor_shell" }, "linux": { - "hash": "818bc29ee85739bb044c16f7463d4b974c014f68", - "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/linux/82992fff76e4b8a6efd8b19469b297d627724a92/trace_processor_shell" + "hash": "a7b07497a9a38534d069aa83eb511c74b0d4d054", + "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/linux/38d6e838e2477a1aab2aa65edc52b727f50cb61d/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/tools/typescript/validate_tsconfig.py b/tools/typescript/validate_tsconfig.py index 918c2b6..753d822 100644 --- a/tools/typescript/validate_tsconfig.py +++ b/tools/typescript/validate_tsconfig.py
@@ -148,6 +148,8 @@ 'chrome/browser/resources/chromeos/accessibility', # TODO(crbug.com/41484340): Migrate to TypeScript. 'chrome/browser/resources/device_log', + # TODO(crbug.com/385341235): Migrate inspect to TypeScript. + 'chrome/browser/resources/inspect', 'chrome/test/data/webui', # TODO(crbug.com/40848285): Migrate bluetooth-internals to TypeScript and # remove exception.
diff --git a/tools/utr/README.md b/tools/utr/README.md index ef2ab4e..8583245 100644 --- a/tools/utr/README.md +++ b/tools/utr/README.md
@@ -62,6 +62,10 @@ runs basic functional test suites on CrOS VMs running on intel. Use `-B ci -b chromeos-amd64-generic-rel-gtest` on the UTR cmd line. +Note that the names of the above builders may change over time and the links +may eventually break. Navigate the build console to find the current list of +running builders. + ## Command-line Examples Below are some example invocations of the UTR: @@ -100,6 +104,62 @@ vpython3 run.py -B try -b linux-chromeos-rel -t interactive_ui_tests test -- --gtest_filter=TestClass.TestCase --gtest_repeat=100 ``` +## Custom builder configs + +For the specified builder, the UTR will reuse its precise configs. This includes +things like GN args, test targets, and test dimensions. These configs are +encoded as starlark in the checkout, and are read at UTR invocation-time. +Consequently, you can make local modifications to these configs and they will be +reflected in any subsequent UTR invocation for that builder. + +Example: at time of writing, the +[Linux Tests](https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20Tests) +builder runs tests on Ubuntu-22.04 (jammy). To test out running its tests on +Ubuntu-24.04 (noble), you would find its builder config in the +[infra starlark dir](https://source.chromium.org/chromium/chromium/src/+/main:infra/config/subprojects/) +in the repo. It should look something like: +``` +ci.thin_tester( + name = "Linux Tests", + triggered_by = ["ci/Linux Builder"], + ... +) +``` + +Find the line that controls the dimensions its tests target: +``` + ... + targets = targets.bundle( + ... + mixins = [ + "isolate_profile_data", + "linux-jammy", + ], + ... +``` + +And change the Jammy mixin to Noble: +``` + ... + targets = targets.bundle( + ... + mixins = [ + "isolate_profile_data", + "linux-noble", + ], + ... +``` + +Then regen the infra configs, and re-run the UTR. Within the UTR invocation, +it should now run base_unittests on Ubuntu-24.04 rather than Ubuntu-22.04: +```sh +$ ./infra/config/main.star +$ vpython3 run.py -B ci -b 'Linux Tests' -t base_unittests compile-and-test +``` + +See [here](../../infra/config/targets/README.md) for more info about how a +builder's tests are configured in starlark. + ## Questions/feedback If you have any usage questions or suggestions for feedback, feel free to file
diff --git a/ui/accessibility/platform/ax_platform_node_id.h b/ui/accessibility/platform/ax_platform_node_id.h index 0f03f5c8..3c8331c 100644 --- a/ui/accessibility/platform/ax_platform_node_id.h +++ b/ui/accessibility/platform/ax_platform_node_id.h
@@ -55,4 +55,9 @@ } // namespace ui +namespace std { +template <> +struct std::hash<ui::AXPlatformNodeId> + : std::hash<base::StrongAlias<class ui::AXPlatformNodeIdTag, int32_t>> {}; +} // namespace std #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_ID_H_
diff --git a/ui/accessibility/platform/ax_unique_id.cc b/ui/accessibility/platform/ax_unique_id.cc index bbd9806a..6ed9a7b 100644 --- a/ui/accessibility/platform/ax_unique_id.cc +++ b/ui/accessibility/platform/ax_unique_id.cc
@@ -15,11 +15,8 @@ namespace { // Returns the container of assigned IDs. -std::unordered_set<AXPlatformNodeId, typename AXPlatformNodeId::Hasher>& -GetAssignedIds() { - static base::NoDestructor< - std::unordered_set<AXPlatformNodeId, typename AXPlatformNodeId::Hasher>> - assigned_ids; +std::unordered_set<AXPlatformNodeId>& GetAssignedIds() { + static base::NoDestructor<std::unordered_set<AXPlatformNodeId>> assigned_ids; return *assigned_ids; }
diff --git a/ui/android/BUILD.gn b/ui/android/BUILD.gn index c413cc73..5383fcc8 100644 --- a/ui/android/BUILD.gn +++ b/ui/android/BUILD.gn
@@ -775,7 +775,6 @@ "java/src/org/chromium/ui/listmenu/ListMenuButtonTest.java", "java/src/org/chromium/ui/widget/TextViewWithTightWrapTest.java", "javatests/src/org/chromium/ui/base/ClipboardAndroidTest.java", - "javatests/src/org/chromium/ui/base/EventForwarderDeviceTest.java", "javatests/src/org/chromium/ui/util/WindowInsetsUtilsJavaUnitTest.java", "junit/src/org/chromium/ui/widget/TextViewWithLeadingTest.java", ] @@ -796,7 +795,6 @@ "//third_party/androidx:androidx_test_runner_java", "//third_party/hamcrest:hamcrest_java", "//third_party/hamcrest:hamcrest_library_java", - "//third_party/jni_zero:gendeps_java", "//third_party/junit", "//third_party/mockito:mockito_java", ]
diff --git a/ui/android/event_forwarder.cc b/ui/android/event_forwarder.cc index b7dec48b..34c80f23 100644 --- a/ui/android/event_forwarder.cc +++ b/ui/android/event_forwarder.cc
@@ -245,37 +245,6 @@ return view_->OnGenericMotionEvent(event); } -void EventForwarder::OnMouseWheelEvent( - JNIEnv* env, - const base::android::JavaParamRef<jobject>& obj, - jlong time_ns, - jfloat x, - jfloat y, - jfloat raw_x, - jfloat raw_y, - jfloat delta_x, - jfloat delta_y, - jint meta_state, - jint source) { - ui::MotionEventAndroid::Pointer pointer( - /*id=*/0, x, y, /*touch_major_pixels=*/0.0f, /*touch_minor_pixels=*/0.0f, - /*orientation_rad=*/0.0f, /*tilt_rad=*/0.0f, /*tool_type=*/0); - - auto* window = view_->GetWindowAndroid(); - float pixels_per_tick = - window ? window->mouse_wheel_scroll_factor() - : ui::kDefaultMouseWheelTickMultiplier * view_->GetDipScale(); - ui::MotionEventAndroidJava event( - env, nullptr, 1.f / view_->GetDipScale(), delta_x / pixels_per_tick, - delta_y / pixels_per_tick, pixels_per_tick, - base::TimeTicks::FromJavaNanoTime(time_ns), /*android_action=*/0, - /*pointer_count=*/1, /*history_size=*/0, /*action_index=*/0, - /*android_action_button=*/0, /*android_gesture_classification=*/0, 0, - meta_state, source, /*raw_offset_x_pixels=*/0, - /*raw_offset_y_pixels=*/0, /*for_touch_handle=*/false, &pointer, nullptr); - view_->OnMouseWheelEvent(event); -} - jboolean EventForwarder::OnKeyUp(JNIEnv* env, const JavaParamRef<jobject>& obj, const JavaParamRef<jobject>& key_event,
diff --git a/ui/android/event_forwarder.h b/ui/android/event_forwarder.h index fb6a1ac..37dae365 100644 --- a/ui/android/event_forwarder.h +++ b/ui/android/event_forwarder.h
@@ -120,18 +120,6 @@ jlong event_time_ns, jlong down_time_ms); - void OnMouseWheelEvent(JNIEnv* env, - const base::android::JavaParamRef<jobject>& obj, - jlong time_ns, - jfloat x, - jfloat y, - jfloat raw_x, - jfloat raw_y, - jfloat delta_x, - jfloat delta_y, - jint meta_state, - jint source); - jboolean OnKeyUp(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj, const base::android::JavaParamRef<jobject>& key_event,
diff --git a/ui/android/java/src/org/chromium/ui/base/EventForwarder.java b/ui/android/java/src/org/chromium/ui/base/EventForwarder.java index d878949..5810992f 100644 --- a/ui/android/java/src/org/chromium/ui/base/EventForwarder.java +++ b/ui/android/java/src/org/chromium/ui/base/EventForwarder.java
@@ -41,8 +41,6 @@ private static final String TAG = "EventForwarder"; private final boolean mIsDragDropEnabled; private final boolean mConvertTrackpadEventsToMouse; - private final boolean mIsAtLeastU = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE; // The mime type for a URL. private static final String URL_MIME_TYPE = "text/x-moz-url"; @@ -61,13 +59,6 @@ // Track the last tool type of touch sequence. private int mLastToolType; - // Tracks the starting position of the last trackpad scroll. - // Only used when isTrackpadScrollEventFromAtLeastU() is true. - private float mLastTrackpadScrollStartX; - private float mLastTrackpadScrollStartY; - private float mLastTrackpadScrollStartRawX; - private float mLastTrackpadScrollStartRawY; - // Delegate to call WebContents functionality. private @Nullable StylusWritingDelegate mStylusWritingDelegate; @@ -201,16 +192,6 @@ } else if (isTrackpadToMouseEventConversionEnabled() && isTrackpadToMouseConversionEvent(event)) { return onMouseEvent(event); - } else if (isTrackpadToMouseEventConversionEnabled() - && isTrackpadScrollEventFromAtLeastU(event)) { - // At API level 34+, trackpad scroll events carry - // AXIS_GESTURE_SCROLL_{X,Y}_DISTANCE information. Send such events - // separately, which are converted to mouse wheel events later. - // - // Trackpad scroll events prior to API level 34 will be handled in - // the same way as touchscreen swipe. - onTrackpadScrollEvent(event); - return true; } else if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) { // TODO(mustaq): Should we include MotionEvent.TOOL_TYPE_STYLUS here? // crbug.com/592082 @@ -501,30 +482,6 @@ return true; } - private void onTrackpadScrollEvent(MotionEvent event) { - // Convert trackpad scroll to mouse wheel event. - if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { - mLastTrackpadScrollStartX = event.getX(); - mLastTrackpadScrollStartY = event.getY() + mCurrentTouchOffsetY; - mLastTrackpadScrollStartRawX = event.getRawX(); - mLastTrackpadScrollStartRawY = event.getRawY() + mCurrentTouchOffsetY; - } - - EventForwarderJni.get() - .onMouseWheelEvent( - mNativeEventForwarder, - EventForwarder.this, - MotionEventUtils.getEventTimeNanos(event), - mLastTrackpadScrollStartX, - mLastTrackpadScrollStartY, - mLastTrackpadScrollStartRawX, - mLastTrackpadScrollStartRawY, - -event.getAxisValue(MotionEvent.AXIS_GESTURE_SCROLL_X_DISTANCE), - -event.getAxisValue(MotionEvent.AXIS_GESTURE_SCROLL_Y_DISTANCE), - event.getMetaState(), - event.getSource()); - } - /** * Manages internal state to work around a device-specific issue. Needs to be called per every * mouse event to update the state. @@ -568,16 +525,6 @@ return false; } - /** Only supports API level 34+. */ - public boolean isTrackpadScrollEventFromAtLeastU(MotionEvent event) { - return mIsAtLeastU - && event.getClassification() == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE - && (event.getActionMasked() == MotionEvent.ACTION_DOWN - || event.getActionMasked() == MotionEvent.ACTION_MOVE - || event.getActionMasked() == MotionEvent.ACTION_UP - || event.getActionMasked() == MotionEvent.ACTION_CANCEL); - } - /** * Returns true if a {@link MotionEvent} is detected to be a trackpad event. Note that {@link * MotionEvent.TOOL_TYPE_FINGER} is used here along with {@link InputDevice.SOURCE_MOUSE} @@ -927,19 +874,6 @@ long timeNs, long downTimeMs); - void onMouseWheelEvent( - long nativeEventForwarder, - EventForwarder caller, - long timeNs, - float x, - float y, - float rawX, - float rawY, - float deltaX, - float deltaY, - int metaState, - int source); - boolean onKeyUp( long nativeEventForwarder, EventForwarder caller, KeyEvent event, int keyCode);
diff --git a/ui/android/java/src/org/chromium/ui/util/WindowInsetsUtils.java b/ui/android/java/src/org/chromium/ui/util/WindowInsetsUtils.java index 8c32485a..5aec28c 100644 --- a/ui/android/java/src/org/chromium/ui/util/WindowInsetsUtils.java +++ b/ui/android/java/src/org/chromium/ui/util/WindowInsetsUtils.java
@@ -103,7 +103,8 @@ * Get the Rect with the maximum width within the |regionRect| that is not blocked by any rects * within the |blockedRects|. This algorithm only prioritizes the width of the returned Rects, * so the returned area does not necessarily have the maximum area. If there are multiple rects - * with the same width, this method will bias the first Rect found in the region. + * with the same width, this method will bias the first Rect found in the region. If + * |blockedRects| is empty, this method will return an empty rect. * * @see Region * @see RegionIterator @@ -113,7 +114,7 @@ */ public static Rect getWidestUnoccludedRect(Rect regionRect, List<Rect> blockedRects) { if (sWidestUnoccludedRectForTesting != null) return sWidestUnoccludedRectForTesting; - if (regionRect.isEmpty()) return regionRect; + if (regionRect.isEmpty() || blockedRects.isEmpty()) return new Rect(); Region region = new Region(regionRect); for (Rect rect : blockedRects) {
diff --git a/ui/android/javatests/src/org/chromium/ui/base/EventForwarderDeviceTest.java b/ui/android/javatests/src/org/chromium/ui/base/EventForwarderDeviceTest.java deleted file mode 100644 index 7055468..0000000 --- a/ui/android/javatests/src/org/chromium/ui/base/EventForwarderDeviceTest.java +++ /dev/null
@@ -1,145 +0,0 @@ -// Copyright 2024 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.ui.base; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import android.os.Build; -import android.view.InputDevice; -import android.view.MotionEvent; - -import androidx.test.filters.SmallTest; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; - -import org.chromium.base.test.BaseJUnit4ClassRunner; -import org.chromium.base.test.util.Batch; -import org.chromium.base.test.util.MinAndroidSdkLevel; -import org.chromium.ui.MotionEventUtils; - -/** - * Tests logic in the {@link EventForwarder} class. - * - * <p>Most of the EventForwarder test cases are in Robolectric JUnit tests. However, somehow - * MotionEvent.obtain() doesn't set the classification field properly in Robolectric tests. - * Therefore this test class is added to test those cases where classification is needed. - */ -@RunWith(BaseJUnit4ClassRunner.class) -@Batch(Batch.UNIT_TESTS) -public class EventForwarderDeviceTest { - @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); - - @Mock EventForwarder.Natives mNativeMock; - - private static final long NATIVE_EVENT_FORWARDER_ID = 1; - - @Before - public void setUp() { - EventForwarderJni.setInstanceForTesting(mNativeMock); - } - - @Test - @SmallTest - @MinAndroidSdkLevel(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) - public void testSendTrackpadScrollAsMouseWheelToNativeAtLeastU() { - EventForwarder eventForwarder = new EventForwarder(NATIVE_EVENT_FORWARDER_ID, true, true); - MotionEvent startEvent = - getTrackpadScrollEvent( - MotionEvent.ACTION_DOWN, - /* x= */ 13, - /* y= */ 24, - /* distanceX= */ 15, - /* distanceY= */ 99); - eventForwarder.onTouchEvent(startEvent); - - verifyNativeMouseWheelEventSent(eventForwarder, startEvent, startEvent); - - MotionEvent moveEvent = - getTrackpadScrollEvent( - MotionEvent.ACTION_MOVE, - /* x= */ 35, - /* y= */ 49, - /* distanceX= */ 88, - /* distanceY= */ 64); - eventForwarder.onTouchEvent(moveEvent); - - verifyNativeMouseWheelEventSent(eventForwarder, startEvent, moveEvent); - } - - private void verifyNativeMouseWheelEventSent( - EventForwarder eventForwarder, - MotionEvent trackpadScrollStartEvent, - MotionEvent trackpadScrollCurrentEvent) { - verify(mNativeMock, times(1)) - .onMouseWheelEvent( - EventForwarderDeviceTest.NATIVE_EVENT_FORWARDER_ID, - eventForwarder, - MotionEventUtils.getEventTimeNanos(trackpadScrollCurrentEvent), - trackpadScrollStartEvent.getX(), - trackpadScrollStartEvent.getY(), - trackpadScrollStartEvent.getRawX(), - trackpadScrollStartEvent.getRawY(), - -trackpadScrollCurrentEvent.getAxisValue( - MotionEvent.AXIS_GESTURE_SCROLL_X_DISTANCE), - -trackpadScrollCurrentEvent.getAxisValue( - MotionEvent.AXIS_GESTURE_SCROLL_Y_DISTANCE), - trackpadScrollCurrentEvent.getMetaState(), - trackpadScrollCurrentEvent.getSource()); - } - - private static MotionEvent getTrackpadScrollEvent( - int action, float x, float y, float distanceX, float distanceY) { - return MotionEvent.obtain( - /* downTime= */ 0, - /* eventTime= */ 100, - action, - /* pointerCount= */ 1, - getToolTypeFingerProperties(), - getPointerCoords(x, y, distanceX, distanceY), - /* metaState= */ 0, - /* buttonState= */ 0, - /* xPrecision= */ 0, - /* yPrecision= */ 0, - /* deviceId= */ 0, - /* edgeFlags= */ 0, - getTrackpadSource(), - /* displayId= */ 0, - /* flags= */ 0, - MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE); - } - - private static MotionEvent.PointerProperties[] getToolTypeFingerProperties() { - MotionEvent.PointerProperties[] pointerPropertiesArray = - new MotionEvent.PointerProperties[1]; - MotionEvent.PointerProperties trackpadProperties = new MotionEvent.PointerProperties(); - trackpadProperties.id = 7; - trackpadProperties.toolType = MotionEvent.TOOL_TYPE_FINGER; - pointerPropertiesArray[0] = trackpadProperties; - return pointerPropertiesArray; - } - - private static MotionEvent.PointerCoords[] getPointerCoords( - float x, float y, float distanceX, float distanceY) { - MotionEvent.PointerCoords[] pointerCoordsArray = new MotionEvent.PointerCoords[1]; - MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords(); - coords.x = x; - coords.y = y; - coords.setAxisValue(MotionEvent.AXIS_GESTURE_SCROLL_X_DISTANCE, distanceX); - coords.setAxisValue(MotionEvent.AXIS_GESTURE_SCROLL_Y_DISTANCE, distanceY); - pointerCoordsArray[0] = coords; - return pointerCoordsArray; - } - - private static int getTrackpadSource() { - return InputDevice.SOURCE_MOUSE; - } -}
diff --git a/ui/android/javatests/src/org/chromium/ui/util/WindowInsetsUtilsJavaUnitTest.java b/ui/android/javatests/src/org/chromium/ui/util/WindowInsetsUtilsJavaUnitTest.java index b4174381..e14eaf5 100644 --- a/ui/android/javatests/src/org/chromium/ui/util/WindowInsetsUtilsJavaUnitTest.java +++ b/ui/android/javatests/src/org/chromium/ui/util/WindowInsetsUtilsJavaUnitTest.java
@@ -114,4 +114,12 @@ WindowInsetsUtils.getBoundingRectsFromInsets( insets, WindowInsetsCompat.Type.captionBar())); } + + @Test + @SmallTest + public void testGetWidestUnoccludedRect_NoBlockedRects() { + Rect region = new Rect(0, 0, 600, 800); + List<Rect> blocks = List.of(); + assertEquals(new Rect(), WindowInsetsUtils.getWidestUnoccludedRect(region, blocks)); + } }
diff --git a/ui/android/junit/src/org/chromium/ui/widget/TextViewWithLeadingTest.java b/ui/android/junit/src/org/chromium/ui/widget/TextViewWithLeadingTest.java index 02125acc..5029609 100644 --- a/ui/android/junit/src/org/chromium/ui/widget/TextViewWithLeadingTest.java +++ b/ui/android/junit/src/org/chromium/ui/widget/TextViewWithLeadingTest.java
@@ -15,22 +15,20 @@ import androidx.annotation.LayoutRes; import androidx.test.filters.MediumTest; -import org.junit.After; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; -import org.chromium.base.FeatureList; import org.chromium.base.test.BaseActivityTestRule; import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.util.Batch; +import org.chromium.base.test.util.Features.DisableFeatures; +import org.chromium.base.test.util.Features.EnableFeatures; import org.chromium.ui.R; import org.chromium.ui.base.UiAndroidFeatures; import org.chromium.ui.test.util.BlankUiTestActivity; -import java.util.Collections; - /** Unit tests for {@link TextViewWithLeading}. */ @RunWith(BaseJUnit4ClassRunner.class) @Batch(Batch.PER_CLASS) @@ -44,11 +42,6 @@ sActivityTestRule.launchActivity(null); } - @After - public void after() { - FeatureList.setTestFeatures(null); - } - private void inflateAndVerify(@LayoutRes int layoutRes) { TextView textView = (TextView) inflate(layoutRes); assertNotEquals(/* expected= */ 0, textView.getLineSpacingExtra(), /* delta= */ 1); @@ -91,28 +84,22 @@ @Test(expected = InflateException.class) @MediumTest + @EnableFeatures(UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING) public void testNoLeading() { - FeatureList.setTestFeatures( - Collections.singletonMap( - UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING, true)); inflate(R.layout.text_view_with_leading_no_leading); } @Test @MediumTest + @DisableFeatures(UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING) public void testLeadingKillSwitch() { - FeatureList.setTestFeatures( - Collections.singletonMap( - UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING, false)); inflateAndVerify(R.layout.text_view_with_leading_direct); } @Test @MediumTest + @DisableFeatures(UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING) public void testNoLeadingKillSwitch() { - FeatureList.setTestFeatures( - Collections.singletonMap( - UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING, false)); inflate(R.layout.text_view_with_leading_no_leading); } }
diff --git a/ui/base/models/image_model_unittest.cc b/ui/base/models/image_model_unittest.cc index d9013ee..93ef595b 100644 --- a/ui/base/models/image_model_unittest.cc +++ b/ui/base/models/image_model_unittest.cc
@@ -21,7 +21,7 @@ const gfx::VectorIcon& GetCircleVectorIcon() { static constexpr gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18, 5}; - static const gfx::VectorIconRep rep[] = {{path, 4}}; + static const gfx::VectorIconRep rep[] = {{path}}; static constexpr gfx::VectorIcon circle_icon = {rep, 1, "circle"}; return circle_icon; @@ -31,7 +31,7 @@ static constexpr gfx::PathElement path[] = { gfx::CommandType::LINE_TO, 0, 10, gfx::CommandType::LINE_TO, 10, 10, gfx::CommandType::LINE_TO, 10, 0, gfx::CommandType::CLOSE}; - static const gfx::VectorIconRep rep[] = {{path, 10}}; + static const gfx::VectorIconRep rep[] = {{path}}; static constexpr gfx::VectorIcon rect_icon = {rep, 1, "rect"}; return rect_icon;
diff --git a/ui/base/themed_vector_icon_unittest.cc b/ui/base/themed_vector_icon_unittest.cc index cb7f7ed..0750f3a 100644 --- a/ui/base/themed_vector_icon_unittest.cc +++ b/ui/base/themed_vector_icon_unittest.cc
@@ -15,7 +15,7 @@ const gfx::VectorIcon* GetVectorIcon() { static constexpr gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18, 5}; - static const gfx::VectorIconRep rep[] = {{path, 4}}; + static const gfx::VectorIconRep rep[] = {{path}}; static constexpr gfx::VectorIcon circle_icon = {rep, 1, "circle"}; return &circle_icon;
diff --git a/ui/gfx/paint_vector_icon.cc b/ui/gfx/paint_vector_icon.cc index 5f94c4ba..f47d538 100644 --- a/ui/gfx/paint_vector_icon.cc +++ b/ui/gfx/paint_vector_icon.cc
@@ -441,7 +441,10 @@ VectorIconSource(const std::string& definition, int dip_size, SkColor color) : CanvasImageSource(Size(dip_size, dip_size)), - data_(kNoneIcon, dip_size, color, &kNoneIcon), + data_(VectorIcon::EmptyIcon(), + dip_size, + color, + &VectorIcon::EmptyIcon()), path_(PathFromSource(definition)) {} VectorIconSource(const VectorIconSource&) = delete; @@ -510,15 +513,13 @@ : icon(icon), dip_size(dip_size), color(color), - badge_icon(badge_icon ? *badge_icon : kNoneIcon) { + badge_icon(badge_icon ? *badge_icon : VectorIcon::EmptyIcon()) { if (dip_size == 0) this->dip_size = GetDefaultSizeOfVectorIcon(icon); } IconDescription::~IconDescription() {} -const VectorIcon kNoneIcon = {}; - void PaintVectorIcon(Canvas* canvas, const VectorIcon& icon, SkColor color) { PaintVectorIcon(canvas, icon, GetDefaultSizeOfVectorIcon(icon), color); } @@ -550,7 +551,8 @@ ImageSkia CreateVectorIcon(const VectorIcon& icon, int dip_size, SkColor color) { - return CreateVectorIcon(IconDescription(icon, dip_size, color, &kNoneIcon)); + return CreateVectorIcon( + IconDescription(icon, dip_size, color, &VectorIcon::EmptyIcon())); } ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon,
diff --git a/ui/gfx/paint_vector_icon.h b/ui/gfx/paint_vector_icon.h index bb04745..7c4ab54 100644 --- a/ui/gfx/paint_vector_icon.h +++ b/ui/gfx/paint_vector_icon.h
@@ -36,8 +36,6 @@ const raw_ref<const VectorIcon> badge_icon; }; -COMPONENT_EXPORT(GFX) extern const VectorIcon kNoneIcon; - // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |color| is // used as the fill. The size will come from the .icon file (the 1x version, if // multiple versions exist).
diff --git a/ui/gfx/paint_vector_icon_unittest.cc b/ui/gfx/paint_vector_icon_unittest.cc index 34199eb..17f2388 100644 --- a/ui/gfx/paint_vector_icon_unittest.cc +++ b/ui/gfx/paint_vector_icon_unittest.cc
@@ -52,7 +52,7 @@ MOVE_TO, 4, 5, LINE_TO, 10, 11, CLOSE, // This move should use (4, 5) as the start point rather than (10, 11). R_MOVE_TO, 20, 21, R_LINE_TO, 50, 51}; - const VectorIconRep rep_list[] = {{elements, std::size(elements)}}; + const VectorIconRep rep_list[] = {{elements}}; const VectorIcon icon(rep_list, 1u, nullptr); PaintVectorIcon(&canvas, icon, 100, SK_ColorMAGENTA); @@ -89,7 +89,7 @@ NEW_PATH, FILL_RULE_NONZERO, MOVE_TO, 110, 0, R_H_LINE_TO, 90, R_V_LINE_TO, 90, R_H_LINE_TO, -90, CLOSE, MOVE_TO, 130, 20, R_H_LINE_TO, 50, R_V_LINE_TO, 50, R_H_LINE_TO, -50, CLOSE}; - const VectorIconRep rep_list[] = {{elements, std::size(elements)}}; + const VectorIconRep rep_list[] = {{elements}}; const VectorIcon icon(rep_list, 1u, nullptr); PaintVectorIcon(&canvas, icon, 100, SK_ColorBLACK); @@ -126,7 +126,7 @@ R_H_LINE_TO, -20, CLOSE}; - const VectorIconRep rep_list[] = {{elements, std::size(elements)}}; + const VectorIconRep rep_list[] = {{elements}}; const VectorIcon icon(rep_list, 1u, nullptr); PaintVectorIcon(&canvas, icon, canvas_size, color); @@ -254,11 +254,8 @@ 0, CLOSE}; // VectorIconReps are always sorted in descending order of size. - const VectorIconRep rep_list[] = {{elements48, std::size(elements48)}, - {elements32, std::size(elements32)}, - {elements24, std::size(elements24)}, - {elements20, std::size(elements20)}, - {elements16, std::size(elements16)}}; + const VectorIconRep rep_list[] = { + {elements48}, {elements32}, {elements24}, {elements20}, {elements16}}; const VectorIcon icon(rep_list, 5u, nullptr); // Test exact sizes paint the correctly sized icon, including the largest and
diff --git a/ui/gfx/vector_icon_types.h b/ui/gfx/vector_icon_types.h index 82f6bd1..8f9065c 100644 --- a/ui/gfx/vector_icon_types.h +++ b/ui/gfx/vector_icon_types.h
@@ -93,29 +93,34 @@ // Describes the drawing commands for a single vector icon at a particular pixel // size or range of sizes. struct VectorIconRep { - VectorIconRep() = default; - constexpr VectorIconRep(const PathElement* path_data, size_t path_size) - : path(path_data, path_size) {} - - VectorIconRep(const VectorIconRep&) = delete; - VectorIconRep& operator=(const VectorIconRep&) = delete; - base::raw_span<const PathElement> path; }; // A vector icon that stores one or more representations to be used for various // scale factors and pixel dimensions. +// +// Because icons are returned and even stored as references, dynamically +// constructing one isn't safe. Use `EmptyIcon` for empty icons, and the +// autogenerated named icon constants for others. +// TODO(crbug.com/343248822): Make these types easy to use safely. struct VectorIcon { - VectorIcon() = default; + static const VectorIcon& EmptyIcon() { + static constexpr VectorIcon kEmptyIcon; + return kEmptyIcon; + } + constexpr VectorIcon(const VectorIconRep* reps_data, size_t reps_size, const char* name) : reps(reps_data, reps_size), name(name) {} + // Copying is problematic because the output of `PaintVectorIcon()` is cached + // keyed on `VectorIcon*`, and because of the dangling ref issues mentioned + // above. VectorIcon(const VectorIcon&) = delete; VectorIcon& operator=(const VectorIcon&) = delete; - bool is_empty() const { return reps.empty(); } + constexpr bool is_empty() const { return reps.empty(); } base::raw_span<const VectorIconRep> reps; @@ -124,7 +129,8 @@ // should be careful to ensure this is unique. const char* name = nullptr; - bool operator<(const VectorIcon& other) const; + private: + constexpr VectorIcon() = default; }; } // namespace gfx
diff --git a/ui/menus/simple_menu_model_unittest.cc b/ui/menus/simple_menu_model_unittest.cc index 803934f..7112f981 100644 --- a/ui/menus/simple_menu_model_unittest.cc +++ b/ui/menus/simple_menu_model_unittest.cc
@@ -273,7 +273,7 @@ EXPECT_TRUE(simple_menu_model.GetIconAt(0).IsEmpty()); gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18, 5}; - gfx::VectorIconRep rep[] = {{path, 4}}; + gfx::VectorIconRep rep[] = {{path}}; gfx::VectorIcon circle_icon = {rep, 1, "circle"}; simple_menu_model.AddItemWithIcon(
diff --git a/ui/message_center/public/cpp/notification.h b/ui/message_center/public/cpp/notification.h index fe0b0c1a..5a47ad04 100644 --- a/ui/message_center/public/cpp/notification.h +++ b/ui/message_center/public/cpp/notification.h
@@ -20,7 +20,6 @@ #include "ui/gfx/color_palette.h" #include "ui/gfx/geometry/skia_conversions.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/vector_icon_types.h" #include "ui/message_center/public/cpp/message_center_public_export.h" #include "ui/message_center/public/cpp/notification_delegate.h" @@ -110,7 +109,7 @@ gfx::Image icon; // Vector icon to that's used for icon-only notification buttons. - raw_ptr<const gfx::VectorIcon> vector_icon = &gfx::kNoneIcon; + raw_ptr<const gfx::VectorIcon> vector_icon = &gfx::VectorIcon::EmptyIcon(); // Accessible name to be used for the button's tooltip. Required when creating // an icon-only notification button. @@ -191,7 +190,8 @@ // retain VectorIcon reference. https://crbug.com/760866 // RAW_PTR_EXCLUSION: Never allocated by PartitionAlloc (always points to a // global), so there is no benefit to using a raw_ptr, only cost. - RAW_PTR_EXCLUSION const gfx::VectorIcon* vector_small_image = &gfx::kNoneIcon; + RAW_PTR_EXCLUSION const gfx::VectorIcon* vector_small_image = + &gfx::VectorIcon::EmptyIcon(); // Vector image to display on the parent notification of this notification, // illustrating the source of the group notification that this notification @@ -200,7 +200,7 @@ // RAW_PTR_EXCLUSION: Never allocated by PartitionAlloc (always points to a // global), so there is no benefit to using a raw_ptr, only cost. RAW_PTR_EXCLUSION const gfx::VectorIcon* parent_vector_small_image = - &gfx::kNoneIcon; + &gfx::VectorIcon::EmptyIcon(); // Items to display on the notification. Only applicable for notifications // that have type NOTIFICATION_TYPE_MULTIPLE.
diff --git a/ui/views/controls/button/image_button_factory_unittest.cc b/ui/views/controls/button/image_button_factory_unittest.cc index 8b4eed8..2a2b018 100644 --- a/ui/views/controls/button/image_button_factory_unittest.cc +++ b/ui/views/controls/button/image_button_factory_unittest.cc
@@ -104,7 +104,7 @@ CreateVectorToggleImageButton(Button::PressedCallback()); ui::AXNodeData data; const ui::ImageModel& image = - ui::ImageModel::FromVectorIcon(gfx::VectorIcon(), 23, 56); + ui::ImageModel::FromVectorIcon(gfx::VectorIcon::EmptyIcon(), 23, 56); toggle_image_button->SetToggledImageModel(Button::STATE_NORMAL, image); EXPECT_EQ(data.GetCheckedState(), ax::mojom::CheckedState::kNone);
diff --git a/ui/webui/resources/cr_components/history_clusters/clusters.ts b/ui/webui/resources/cr_components/history_clusters/clusters.ts index edb3e2b..1898b60 100644 --- a/ui/webui/resources/cr_components/history_clusters/clusters.ts +++ b/ui/webui/resources/cr_components/history_clusters/clusters.ts
@@ -113,6 +113,14 @@ scrollOffset: {type: Number}, scrollTarget: {type: Object}, + // Whether this element is active, i.e. visible to the user. Defaults to + // true. Clients should set to false when this element is inactive, + // e.g. in a tabbed UI when the active tab doesn't contain this element. + isActive: { + type: Boolean, + reflect: true, + }, + isEmpty: { type: Boolean, reflect: true, @@ -123,6 +131,7 @@ //============================================================================ // Properties //============================================================================ + isActive: boolean = true; isEmpty: boolean = true; query: string = ''; scrollOffset: number = 0; @@ -134,7 +143,19 @@ protected resultQuery_: string = ''; private callbackRouter_: PageCallbackRouter; private inSidePanel_: boolean = loadTimeData.getBoolean('inSidePanel'); - private scrollListener_: EventListener = () => this.onScroll_(); + private lastOffsetHeight_: number = 0; + private resizeObserver_: ResizeObserver = new ResizeObserver(() => { + if (this.lastOffsetHeight_ === 0) { + this.lastOffsetHeight_ = this.scrollTarget.offsetHeight; + return; + } + if (this.scrollTarget.offsetHeight > this.lastOffsetHeight_) { + this.lastOffsetHeight_ = this.scrollTarget.offsetHeight; + this.onScrollOrResize_(); + } + }); + private scrollDebounce_: number = 200; + private scrollListener_: EventListener = () => this.onScrollOrResize_(); private onClustersQueryResultListenerId_: number|null = null; private onClusterImageUpdatedListenerId_: number|null = null; private onVisitsRemovedListenerId_: number|null = null; @@ -224,11 +245,42 @@ if (changedProperties.has('scrollTarget')) { const oldTarget = changedProperties.get('scrollTarget'); + // Remove old listeners. ResizeObserver always listens, scroll observer + // is only on when this element is active. if (oldTarget) { - oldTarget.removeEventListener('scroll', this.scrollListener_); + this.resizeObserver_.disconnect(); + // Also remove the scroll listener if the element is currently active + // or was active and changed to inactive this lifecycle. + if (this.isActive || changedProperties.has('isActive')) { + oldTarget.removeEventListener('scroll', this.scrollListener_); + } } if (this.scrollTarget) { + this.resizeObserver_.observe(this.scrollTarget); + if (this.isActive) { + this.scrollTarget.addEventListener('scroll', this.scrollListener_); + } + } + } else if (changedProperties.has('isActive')) { + if (this.isActive) { + // Active changed from false to true. Add the scroll observer. this.scrollTarget.addEventListener('scroll', this.scrollListener_); + } else { + // Active changed from true to false. Remove scroll observer. + this.scrollTarget.removeEventListener('scroll', this.scrollListener_); + } + } + + const changedPrivateProperties = + changedProperties as Map<PropertyKey, unknown>; + if (changedPrivateProperties.has('clusters_')) { + const previous = + changedPrivateProperties.get('clusters_') as (Cluster[] | undefined); + const clustersRemoved = + previous && (previous.length > this.clusters_.length); + if (clustersRemoved && this.canLoadMore_ && + this.$.clusters.offsetHeight < this.scrollTarget.offsetHeight) { + this.onLoadMoreButtonClick_(); } } } @@ -311,6 +363,10 @@ } } + setScrollDebounceForTest(debounce: number) { + this.scrollDebounce_ = debounce; + } + /** * Called when the scrollable area has been scrolled nearly to the bottom. */ @@ -405,7 +461,8 @@ // Do this on browser idle to avoid jank and to give the DOM a chance to be // updated with the results we just got. this.onBrowserIdle_().then(() => { - if (this.scrollTarget.scrollHeight <= this.scrollTarget.clientHeight && + if ((this.$.clusters.offsetHeight < this.scrollTarget.offsetHeight || + this.scrollTarget.scrollHeight <= this.scrollTarget.clientHeight) && this.canLoadMore_) { this.onLoadMoreButtonClick_(); } @@ -479,18 +536,19 @@ })); } - private onScroll_() { + private onScrollOrResize_() { // Debounce by 200ms. if (this.scrollTimeout_) { clearTimeout(this.scrollTimeout_); } - this.scrollTimeout_ = setTimeout(() => this.onScrollTimeout_(), 200); + this.scrollTimeout_ = + setTimeout(() => this.onScrollTimeout_(), this.scrollDebounce_); } private onScrollTimeout_() { this.scrollTimeout_ = null; - const lowerScroll = - this.scrollTarget.offsetHeight - this.scrollTarget.scrollTop; + const lowerScroll = this.scrollTarget.scrollHeight - + this.scrollTarget.scrollTop - this.scrollTarget.offsetHeight; if (lowerScroll < 500) { this.onScrolledToBottom_(); }
diff --git a/ui/webui/resources/cr_components/history_embeddings/history_embeddings.mojom b/ui/webui/resources/cr_components/history_embeddings/history_embeddings.mojom index 4c17221..1c03d6e 100644 --- a/ui/webui/resources/cr_components/history_embeddings/history_embeddings.mojom +++ b/ui/webui/resources/cr_components/history_embeddings/history_embeddings.mojom
@@ -56,6 +56,10 @@ // When present, this contains information about how to mark this // SearchResultItem as the query answer. Most items will not have it. AnswerData? answer_data; + + // Set to true for results that have at least 1 visit known to sync. This is + // used to determine if the UI can request images for the URL. + bool is_url_known_to_sync; }; // Represents a search query for the history embeddings database.
diff --git a/v8 b/v8 index 8d90bc0..4551bf1 160000 --- a/v8 +++ b/v8
@@ -1 +1 @@ -Subproject commit 8d90bc07afaf3d2a0b8fabb44ebc6dcec67e02ad +Subproject commit 4551bf13781091625662a39f2b02b3b9ebe1c42b