diff --git a/DEPS b/DEPS index e81a9880..3d9ea09 100644 --- a/DEPS +++ b/DEPS
@@ -297,15 +297,15 @@ # 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': 'd8a4a8a966952e9326973f05b69e0c26ff679d5c', + 'skia_revision': 'e96d4aa2ad3bad205154deec3c4e979e5852ffe7', # 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': '4b11554998f6fb5ee4c17a807979915ceb3b1665', + 'v8_revision': '709443dcb7102cf51cf3ee8645b784483cd208f8', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '4c941149774f38dd7090747cf561d4cdc2c3bda2', + 'angle_revision': 'b9fd47b8d2bd001a8a65c2df355108b50d6da64b', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -368,7 +368,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': '6dbdca4bea6d53025e454524571f685731486cf5', + 'catapult_revision': '42f4f9ca7d140e7d8ecf0e3c4b06ea44d9cfc5f1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -412,7 +412,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': '735e4b4fa1ef359f2db9308522f5715a3130debd', + 'dawn_revision': 'cdb53972831c7c466b5a9c3173b90fc6b16626ef', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -884,7 +884,7 @@ 'packages': [ { 'package': 'chromium/rts/model/windows-amd64', - 'version': 'Qp5TftY44SnXcyr8KTckJ5Q9WdRY_UABjXUhYrJYUO8C', + 'version': 'EdjH-IqvBY46yCmx-PVDk3g_UvVAWHNjF-3ta5f6xfIC', }, ], 'dep_type': 'cipd', @@ -1221,7 +1221,7 @@ Var('chromium_git') + '/chromium/deps/flac.git' + '@' + 'af862024c8c8fa0ae07ced05e89013d881b00596', 'src/third_party/flatbuffers/src': - Var('chromium_git') + '/external/github.com/google/flatbuffers.git' + '@' + '0fe13cb28ce5a3fb81f654b21cb37c9821194962', + Var('chromium_git') + '/external/github.com/google/flatbuffers.git' + '@' + 'a3508f36d5ef2272323d946dccf7816b6bde55db', # Used for embedded builds. CrOS & Linux use the system version. 'src/third_party/fontconfig/src': { @@ -1732,7 +1732,7 @@ Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '8a9afc652513fae1a913f3db1648e5adc54239b1', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '48ac38ec9b606844a346fb82b9101ba0c2d7be2b', + Var('webrtc_git') + '/src.git' + '@' + '1c5f317e178abd4334903e6beb37b03cc139f80c', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'), @@ -1805,7 +1805,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@2a3cb3b7d36a36ba60d4e34199e5144da605d9c3', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@4f6a554e1d38fa0c99b6de0256905fa01970d460', 'condition': 'checkout_src_internal', },
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 5c170f44..eef1c78 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -2880,6 +2880,7 @@ "system/power/power_prefs_unittest.cc", "system/power/power_status_unittest.cc", "system/power/video_activity_notifier_unittest.cc", + "system/privacy/privacy_indicators_controller_unittest.cc", "system/privacy_hub/camera_privacy_switch_controller_unittest.cc", "system/privacy_hub/microphone_privacy_switch_controller_unittest.cc", "system/progress_indicator/progress_indicator_animation_registry_unittest.cc", @@ -3429,6 +3430,8 @@ "test/ash_pixel_test_init_params.h", "test/ash_test_base.cc", "test/ash_test_base.h", + "test/ash_test_color_generator.cc", + "test/ash_test_color_generator.h", "test/ash_test_helper.cc", "test/ash_test_helper.h", "test/ash_test_suite.cc",
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index dc773a30e..45b83361 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd
@@ -3930,6 +3930,12 @@ <message name="IDS_PRIVACY_NOTIFICATION_MESSAGE_MIC" desc="Message label for a notification shown when an app is using the microphone."> <ph name="APP_NAME">$1<ex>Google meet</ex></ph> is currently using your microphone </message> + <message name="IDS_PRIVACY_NOTIFICATION_BUTTON_APP_LAUNCH" desc="Title for the launch app button of the notification shown when an app is using the camera/microphone."> + Go to app + </message> + <message name="IDS_PRIVACY_NOTIFICATION_BUTTON_APP_SETTINGS" desc="Title for the launch app button of the notification shown when an app is using the camera/microphone."> + App settings + </message> <!-- Strings for microphone mute switch notification --> <message name="IDS_MICROPHONE_MUTED_NOTIFICATION_TITLE" desc="Title for a notification shown to the users when an app tries to use the microphone while the microphone is muted.i Similar to IDS_MICROPHONE_MUTED_NOTIFICATION_TITLE_WITH_APP_NAME, except this message contains a generic app name string. Used when the name of the app that's using the microphone cannot be determined.">
diff --git a/ash/ash_strings_grd/IDS_PRIVACY_NOTIFICATION_BUTTON_APP_LAUNCH.png.sha1 b/ash/ash_strings_grd/IDS_PRIVACY_NOTIFICATION_BUTTON_APP_LAUNCH.png.sha1 new file mode 100644 index 0000000..4fc298e --- /dev/null +++ b/ash/ash_strings_grd/IDS_PRIVACY_NOTIFICATION_BUTTON_APP_LAUNCH.png.sha1
@@ -0,0 +1 @@ +b39e1039abbe8b4b283caaa49179df03e639d98b \ No newline at end of file
diff --git a/ash/ash_strings_grd/IDS_PRIVACY_NOTIFICATION_BUTTON_APP_SETTINGS.png.sha1 b/ash/ash_strings_grd/IDS_PRIVACY_NOTIFICATION_BUTTON_APP_SETTINGS.png.sha1 new file mode 100644 index 0000000..b7eb270 --- /dev/null +++ b/ash/ash_strings_grd/IDS_PRIVACY_NOTIFICATION_BUTTON_APP_SETTINGS.png.sha1
@@ -0,0 +1 @@ +0db2f5a5696cfaae437f53d87945927583da33df \ No newline at end of file
diff --git a/ash/shelf/test/scrollable_shelf_test_base.cc b/ash/shelf/test/scrollable_shelf_test_base.cc index f93ffb9..8ed8e2d6 100644 --- a/ash/shelf/test/scrollable_shelf_test_base.cc +++ b/ash/shelf/test/scrollable_shelf_test_base.cc
@@ -13,11 +13,6 @@ namespace ash { namespace { -// The array of the candidate colors for app icons. -constexpr std::array<SkColor, 7> kColorArray = { - SK_ColorWHITE, SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, - SK_ColorYELLOW, SK_ColorCYAN, SK_ColorMAGENTA}; - // Create a test 1x1 icon image with a given |color|. gfx::ImageSkia CreateImageSkiaIcon(SkColor color) { SkBitmap bitmap; @@ -55,7 +50,9 @@ bool use_alternative_color) { for (int i = 0; i < number; i++) AddAppShortcutWithIconColor( - TYPE_PINNED_APP, use_alternative_color ? GetNextColor() : SK_ColorRED); + TYPE_PINNED_APP, use_alternative_color + ? icon_color_generator_.GetAlternativeColor() + : icon_color_generator_.default_color()); } void ScrollableShelfTestBase::AddAppShortcutsUntilOverflow( @@ -63,7 +60,9 @@ while (scrollable_shelf_view_->layout_strategy_for_test() == ScrollableShelfView::kNotShowArrowButtons) { AddAppShortcutWithIconColor( - TYPE_PINNED_APP, use_alternative_color ? GetNextColor() : SK_ColorRED); + TYPE_PINNED_APP, use_alternative_color + ? icon_color_generator_.GetAlternativeColor() + : icon_color_generator_.default_color()); } } @@ -80,10 +79,4 @@ return item.id; } -SkColor ScrollableShelfTestBase::GetNextColor() { - const SkColor color = kColorArray[next_color_index_]; - next_color_index_ = (next_color_index_ + 1) % kColorArray.size(); - return color; -} - } // namespace ash
diff --git a/ash/shelf/test/scrollable_shelf_test_base.h b/ash/shelf/test/scrollable_shelf_test_base.h index e36ce89..39786c0 100644 --- a/ash/shelf/test/scrollable_shelf_test_base.h +++ b/ash/shelf/test/scrollable_shelf_test_base.h
@@ -7,6 +7,7 @@ #include "ash/public/cpp/shelf_types.h" #include "ash/test/ash_test_base.h" +#include "ash/test/ash_test_color_generator.h" namespace ash { class ScrollableShelfView; @@ -38,10 +39,6 @@ // Adds a shelf item of the specified type and color. ShelfID AddAppShortcutWithIconColor(ShelfItemType item_type, SkColor color); - // Returns a color used to paint an icon. Called when neighboring pinned - // apps should have different icon colors. - SkColor GetNextColor(); - ScrollableShelfView* scrollable_shelf_view_ = nullptr; ShelfView* shelf_view_ = nullptr; std::unique_ptr<ShelfViewTestAPI> test_api_; @@ -49,9 +46,7 @@ // Used as the id of the next pinned app. Updates when an app is pinned. int id_ = 0; - // Indicates the color to be returned by `GetNextColor()`. Updates when - // `GetNextColor()` is called. - size_t next_color_index_ = 0; + AshTestColorGenerator icon_color_generator_{/*default_color=*/SK_ColorRED}; }; } // namespace ash
diff --git a/ash/system/privacy/privacy_indicators_controller.cc b/ash/system/privacy/privacy_indicators_controller.cc index 2f84881..2fced6f 100644 --- a/ash/system/privacy/privacy_indicators_controller.cc +++ b/ash/system/privacy/privacy_indicators_controller.cc
@@ -17,15 +17,46 @@ namespace ash { namespace { + const char kPrivacyIndicatorsNotificationIdPrefix[] = "privacy-indicators"; const char kPrivacyIndicatorsNotifierId[] = "ash.privacy-indicators"; + +// Keep track of the button indexes in the privacy indicators notification. +enum PrivacyIndicatorsNotificationButton { kAppLaunch, kAppSettings }; + } // namespace +PrivacyIndicatorsNotificationDelegate::PrivacyIndicatorsNotificationDelegate( + const AppActionClosure& launch_app, + const AppActionClosure& launch_settings) + : launch_app_(launch_app), launch_settings_(launch_settings) {} + +PrivacyIndicatorsNotificationDelegate:: + ~PrivacyIndicatorsNotificationDelegate() = default; + +void PrivacyIndicatorsNotificationDelegate::Click( + const absl::optional<int>& button_index, + const absl::optional<std::u16string>& reply) { + // Click on the notification body is no-op. + if (!button_index) + return; + + switch (button_index.value()) { + case PrivacyIndicatorsNotificationButton::kAppLaunch: + launch_app_.Run(); + break; + case PrivacyIndicatorsNotificationButton::kAppSettings: + launch_settings_.Run(); + break; + } +} + void ModifyPrivacyIndicatorsNotification( const std::string& app_id, absl::optional<std::u16string> app_name, bool camera_is_used, - bool microphone_is_used) { + bool microphone_is_used, + scoped_refptr<PrivacyIndicatorsNotificationDelegate> delegate) { auto* message_center = message_center::MessageCenter::Get(); std::string id = kPrivacyIndicatorsNotificationIdPrefix + app_id; bool notification_exist = message_center->FindVisibleNotificationById(id); @@ -38,6 +69,7 @@ std::u16string app_name_str = app_name.value_or(l10n_util::GetStringUTF16( IDS_PRIVACY_NOTIFICATION_MESSAGE_DEFAULT_APP_NAME)); + std::u16string title; std::u16string message; if (camera_is_used && microphone_is_used) { @@ -60,6 +92,13 @@ // Make the notification low priority so that it is silently added (no popup). optional_fields.priority = message_center::LOW_PRIORITY; + // Note: The order of buttons added here should match the order in + // PrivacyIndicatorsNotificationButton. + optional_fields.buttons.emplace_back( + l10n_util::GetStringUTF16(IDS_PRIVACY_NOTIFICATION_BUTTON_APP_LAUNCH)); + optional_fields.buttons.emplace_back( + l10n_util::GetStringUTF16(IDS_PRIVACY_NOTIFICATION_BUTTON_APP_SETTINGS)); + auto notification = CreateSystemNotification( message_center::NotificationType::NOTIFICATION_TYPE_SIMPLE, id, title, message, @@ -69,7 +108,7 @@ kPrivacyIndicatorsNotifierId, NotificationCatalogName::kPrivacyIndicators), optional_fields, - /*delegate=*/nullptr, kImeMenuMicrophoneIcon, + /*delegate=*/delegate, kImeMenuMicrophoneIcon, message_center::SystemNotificationWarningLevel::NORMAL); notification->set_accent_color_id(ui::kColorAshPrivacyIndicatorsBackground);
diff --git a/ash/system/privacy/privacy_indicators_controller.h b/ash/system/privacy/privacy_indicators_controller.h index ab783095..50b7e7f1 100644 --- a/ash/system/privacy/privacy_indicators_controller.h +++ b/ash/system/privacy/privacy_indicators_controller.h
@@ -9,16 +9,48 @@ #include "ash/ash_export.h" #include "third_party/abseil-cpp/absl/types/optional.h" +#include "ui/message_center/public/cpp/notification_delegate.h" namespace ash { +using AppActionClosure = base::RepeatingCallback<void(void)>; + +// An interface for the delegate of the privacy indicators notification, +// handling launching the app and its settings. +class ASH_EXPORT PrivacyIndicatorsNotificationDelegate + : public message_center::NotificationDelegate { + public: + PrivacyIndicatorsNotificationDelegate( + const AppActionClosure& launch_app, + const AppActionClosure& launch_settings); + PrivacyIndicatorsNotificationDelegate( + const PrivacyIndicatorsNotificationDelegate&) = delete; + PrivacyIndicatorsNotificationDelegate& operator=( + const PrivacyIndicatorsNotificationDelegate&) = delete; + + // message_center::NotificationDelegate: + void Click(const absl::optional<int>& button_index, + const absl::optional<std::u16string>& reply) override; + + protected: + ~PrivacyIndicatorsNotificationDelegate() override; + + private: + const AppActionClosure launch_app_; + const AppActionClosure launch_settings_; +}; + // Add, update, or remove the privacy notification associated with the given // `app_id`. -void ASH_EXPORT -ModifyPrivacyIndicatorsNotification(const std::string& app_id, - absl::optional<std::u16string> app_name, - bool camera_is_used, - bool microphone_is_used); +// The given scoped_refptr for `delegate` will be passed as a parameter for +// CreateSystemNotification() in case of adding/updating the notification, can +// be provided as a nullptr if irrelevant. +void ASH_EXPORT ModifyPrivacyIndicatorsNotification( + const std::string& app_id, + absl::optional<std::u16string> app_name, + bool camera_is_used, + bool microphone_is_used, + scoped_refptr<PrivacyIndicatorsNotificationDelegate> delegate); } // namespace ash
diff --git a/ash/system/privacy/privacy_indicators_controller_unittest.cc b/ash/system/privacy/privacy_indicators_controller_unittest.cc new file mode 100644 index 0000000..86227a2 --- /dev/null +++ b/ash/system/privacy/privacy_indicators_controller_unittest.cc
@@ -0,0 +1,135 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/system/privacy/privacy_indicators_controller.h" + +#include <string> + +#include "ash/system/message_center/ash_message_popup_collection.h" +#include "ash/system/message_center/unified_message_center_bubble.h" +#include "ash/system/message_center/unified_message_center_view.h" +#include "ash/system/message_center/unified_message_list_view.h" +#include "ash/system/unified/unified_system_tray.h" +#include "ash/test/ash_test_base.h" +#include "base/bind.h" +#include "ui/events/test/event_generator.h" +#include "ui/message_center/message_center.h" +#include "ui/message_center/views/notification_view_base.h" +#include "ui/views/widget/widget_utils.h" + +namespace ash { + +namespace { + +const char kPrivacyIndicatorsNotificationIdPrefix[] = "privacy-indicators"; + +class TestDelegate : public PrivacyIndicatorsNotificationDelegate { + public: + TestDelegate() + : PrivacyIndicatorsNotificationDelegate( + base::BindRepeating(&TestDelegate::LaunchApp, + base::Unretained(this)), + base::BindRepeating(&TestDelegate::LaunchAppSettings, + base::Unretained(this))) {} + TestDelegate(const TestDelegate&) = delete; + TestDelegate& operator=(const TestDelegate&) = delete; + + void LaunchApp() { launch_app_called_ = true; } + void LaunchAppSettings() { launch_settings_called_ = true; } + + bool launch_app_called() { return launch_app_called_; } + bool launch_settings_called() { return launch_settings_called_; } + + private: + ~TestDelegate() override = default; + + bool launch_app_called_ = false; + bool launch_settings_called_ = false; +}; + +} // namespace + +class PrivacyIndicatorsControllerTest : public AshTestBase { + public: + PrivacyIndicatorsControllerTest() = default; + PrivacyIndicatorsControllerTest(const PrivacyIndicatorsControllerTest&) = + delete; + PrivacyIndicatorsControllerTest& operator=( + const PrivacyIndicatorsControllerTest&) = delete; + ~PrivacyIndicatorsControllerTest() override = default; + + // Get the notification view from message center associated with `id`. + views::View* GetNotificationViewFromMessageCenter(const std::string& id) { + return GetPrimaryUnifiedSystemTray() + ->message_center_bubble() + ->message_center_view() + ->message_list_view() + ->GetMessageViewForNotificationId(id); + } + + // Get the popup notification view associated with `id`. + views::View* GetPopupNotificationView(const std::string& id) { + return GetPrimaryUnifiedSystemTray() + ->GetMessagePopupCollection() + ->GetMessageViewForNotificationId(id); + } + + void ClickView(message_center::NotificationViewBase* view, int button_index) { + auto* action_buttons = view->GetViewByID( + message_center::NotificationViewBase::kActionButtonsRow); + + auto* button_view = action_buttons->children()[button_index]; + + ui::test::EventGenerator generator(GetRootWindow(button_view->GetWidget())); + gfx::Point cursor_location = button_view->GetBoundsInScreen().CenterPoint(); + generator.MoveMouseTo(cursor_location); + generator.ClickLeftButton(); + } +}; + +TEST_F(PrivacyIndicatorsControllerTest, NotificationMetadata) { + std::string app_id = "test_app_id"; + std::u16string app_name = u"test_app_name"; + std::string notification_id = kPrivacyIndicatorsNotificationIdPrefix + app_id; + scoped_refptr<TestDelegate> delegate = base::MakeRefCounted<TestDelegate>(); + ash::ModifyPrivacyIndicatorsNotification( + app_id, app_name, /*camera_is_used=*/true, /*microphone_is_used=*/true, + delegate); + + auto* notification = + message_center::MessageCenter::Get()->FindNotificationById( + notification_id); + + // Notification message should contains app name. + EXPECT_NE(std::string::npos, notification->message().find(app_name)); +} + +TEST_F(PrivacyIndicatorsControllerTest, NotificationClickButton) { + std::string app_id = "test_app_id"; + std::string notification_id = kPrivacyIndicatorsNotificationIdPrefix + app_id; + scoped_refptr<TestDelegate> delegate = base::MakeRefCounted<TestDelegate>(); + ash::ModifyPrivacyIndicatorsNotification( + app_id, u"test_app_name", /*camera_is_used=*/true, + /*microphone_is_used=*/true, delegate); + + // Privacy indicators notification should not be a popup. It is silently added + // to the tray. + EXPECT_FALSE(GetPopupNotificationView(notification_id)); + GetPrimaryUnifiedSystemTray()->ShowBubble(); + auto* notification_view = static_cast<message_center::NotificationViewBase*>( + GetNotificationViewFromMessageCenter(notification_id)); + EXPECT_TRUE(notification_view); + + // Clicking the first button will trigger launching the app. + EXPECT_FALSE(delegate->launch_app_called()); + ClickView(notification_view, 0); + EXPECT_TRUE(delegate->launch_app_called()); + + // Clicking the first button will trigger launching the app settings. + EXPECT_FALSE(delegate->launch_settings_called()); + ClickView(notification_view, 1); + EXPECT_TRUE(delegate->launch_settings_called()); +} + +} // namespace ash
diff --git a/ash/test/ash_test_color_generator.cc b/ash/test/ash_test_color_generator.cc new file mode 100644 index 0000000..e34e4af --- /dev/null +++ b/ash/test/ash_test_color_generator.cc
@@ -0,0 +1,29 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/test/ash_test_color_generator.h" + +namespace ash { + +namespace { + +// The array of the candidate colors for app icons. +constexpr std::array<SkColor, 7> kColorArray = { + SK_ColorWHITE, SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, + SK_ColorYELLOW, SK_ColorCYAN, SK_ColorMAGENTA}; + +} // namespace + +AshTestColorGenerator::AshTestColorGenerator(SkColor default_color) + : default_color_(default_color) {} + +AshTestColorGenerator::~AshTestColorGenerator() = default; + +SkColor AshTestColorGenerator::GetAlternativeColor() { + const SkColor color = kColorArray[next_color_index_]; + next_color_index_ = (next_color_index_ + 1) % kColorArray.size(); + return color; +} + +} // namespace ash
diff --git a/ash/test/ash_test_color_generator.h b/ash/test/ash_test_color_generator.h new file mode 100644 index 0000000..3efe6d0 --- /dev/null +++ b/ash/test/ash_test_color_generator.h
@@ -0,0 +1,34 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_TEST_ASH_TEST_COLOR_GENERATOR_H_ +#define ASH_TEST_ASH_TEST_COLOR_GENERATOR_H_ + +#include "third_party/skia/include/core/SkColor.h" + +namespace ash { + +// A helper class to return a color. Usually used for solid-colored icons. +class AshTestColorGenerator { + public: + explicit AshTestColorGenerator(SkColor default_color); + AshTestColorGenerator(const AshTestColorGenerator&) = delete; + AshTestColorGenerator& operator=(const AshTestColorGenerator&) = delete; + ~AshTestColorGenerator(); + + SkColor default_color() const { return default_color_; } + + // This method guarantees that two consequent callings get different colors. + SkColor GetAlternativeColor(); + + private: + const SkColor default_color_; + + // The next color to be returned by `GetAlternativeColor()`. + size_t next_color_index_ = 0; +}; + +} // namespace ash + +#endif // ASH_TEST_ASH_TEST_COLOR_GENERATOR_H_
diff --git a/ash/webui/camera_app_ui/camera_app_helper_impl.cc b/ash/webui/camera_app_ui/camera_app_helper_impl.cc index 8485651..1f2ce0f 100644 --- a/ash/webui/camera_app_ui/camera_app_helper_impl.cc +++ b/ash/webui/camera_app_ui/camera_app_helper_impl.cc
@@ -12,7 +12,7 @@ #include "base/callback_helpers.h" #include "base/notreached.h" #include "base/strings/string_number_conversions.h" -#include "base/trace_event/trace_event.h" +#include "base/trace_event/typed_macros.h" #include "chromeos/utils/pdf_conversion.h" #include "content/public/browser/web_contents.h" #include "net/base/url_util.h" @@ -143,11 +143,13 @@ } void CameraAppHelperImpl::StartPerfEventTrace(const std::string& event) { - TRACE_EVENT_BEGIN0("camera", event.c_str()); + TRACE_EVENT_BEGIN("camera", nullptr, [&](perfetto::EventContext ctx) { + ctx.event()->set_name(event); + }); } void CameraAppHelperImpl::StopPerfEventTrace(const std::string& event) { - TRACE_EVENT_END0("camera", event.c_str()); + TRACE_EVENT_END("camera"); } void CameraAppHelperImpl::SetTabletMonitor(
diff --git a/ash/webui/os_feedback_ui/backend/histogram_util.cc b/ash/webui/os_feedback_ui/backend/histogram_util.cc index 241923c..ef2a11e 100644 --- a/ash/webui/os_feedback_ui/backend/histogram_util.cc +++ b/ash/webui/os_feedback_ui/backend/histogram_util.cc
@@ -17,8 +17,23 @@ } void EmitFeedbackAppPreSubmitAction(mojom::FeedbackAppPreSubmitAction action) { - // TODO(longbowei) Add preSubmit actions and use switch case statement. - base::UmaHistogramBoolean(kFeedbackAppViewedScreenshot, true); + switch (action) { + case mojom::FeedbackAppPreSubmitAction::kViewedScreenshot: + base::UmaHistogramBoolean(kFeedbackAppViewedScreenshot, true); + break; + case mojom::FeedbackAppPreSubmitAction::kViewedImage: + base::UmaHistogramBoolean(kFeedbackAppViewedImage, true); + break; + case mojom::FeedbackAppPreSubmitAction::kViewedSystemAndAppInfo: + base::UmaHistogramBoolean(kFeedbackAppViewedSystemAndAppInfo, true); + break; + case mojom::FeedbackAppPreSubmitAction::kViewedMetrics: + base::UmaHistogramBoolean(kFeedbackAppViewedMetrics, true); + break; + // TODO(longbowei): Handle ViewedHelpContent case. + case mojom::FeedbackAppPreSubmitAction::kViewedHelpContent: + break; + } } void EmitFeedbackAppIncludedScreenshot(bool included_screenshot) {
diff --git a/ash/webui/os_feedback_ui/backend/histogram_util.h b/ash/webui/os_feedback_ui/backend/histogram_util.h index 96d68f5..a51a5fd 100644 --- a/ash/webui/os_feedback_ui/backend/histogram_util.h +++ b/ash/webui/os_feedback_ui/backend/histogram_util.h
@@ -20,6 +20,11 @@ "Feedback.ChromeOSApp.IncludedScreenshot"; constexpr char kFeedbackAppViewedScreenshot[] = "Feedback.ChromeOSApp.ViewedScreenshot"; +constexpr char kFeedbackAppViewedImage[] = "Feedback.ChromeOSApp.ViewedImage"; +constexpr char kFeedbackAppViewedMetrics[] = + "Feedback.ChromeOSApp.ViewedMetrics"; +constexpr char kFeedbackAppViewedSystemAndAppInfo[] = + "Feedback.ChromeOSApp.ViewedSystemAndAppInfo"; constexpr char kFeedbackAppCanContactUser[] = "Feedback.ChromeOSApp.CanContactUser"; constexpr char kFeedbackAppIncludedFile[] = "Feedback.ChromeOSApp.IncludedFile";
diff --git a/ash/webui/os_feedback_ui/resources/file_attachment.js b/ash/webui/os_feedback_ui/resources/file_attachment.js index 4062d70d4..314e1d4a 100644 --- a/ash/webui/os_feedback_ui/resources/file_attachment.js +++ b/ash/webui/os_feedback_ui/resources/file_attachment.js
@@ -15,7 +15,8 @@ import {I18nBehavior, I18nBehaviorInterface} from 'chrome://resources/js/i18n_behavior.m.js'; import {html, mixinBehaviors, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {AttachedFile} from './feedback_types.js'; +import {AttachedFile, FeedbackAppPreSubmitAction, FeedbackServiceProviderInterface} from './feedback_types.js'; +import {getFeedbackServiceProvider} from './mojo_interface_provider.js'; /** * @fileoverview @@ -80,6 +81,9 @@ * @protected {boolean} */ this.hasSelectedAFile_; + + /** @private {!FeedbackServiceProviderInterface} */ + this.feedbackServiceProvider_ = getFeedbackServiceProvider(); } ready() { @@ -155,6 +159,8 @@ handleSelectedImageClick_() { this.$.selectedImageDialog.showModal(); this.$.closeDialogButton.focus(); + this.feedbackServiceProvider_.recordPreSubmitAction( + FeedbackAppPreSubmitAction.kViewedImage); } /** @protected */
diff --git a/ash/webui/os_feedback_ui/resources/share_data_page.js b/ash/webui/os_feedback_ui/resources/share_data_page.js index c65d4813..a6fcb89 100644 --- a/ash/webui/os_feedback_ui/resources/share_data_page.js +++ b/ash/webui/os_feedback_ui/resources/share_data_page.js
@@ -316,13 +316,19 @@ const sysInfoLink = this.shadowRoot.querySelector('#sysInfoLink'); // Setting href causes <a> tag to display as link. sysInfoLink.setAttribute('href', '#'); - sysInfoLink.addEventListener( - 'click', (e) => void this.handleOpenSystemInfoDialog_(e)); + sysInfoLink.addEventListener('click', (e) => { + this.handleOpenSystemInfoDialog_(e); + this.feedbackServiceProvider_.recordPreSubmitAction( + FeedbackAppPreSubmitAction.kViewedSystemAndAppInfo); + }); const histogramsLink = this.shadowRoot.querySelector('#histogramsLink'); histogramsLink.setAttribute('href', '#'); - histogramsLink.addEventListener( - 'click', (e) => void this.handleOpenMetricsDialog_(e)); + histogramsLink.addEventListener('click', (e) => { + this.handleOpenMetricsDialog_(e); + this.feedbackServiceProvider_.recordPreSubmitAction( + FeedbackAppPreSubmitAction.kViewedMetrics); + }); } /** @private */
diff --git a/base/android/child_process_binding_types.h b/base/android/child_process_binding_types.h index a3900d5..7dec4263 100644 --- a/base/android/child_process_binding_types.h +++ b/base/android/child_process_binding_types.h
@@ -9,12 +9,13 @@ namespace android { // Defines the state of bindgings with child process. See ChildProcessConnection -// to see what the bindings are. Note these values are used as array indices. +// to see what the bindings are. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.base enum class ChildBindingState { UNBOUND, WAIVED, - MODERATE, + NOT_PERCEPTIBLE, + VISIBLE, STRONG, MAX_VALUE = STRONG };
diff --git a/base/android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java b/base/android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java index 873ca0d..f38f8c6b 100644 --- a/base/android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java +++ b/base/android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java
@@ -10,6 +10,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -48,8 +49,9 @@ */ public class ChildProcessConnection { private static final String TAG = "ChildProcessConn"; - private static final int NUM_BINDING_STATES = ChildBindingState.MAX_VALUE + 1; private static final int FALLBACK_TIMEOUT_IN_SECONDS = 10; + private static final boolean SUPPORT_NOT_PERCEPTIBLE_BINDING = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; /** * Used to notify the consumer about the process start. These callbacks will be invoked before @@ -121,6 +123,13 @@ } /** + * Run time check if not perceptible binding is supported. + */ + public static boolean supportNotPerceptibleBinding() { + return SUPPORT_NOT_PERCEPTIBLE_BINDING; + } + + /** * The string passed to bindToCaller to identify this class loader. */ @VisibleForTesting @@ -229,10 +238,14 @@ // Strong binding will make the service priority equal to the priority of the activity. private ChildServiceConnection mStrongBinding; - // Moderate binding will make the service priority equal to the priority of a visible process + // Visible binding will make the service priority equal to the priority of a visible process // while the app is in the foreground. // This is also used as the initial binding before any priorities are set. - private ChildServiceConnection mModerateBinding; + private ChildServiceConnection mVisibleBinding; + + // On Android Q+ a not perceptible binding will make the service priority below that of a + // perceptible process of a backgrounded app. Only created on Android Q+. + private ChildServiceConnection mNotPerceptibleBinding; // Low priority binding maintained in the entire lifetime of the connection, i.e. between calls // to start() and stop(). @@ -240,7 +253,8 @@ // Refcount of bindings. private int mStrongBindingCount; - private int mModerateBindingCount; + private int mVisibleBindingCount; + private int mNotPerceptibleBindingCount; private int mGroup; private int mImportanceInGroup; @@ -348,8 +362,14 @@ int defaultFlags = Context.BIND_AUTO_CREATE | (mBindAsExternalService ? Context.BIND_EXTERNAL_SERVICE : 0); - mModerateBinding = mConnectionFactory.createConnection( + mVisibleBinding = mConnectionFactory.createConnection( intent, defaultFlags, mConnectionDelegate, mInstanceName); + if (supportNotPerceptibleBinding()) { + mNotPerceptibleBinding = mConnectionFactory.createConnection(intent, + defaultFlags | Context.BIND_NOT_PERCEPTIBLE, mConnectionDelegate, + mInstanceName); + } + mStrongBinding = mConnectionFactory.createConnection( intent, defaultFlags | Context.BIND_IMPORTANT, mConnectionDelegate, mInstanceName); mWaivedBinding = mConnectionFactory.createConnection(intent, @@ -667,7 +687,8 @@ StringBuilder s = new StringBuilder(); s.append("bindings:"); s.append(mWaivedBinding.isBound() ? "W" : " "); - s.append(mModerateBinding.isBound() ? "M" : " "); + s.append(mVisibleBinding.isBound() ? "V" : " "); + s.append(supportNotPerceptibleBinding() && mNotPerceptibleBinding.isBound() ? "N" : " "); s.append(mStrongBinding.isBound() ? "S" : " "); return s.toString(); } @@ -792,8 +813,8 @@ mStrongBindingCount++; success = mStrongBinding.bindServiceConnection(); } else { - mModerateBindingCount++; - success = mModerateBinding.bindServiceConnection(); + mVisibleBindingCount++; + success = mVisibleBinding.bindServiceConnection(); } if (!success) { // Note this error condition is generally transient so `sAlwaysFallback` is @@ -832,10 +853,15 @@ assert mFallbackServiceName != null; Log.w(TAG, "Fallback to %s", mFallbackServiceName); boolean isStrongBindingBound = mStrongBinding.isBound(); - boolean isModerateBindingBound = mModerateBinding.isBound(); + boolean isVisibleBindingBound = mVisibleBinding.isBound(); + boolean isNotPerceptibleBindingBound = + supportNotPerceptibleBinding() && mNotPerceptibleBinding.isBound(); boolean isWaivedBindingBound = mWaivedBinding.isBound(); mStrongBinding.retire(); - mModerateBinding.retire(); + mVisibleBinding.retire(); + if (supportNotPerceptibleBinding()) { + mNotPerceptibleBinding.retire(); + } mWaivedBinding.retire(); createBindings(mFallbackServiceName); // Expect all bindings to succeed or fail together. So early out as soon as @@ -845,8 +871,13 @@ return false; } } - if (isModerateBindingBound) { - if (!mModerateBinding.bindServiceConnection()) { + if (isVisibleBindingBound) { + if (!mVisibleBinding.bindServiceConnection()) { + return false; + } + } + if (isNotPerceptibleBindingBound) { + if (!mNotPerceptibleBinding.bindServiceConnection()) { return false; } } @@ -866,7 +897,10 @@ mUnbound = true; mStrongBinding.unbindServiceConnection(); mWaivedBinding.unbindServiceConnection(); - mModerateBinding.unbindServiceConnection(); + if (supportNotPerceptibleBinding()) { + mNotPerceptibleBinding.unbindServiceConnection(); + } + mVisibleBinding.unbindServiceConnection(); updateBindingState(); if (mMemoryPressureCallback != null) { @@ -931,38 +965,76 @@ } } - public boolean isModerateBindingBound() { + public boolean isVisibleBindingBound() { assert isRunningOnLauncherThread(); - return mModerateBinding.isBound(); + return mVisibleBinding.isBound(); } - public int getModerateBindingCount() { + public int getVisibleBindingCount() { assert isRunningOnLauncherThread(); - return mModerateBindingCount; + return mVisibleBindingCount; } - public void addModerateBinding() { + public void addVisibleBinding() { assert isRunningOnLauncherThread(); if (!isConnected()) { Log.w(TAG, "The connection is not bound for %d", getPid()); return; } - if (mModerateBindingCount == 0) { - mModerateBinding.bindServiceConnection(); + if (mVisibleBindingCount == 0) { + mVisibleBinding.bindServiceConnection(); updateBindingState(); } - mModerateBindingCount++; + mVisibleBindingCount++; } - public void removeModerateBinding() { + public void removeVisibleBinding() { assert isRunningOnLauncherThread(); if (!isConnected()) { return; } - assert mModerateBindingCount > 0; - mModerateBindingCount--; - if (mModerateBindingCount == 0) { - mModerateBinding.unbindServiceConnection(); + assert mVisibleBindingCount > 0; + mVisibleBindingCount--; + if (mVisibleBindingCount == 0) { + mVisibleBinding.unbindServiceConnection(); + updateBindingState(); + } + } + + public boolean isNotPerceptibleBindingBound() { + assert isRunningOnLauncherThread(); + return supportNotPerceptibleBinding() && mNotPerceptibleBinding.isBound(); + } + + public int getNotPerceptibleBindingCount() { + assert isRunningOnLauncherThread(); + return mNotPerceptibleBindingCount; + } + + public void addNotPerceptibleBinding() { + assert isRunningOnLauncherThread(); + assert supportNotPerceptibleBinding(); + if (!isConnected()) { + Log.w(TAG, "The connection is not bound for %d", getPid()); + return; + } + if (mNotPerceptibleBindingCount == 0) { + mNotPerceptibleBinding.bindServiceConnection(); + updateBindingState(); + } + mNotPerceptibleBindingCount++; + } + + public void removeNotPerceptibleBinding() { + assert isRunningOnLauncherThread(); + assert supportNotPerceptibleBinding(); + if (!isConnected()) { + return; + } + assert mNotPerceptibleBindingCount > 0; + mNotPerceptibleBindingCount--; + if (mNotPerceptibleBindingCount == 0) { + mNotPerceptibleBinding.unbindServiceConnection(); updateBindingState(); } } @@ -1018,8 +1090,10 @@ newBindingState = ChildBindingState.UNBOUND; } else if (mStrongBinding.isBound()) { newBindingState = ChildBindingState.STRONG; - } else if (mModerateBinding.isBound()) { - newBindingState = ChildBindingState.MODERATE; + } else if (mVisibleBinding.isBound()) { + newBindingState = ChildBindingState.VISIBLE; + } else if (supportNotPerceptibleBinding() && mNotPerceptibleBinding.isBound()) { + newBindingState = ChildBindingState.NOT_PERCEPTIBLE; } else { assert mWaivedBinding.isBound(); newBindingState = ChildBindingState.WAIVED;
diff --git a/base/android/junit/src/org/chromium/base/process_launcher/ChildProcessConnectionTest.java b/base/android/junit/src/org/chromium/base/process_launcher/ChildProcessConnectionTest.java index ffbccdc..5bc8772e 100644 --- a/base/android/junit/src/org/chromium/base/process_launcher/ChildProcessConnectionTest.java +++ b/base/android/junit/src/org/chromium/base/process_launcher/ChildProcessConnectionTest.java
@@ -237,7 +237,7 @@ ChildProcessConnection connection = createDefaultTestConnection(); assertNotNull(mFirstServiceConnection); connection.start(false /* useStrongBinding */, mServiceCallback); - Assert.assertTrue(connection.isModerateBindingBound()); + Assert.assertTrue(connection.isVisibleBindingBound()); Assert.assertFalse(connection.didOnServiceConnectedForTesting()); verify(mServiceCallback, never()).onChildStarted(); verify(mServiceCallback, never()).onChildStartFailed(any()); @@ -260,7 +260,7 @@ doReturn(false).when(mFirstServiceConnection).bindServiceConnection(); connection.start(false /* useStrongBinding */, mServiceCallback); - Assert.assertFalse(connection.isModerateBindingBound()); + Assert.assertFalse(connection.isVisibleBindingBound()); Assert.assertFalse(connection.didOnServiceConnectedForTesting()); verify(mServiceCallback, never()).onChildStarted(); verify(mServiceCallback, never()).onChildStartFailed(any()); @@ -501,10 +501,15 @@ verify(mConnectionCallback, times(1)).onConnected(connection); // Add strong binding so that connection is oom protected. - connection.removeModerateBinding(); + connection.removeVisibleBinding(); assertEquals(ChildBindingState.WAIVED, connection.bindingStateCurrentOrWhenDied()); - connection.addModerateBinding(); - assertEquals(ChildBindingState.MODERATE, connection.bindingStateCurrentOrWhenDied()); + if (ChildProcessConnection.supportNotPerceptibleBinding()) { + connection.addNotPerceptibleBinding(); + assertEquals( + ChildBindingState.NOT_PERCEPTIBLE, connection.bindingStateCurrentOrWhenDied()); + } + connection.addVisibleBinding(); + assertEquals(ChildBindingState.VISIBLE, connection.bindingStateCurrentOrWhenDied()); connection.addStrongBinding(); assertEquals(ChildBindingState.STRONG, connection.bindingStateCurrentOrWhenDied());
diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc index 58f05f20..0d157d14 100644 --- a/base/test/launcher/unit_test_launcher.cc +++ b/base/test/launcher/unit_test_launcher.cc
@@ -39,10 +39,6 @@ #include "base/files/file_descriptor_watcher_posix.h" #endif -#if BUILDFLAG(IS_WIN) -#include "base/debug/handle_hooks_win.h" -#endif - namespace base { namespace { @@ -174,9 +170,6 @@ force_single_process = true; } } -#if BUILDFLAG(IS_WIN) - base::debug::HandleHooks::PatchLoadedModules(); -#endif // BUILDFLAG(IS_WIN) if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestHelpFlag) || CommandLine::ForCurrentProcess()->HasSwitch(kGTestListTestsFlag) ||
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 2b749fb..a20191c9 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc
@@ -80,6 +80,8 @@ #include <crtdbg.h> #endif // _DEBUG #include <windows.h> + +#include "base/debug/handle_hooks_win.h" #endif // BUILDFLAG(IS_WIN) namespace base { @@ -340,6 +342,10 @@ void TestSuite::PreInitialize() { DCHECK(!is_initialized_); +#if BUILDFLAG(IS_WIN) + base::debug::HandleHooks::PatchLoadedModules(); +#endif // BUILDFLAG(IS_WIN) + // The default death_test_style of "fast" is a frequent source of subtle test // flakiness. And on some platforms like macOS, use of system libraries after // fork() but before exec() is unsafe. Using the threadsafe style by default
diff --git a/build/add_rts_filters.py b/build/add_rts_filters.py index c98cf8d..4186c39 100755 --- a/build/add_rts_filters.py +++ b/build/add_rts_filters.py
@@ -2,11 +2,10 @@ # Copyright (c) 2021 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Creates a dummy RTS filter file and a dummy inverse filter file if a - real ones do not exist yet. Real filter files (and their inverse) are - generated by the RTS binary for suites with any skippable tests. The - rest of the suites need to have dummy files because gn will expect the - file to be present. +"""Creates a dummy RTS filter file if a real one doesn't exist yes. + Real filter files are generated by the RTS binary for suites with any + skippable tests. The rest of the suites need to have dummy files because gn + will expect the file to be present. Implementation uses try / except because the filter files are written relatively close to when this code creates the dummy files. @@ -23,15 +22,6 @@ def main(): filter_file = sys.argv[1] - # '*' is a dummy that means run everything - write_filter_file(filter_file, '*') - - inverted_filter_file = sys.argv[1] - # '-*' is a dummy that means run nothing - write_filter_file(inverted_filter_file, '-*') - - -def write_filter_file(filter_file, filter_string): directory = os.path.dirname(filter_file) try: os.makedirs(directory) @@ -40,6 +30,7 @@ pass else: raise + try: fp = os.open(filter_file, os.O_CREAT | os.O_EXCL | os.O_WRONLY) except OSError as err: @@ -49,7 +40,7 @@ raise else: with os.fdopen(fp, 'w') as file_obj: - file_obj.write(filter_string) + file_obj.write('*') # '*' is a dummy that means run everything if __name__ == '__main__':
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index ef8ac01..c909fba 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni
@@ -3885,16 +3885,8 @@ action("${invoker.target_name}__rts_filters") { script = "//build/add_rts_filters.py" rts_file = "${root_build_dir}/gen/rts/${invoker.target_name}.filter" - inverted_rts_file = - "${root_build_dir}/gen/rts/${invoker.target_name}_inverted.filter" - args = [ - rebase_path(rts_file, root_build_dir), - rebase_path(inverted_rts_file, root_build_dir), - ] - outputs = [ - rts_file, - inverted_rts_file, - ] + args = [ rebase_path(rts_file, root_build_dir) ] + outputs = [ rts_file ] } } _incremental_apk = !(defined(invoker.never_incremental) &&
diff --git a/build/util/version_test.py b/build/util/version_test.py index bbd14d8..375f382f 100644 --- a/build/util/version_test.py +++ b/build/util/version_test.py
@@ -105,15 +105,13 @@ get_new_args=lambda args: self._EXAMPLE_ANDROID_ARGS) contents = output['contents'] - self.assertRegexpMatches(contents, r'\bchrome_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\bchrome_modern_version_code = "\d+"\s') - self.assertRegexpMatches(contents, r'\bmonochrome_version_code = "\d+"\s') - self.assertRegexpMatches(contents, r'\btrichrome_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\bwebview_stable_version_code = "\d+"\s') - self.assertRegexpMatches(contents, r'\bwebview_beta_version_code = "\d+"\s') - self.assertRegexpMatches(contents, r'\bwebview_dev_version_code = "\d+"\s') + self.assertRegex(contents, r'\bchrome_version_code = "\d+"\s') + self.assertRegex(contents, r'\bchrome_modern_version_code = "\d+"\s') + self.assertRegex(contents, r'\bmonochrome_version_code = "\d+"\s') + self.assertRegex(contents, r'\btrichrome_version_code = "\d+"\s') + self.assertRegex(contents, r'\bwebview_stable_version_code = "\d+"\s') + self.assertRegex(contents, r'\bwebview_beta_version_code = "\d+"\s') + self.assertRegex(contents, r'\bwebview_dev_version_code = "\d+"\s') def testBuildOutputAndroidArchVariantsArm64(self): """Assert 64-bit-specific version codes""" @@ -129,14 +127,10 @@ output = self._RunBuildOutput(get_new_args=lambda args: new_args) contents = output['contents'] - self.assertRegexpMatches(contents, - r'\bmonochrome_64_32_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\bmonochrome_64_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\btrichrome_64_32_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\btrichrome_64_version_code = "\d+"\s') + self.assertRegex(contents, r'\bmonochrome_64_32_version_code = "\d+"\s') + self.assertRegex(contents, r'\bmonochrome_64_version_code = "\d+"\s') + self.assertRegex(contents, r'\btrichrome_64_32_version_code = "\d+"\s') + self.assertRegex(contents, r'\btrichrome_64_version_code = "\d+"\s') def testBuildOutputAndroidArchVariantsX64(self): """Assert 64-bit-specific version codes""" @@ -152,14 +146,10 @@ output = self._RunBuildOutput(get_new_args=lambda args: new_args) contents = output['contents'] - self.assertRegexpMatches(contents, - r'\bmonochrome_64_32_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\bmonochrome_64_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\btrichrome_64_32_version_code = "\d+"\s') - self.assertRegexpMatches(contents, - r'\btrichrome_64_version_code = "\d+"\s') + self.assertRegex(contents, r'\bmonochrome_64_32_version_code = "\d+"\s') + self.assertRegex(contents, r'\bmonochrome_64_version_code = "\d+"\s') + self.assertRegex(contents, r'\btrichrome_64_32_version_code = "\d+"\s') + self.assertRegex(contents, r'\btrichrome_64_version_code = "\d+"\s') def testBuildOutputAndroidChromeArchInput(self): """Assert it raises an exception when using an invalid architecture input"""
diff --git a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorTest.java b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorTest.java index 4611dd80..7d5deec 100644 --- a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorTest.java +++ b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabSelectionEditorTest.java
@@ -40,6 +40,7 @@ import org.chromium.base.test.util.Batch; 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.Feature; import org.chromium.base.test.util.FlakyTest; import org.chromium.base.test.util.Restriction; @@ -320,6 +321,7 @@ @MediumTest @EnableFeatures({ChromeFeatureList.TAB_SELECTION_EDITOR_V2}) @Restriction({UiRestriction.RESTRICTION_TYPE_PHONE}) + @DisabledTest(message = "https://crbug.com/1352950") public void testConfigureToolbarMenuItems() { prepareBlankTab(2, false); List<Tab> tabs = getTabsInCurrentTabModel(); @@ -348,6 +350,9 @@ closeId, "Close"); verifyToolbarMenuItemState(groupId, /*enabled=*/true); + // TODO(crbug.com/1352950): This step failed to deselect the first tab. It is likely + // verifyToolbarMenuItemState() left the menu open (race condition?) so the deselect click + // got consumed prior to clicking on the tab. for (int i = 0; i < tabs.size(); i++) { mRobot.actionRobot.clickItemAtAdapterPosition(i); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java index 617b2d9..751bd82 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -2495,15 +2495,15 @@ intent, IntentHandler.EXTRA_OPEN_ADDITIONAL_URLS_IN_TAB_GROUP, false); if (additionalUrls != null) { final Tab parent = openAdditionalUrlsInTabGroup ? firstTab : null; + @TabLaunchType + int additionalUrlLaunchType = openAdditionalUrlsInTabGroup + ? TabLaunchType.FROM_LONGPRESS_BACKGROUND_IN_GROUP + : TabLaunchType.FROM_RESTORE; for (int i = 0; i < additionalUrls.size(); i++) { - // Tabs with a parent are always inserted at parent_index +1. In order for the - // final order of tabs to reflect the order given in additionalUrls, we need to - // iterate in reverse order. - String url = parent == null ? additionalUrls.get(i) - : additionalUrls.get(additionalUrls.size() - i - 1); + String url = additionalUrls.get(i); LoadUrlParams copy = LoadUrlParams.copy(loadUrlParams); copy.setUrl(url); - tabCreator.createNewTab(copy, TabLaunchType.FROM_RESTORE, parent); + tabCreator.createNewTab(copy, additionalUrlLaunchType, parent); } } return firstTab;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java index 8da62ff..6b2621a2 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java
@@ -49,6 +49,7 @@ import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.TabCreator; import org.chromium.chrome.browser.tabmodel.document.TabDelegate; +import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager.SnackbarController; @@ -257,6 +258,11 @@ public void onOptOut() { onHistoryClustersOptOutChanged(false); } + + @Override + public boolean areTabGroupsEnabled() { + return TabUiFeatureUtilities.isTabGroupsAndroidEnabled(mActivity); + } }; mHistoryClustersCoordinator = new HistoryClustersCoordinator(
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ChromePaymentRequestService.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ChromePaymentRequestService.java index a1e67a1b..0b2e55f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ChromePaymentRequestService.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ChromePaymentRequestService.java
@@ -10,7 +10,6 @@ import androidx.annotation.Nullable; import org.chromium.chrome.browser.app.ChromeActivity; -import org.chromium.chrome.browser.autofill.PersonalDataManager; import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher; import org.chromium.chrome.browser.payments.ui.PaymentUiService; import org.chromium.chrome.browser.tabmodel.TabModel; @@ -366,9 +365,7 @@ // Implements BrowserPaymentRequest: @Override public void onInstrumentDetailsLoading() { - assert mPaymentUiService.getSelectedPaymentApp() == null - || mPaymentUiService.getSelectedPaymentApp().getPaymentAppType() - == PaymentAppType.AUTOFILL; + assert mPaymentUiService.getSelectedPaymentApp() == null; mPaymentUiService.showProcessingMessage(); } @@ -383,7 +380,7 @@ mPaymentUiService.getSelectedContact(), selectedPaymentApp, mSpec.getPaymentOptions()); mPaymentRequestService.invokePaymentApp(selectedPaymentApp, paymentResponseHelper); - return selectedPaymentApp.getPaymentAppType() != PaymentAppType.AUTOFILL; + return true; } private PaymentHandlerHost getPaymentHandlerHost() { @@ -485,15 +482,6 @@ // Implements BrowserPaymentRequest: @Override public void onInstrumentDetailsReady() { - // If the payment app was an Autofill credit card with an identifier, record its use. - PaymentApp selectedPaymentApp = mPaymentUiService.getSelectedPaymentApp(); - if (selectedPaymentApp != null - && selectedPaymentApp.getPaymentAppType() == PaymentAppType.AUTOFILL - && !selectedPaymentApp.getIdentifier().isEmpty()) { - PersonalDataManager.getInstance().recordAndLogCreditCardUse( - selectedPaymentApp.getIdentifier()); - } - // Showing the app selector UI if we were previously skipping it so the loading // spinner shows up until the merchant notifies that payment was completed. if (mHasSkippedAppSelector) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentAppComparator.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentAppComparator.java index 6bb2f3a..030db7b0 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentAppComparator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentAppComparator.java
@@ -8,7 +8,6 @@ import org.chromium.chrome.browser.payments.PaymentPreferencesUtil; import org.chromium.components.autofill.Completable; import org.chromium.components.payments.PaymentApp; -import org.chromium.components.payments.PaymentAppType; import org.chromium.components.payments.PaymentRequestParams; import org.chromium.payments.mojom.PaymentOptions; @@ -82,22 +81,16 @@ /** * Sorts the payment apps by several rules: - * Rule 1: Non-autofill before autofill. - * Rule 2: Complete apps before incomplete apps. - * Rule 3: When shipping address is requested, apps which will handle shipping address before + * Rule 1: Complete apps before incomplete apps. + * Rule 2: When shipping address is requested, apps which will handle shipping address before * others. - * Rule 4: When payer's contact information is requested, apps which will handle more required + * Rule 3: When payer's contact information is requested, apps which will handle more required * contact fields (name, email, phone) come before others. - * Rule 5: Preselectable apps before non-preselectable apps. - * Rule 6: Frequently and recently used apps before rarely and non-recently used apps. + * Rule 4: Preselectable apps before non-preselectable apps. + * Rule 5: Frequently and recently used apps before rarely and non-recently used apps. */ @Override public int compare(PaymentApp a, PaymentApp b) { - // Non-autofill apps first. - int autofill = (a.getPaymentAppType() == PaymentAppType.AUTOFILL ? 1 : 0) - - (b.getPaymentAppType() == PaymentAppType.AUTOFILL ? 1 : 0); - if (autofill != 0) return autofill; - // Complete cards before cards with missing information. int completeness = compareCompletablesByCompleteness(b, a); if (completeness != 0) return completeness; @@ -142,4 +135,4 @@ // More frequently and recently used apps first. return compareAppsByRankingScore(b, a); } -} \ No newline at end of file +}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java index 7ec8e9f..3c95898 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java
@@ -51,8 +51,6 @@ import org.chromium.components.browser_ui.widget.FadingEdgeScrollView; import org.chromium.components.browser_ui.widget.animation.FocusAnimator; import org.chromium.components.browser_ui.widget.animation.Interpolators; -import org.chromium.components.payments.PaymentApp; -import org.chromium.components.payments.PaymentAppType; import org.chromium.components.payments.PaymentFeatureList; import org.chromium.components.signin.base.CoreAccountInfo; import org.chromium.components.signin.identitymanager.ConsentLevel; @@ -494,6 +492,7 @@ mBottomBar = (ViewGroup) mRequestView.findViewById(R.id.bottom_bar); mPayButton = (Button) mBottomBar.findViewById(R.id.button_primary); mPayButton.setOnClickListener(this); + mPayButton.setText(R.string.payments_continue_button); mEditButton = (Button) mBottomBar.findViewById(R.id.button_secondary); mEditButton.setOnClickListener(this); @@ -1010,13 +1009,6 @@ && mPaymentMethodSectionInformation.getSelectedItem() != null && !mIsClientCheckingSelection && !mIsEditingPaymentItem && !mIsClosing); - PaymentApp selectedApp = mPaymentMethodSectionInformation == null - ? null - : (PaymentApp) mPaymentMethodSectionInformation.getSelectedItem(); - mPayButton.setText( - selectedApp != null && selectedApp.getPaymentAppType() != PaymentAppType.AUTOFILL - ? R.string.payments_continue_button - : R.string.payments_pay_button); mReadyToPayNotifierForTest.run(); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/share/crow/CrowButtonDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/share/crow/CrowButtonDelegateImpl.java index 0b77aac..b105962 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/share/crow/CrowButtonDelegateImpl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/share/crow/CrowButtonDelegateImpl.java
@@ -59,7 +59,14 @@ callback.onResult(false); return; } - // Check our (current) exact list first. + + // Any host present in the denylist should not have the feature enabled. + if (CrowBridge.denylistContainsHost(url.getHost())) { + callback.onResult(false); + return; + } + + // Check for an exact match against our allowlist. // Fall back to page optimizations if the study param is enabled. if (!getPublicationId(url).equals(DOMAIN_ID_NONE)) { callback.onResult(true); @@ -130,8 +137,8 @@ private String getPublicationId(GURL url) { String host = url.getHost(); - // First check the downloaded component. - String publicationID = CrowBridge.getPublicationIDForHost(host); + // Check the allowlist for an exact match. + String publicationID = CrowBridge.getPublicationIDFromAllowlist(host); if (!publicationID.isEmpty()) { return publicationID; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/RequestDesktopUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/RequestDesktopUtils.java index 1cac7bf..73505c78 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/RequestDesktopUtils.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/RequestDesktopUtils.java
@@ -19,6 +19,7 @@ import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.profiles.Profile; +import org.chromium.chrome.browser.tab.TabUtils.LoadIfNeededCaller; import org.chromium.components.browser_ui.site_settings.SingleCategorySettings; import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory; import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge; @@ -52,6 +53,15 @@ static final String PARAM_SHOW_MESSAGE_ON_GLOBAL_SETTING_DEFAULT_ON = "show_message_on_default_on"; + static final String PARAM_GLOBAL_SETTING_OPT_IN_ENABLED = "show_opt_in_message"; + static final String PARAM_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES = + "opt_in_display_size_min_threshold_inches"; + static final double DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES = 10.0; + static final String PARAM_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MAX_THRESHOLD_INCHES = + "opt_in_display_size_max_threshold_inches"; + static final double DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MAX_THRESHOLD_INCHES = + Double.MAX_VALUE; + // Note: these values must match the UserAgentRequestType enum in enums.xml. @IntDef({UserAgentRequestType.REQUEST_DESKTOP, UserAgentRequestType.REQUEST_MOBILE}) @Retention(RetentionPolicy.SOURCE) @@ -156,11 +166,18 @@ * @param displaySizeInInches The device primary display size, in inches. * @return Whether the desktop site global setting should be default-enabled. */ - public static boolean shouldDefaultEnableGlobalSetting(double displaySizeInInches) { + static boolean shouldDefaultEnableGlobalSetting(double displaySizeInInches) { if (!ChromeFeatureList.isEnabled(ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS)) { return false; } + // If the device is part of an opt-in experiment arm, avoid default-enabling the setting. + if (ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean( + ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS, + PARAM_GLOBAL_SETTING_OPT_IN_ENABLED, false)) { + return false; + } + // Check whether default-on for low end devices is disabled. if (!ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean( ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS, @@ -267,4 +284,103 @@ ChromePreferenceKeys.DEFAULT_ENABLED_DESKTOP_SITE_GLOBAL_SETTING_SHOW_MESSAGE); return true; } + + /** + * @param displaySizeInInches The device primary display size, in inches. + * @param profile The current {@link Profile}. + * @return Whether the message to opt-in to the desktop site global setting should be shown. + */ + static boolean shouldShowGlobalSettingOptInMessage( + double displaySizeInInches, Profile profile) { + if (!ChromeFeatureList.isEnabled(ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS)) { + return false; + } + + // Present the message only if opt-in is enabled. + if (!ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean( + ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS, + PARAM_GLOBAL_SETTING_OPT_IN_ENABLED, false)) { + return false; + } + + // Present the message at most once on a device. + if (SharedPreferencesManager.getInstance().contains( + ChromePreferenceKeys.DESKTOP_SITE_GLOBAL_SETTING_OPT_IN_MESSAGE_SHOWN)) { + return false; + } + + // Present the message only if the user has not previously updated the global setting. + if (SharedPreferencesManager.getInstance().contains( + SingleCategorySettings + .USER_ENABLED_DESKTOP_SITE_GLOBAL_SETTING_PREFERENCE_KEY)) { + return false; + } + + // Present the message only if the desktop site global setting is off. + if (WebsitePreferenceBridge.isCategoryEnabled( + profile, ContentSettingsType.REQUEST_DESKTOP_SITE)) { + return false; + } + + // Present the message only if the device falls within the range of screen sizes for the + // opt-in. + return displaySizeInInches >= ChromeFeatureList.getFieldTrialParamByFeatureAsDouble( + ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS, + PARAM_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES, + DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES) + && displaySizeInInches < ChromeFeatureList.getFieldTrialParamByFeatureAsDouble( + ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS, + PARAM_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MAX_THRESHOLD_INCHES, + DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MAX_THRESHOLD_INCHES); + } + + /** + * Creates and shows a message to the user to opt-in to the desktop site global setting based on + * device conditions. + * @param displaySizeInInches The device primary display size, in inches. + * @param profile The current {@link Profile}. + * @param messageDispatcher The {@link MessageDispatcher} to enqueue the message. + * @param context The current context. + * @param tab The {@link Tab} where the message is shown. + * @return Whether the opt-in message was shown. + */ + public static boolean maybeShowGlobalSettingOptInMessage(double displaySizeInInches, + Profile profile, MessageDispatcher messageDispatcher, Context context, Tab tab) { + if (messageDispatcher == null) return false; + + if (!shouldShowGlobalSettingOptInMessage(displaySizeInInches, profile)) { + return false; + } + + Resources resources = context.getResources(); + PropertyModel message = + new PropertyModel.Builder(MessageBannerProperties.ALL_KEYS) + .with(MessageBannerProperties.MESSAGE_IDENTIFIER, + MessageIdentifier.DESKTOP_SITE_GLOBAL_OPT_IN) + .with(MessageBannerProperties.TITLE, + resources.getString(R.string.rds_global_opt_in_message_title)) + .with(MessageBannerProperties.ICON_RESOURCE_ID, + R.drawable.ic_desktop_windows) + .with(MessageBannerProperties.PRIMARY_BUTTON_TEXT, + resources.getString(R.string.yes)) + .with(MessageBannerProperties.ON_PRIMARY_ACTION, + () -> { + WebsitePreferenceBridge.setCategoryEnabled(profile, + ContentSettingsType.REQUEST_DESKTOP_SITE, true); + // TODO(crbug.com/1350274): Remove this explicit load when this + // bug is addressed. + if (tab != null) { + tab.loadIfNeeded( + LoadIfNeededCaller + .MAYBE_SHOW_GLOBAL_SETTING_OPT_IN_MESSAGE); + } + return PrimaryActionClickBehavior.DISMISS_IMMEDIATELY; + }) + .build(); + + messageDispatcher.enqueueWindowScopedMessage(message, false); + SharedPreferencesManager.getInstance().writeBoolean( + ChromePreferenceKeys.DESKTOP_SITE_GLOBAL_SETTING_OPT_IN_MESSAGE_SHOWN, true); + return true; + } } \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabUtils.java index 0fa88e9..e108fc0 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabUtils.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabUtils.java
@@ -66,7 +66,8 @@ @IntDef({LoadIfNeededCaller.SET_TAB, LoadIfNeededCaller.ON_ACTIVITY_SHOWN, LoadIfNeededCaller.ON_ACTIVITY_SHOWN_THEN_SHOW, LoadIfNeededCaller.REQUEST_TO_SHOW_TAB, LoadIfNeededCaller.REQUEST_TO_SHOW_TAB_THEN_SHOW, - LoadIfNeededCaller.ON_FINISH_NATIVE_INITIALIZATION, LoadIfNeededCaller.OTHER}) + LoadIfNeededCaller.ON_FINISH_NATIVE_INITIALIZATION, + LoadIfNeededCaller.MAYBE_SHOW_GLOBAL_SETTING_OPT_IN_MESSAGE, LoadIfNeededCaller.OTHER}) @Retention(RetentionPolicy.SOURCE) public @interface LoadIfNeededCaller { int SET_TAB = 0; @@ -75,7 +76,8 @@ int REQUEST_TO_SHOW_TAB = 3; int REQUEST_TO_SHOW_TAB_THEN_SHOW = 4; int ON_FINISH_NATIVE_INITIALIZATION = 5; - int OTHER = 6; + int MAYBE_SHOW_GLOBAL_SETTING_OPT_IN_MESSAGE = 6; + int OTHER = 7; } // Do not instantiate this class.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java index a6cb694..5596ce0 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabbed_mode/TabbedRootUiCoordinator.java
@@ -658,6 +658,12 @@ } if (!didTriggerPromo) { + didTriggerPromo = RequestDesktopUtils.maybeShowGlobalSettingOptInMessage( + getPrimaryDisplaySizeInInches(), Profile.getLastUsedRegularProfile(), + mMessageDispatcher, mActivity, mActivityTabProvider.get()); + } + + if (!didTriggerPromo) { didTriggerPromo = RequestDesktopUtils.maybeShowDefaultEnableGlobalSettingMessage( Profile.getLastUsedRegularProfile(), mMessageDispatcher, mActivity); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java index 20c731a..7d22e27 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java
@@ -818,7 +818,7 @@ /** * @return The primary display size of the device, in inches. */ - private double getPrimaryDisplaySizeInInches() { + protected double getPrimaryDisplaySizeInInches() { DisplayAndroid display = DisplayAndroid.getNonMultiDisplay(mActivity); double xInches = display.getDisplayWidth() / display.getXdpi(); double yInches = display.getDisplayHeight() / display.getYdpi();
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinatorTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinatorTest.java index 86ff4fe..27d1549 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinatorTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinatorTest.java
@@ -7,6 +7,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyString; @@ -100,7 +101,7 @@ @Override public boolean isSeparateActivity() { - return true; + return mIsSeparateActivity; } @Override @@ -156,6 +157,11 @@ public void markVisitForRemoval(ClusterVisit clusterVisit) { mVisitsForRemoval.add(clusterVisit); } + + @Override + public boolean areTabGroupsEnabled() { + return mAreTabGroupsEnabled; + } } @Rule @@ -204,6 +210,8 @@ new TestHistoryClustersDelegate(); private List<ClusterVisit> mVisitsForRemoval = new ArrayList<>(); private SelectionDelegate<ClusterVisit> mSelectionDelegate = new SelectionDelegate<>(); + private boolean mIsSeparateActivity = true; + private boolean mAreTabGroupsEnabled = true; @Before public void setUp() { @@ -465,6 +473,31 @@ mActivity.getString(R.string.accessibility_list_remove_button, mVisit2.getTitle())); } + @Test + public void testMenuItemVisibility() { + mIsSeparateActivity = false; + mAreTabGroupsEnabled = false; + mHistoryClustersCoordinator.inflateActivityView(); + HistoryClustersToolbar toolbar = mHistoryClustersCoordinator.getActivityContentView() + .findViewById(R.id.selectable_list) + .findViewById(R.id.action_bar); + + assertNotNull(toolbar); + assertNull(toolbar.getMenu().findItem(R.id.close_menu_id)); + assertNull(toolbar.getMenu().findItem(R.id.selection_mode_open_in_tab_group)); + + mIsSeparateActivity = true; + mAreTabGroupsEnabled = true; + mHistoryClustersCoordinator.inflateActivityView(); + toolbar = mHistoryClustersCoordinator.getActivityContentView() + .findViewById(R.id.selectable_list) + .findViewById(R.id.action_bar); + + assertNotNull(toolbar); + assertNotNull(toolbar.getMenu().findItem(R.id.close_menu_id)); + assertNotNull(toolbar.getMenu().findItem(R.id.selection_mode_open_in_tab_group)); + } + private <T> void fulfillPromise(Promise<T> promise, T result) { promise.fulfill(result); ShadowLooper.idleMainLooper();
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 42e49fe..3a68c38c 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
@@ -44,6 +44,7 @@ import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.tab.RequestDesktopUtilsUnitTest.ShadowSysUtils; +import org.chromium.chrome.browser.tab.TabUtils.LoadIfNeededCaller; import org.chromium.components.browser_ui.site_settings.SingleCategorySettings; import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge; import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridgeJni; @@ -83,6 +84,8 @@ private MessageDispatcher mMessageDispatcher; @Mock private Activity mActivity; + @Mock + private Profile mProfile; private @ContentSettingValues int mRdsDefaultValue; private SharedPreferencesManager mSharedPreferencesManager; @@ -91,6 +94,8 @@ private final GURL mGoogleUrl = new GURL(JUnitTestGURLs.GOOGLE_URL); private final GURL mMapsUrl = new GURL(JUnitTestGURLs.MAPS_URL); + private Resources mResources; + private final TestValues mTestValues = new TestValues(); @Implements(SysUtils.class) @@ -142,6 +147,9 @@ mSharedPreferencesManager = SharedPreferencesManager.getInstance(); mSharedPreferencesManager.disableKeyCheckerForTesting(); + + mResources = ApplicationProvider.getApplicationContext().getResources(); + when(mActivity.getResources()).thenReturn(mResources); } @After @@ -321,22 +329,33 @@ } @Test + public void testMaybeDefaultEnableGlobalSetting_DoNotEnableOnOptInEnabled() { + Map<String, String> params = new HashMap<>(); + params.put(RequestDesktopUtils.PARAM_GLOBAL_SETTING_OPT_IN_ENABLED, "true"); + enableFeatureRequestDesktopSiteDefaults(params); + + boolean didDefaultEnable = RequestDesktopUtils.maybeDefaultEnableGlobalSetting( + RequestDesktopUtils.DEFAULT_GLOBAL_SETTING_DEFAULT_ON_DISPLAY_SIZE_THRESHOLD_INCHES, + Mockito.mock(Profile.class)); + Assert.assertFalse( + "Desktop site global setting should not be default-enabled when opt-in is enabled.", + didDefaultEnable); + } + + @Test public void testMaybeShowDefaultEnableGlobalSettingMessage() { enableFeatureRequestDesktopSiteDefaults(null); - Resources resources = ApplicationProvider.getApplicationContext().getResources(); - when(mActivity.getResources()).thenReturn(resources); - Profile profile = mock(Profile.class); // Default-enable the global setting before the message is shown. RequestDesktopUtils.maybeDefaultEnableGlobalSetting( RequestDesktopUtils.DEFAULT_GLOBAL_SETTING_DEFAULT_ON_DISPLAY_SIZE_THRESHOLD_INCHES, - profile); + mProfile); when(mWebsitePreferenceBridgeJniMock.isContentSettingEnabled( - profile, ContentSettingsType.REQUEST_DESKTOP_SITE)) + mProfile, ContentSettingsType.REQUEST_DESKTOP_SITE)) .thenReturn(true); RequestDesktopUtils.maybeShowDefaultEnableGlobalSettingMessage( - profile, mMessageDispatcher, mActivity); + mProfile, mMessageDispatcher, mActivity); ArgumentCaptor<PropertyModel> message = ArgumentCaptor.forClass(PropertyModel.class); verify(mMessageDispatcher).enqueueWindowScopedMessage(message.capture(), eq(false)); @@ -344,10 +363,10 @@ MessageIdentifier.DESKTOP_SITE_GLOBAL_DEFAULT_OPT_OUT, message.getValue().get(MessageBannerProperties.MESSAGE_IDENTIFIER)); Assert.assertEquals("Message title should match.", - resources.getString(R.string.rds_global_default_on_message_title), + mResources.getString(R.string.rds_global_default_on_message_title), message.getValue().get(MessageBannerProperties.TITLE)); Assert.assertEquals("Message primary button text should match.", - resources.getString(R.string.rds_global_default_on_message_button), + mResources.getString(R.string.rds_global_default_on_message_button), message.getValue().get(MessageBannerProperties.PRIMARY_BUTTON_TEXT)); Assert.assertEquals("Message icon resource ID should match.", R.drawable.ic_desktop_windows, message.getValue().get(MessageBannerProperties.ICON_RESOURCE_ID)); @@ -361,7 +380,6 @@ @Test public void testMaybeShowDefaultEnableGlobalSettingMessage_DoNotShowIfSettingIsDisabled() { enableFeatureRequestDesktopSiteDefaults(null); - Profile profile = mock(Profile.class); // Preference is set when the setting is default-enabled. mSharedPreferencesManager.writeBoolean( @@ -370,11 +388,11 @@ // Simulate disabling of the setting by the user before the message is shown. when(mWebsitePreferenceBridgeJniMock.isContentSettingEnabled( - profile, ContentSettingsType.REQUEST_DESKTOP_SITE)) + mProfile, ContentSettingsType.REQUEST_DESKTOP_SITE)) .thenReturn(false); boolean shown = RequestDesktopUtils.maybeShowDefaultEnableGlobalSettingMessage( - profile, mMessageDispatcher, mActivity); + mProfile, mMessageDispatcher, mActivity); Assert.assertFalse( "Message should not be shown if the content setting is disabled.", shown); Assert.assertFalse( @@ -384,6 +402,82 @@ .DEFAULT_ENABLED_DESKTOP_SITE_GLOBAL_SETTING_SHOW_MESSAGE)); } + @Test + public void testMaybeShowGlobalSettingOptInMessage() { + Map<String, String> params = new HashMap<>(); + params.put(RequestDesktopUtils.PARAM_GLOBAL_SETTING_OPT_IN_ENABLED, "true"); + enableFeatureRequestDesktopSiteDefaults(params); + Tab tab = mock(Tab.class); + when(tab.loadIfNeeded(LoadIfNeededCaller.MAYBE_SHOW_GLOBAL_SETTING_OPT_IN_MESSAGE)) + .thenReturn(true); + + boolean shown = RequestDesktopUtils.maybeShowGlobalSettingOptInMessage( + RequestDesktopUtils.DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES, + mProfile, mMessageDispatcher, mActivity, tab); + Assert.assertTrue("Desktop site global setting opt-in message should be shown.", shown); + + ArgumentCaptor<PropertyModel> message = ArgumentCaptor.forClass(PropertyModel.class); + verify(mMessageDispatcher).enqueueWindowScopedMessage(message.capture(), eq(false)); + Assert.assertEquals("Message identifier should match.", + MessageIdentifier.DESKTOP_SITE_GLOBAL_OPT_IN, + message.getValue().get(MessageBannerProperties.MESSAGE_IDENTIFIER)); + Assert.assertEquals("Message title should match.", + mResources.getString(R.string.rds_global_opt_in_message_title), + message.getValue().get(MessageBannerProperties.TITLE)); + Assert.assertEquals("Message primary button text should match.", + mResources.getString(R.string.yes), + message.getValue().get(MessageBannerProperties.PRIMARY_BUTTON_TEXT)); + Assert.assertEquals("Message icon resource ID should match.", R.drawable.ic_desktop_windows, + message.getValue().get(MessageBannerProperties.ICON_RESOURCE_ID)); + Assert.assertTrue( + "SharedPreference DESKTOP_SITE_GLOBAL_SETTING_OPT_IN_MESSAGE_SHOWN should be true.", + mSharedPreferencesManager.readBoolean( + ChromePreferenceKeys.DESKTOP_SITE_GLOBAL_SETTING_OPT_IN_MESSAGE_SHOWN, + false)); + } + + @Test + public void testMaybeShowGlobalSettingOptInMessage_ShowAtMostOnce() { + Map<String, String> params = new HashMap<>(); + params.put(RequestDesktopUtils.PARAM_GLOBAL_SETTING_OPT_IN_ENABLED, "true"); + enableFeatureRequestDesktopSiteDefaults(params); + Tab tab = mock(Tab.class); + when(tab.loadIfNeeded(LoadIfNeededCaller.MAYBE_SHOW_GLOBAL_SETTING_OPT_IN_MESSAGE)) + .thenReturn(true); + + boolean shown = RequestDesktopUtils.maybeShowGlobalSettingOptInMessage( + RequestDesktopUtils.DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES, + mProfile, mMessageDispatcher, mActivity, tab); + + boolean shouldShow = RequestDesktopUtils.shouldShowGlobalSettingOptInMessage( + RequestDesktopUtils.DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES, + mProfile); + Assert.assertFalse( + "Desktop site global setting opt-in message should be shown at most once.", + shouldShow); + } + + @Test + public void testMaybeShowGlobalSettingOptInMessage_DoNotShowIfSettingIsEnabled() { + Map<String, String> params = new HashMap<>(); + params.put(RequestDesktopUtils.PARAM_GLOBAL_SETTING_OPT_IN_ENABLED, "true"); + enableFeatureRequestDesktopSiteDefaults(params); + Tab tab = mock(Tab.class); + when(tab.loadIfNeeded(LoadIfNeededCaller.MAYBE_SHOW_GLOBAL_SETTING_OPT_IN_MESSAGE)) + .thenReturn(true); + + when(mWebsitePreferenceBridgeJniMock.isContentSettingEnabled( + mProfile, ContentSettingsType.REQUEST_DESKTOP_SITE)) + .thenReturn(true); + + boolean shown = RequestDesktopUtils.maybeShowGlobalSettingOptInMessage( + RequestDesktopUtils.DEFAULT_GLOBAL_SETTING_OPT_IN_DISPLAY_SIZE_MIN_THRESHOLD_INCHES, + mProfile, mMessageDispatcher, mActivity, tab); + Assert.assertFalse( + "Desktop site global setting opt-in message should not be shown when the setting is already enabled.", + shown); + } + private void enableFeatureRequestDesktopSiteDefaults(Map<String, String> params) { mTestValues.addFeatureFlagOverride(ChromeFeatureList.REQUEST_DESKTOP_SITE_DEFAULTS, true); if (params != null) {
diff --git a/chrome/android/profiles/newest.txt b/chrome/android/profiles/newest.txt index cb7922a..a4deefb 100644 --- a/chrome/android/profiles/newest.txt +++ b/chrome/android/profiles/newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-106.0.5240.0_rc-r1-merged.afdo.bz2 +chromeos-chrome-amd64-106.0.5241.0_rc-r1-merged.afdo.bz2
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index da934f52..566503f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd
@@ -4295,7 +4295,7 @@ <message name="IDS_EXTENSION_BLOCKED_ACTION_BUBBLE_MULTIPLE_EXTENSIONS_TITLE" desc="Title of the bubble to tell users that in order to run or block an extension, they'll need to refresh the page."> Reload the page to use these extensions </message> - <message name="IDS_EXTENSION_BLOCKED_ACTION_BUBBLE_UPDATE_PERMISSIONS_TITLE" desc="Title of the bubble to tell users that in order to change site permissions, they'll need to refresh the page."> + <message name="IDS_EXTENSION_BLOCKED_ACTION_BUBBLE_UPDATE_PERMISSIONS_TITLE" desc="Title of the bubble to tell users that in order to apply the changes selected, they'll need to refresh the page."> Reload the page to apply your changes </message> </if>
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index fd8ccb0c..0fc61a2e 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -2069,6 +2069,7 @@ "//components/client_hints/browser", "//components/cloud_devices/common", "//components/commerce/core:commerce_heuristics_data", + "//components/commerce/core:commerce_subscription_db_content_proto", "//components/commerce/core:feature_list", "//components/commerce/core:persisted_state_db_content_proto", "//components/commerce/core:shopping_service", @@ -5708,6 +5709,8 @@ "chromeos/extensions/login_screen/login_state/login_state_api.h", "chromeos/extensions/login_screen/login_state/session_state_changed_event_dispatcher.cc", "chromeos/extensions/login_screen/login_state/session_state_changed_event_dispatcher.h", + "chromeos/reporting/metric_default_utils.cc", + "chromeos/reporting/metric_default_utils.h", "chromeos/reporting/network/network_bandwidth_sampler.cc", "chromeos/reporting/network/network_bandwidth_sampler.h", "chromeos/tablet_mode/chrome_content_browser_client_tablet_mode_part.cc",
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 6c316e0..bdc5adc8 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -4938,10 +4938,6 @@ {"web-payment-api-csp", flag_descriptions::kWebPaymentAPICSPName, flag_descriptions::kWebPaymentAPICSPDescription, kOsAll, FEATURE_VALUE_TYPE(features::kWebPaymentAPICSP)}, - {"enable-payment-request-basic-card", - flag_descriptions::kPaymentRequestBasicCardName, - flag_descriptions::kPaymentRequestBasicCardDescription, kOsAll, - FEATURE_VALUE_TYPE(features::kPaymentRequestBasicCard)}, {"identity-in-can-make-payment", flag_descriptions::kIdentityInCanMakePaymentEventFeatureName, flag_descriptions::kIdentityInCanMakePaymentEventFeatureDescription, @@ -8884,13 +8880,6 @@ FEATURE_VALUE_TYPE(features::kSafetyCheckPermissions)}, #endif // !BUILDFLAG(IS_ANDROID) -#if !BUILDFLAG(IS_ANDROID) - {media_router::switches::kAccessCodeCastDeviceDurationSwitch, - flag_descriptions::kAccessCodeCastDeviceDurationName, - flag_descriptions::kAccessCodeCastDeviceDurationDescription, kOsDesktop, - FEATURE_VALUE_TYPE(features::kAccessCodeCastRememberDevices)}, -#endif // !BUILDFLAG(IS_ANDROID) - #if BUILDFLAG(IS_ANDROID) {"bulk-tab-restore-android", flag_descriptions::kBulkTabRestoreAndroidName, flag_descriptions::kBulkTabRestoreAndroidDescription, kOsAndroid, @@ -9126,6 +9115,14 @@ FEATURE_VALUE_TYPE(::features::kReduceGpuPriorityOnBackground)}, #endif +#if BUILDFLAG(IS_ANDROID) + {"binding-manager-use-not-perceptible-binding", + flag_descriptions::kBindingManagerUseNotPerceptibleBindingName, + flag_descriptions::kBindingManagerUseNotPerceptibleBindingDescription, + kOsAndroid, + FEATURE_VALUE_TYPE(::features::kBindingManagerUseNotPerceptibleBinding)}, +#endif + // NOTE: Adding a new flag requires adding a corresponding entry to enum // "LoginCustomFlags" in tools/metrics/histograms/enums.xml. See "Flag // Histograms" in tools/metrics/histograms/README.md (run the @@ -9264,14 +9261,6 @@ channel != version_info::Channel::UNKNOWN) { return true; } -#if !BUILDFLAG(IS_ANDROID) - // Only show the AccessCodeCast duration flag if the AccessCodeCast Ui is - // displayed and it is only available on Dev/Canary channels. - if (!strcmp(media_router::switches::kAccessCodeCastDeviceDurationSwitch, - entry.internal_name)) { - return !media_router::IsAccessCodeCastEnabled(); - } -#endif // !BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_WIN) // HDR mode works, but displays everything horribly wrong prior to windows 10.
diff --git a/chrome/browser/after_startup_task_utils_unittest.cc b/chrome/browser/after_startup_task_utils_unittest.cc index 95a7401..9c3d306 100644 --- a/chrome/browser/after_startup_task_utils_unittest.cc +++ b/chrome/browser/after_startup_task_utils_unittest.cc
@@ -14,6 +14,7 @@ #include "base/task/sequenced_task_runner.h" #include "base/task/task_runner_util.h" #include "base/task/thread_pool.h" +#include "base/test/bind.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/browser_task_environment.h" @@ -110,7 +111,7 @@ FROM_HERE, base::BindOnce(&AfterStartupTaskUtils::PostTask, from_here, std::move(task_runner), std::move(task)), - base::BindOnce(&base::RunLoop::Quit, base::Unretained(&run_loop))); + base::BindLambdaForTesting([&]() { run_loop.Quit(); })); run_loop.Run(); } @@ -119,7 +120,7 @@ base::RunLoop run_loop; background_sequence_->real_runner()->PostTaskAndReply( FROM_HERE, base::DoNothing(), - base::BindOnce(&base::RunLoop::Quit, base::Unretained(&run_loop))); + base::BindLambdaForTesting([&]() { run_loop.Quit(); })); run_loop.Run(); }
diff --git a/chrome/browser/apps/app_service/browser_app_instance_tracker_browsertest.cc b/chrome/browser/apps/app_service/browser_app_instance_tracker_browsertest.cc index d707238..5d3365b 100644 --- a/chrome/browser/apps/app_service/browser_app_instance_tracker_browsertest.cc +++ b/chrome/browser/apps/app_service/browser_app_instance_tracker_browsertest.cc
@@ -941,7 +941,7 @@ // Attach. int dst_index = browser1->tab_strip_model()->count(); browser1->tab_strip_model()->InsertWebContentsAt( - dst_index, std::move(detached), TabStripModel::ADD_ACTIVE); + dst_index, std::move(detached), AddTabTypes::ADD_ACTIVE); recorder.Verify({ // background tab in the dragged-from browser gets activated when the // active tab is detached @@ -995,7 +995,7 @@ // Attach. int dst_index = browser2->tab_strip_model()->count(); browser2->tab_strip_model()->InsertWebContentsAt( - dst_index, std::move(detached), TabStripModel::ADD_ACTIVE); + dst_index, std::move(detached), AddTabTypes::ADD_ACTIVE); recorder.Verify({ // source browser goes into background when app browser is created {"updated", 1, kChromeWindow, "", window1, "", kInactive, false},
diff --git a/chrome/browser/apps/app_service/launch_utils.cc b/chrome/browser/apps/app_service/launch_utils.cc index 6371366..6dfb08d 100644 --- a/chrome/browser/apps/app_service/launch_utils.cc +++ b/chrome/browser/apps/app_service/launch_utils.cc
@@ -177,7 +177,7 @@ NavigateParams params(browser, GURL(chrome::kChromeUINewTabURL), ui::PAGE_TRANSITION_AUTO_TOPLEVEL); params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; - params.tabstrip_add_types = TabStripModel::ADD_ACTIVE; + params.tabstrip_add_types = AddTabTypes::ADD_ACTIVE; Navigate(¶ms); browser->window()->Show();
diff --git a/chrome/browser/apps/app_shim/app_shim_manager_mac.cc b/chrome/browser/apps/app_shim/app_shim_manager_mac.cc index cba674a..90c83407 100644 --- a/chrome/browser/apps/app_shim/app_shim_manager_mac.cc +++ b/chrome/browser/apps/app_shim/app_shim_manager_mac.cc
@@ -882,7 +882,7 @@ Browser::CreateParams(Browser::TYPE_NORMAL, profile, true)); browser->window()->Show(); NavigateParams params(browser, url, ui::PAGE_TRANSITION_AUTO_BOOKMARK); - params.tabstrip_add_types = TabStripModel::ADD_ACTIVE; + params.tabstrip_add_types = AddTabTypes::ADD_ACTIVE; params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; Navigate(¶ms); }
diff --git a/chrome/browser/apps/platform_apps/platform_app_launch.cc b/chrome/browser/apps/platform_apps/platform_app_launch.cc index 2579f7e..15e2f24 100644 --- a/chrome/browser/apps/platform_apps/platform_app_launch.cc +++ b/chrome/browser/apps/platform_apps/platform_app_launch.cc
@@ -143,7 +143,7 @@ NavigateParams params(browser, url, ui::PAGE_TRANSITION_AUTO_TOPLEVEL); params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; - params.tabstrip_add_types = TabStripModel::ADD_ACTIVE; + params.tabstrip_add_types = AddTabTypes::ADD_ACTIVE; Navigate(¶ms); browser->window()->Show();
diff --git a/chrome/browser/ash/app_restore/full_restore_service_unittest.cc b/chrome/browser/ash/app_restore/full_restore_service_unittest.cc index 82935f93..9f74560 100644 --- a/chrome/browser/ash/app_restore/full_restore_service_unittest.cc +++ b/chrome/browser/ash/app_restore/full_restore_service_unittest.cc
@@ -41,8 +41,8 @@ #include "components/sync/model/syncable_service.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/preference_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/user_manager/scoped_user_manager.h" #include "content/public/test/browser_task_environment.h"
diff --git a/chrome/browser/ash/arc/bluetooth/arc_bluetooth_task_queue_unittest.cc b/chrome/browser/ash/arc/bluetooth/arc_bluetooth_task_queue_unittest.cc index 1ca4838a..614bd37 100644 --- a/chrome/browser/ash/arc/bluetooth/arc_bluetooth_task_queue_unittest.cc +++ b/chrome/browser/ash/arc/bluetooth/arc_bluetooth_task_queue_unittest.cc
@@ -4,8 +4,8 @@ #include "chrome/browser/ash/arc/bluetooth/arc_bluetooth_task_queue.h" -#include "base/bind.h" #include "base/callback_helpers.h" +#include "base/test/bind.h" #include "testing/gtest/include/gtest/gtest.h" namespace arc { @@ -14,7 +14,7 @@ bool done = false; ArcBluetoothTaskQueue task_queue; task_queue.Push(base::DoNothing()); - task_queue.Push(base::BindOnce([](bool* done) { *done = true; }, &done)); + task_queue.Push(base::BindLambdaForTesting([&]() { done = true; })); EXPECT_FALSE(done); task_queue.Pop(); EXPECT_TRUE(done); @@ -24,9 +24,9 @@ TEST(ArcBluetoothTaskQueueTest, Order) { std::string str; ArcBluetoothTaskQueue task_queue; - task_queue.Push(base::BindOnce([](std::string* str) { *str += '1'; }, &str)); - task_queue.Push(base::BindOnce([](std::string* str) { *str += '2'; }, &str)); - task_queue.Push(base::BindOnce([](std::string* str) { *str += '3'; }, &str)); + task_queue.Push(base::BindLambdaForTesting([&]() { str += '1'; })); + task_queue.Push(base::BindLambdaForTesting([&]() { str += '2'; })); + task_queue.Push(base::BindLambdaForTesting([&]() { str += '3'; })); task_queue.Pop(); task_queue.Pop(); task_queue.Pop();
diff --git a/chrome/browser/ash/arc/fileapi/arc_file_system_bridge_unittest.cc b/chrome/browser/ash/arc/fileapi/arc_file_system_bridge_unittest.cc index 49dda78..f28ae9d 100644 --- a/chrome/browser/ash/arc/fileapi/arc_file_system_bridge_unittest.cc +++ b/chrome/browser/ash/arc/fileapi/arc_file_system_bridge_unittest.cc
@@ -10,12 +10,12 @@ #include "ash/components/arc/session/arc_bridge_service.h" #include "ash/components/arc/test/connection_holder_util.h" #include "ash/components/arc/test/fake_file_system_instance.h" -#include "base/bind.h" #include "base/files/file.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/bind.h" #include "base/time/time.h" #include "chrome/browser/ash/arc/fileapi/chrome_content_provider_url_util.h" #include "chrome/browser/ash/file_manager/path_util.h" @@ -101,14 +101,12 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetFileName( EncodeToChromeContentProviderUrl(GURL(kTestUrl)).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, - const absl::optional<std::string>& result) { - run_loop->Quit(); + base::BindLambdaForTesting( + [&](const absl::optional<std::string>& result) { + run_loop.Quit(); ASSERT_TRUE(result.has_value()); EXPECT_EQ("hello.txt", result.value()); - }, - &run_loop)); + })); run_loop.Run(); } @@ -122,14 +120,12 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetFileName( EncodeToChromeContentProviderUrl(url).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, const std::string& expected, - const absl::optional<std::string>& result) { - run_loop->Quit(); + base::BindLambdaForTesting( + [&](const absl::optional<std::string>& result) { + run_loop.Quit(); ASSERT_TRUE(result.has_value()); - EXPECT_EQ(expected, result.value()); - }, - &run_loop, filename)); + EXPECT_EQ(filename, result.value()); + })); run_loop.Run(); } @@ -141,14 +137,12 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetFileName( EncodeToChromeContentProviderUrl(url).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, - const absl::optional<std::string>& result) { - run_loop->Quit(); + base::BindLambdaForTesting( + [&](const absl::optional<std::string>& result) { + run_loop.Quit(); ASSERT_TRUE(result.has_value()); EXPECT_EQ("\xF0\x9F\x94\x92", result.value()); - }, - &run_loop)); + })); run_loop.Run(); } @@ -159,13 +153,11 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetFileName( EncodeToChromeContentProviderUrl(url).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, - const absl::optional<std::string>& result) { - run_loop->Quit(); + base::BindLambdaForTesting( + [&](const absl::optional<std::string>& result) { + run_loop.Quit(); ASSERT_FALSE(result.has_value()); - }, - &run_loop)); + })); run_loop.Run(); } @@ -173,12 +165,10 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetFileSize( EncodeToChromeContentProviderUrl(GURL(kTestUrl)).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, int64_t result) { - EXPECT_EQ(kTestFileSize, result); - run_loop->Quit(); - }, - &run_loop)); + base::BindLambdaForTesting([&](int64_t result) { + EXPECT_EQ(kTestFileSize, result); + run_loop.Quit(); + })); run_loop.Run(); } @@ -189,14 +179,11 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetLastModified( EncodeToChromeContentProviderUrl(GURL(kTestUrl)), - base::BindOnce( - [](base::RunLoop* run_loop, const base::Time& expected, - const absl::optional<base::Time> result) { - ASSERT_TRUE(result.has_value()); - EXPECT_EQ(expected, result.value()); - run_loop->Quit(); - }, - &run_loop, expected)); + base::BindLambdaForTesting([&](const absl::optional<base::Time> result) { + ASSERT_TRUE(result.has_value()); + EXPECT_EQ(expected, result.value()); + run_loop.Quit(); + })); run_loop.Run(); } @@ -204,14 +191,12 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetFileType( EncodeToChromeContentProviderUrl(GURL(kTestUrl)).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, - const absl::optional<std::string>& result) { + base::BindLambdaForTesting( + [&](const absl::optional<std::string>& result) { ASSERT_TRUE(result.has_value()); EXPECT_EQ(kTestFileType, result.value()); - run_loop->Quit(); - }, - &run_loop)); + run_loop.Quit(); + })); run_loop.Run(); } @@ -227,14 +212,11 @@ base::RunLoop run_loop; arc_file_system_bridge_->GetVirtualFileId( EncodeToChromeContentProviderUrl(GURL(kTestUrl)).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, const char* kId, - const absl::optional<std::string>& id) { - ASSERT_NE(absl::nullopt, id); - EXPECT_EQ(kId, id.value()); - run_loop->Quit(); - }, - &run_loop, kId)); + base::BindLambdaForTesting([&](const absl::optional<std::string>& id) { + ASSERT_NE(absl::nullopt, id); + EXPECT_EQ(kId, id.value()); + run_loop.Quit(); + })); run_loop.Run(); content::RunAllTasksUntilIdle(); @@ -262,12 +244,10 @@ base::RunLoop run_loop; arc_file_system_bridge_->OpenFileToRead( EncodeToChromeContentProviderUrl(GURL(kTestUrl)).spec(), - base::BindOnce( - [](base::RunLoop* run_loop, mojo::ScopedHandle result) { - EXPECT_TRUE(result.is_valid()); - run_loop->Quit(); - }, - &run_loop)); + base::BindLambdaForTesting([&](mojo::ScopedHandle result) { + EXPECT_TRUE(result.is_valid()); + run_loop.Quit(); + })); run_loop.Run(); // HandleReadRequest().
diff --git a/chrome/browser/ash/arc/session/arc_session_manager_unittest.cc b/chrome/browser/ash/arc/session/arc_session_manager_unittest.cc index 8b921e6b..756f938 100644 --- a/chrome/browser/ash/arc/session/arc_session_manager_unittest.cc +++ b/chrome/browser/ash/arc/session/arc_session_manager_unittest.cc
@@ -63,8 +63,8 @@ #include "components/prefs/pref_service.h" #include "components/prefs/testing_pref_service.h" #include "components/session_manager/core/session_manager.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/user_manager/known_user.h" #include "components/user_manager/scoped_user_manager.h"
diff --git a/chrome/browser/ash/net/network_portal_detector_impl.cc b/chrome/browser/ash/net/network_portal_detector_impl.cc index d66cecd2..9b87b57 100644 --- a/chrome/browser/ash/net/network_portal_detector_impl.cc +++ b/chrome/browser/ash/net/network_portal_detector_impl.cc
@@ -143,14 +143,13 @@ if (enabled_) return; + NET_LOG(EVENT) << "NetworkPortalDetector Enabled."; DCHECK(is_idle()); enabled_ = true; const NetworkState* network = DefaultNetwork(); if (!network) return; - NET_LOG(EVENT) << "Starting detection attempt:" - << " id=" << NetworkId(network); SetNetworkPortalState(network, NetworkState::PortalState::kUnknown); StartDetection(); } @@ -164,8 +163,12 @@ void NetworkPortalDetectorImpl::StartPortalDetection() { if (!is_idle()) return; + const NetworkState* network = DefaultNetwork(); + if (!network) { + NET_LOG(ERROR) << "StartPortalDetection called with no default network."; + return; + } StartDetection(); - return; } void NetworkPortalDetectorImpl::SetStrategy( @@ -175,75 +178,66 @@ strategy_ = PortalDetectorStrategy::CreateById(id, this); if (!is_idle()) StopDetection(); - StartPortalDetection(); + StartDetection(); } -void NetworkPortalDetectorImpl::DefaultNetworkChanged( - const NetworkState* default_network) { +void NetworkPortalDetectorImpl::PortalStateChanged( + const NetworkState* default_network, + NetworkState::PortalState portal_state) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - if (!default_network) { - NET_LOG(EVENT) << "Default network changed: None"; - + if (!default_network || !default_network->IsConnectedState()) { + NET_LOG(EVENT) + << "No connected default network, stopping portal detection."; default_network_id_ = std::string(); - default_proxy_config_ = base::Value(); - StopDetection(); - - DetectionCompleted(nullptr, CAPTIVE_PORTAL_STATUS_OFFLINE, -1); + DetectionCompleted(nullptr, CAPTIVE_PORTAL_STATUS_OFFLINE); return; } - bool network_changed = (default_network_id_ != default_network->guid()); - if (network_changed) - default_network_id_ = default_network->guid(); + default_network_id_ = default_network->guid(); + bool has_proxy = !default_network->proxy_config().is_none(); + NET_LOG(EVENT) << "PortalStateChanged, id=" + << NetworkGuidId(default_network_id_) + << " state=" << default_network->connection_state() + << " portal_state=" << portal_state + << " has_proxy=" << has_proxy; - bool connection_state_changed = - (default_connection_state_ != default_network->connection_state()); - default_connection_state_ = default_network->connection_state(); - - bool proxy_config_changed = false; - const base::Value& default_network_proxy_config = - default_network->proxy_config(); - if (default_network_proxy_config.is_none()) { - if (!default_proxy_config_.is_none()) { - proxy_config_changed = true; - default_proxy_config_ = base::Value(); - } - } else if (network_changed || - default_proxy_config_ != default_network_proxy_config) { - proxy_config_changed = true; - default_proxy_config_ = default_network_proxy_config.Clone(); - } - - NET_LOG(EVENT) << "Default network changed:" - << " id=" << NetworkGuidId(default_network_id_) - << " state=" << default_connection_state_ - << " changed=" << network_changed - << " proxy_config_changed=" << proxy_config_changed - << " state_changed=" << connection_state_changed; - - if (network_changed || connection_state_changed || proxy_config_changed) - StopDetection(); - - if (!NetworkState::StateIsConnected(default_connection_state_)) - return; - - if (proxy_config_changed) { - ScheduleAttempt(base::Seconds(kProxyChangeDelaySec)); - return; - } - - if (is_idle()) { - // Initiate Captive Portal detection if network's captive - // portal state is unknown (e.g. for freshly created networks), - // offline or if network connection state was changed. - CaptivePortalStatus status = GetCaptivePortalStatus(); - if (status == CAPTIVE_PORTAL_STATUS_UNKNOWN || - status == CAPTIVE_PORTAL_STATUS_OFFLINE || - (!network_changed && connection_state_changed)) { - ScheduleAttempt(base::TimeDelta()); - } + switch (portal_state) { + case NetworkState::PortalState::kUnknown: + // Not expected. Shill detection failed or unexpected results, use Chrome + // portal detection. + NET_LOG(ERROR) << "Unknown PortalState, scheduling Chrome detection."; + ScheduleAttempt(); + return; + case NetworkState::PortalState::kOnline: + // If a proxy is configured, use captive_portal_detector_ to detect a + // proxy auth required (407) response. + if (has_proxy) + ScheduleAttempt(); + else + DetectionCompleted(default_network, CAPTIVE_PORTAL_STATUS_ONLINE); + return; + case NetworkState::PortalState::kPortalSuspected: + // Shill result was inconclusive. + ScheduleAttempt(); + return; + case NetworkState::PortalState::kPortal: + DetectionCompleted(default_network, CAPTIVE_PORTAL_STATUS_PORTAL); + return; + case NetworkState::PortalState::kNoInternet: + // If a proxy is configured it may be interfering with Shill portal + // detection + if (has_proxy) + ScheduleAttempt(); + else + DetectionCompleted(default_network, CAPTIVE_PORTAL_STATUS_ONLINE); + return; + case NetworkState::PortalState::kProxyAuthRequired: + // This may happen if a global proxy is applied. Run Chrome detection + // to verify. + ScheduleAttempt(); + return; } } @@ -269,15 +263,18 @@ // NetworkPortalDetectorImpl, private: void NetworkPortalDetectorImpl::StartDetection() { - DCHECK(is_idle()); + NET_LOG(EVENT) << "StartDetection"; ResetStrategyAndCounters(); default_portal_status_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; detection_start_time_ = NowTicks(); - ScheduleAttempt(base::TimeDelta()); + ScheduleAttempt(); } void NetworkPortalDetectorImpl::StopDetection() { + if (is_idle()) + return; + NET_LOG(EVENT) << "StopDetection"; attempt_task_.Cancel(); attempt_timeout_.Cancel(); captive_portal_detector_->Cancel(); @@ -363,15 +360,6 @@ } } - // If using a fake profile client, also fake being behind a captive portal - // if the default network is in portal state. - if (result != captive_portal::RESULT_NO_RESPONSE && - ShillProfileClient::Get()->GetTestInterface() && - shill_is_captive_portal) { - result = captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL; - response_code = 200; - } - state_ = STATE_IDLE; attempt_timeout_.Cancel(); @@ -439,25 +427,25 @@ else no_response_result_count_ = 0; + bool detection_completed = false; if (status == CAPTIVE_PORTAL_STATUS_ONLINE || status == CAPTIVE_PORTAL_STATUS_PORTAL || status == CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED) { // Chrome positively identified an online, portal or proxy auth state. // No need to continue detection. - DetectionCompleted(network, status, response_code); - return; - } - - if (same_detection_result_count_ >= kMaxOfflineResultsBeforeReport) { + detection_completed = true; + } else if (same_detection_result_count_ >= kMaxOfflineResultsBeforeReport) { NET_LOG(EVENT) << "Max identical portal detection results reached: " << same_detection_result_count_ << " Status: " << status; - DetectionCompleted(network, status, response_code); - return; + detection_completed = true; } - // Observers (via DetectionCompleted) may already schedule a new attempt. - if (is_idle()) + if (detection_completed) { + response_code_for_testing_ = response_code; + DetectionCompleted(network, status); + } else if (is_idle()) { ScheduleAttempt(results.retry_after_delta); + } } void NetworkPortalDetectorImpl::Observe( @@ -475,21 +463,34 @@ void NetworkPortalDetectorImpl::DetectionCompleted( const NetworkState* network, - const CaptivePortalStatus& status, - int response_code) { + const CaptivePortalStatus& status) { NET_LOG(EVENT) << "NetworkPortalDetector: DetectionCompleted: id=" << (network ? NetworkGuidId(network->guid()) : "<none>") - << ", status=" << status - << ", response_code=" << response_code; + << ", status=" << status; default_portal_status_ = status; - response_code_for_testing_ = response_code; if (network) { - // TODO(b/207069182): Set online and proxy_auth_required also. - auto portal_state = - status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL - ? NetworkState::PortalState::kPortal - : NetworkState::PortalState::kUnknown; + NetworkState::PortalState portal_state; + switch (status) { + case CAPTIVE_PORTAL_STATUS_UNKNOWN: + case CAPTIVE_PORTAL_STATUS_COUNT: + case CAPTIVE_PORTAL_STATUS_OFFLINE: + portal_state = NetworkState::PortalState::kUnknown; + break; + case CAPTIVE_PORTAL_STATUS_ONLINE: + // TODO(b/207069182): This should state PortalState::kOnline. + portal_state = NetworkState::PortalState::kUnknown; + break; + case CAPTIVE_PORTAL_STATUS_PORTAL: + portal_state = NetworkState::PortalState::kPortal; + break; + case CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: + // TODO(b/207069182): This should state PortalState::kProxyAuthRequired. + portal_state = NetworkState::PortalState::kUnknown; + break; + } + // Note: setting an unknown portal state will ignore the Chrome result and + // fall back to the Shill result. SetNetworkPortalState(network, portal_state); } for (auto& observer : observers_)
diff --git a/chrome/browser/ash/net/network_portal_detector_impl.h b/chrome/browser/ash/net/network_portal_detector_impl.h index e73e1425..357bbd9b 100644 --- a/chrome/browser/ash/net/network_portal_detector_impl.h +++ b/chrome/browser/ash/net/network_portal_detector_impl.h
@@ -28,10 +28,6 @@ #include "content/public/browser/notification_registrar.h" #include "url/gurl.h" -namespace base { -class Value; -} - namespace network { class SharedURLLoaderFactory; namespace mojom { @@ -83,7 +79,7 @@ void RetryDetection(); // Initiates Captive Portal detection attempt after |delay|. - void ScheduleAttempt(const base::TimeDelta& delay); + void ScheduleAttempt(const base::TimeDelta& delay = base::TimeDelta()); // Starts detection attempt. void StartAttempt(); @@ -107,8 +103,9 @@ void SetStrategy(PortalDetectorStrategy::StrategyId id) override; // NetworkStateHandlerObserver implementation: - void DefaultNetworkChanged(const NetworkState* network) override; void OnShuttingDown() override; + void PortalStateChanged(const NetworkState* default_network, + NetworkState::PortalState portal_state) override; // PortalDetectorStrategy::Delegate implementation: int NoResponseResultCount() override; @@ -120,11 +117,8 @@ const content::NotificationSource& source, const content::NotificationDetails& details) override; - // Called synchronously from OnAttemptCompleted with the current default - // network. Stores the captive portal status and notifies observers. void DetectionCompleted(const NetworkState* network, - const CaptivePortalStatus& results, - int response_code); + const CaptivePortalStatus& results); State state() const { return state_; } @@ -174,12 +168,6 @@ // Unique identifier of the default network. std::string default_network_id_; - // Connection state of the default network. - std::string default_connection_state_; - - // Proxy configuration of the default network. - base::Value default_proxy_config_; - CaptivePortalStatus default_portal_status_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; int response_code_for_testing_ = -1;
diff --git a/chrome/browser/ash/net/network_portal_detector_impl_browsertest.cc b/chrome/browser/ash/net/network_portal_detector_impl_browsertest.cc index 47426725..0080d16f 100644 --- a/chrome/browser/ash/net/network_portal_detector_impl_browsertest.cc +++ b/chrome/browser/ash/net/network_portal_detector_impl_browsertest.cc
@@ -53,7 +53,6 @@ constexpr char kTestUserGaiaId[] = "1234567890"; constexpr char kWifiServicePath[] = "/service/wifi"; constexpr char kWifiGuid[] = "wifi"; -constexpr char kProbeUrl[] = "http://play.googleapis.com/generate_204"; void ErrorCallbackFunction(const std::string& error_name, const std::string& error_message) { @@ -67,6 +66,14 @@ base::RunLoop().RunUntilIdle(); } +void SetPortal(const std::string& service_path) { + ShillServiceClient::Get()->SetProperty( + dbus::ObjectPath(kWifiServicePath), shill::kStateProperty, + base::Value(shill::kStateRedirectFound), base::DoNothing(), + base::BindOnce(&ErrorCallbackFunction)); + base::RunLoop().RunUntilIdle(); +} + } // namespace class NetworkPortalDetectorImplBrowserTest @@ -93,16 +100,8 @@ ShillServiceClient::Get()->GetTestInterface(); service_test->ClearServices(); service_test->AddService(kWifiServicePath, kWifiGuid, "wifi", - shill::kTypeEthernet, shill::kStateIdle, + shill::kTypeWifi, shill::kStateIdle, true /* add_to_visible */); - ShillServiceClient::Get()->SetProperty( - dbus::ObjectPath(kWifiServicePath), shill::kStateProperty, - base::Value(shill::kStateRedirectFound), base::DoNothing(), - base::BindOnce(&ErrorCallbackFunction)); - ShillServiceClient::Get()->SetProperty( - dbus::ObjectPath(kWifiServicePath), shill::kProbeUrlProperty, - base::Value(kProbeUrl), base::DoNothing(), - base::BindOnce(&ErrorCallbackFunction)); display_service_ = std::make_unique<NotificationDisplayServiceTester>( nullptr /* profile */); @@ -166,33 +165,37 @@ LoginUser(test_account_id_); content::RunAllPendingInMessageLoop(); - // User connects to wifi. - SetConnected(kWifiServicePath); - ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_SESSION, strategy()->Id()); - // No notification until portal detection is completed. EXPECT_FALSE(display_service_->GetNotification(kNotificationId)); - RestartDetection(); - EXPECT_EQ(kProbeUrl, get_probe_url()); - CompleteURLFetch(net::OK, 200, nullptr); - // Ensure that NetworkStateHandler is updated. + // Set connected should not trigger portal detection. + SetConnected(kWifiServicePath); + + chromeos::NetworkStateHandler* network_state_handler = + chromeos::NetworkHandler::Get()->network_state_handler(); const chromeos::NetworkState* default_network = - chromeos::NetworkHandler::Get() - ->network_state_handler() - ->DefaultNetwork(); + network_state_handler->DefaultNetwork(); + ASSERT_TRUE(default_network); + EXPECT_EQ(default_network->GetPortalState(), + chromeos::NetworkState::PortalState::kOnline); + EXPECT_FALSE(display_service_->GetNotification(kNotificationId)); + EXPECT_EQ(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, + network_portal_detector::GetInstance()->GetCaptivePortalStatus()); + + // Setting a portal state should set portal detection and display a + // notification + SetPortal(kWifiServicePath); + + default_network = network_state_handler->DefaultNetwork(); ASSERT_TRUE(default_network); EXPECT_EQ(default_network->GetPortalState(), chromeos::NetworkState::PortalState::kPortal); - - // Check that the default network is detected as behind a portal and that - // notification is displayed. EXPECT_TRUE(display_service_->GetNotification(kNotificationId)); EXPECT_EQ(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, network_portal_detector::GetInstance()->GetCaptivePortalStatus()); - // User explicitly closes the notification. + // Explicitly close the notification. display_service_->RemoveNotification(NotificationHandler::Type::TRANSIENT, kNotificationId, true); } @@ -223,15 +226,11 @@ ProfileManager::GetActiveUserProfile()->GetPrefs()->SetBoolean( prefs::kCaptivePortalAuthenticationIgnoresProxy, preference_value); - // User connects to wifi. - SetConnected(kWifiServicePath); - EXPECT_EQ(PortalDetectorStrategy::STRATEGY_ID_SESSION, strategy()->Id()); - // No notification until portal detection is completed. - EXPECT_FALSE(display_service_->GetNotification(kNotificationId)); - RestartDetection(); - CompleteURLFetch(net::OK, 200, nullptr); + // User connects to portalled wifi. + SetConnected(kWifiServicePath); + SetPortal(kWifiServicePath); // Check that the network is behind a portal and a notification is displayed. EXPECT_TRUE(display_service_->GetNotification(kNotificationId));
diff --git a/chrome/browser/ash/net/network_portal_detector_impl_unittest.cc b/chrome/browser/ash/net/network_portal_detector_impl_unittest.cc index 7016950..78ccdba 100644 --- a/chrome/browser/ash/net/network_portal_detector_impl_unittest.cc +++ b/chrome/browser/ash/net/network_portal_detector_impl_unittest.cc
@@ -18,6 +18,7 @@ #include "base/metrics/histogram_samples.h" #include "base/metrics/statistics_recorder.h" #include "base/run_loop.h" +#include "base/strings/stringprintf.h" #include "base/test/metrics/histogram_tester.h" #include "chrome/browser/ash/login/users/fake_chrome_user_manager.h" #include "chrome/browser/ash/net/network_portal_detector_test_utils.h" @@ -55,6 +56,7 @@ const char kStubEthernet[] = "stub_ethernet"; const char kStubWireless1[] = "stub_wifi1"; const char kStubWireless2[] = "stub_wifi2"; +const int kStatusCodeUnset = -1; void ErrorCallbackFunction(const std::string& error_name, const std::string& error_message) { @@ -197,7 +199,7 @@ PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); } - void stop_detection() { network_portal_detector()->StopDetection(); } + void StopDetection() { network_portal_detector()->StopDetection(); } bool attempt_timeout_is_cancelled() { return network_portal_detector()->AttemptTimeoutIsCancelledForTesting(); @@ -235,10 +237,11 @@ network_portal_detector()->set_time_ticks_for_testing(time_ticks); } - void SetBehindPortal(const std::string& service_path) { + void SetNetworkState(const std::string& service_path, + const std::string& state) { ShillServiceClient::Get()->SetProperty( dbus::ObjectPath(service_path), shill::kStateProperty, - base::Value(shill::kStateNoConnectivity), base::DoNothing(), + base::Value(state), base::DoNothing(), base::BindOnce(&ErrorCallbackFunction)); base::RunLoop().RunUntilIdle(); } @@ -257,6 +260,18 @@ base::RunLoop().RunUntilIdle(); } + // Set a proxy to trigger Chrome portal detection when the connection state + // is 'online'. + void SetConnectedWithProxy(const std::string& service_path) { + SetConnected(service_path); + std::string proxy_config = "{\"mode\":\"test\"}"; + ShillServiceClient::Get()->SetProperty( + dbus::ObjectPath(service_path), shill::kProxyConfigProperty, + base::Value(proxy_config), base::DoNothing(), + base::BindOnce(&ErrorCallbackFunction)); + base::RunLoop().RunUntilIdle(); + } + void SetDisconnected(const std::string& service_path) { ShillServiceClient::Get()->Disconnect( dbus::ObjectPath(service_path), base::DoNothing(), @@ -264,6 +279,11 @@ base::RunLoop().RunUntilIdle(); } + std::string GetRetryResponse(int retry_delay) { + return base::StringPrintf("HTTP/1.1 503 OK\nRetry-After: %d\n\n", + retry_delay); + } + FakeObserver& observer() { return observer_; } private: @@ -302,14 +322,16 @@ ASSERT_EQ(observer().status(), NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN); - // Check HTTP 204 response code. - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); + // Check HTTP 204 response code. CompleteURLFetch(net::OK, 204, nullptr); EXPECT_EQ(State::STATE_IDLE, state()); - EXPECT_EQ(observer().status(), - NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE); + EXPECT_TRUE( + CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, + kStubWireless1)); } TEST_F(NetworkPortalDetectorImplTest, Portal200) { @@ -317,10 +339,11 @@ ASSERT_EQ(observer().status(), NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN); - // Check HTTP 200 response code. - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); + // Check HTTP 200 response code. CompleteURLFetch(net::OK, 200, nullptr); EXPECT_EQ(State::STATE_IDLE, state()); EXPECT_TRUE( @@ -333,14 +356,16 @@ ASSERT_EQ(observer().status(), NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN); - // Check HTTP 302 response code. - SetConnected(kStubEthernet); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); + // Check HTTP 302 response code. CompleteURLFetch(net::OK, 302, nullptr); EXPECT_EQ(State::STATE_IDLE, state()); - EXPECT_TRUE(CheckPortalState( - NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 302, kStubEthernet)); + EXPECT_TRUE( + CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 302, + kStubWireless1)); } TEST_F(NetworkPortalDetectorImplTest, Online2Offline) { @@ -348,8 +373,9 @@ ASSERT_EQ(observer().status(), NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN); - // WiFi is in online state. - SetConnected(kStubWireless1); + // WiFi is in online state with a proxy configured to trigger Chrome portal + // detection. + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); CompleteURLFetch(net::OK, 204, nullptr); @@ -371,7 +397,8 @@ ASSERT_EQ(observer().status(), NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); // WiFi is in portal state. EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); @@ -395,7 +422,8 @@ ASSERT_EQ(observer().status(), NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); CompleteURLFetch(net::OK, 204, nullptr); @@ -405,9 +433,11 @@ CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1)); - // Triggering a connect to the same network will trigger another portal check - // with the same results. - SetConnected(kStubWireless1); + // Reconnecting to the same network will trigger another portal check with the + // same results. + SetDisconnected(kStubWireless1); + set_delay_till_next_attempt(base::TimeDelta()); + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); CompleteURLFetch(net::OK, 204, nullptr); @@ -422,7 +452,8 @@ // Test for Portal -> Online -> Portal network state transitions. ASSERT_EQ(State::STATE_IDLE, state()); - SetBehindPortal(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); CompleteURLFetch(net::OK, 200, nullptr); @@ -432,21 +463,26 @@ CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 200, kStubWireless1)); - SetConnected(kStubWireless1); + // Setting the state to portal-suspected should trigger chrome detection. + set_delay_till_next_attempt(base::TimeDelta()); + SetNetworkState(kStubWireless1, shill::kStatePortalSuspected); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); + // Chreme detects that the network is online. CompleteURLFetch(net::OK, 204, nullptr); - EXPECT_EQ(State::STATE_IDLE, state()); EXPECT_TRUE( CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1)); - SetBehindPortal(kStubWireless1); + // Setting the state back to online should trigger chrome detection since a + // proxy is configured. + set_delay_till_next_attempt(base::TimeDelta()); + SetNetworkState(kStubWireless1, shill::kStateOnline); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); + // Chreme detects that the network is in a portal state. CompleteURLFetch(net::OK, 200, nullptr); - EXPECT_EQ(State::STATE_IDLE, state()); EXPECT_TRUE( CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 200, @@ -463,7 +499,8 @@ ASSERT_EQ(0, same_detection_result_count()); ASSERT_EQ(0, no_response_result_count()); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); // First portal detection timeouts, next portal detection is // scheduled. @@ -474,32 +511,36 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectionRetryAfter) { ASSERT_EQ(State::STATE_IDLE, state()); - const char retry_after[] = "HTTP/1.1 503 OK\nRetry-After: 101\n\n"; + const int retry_delay = 101; + std::string retry_response = GetRetryResponse(retry_delay); ASSERT_EQ(State::STATE_IDLE, state()); ASSERT_EQ(0, no_response_result_count()); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); ASSERT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); - CompleteURLFetch(net::OK, 503, retry_after); + CompleteURLFetch(net::OK, 503, retry_response.c_str()); // First portal detection completed, next portal detection is - // scheduled after 101 seconds. + // scheduled after |retry_delay| seconds. ASSERT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); ASSERT_EQ(1, no_response_result_count()); - ASSERT_EQ(base::Seconds(101), next_attempt_delay()); + ASSERT_EQ(base::Seconds(retry_delay), next_attempt_delay()); } TEST_F(NetworkPortalDetectorImplTest, PortalDetectorRetryAfterIsSmall) { ASSERT_EQ(State::STATE_IDLE, state()); - const char retry_after[] = "HTTP/1.1 503 OK\nRetry-After: 1\n\n"; + const int retry_delay = 1; + std::string retry_response = GetRetryResponse(retry_delay); ASSERT_EQ(State::STATE_IDLE, state()); ASSERT_EQ(0, no_response_result_count()); - SetConnected(kStubWireless1); - CompleteURLFetch(net::OK, 503, retry_after); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); + CompleteURLFetch(net::OK, 503, retry_response.c_str()); // First portal detection completed, next portal detection is // scheduled after 3 seconds (due to minimum time between detection @@ -513,17 +554,17 @@ ASSERT_EQ(0, no_response_result_count()); set_delay_till_next_attempt(base::TimeDelta()); - const char retry_after[] = "HTTP/1.1 503 OK\nRetry-After: 0\n\n"; + const int retry_delay = 0; + std::string retry_response = GetRetryResponse(retry_delay); - EXPECT_EQ(State::STATE_IDLE, state()); - EXPECT_EQ(0, no_response_result_count()); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); + EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); - SetConnected(kStubWireless1); - - CompleteURLFetch(net::OK, 503, retry_after); + CompleteURLFetch(net::OK, 503, retry_response.c_str()); EXPECT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); EXPECT_EQ(1, no_response_result_count()); - EXPECT_EQ(base::Seconds(0), next_attempt_delay()); + EXPECT_EQ(base::Seconds(retry_delay), next_attempt_delay()); // To run CaptivePortalDetector::DetectCaptivePortal(). base::RunLoop().RunUntilIdle(); @@ -541,30 +582,30 @@ ASSERT_EQ(0, no_response_result_count()); set_delay_till_next_attempt(base::TimeDelta()); - const char retry_after[] = "HTTP/1.1 503 OK\nRetry-After: 0\n\n"; + const int retry_delay = 0; + std::string retry_response = GetRetryResponse(retry_delay); - EXPECT_EQ(State::STATE_IDLE, state()); - EXPECT_EQ(0, no_response_result_count()); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); + EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); - SetConnected(kStubWireless1); - - CompleteURLFetch(net::OK, 503, retry_after); + CompleteURLFetch(net::OK, 503, retry_response.c_str()); EXPECT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); EXPECT_EQ(1, no_response_result_count()); - EXPECT_EQ(base::Seconds(0), next_attempt_delay()); + EXPECT_EQ(base::Seconds(retry_delay), next_attempt_delay()); // To run CaptivePortalDetector::DetectCaptivePortal(). base::RunLoop().RunUntilIdle(); - CompleteURLFetch(net::OK, 503, retry_after); + CompleteURLFetch(net::OK, 503, retry_response.c_str()); EXPECT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); EXPECT_EQ(2, no_response_result_count()); - EXPECT_EQ(base::Seconds(0), next_attempt_delay()); + EXPECT_EQ(base::Seconds(retry_delay), next_attempt_delay()); // To run CaptivePortalDetector::DetectCaptivePortal(). base::RunLoop().RunUntilIdle(); - CompleteURLFetch(net::OK, 503, retry_after); + CompleteURLFetch(net::OK, 503, retry_response.c_str()); EXPECT_EQ(State::STATE_IDLE, state()); EXPECT_EQ(3, no_response_result_count()); EXPECT_TRUE( @@ -576,7 +617,10 @@ ASSERT_EQ(State::STATE_IDLE, state()); set_delay_till_next_attempt(base::TimeDelta()); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); + EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); + CompleteURLFetch(net::OK, 407, nullptr); EXPECT_EQ(1, no_response_result_count()); EXPECT_EQ(State::STATE_IDLE, state()); @@ -593,7 +637,8 @@ ASSERT_EQ(State::STATE_IDLE, state()); set_delay_till_next_attempt(base::TimeDelta()); - SetBehindPortal(kStubWireless1); + // Set a portal-suspected state to trigger Chrome portal detection. + SetNetworkState(kStubWireless1, shill::kStatePortalSuspected); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); CompleteURLFetch(net::ERR_CONNECTION_CLOSED, 0, nullptr); @@ -612,36 +657,38 @@ ASSERT_EQ(State::STATE_IDLE, state()); set_no_response_result_count(3); enable_error_screen_strategy(); + + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); + const int retry_delay = 0; + std::string retry_response = GetRetryResponse(retry_delay); + CompleteURLFetch(net::OK, 503, retry_response.c_str()); EXPECT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); + + // Disabling the strategy should cancel detection. disable_error_screen_strategy(); // To run CaptivePortalDetector::DetectCaptivePortal(). base::RunLoop().RunUntilIdle(); + + EXPECT_TRUE( + CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, + kStatusCodeUnset, kStubWireless1)); } TEST_F(NetworkPortalDetectorImplTest, ErrorScreenStrategyForOnlineNetwork) { ASSERT_EQ(State::STATE_IDLE, state()); set_delay_till_next_attempt(base::TimeDelta()); - - SetConnected(kStubWireless1); enable_error_screen_strategy(); - // To run CaptivePortalDetector::DetectCaptivePortal(). - base::RunLoop().RunUntilIdle(); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); CompleteURLFetch(net::OK, 204, nullptr); EXPECT_EQ(State::STATE_IDLE, state()); - EXPECT_TRUE( - CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, - kStubWireless1)); - - disable_error_screen_strategy(); - EXPECT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); // To run CaptivePortalDetector::DetectCaptivePortal(). base::RunLoop().RunUntilIdle(); - EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); - CompleteURLFetch(net::OK, 204, nullptr); EXPECT_TRUE( CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1)); @@ -652,28 +699,34 @@ set_delay_till_next_attempt(base::TimeDelta()); enable_error_screen_strategy(); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); + EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); + + // No response result remains in an online state. CompleteURLFetch(net::ERR_CONNECTION_CLOSED, 0, nullptr); EXPECT_EQ(1, no_response_result_count()); EXPECT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); EXPECT_TRUE( - CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, - kStubWireless1)); + CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, + kStatusCodeUnset, kStubWireless1)); // To run CaptivePortalDetector::DetectCaptivePortal(). base::RunLoop().RunUntilIdle(); + // No response result remains in an online state. CompleteURLFetch(net::ERR_CONNECTION_CLOSED, 0, nullptr); EXPECT_EQ(2, no_response_result_count()); EXPECT_EQ(State::STATE_PORTAL_CHECK_PENDING, state()); EXPECT_TRUE( - CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, - kStubWireless1)); + CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, + kStatusCodeUnset, kStubWireless1)); // To run CaptivePortalDetector::DetectCaptivePortal(). base::RunLoop().RunUntilIdle(); + // OK + 200 response result sets a portal state. CompleteURLFetch(net::OK, 200, nullptr); EXPECT_EQ(0, no_response_result_count()); EXPECT_EQ(State::STATE_IDLE, state()); @@ -693,26 +746,30 @@ ASSERT_EQ(State::STATE_IDLE, state()); set_delay_till_next_attempt(base::TimeDelta()); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); EXPECT_EQ(State::STATE_CHECKING_FOR_PORTAL, state()); EXPECT_TRUE( - CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, - kStubWireless1)); + CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, + kStatusCodeUnset, kStubWireless1)); - stop_detection(); + // Stop Chrome portal detection before it completes, the attempt should be + // cancelled and the result 'unknown'. + StopDetection(); EXPECT_EQ(State::STATE_IDLE, state()); EXPECT_TRUE(attempt_timeout_is_cancelled()); EXPECT_TRUE( - CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, - kStubWireless1)); + CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, + kStatusCodeUnset, kStubWireless1)); } TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts) { ASSERT_EQ(State::STATE_IDLE, state()); set_delay_till_next_attempt(base::TimeDelta()); - SetConnected(kStubWireless1); + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); // First portal detection attempt uses 5sec timeout. EXPECT_TRUE(CheckRequestTimeoutAndCompleteAttempt( @@ -783,7 +840,9 @@ TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts2) { ASSERT_EQ(State::STATE_IDLE, state()); set_delay_till_next_attempt(base::TimeDelta()); - SetConnected(kStubWireless1); + + // Connect with a proxy to trigger Chrome portal detection. + SetConnectedWithProxy(kStubWireless1); // First portal detection attempt for wifi1 uses 5sec timeout. EXPECT_TRUE(CheckRequestTimeoutAndCompleteAttempt(
diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc index 40de4e2..ad64b0b4 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc
@@ -1613,7 +1613,7 @@ std::unique_ptr<content::WebContents> moved_web_contents = browser2->tab_strip_model()->DetachWebContentsAtForInsertion(0); browser1->tab_strip_model()->InsertWebContentsAt( - 0, std::move(moved_web_contents), TabStripModel::ADD_NONE); + 0, std::move(moved_web_contents), AddTabTypes::ADD_NONE); browser1->tab_strip_model()->ActivateTabAt(0); // Cleanup and check reporting.
diff --git a/chrome/browser/ash/policy/reporting/metrics_reporting/metric_reporting_manager.cc b/chrome/browser/ash/policy/reporting/metrics_reporting/metric_reporting_manager.cc index 9d54f70..10999488 100644 --- a/chrome/browser/ash/policy/reporting/metrics_reporting/metric_reporting_manager.cc +++ b/chrome/browser/ash/policy/reporting/metrics_reporting/metric_reporting_manager.cc
@@ -15,6 +15,7 @@ #include "chrome/browser/ash/policy/reporting/metrics_reporting/usb/usb_events_observer.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/reporting/metric_default_utils.h" #include "chrome/browser/chromeos/reporting/network/network_bandwidth_sampler.h" #include "components/reporting/client/report_queue.h" #include "components/reporting/client/report_queue_configuration.h" @@ -29,53 +30,6 @@ namespace em = enterprise_management; namespace reporting { -namespace { - -constexpr base::TimeDelta kDefaultReportUploadFrequencyForTesting = - base::Minutes(5); -constexpr base::TimeDelta kDefaultCollectionRateForTesting = base::Minutes(2); -constexpr base::TimeDelta kDefaultEventCheckingRateForTesting = - base::Minutes(1); - -constexpr base::TimeDelta kInitDelay = base::Minutes(1); -constexpr base::TimeDelta kInitialUploadDelay = base::Minutes(3); - -constexpr base::TimeDelta kDefaultReportUploadFrequency = base::Hours(3); -constexpr base::TimeDelta kDefaultNetworkTelemetryCollectionRate = - base::Minutes(60); -constexpr base::TimeDelta kDefaultNetworkTelemetryEventCheckingRate = - base::Minutes(10); -constexpr base::TimeDelta kDefaultAudioTelemetryCollectionRate = - base::Minutes(10); - -constexpr bool kReportDeviceNetworkStatusDefaultValue = true; -constexpr bool kReportDeviceAudioStatusDefaultValue = true; -constexpr bool kReportDevicePeripheralsDefaultValue = false; - -base::TimeDelta GetDefaultRate(base::TimeDelta default_rate, - base::TimeDelta testing_rate) { - // If telemetry testing rates flag is enabled, use `testing_rate` to reduce - // time before metric collection and reporting. - return base::FeatureList::IsEnabled( - MetricRateController::kEnableTelemetryTestingRates) - ? testing_rate - : default_rate; -} - -base::TimeDelta GetDefaultReportUploadFrequency() { - return GetDefaultRate(kDefaultReportUploadFrequency, - kDefaultReportUploadFrequencyForTesting); -} - -base::TimeDelta GetDefaultCollectionRate(base::TimeDelta default_rate) { - return GetDefaultRate(default_rate, kDefaultCollectionRateForTesting); -} - -base::TimeDelta GetDefaultEventCheckingRate(base::TimeDelta default_rate) { - return GetDefaultRate(default_rate, kDefaultEventCheckingRateForTesting); -} - -} // namespace bool MetricReportingManager::Delegate::IsAffiliated(Profile* profile) { const user_manager::User* const user = @@ -197,12 +151,12 @@ } base::TimeDelta MetricReportingManager::Delegate::GetInitDelay() const { - return kInitDelay; + return metrics::kInitDelay; } base::TimeDelta MetricReportingManager::Delegate::GetInitialUploadDelay() const { - return kInitialUploadDelay; + return metrics::kInitialUploadDelay; } // static @@ -234,7 +188,7 @@ user_telemetry_report_queue_ = delegate_->CreatePeriodicUploadReportQueue( EventType::kUser, Destination::TELEMETRY_METRIC, Priority::MANUAL_BATCH, &reporting_settings_, ::ash::kReportUploadFrequency, - GetDefaultReportUploadFrequency()); + metrics::GetDefaultReportUploadFrequency()); InitOnAffiliatedLogin(); delayed_init_on_login_timer_.Start( @@ -262,7 +216,7 @@ telemetry_report_queue_ = delegate_->CreatePeriodicUploadReportQueue( EventType::kDevice, Destination::TELEMETRY_METRIC, Priority::MANUAL_BATCH, &reporting_settings_, ::ash::kReportUploadFrequency, - GetDefaultReportUploadFrequency()); + metrics::GetDefaultReportUploadFrequency()); event_report_queue_ = delegate_->CreateMetricReportQueue( EventType::kDevice, Destination::EVENT_METRIC, Priority::SLOW_BATCH); peripheral_events_and_telemetry_report_queue_ = @@ -341,12 +295,12 @@ InitEventObserverManager( std::make_unique<AudioEventsObserver>(), /*enable_setting_path=*/::ash::kReportDeviceAudioStatus, - kReportDeviceAudioStatusDefaultValue); + metrics::kReportDeviceAudioStatusDefaultValue); // Network health events observer. InitEventObserverManager( std::make_unique<NetworkEventsObserver>(), /*enable_setting_path=*/::ash::kReportDeviceNetworkStatus, - kReportDeviceNetworkStatusDefaultValue); + metrics::kReportDeviceNetworkStatusDefaultValue); InitPeripheralsCollectors(); } @@ -462,9 +416,10 @@ InitPeriodicCollector( std::move(network_telemetry_sampler), telemetry_report_queue_.get(), /*enable_setting_path=*/::ash::kReportDeviceNetworkStatus, - kReportDeviceNetworkStatusDefaultValue, + metrics::kReportDeviceNetworkStatusDefaultValue, ::ash::kReportDeviceNetworkTelemetryCollectionRateMs, - GetDefaultCollectionRate(kDefaultNetworkTelemetryCollectionRate)); + metrics::GetDefaultCollectionRate( + metrics::kDefaultNetworkTelemetryCollectionRate)); // HttpsLatency events. InitPeriodicEventCollector( @@ -472,29 +427,32 @@ std::make_unique<HttpsLatencyEventDetector>(), /*additional_samplers=*/{}, event_report_queue_.get(), /*enable_setting_path=*/::ash::kReportDeviceNetworkStatus, - kReportDeviceNetworkStatusDefaultValue, + metrics::kReportDeviceNetworkStatusDefaultValue, ::ash::kReportDeviceNetworkTelemetryEventCheckingRateMs, - GetDefaultEventCheckingRate(kDefaultNetworkTelemetryEventCheckingRate)); + metrics::GetDefaultEventCheckingRate( + metrics::kDefaultNetworkTelemetryEventCheckingRate)); // Network bandwidth telemetry. InitPeriodicCollector( std::move(network_bandwidth_sampler), user_telemetry_report_queue_.get(), /*enable_setting_path=*/::ash::kReportDeviceNetworkStatus, - kReportDeviceNetworkStatusDefaultValue, + metrics::kReportDeviceNetworkStatusDefaultValue, ::ash::kReportDeviceNetworkTelemetryCollectionRateMs, - GetDefaultCollectionRate(kDefaultNetworkTelemetryCollectionRate)); + metrics::GetDefaultCollectionRate( + metrics::kDefaultNetworkTelemetryCollectionRate)); } void MetricReportingManager::InitAudioCollectors() { auto audio_telemetry_sampler = std::make_unique<CrosHealthdMetricSampler>( chromeos::cros_healthd::mojom::ProbeCategoryEnum::kAudio, CrosHealthdMetricSampler::MetricType::kTelemetry); - InitPeriodicCollector( - std::move(audio_telemetry_sampler), telemetry_report_queue_.get(), - /*enable_setting_path=*/::ash::kReportDeviceAudioStatus, - kReportDeviceAudioStatusDefaultValue, - ::ash::kReportDeviceAudioStatusCheckingRateMs, - GetDefaultCollectionRate(kDefaultAudioTelemetryCollectionRate)); + InitPeriodicCollector(std::move(audio_telemetry_sampler), + telemetry_report_queue_.get(), + /*enable_setting_path=*/::ash::kReportDeviceAudioStatus, + metrics::kReportDeviceAudioStatusDefaultValue, + ::ash::kReportDeviceAudioStatusCheckingRateMs, + metrics::GetDefaultCollectionRate( + metrics::kDefaultAudioTelemetryCollectionRate)); } void MetricReportingManager::InitPeripheralsCollectors() { @@ -505,7 +463,8 @@ event_observer_managers_.emplace_back(delegate_->CreateEventObserverManager( std::make_unique<UsbEventsObserver>(), peripheral_events_and_telemetry_report_queue_.get(), &reporting_settings_, - ::ash::kReportDevicePeripherals, kReportDevicePeripheralsDefaultValue, + ::ash::kReportDevicePeripherals, + metrics::kReportDevicePeripheralsDefaultValue, /*additional_samplers=*/std::vector<Sampler*>())); auto peripheral_telemetry_sampler = @@ -517,7 +476,8 @@ CreateCrosHealthdOneShotCollector( chromeos::cros_healthd::mojom::ProbeCategoryEnum::kBus, CrosHealthdMetricSampler::MetricType::kTelemetry, - ash::kReportDevicePeripherals, kReportDevicePeripheralsDefaultValue, + ash::kReportDevicePeripherals, + metrics::kReportDevicePeripheralsDefaultValue, peripheral_events_and_telemetry_report_queue_.get()); } } // namespace reporting
diff --git a/chrome/browser/ash/preferences_unittest.cc b/chrome/browser/ash/preferences_unittest.cc index 68b9585..608f746 100644 --- a/chrome/browser/ash/preferences_unittest.cc +++ b/chrome/browser/ash/preferences_unittest.cc
@@ -33,8 +33,8 @@ #include "components/sync/model/syncable_service.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/preference_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/user_manager/scoped_user_manager.h" #include "content/public/test/browser_task_environment.h"
diff --git a/chrome/browser/ash/printing/enterprise_printers_provider_unittest.cc b/chrome/browser/ash/printing/enterprise_printers_provider_unittest.cc index 11b014a3..f1545d56 100644 --- a/chrome/browser/ash/printing/enterprise_printers_provider_unittest.cc +++ b/chrome/browser/ash/printing/enterprise_printers_provider_unittest.cc
@@ -21,7 +21,7 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "components/sync/model/model_type_store.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/model_type_store_test_util.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/ash/printing/oauth2/authorization_zones_manager_unittest.cc b/chrome/browser/ash/printing/oauth2/authorization_zones_manager_unittest.cc index 12f3d40..b7c93db 100644 --- a/chrome/browser/ash/printing/oauth2/authorization_zones_manager_unittest.cc +++ b/chrome/browser/ash/printing/oauth2/authorization_zones_manager_unittest.cc
@@ -19,8 +19,8 @@ #include "chromeos/printing/uri.h" #include "components/sync/model/model_type_store.h" #include "components/sync/protocol/entity_data.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "content/public/test/browser_task_environment.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/ash/printing/oauth2/profile_auth_servers_sync_bridge_unittest.cc b/chrome/browser/ash/printing/oauth2/profile_auth_servers_sync_bridge_unittest.cc index 0b03ac2b..c357064 100644 --- a/chrome/browser/ash/printing/oauth2/profile_auth_servers_sync_bridge_unittest.cc +++ b/chrome/browser/ash/printing/oauth2/profile_auth_servers_sync_bridge_unittest.cc
@@ -19,8 +19,8 @@ #include "components/sync/model/in_memory_metadata_change_list.h" #include "components/sync/model/model_type_store.h" #include "components/sync/protocol/entity_data.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h"
diff --git a/chrome/browser/ash/printing/printers_sync_bridge_unittest.cc b/chrome/browser/ash/printing/printers_sync_bridge_unittest.cc index 7993206..2b50f674 100644 --- a/chrome/browser/ash/printing/printers_sync_bridge_unittest.cc +++ b/chrome/browser/ash/printing/printers_sync_bridge_unittest.cc
@@ -10,7 +10,7 @@ #include "base/debug/dump_without_crashing.h" #include "base/test/task_environment.h" #include "chrome/browser/ash/printing/printers_sync_bridge.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/model_type_store_test_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace ash {
diff --git a/chrome/browser/ash/printing/synced_printers_manager_unittest.cc b/chrome/browser/ash/printing/synced_printers_manager_unittest.cc index 06d6da86..f19335b 100644 --- a/chrome/browser/ash/printing/synced_printers_manager_unittest.cc +++ b/chrome/browser/ash/printing/synced_printers_manager_unittest.cc
@@ -20,7 +20,7 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "components/sync/model/model_type_store.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/model_type_store_test_util.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc b/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc index 03fc1c9..cc29989f 100644 --- a/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc +++ b/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc
@@ -48,9 +48,9 @@ #include "components/services/app_service/public/mojom/types.mojom.h" #include "components/sync/protocol/app_list_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" #include "components/user_manager/user_type.h"
diff --git a/chrome/browser/browser_process_platform_part_chromeos.cc b/chrome/browser/browser_process_platform_part_chromeos.cc index 1445c17..6ab6501 100644 --- a/chrome/browser/browser_process_platform_part_chromeos.cc +++ b/chrome/browser/browser_process_platform_part_chromeos.cc
@@ -157,7 +157,7 @@ if (!handled_by_chrome) continue; - int add_types = TabStripModel::ADD_NONE | TabStripModel::ADD_FORCE_INDEX; + int add_types = AddTabTypes::ADD_NONE | AddTabTypes::ADD_FORCE_INDEX; NavigateParams params(browser, url, ui::PAGE_TRANSITION_AUTO_TOPLEVEL); params.disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB; params.tabstrip_add_types = add_types;
diff --git a/chrome/browser/browsing_data/counters/browsing_data_counter_utils_browsertest.cc b/chrome/browser/browsing_data/counters/browsing_data_counter_utils_browsertest.cc index 56efd91..4775130 100644 --- a/chrome/browser/browsing_data/counters/browsing_data_counter_utils_browsertest.cc +++ b/chrome/browser/browsing_data/counters/browsing_data_counter_utils_browsertest.cc
@@ -14,7 +14,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "components/signin/public/base/signin_buildflags.h" #include "components/sync/driver/sync_service_impl.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include "content/public/test/browser_test.h" #if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/chromeos/extensions/users_private/users_private_api.cc b/chrome/browser/chromeos/extensions/users_private/users_private_api.cc index 5d7d1518..255a14e 100644 --- a/chrome/browser/chromeos/extensions/users_private/users_private_api.cc +++ b/chrome/browser/chromeos/extensions/users_private/users_private_api.cc
@@ -92,9 +92,8 @@ return api_user; } -std::unique_ptr<base::ListValue> GetUsersList( - content::BrowserContext* browser_context) { - std::unique_ptr<base::ListValue> user_list(new base::ListValue); +base::Value::List GetUsersList(content::BrowserContext* browser_context) { + base::Value::List user_list; if (!CanModifyUserList(browser_context)) return user_list; @@ -140,7 +139,7 @@ std::string email = maybe_email ? *maybe_email : std::string(); AccountId account_id = AccountId::FromUserEmail(email); const user_manager::User* user = user_manager->FindUser(account_id); - user_list->Append(base::Value::FromUniquePtrValue( + user_list.Append(base::Value::FromUniquePtrValue( (user ? CreateApiUser(email, *user) : CreateUnknownApiUser(email)) .ToValue())); } @@ -164,8 +163,7 @@ UsersPrivateGetUsersFunction::~UsersPrivateGetUsersFunction() = default; ExtensionFunction::ResponseAction UsersPrivateGetUsersFunction::Run() { - return RespondNow(OneArgument( - base::Value::FromUniquePtrValue(GetUsersList(browser_context())))); + return RespondNow(WithArguments(GetUsersList(browser_context()))); } //////////////////////////////////////////////////////////////////////////////// @@ -182,9 +180,9 @@ std::string username = gaia::CanonicalizeEmail(parameters->email); if (IsExistingUser(username)) { - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } - return RespondNow(OneArgument(base::Value(false))); + return RespondNow(WithArguments(false)); } //////////////////////////////////////////////////////////////////////////////// @@ -201,12 +199,12 @@ // Non-owners should not be able to add users. if (!CanModifyUserList(browser_context())) { - return RespondNow(OneArgument(base::Value(false))); + return RespondNow(WithArguments(false)); } std::string username = gaia::CanonicalizeEmail(parameters->email); if (IsExistingUser(username)) { - return RespondNow(OneArgument(base::Value(false))); + return RespondNow(WithArguments(false)); } base::Value username_value(username); @@ -216,7 +214,7 @@ PrefsUtil* prefs_util = delegate->GetPrefsUtil(); bool added = prefs_util->AppendToListCrosSetting(ash::kAccountsPrefUsers, username_value); - return RespondNow(OneArgument(base::Value(added))); + return RespondNow(WithArguments(added)); } //////////////////////////////////////////////////////////////////////////////// @@ -233,7 +231,7 @@ // Non-owners should not be able to remove users. if (!CanModifyUserList(browser_context())) { - return RespondNow(OneArgument(base::Value(false))); + return RespondNow(WithArguments(false)); } base::Value canonical_email(gaia::CanonicalizeEmail(parameters->email)); @@ -247,7 +245,7 @@ AccountId::FromUserEmail(parameters->email), user_manager::UserRemovalReason::LOCAL_USER_INITIATED, /*delegate=*/nullptr); - return RespondNow(OneArgument(base::Value(removed))); + return RespondNow(WithArguments(removed)); } //////////////////////////////////////////////////////////////////////////////// @@ -260,7 +258,7 @@ ~UsersPrivateIsUserListManagedFunction() {} ExtensionFunction::ResponseAction UsersPrivateIsUserListManagedFunction::Run() { - return RespondNow(OneArgument(base::Value(IsDeviceEnterpriseManaged()))); + return RespondNow(WithArguments(IsDeviceEnterpriseManaged())); } //////////////////////////////////////////////////////////////////////////////// @@ -275,7 +273,7 @@ ExtensionFunction::ResponseAction UsersPrivateGetCurrentUserFunction::Run() { const user_manager::User* user = ash::ProfileHelper::Get()->GetUserByProfile( Profile::FromBrowserContext(browser_context())); - return user ? RespondNow(OneArgument(base::Value::FromUniquePtrValue( + return user ? RespondNow(WithArguments(base::Value::FromUniquePtrValue( CreateApiUser(user->GetAccountId().GetUserEmail(), *user) .ToValue()))) : RespondNow(Error("No Current User")); @@ -296,11 +294,10 @@ const bool is_screen_locked = session_manager::SessionManager::Get()->IsScreenLocked(); - auto result = std::make_unique<base::DictionaryValue>(); - result->SetKey("isLoggedIn", base::Value(is_logged_in)); - result->SetKey("isScreenLocked", base::Value(is_screen_locked)); - return RespondNow( - OneArgument(base::Value::FromUniquePtrValue(std::move(result)))); + base::Value::Dict result; + result.Set("isLoggedIn", base::Value(is_logged_in)); + result.Set("isScreenLocked", base::Value(is_screen_locked)); + return RespondNow(WithArguments(std::move(result))); } } // namespace extensions
diff --git a/chrome/browser/chromeos/reporting/metric_default_utils.cc b/chrome/browser/chromeos/reporting/metric_default_utils.cc new file mode 100644 index 0000000..39127f7 --- /dev/null +++ b/chrome/browser/chromeos/reporting/metric_default_utils.cc
@@ -0,0 +1,40 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/reporting/metric_default_utils.h" + +#include "base/feature_list.h" +#include "base/time/time.h" +#include "components/reporting/metrics/metric_rate_controller.h" + +namespace reporting::metrics { +namespace { + +const base::TimeDelta GetDefaultRate(base::TimeDelta default_rate, + base::TimeDelta testing_rate) { + // If telemetry testing rates flag is enabled, use `testing_rate` to reduce + // time before metric collection and reporting. + return base::FeatureList::IsEnabled( + MetricRateController::kEnableTelemetryTestingRates) + ? testing_rate + : default_rate; +} + +} // namespace + +const base::TimeDelta GetDefaultReportUploadFrequency() { + return GetDefaultRate(kDefaultReportUploadFrequency, + kDefaultReportUploadFrequencyForTesting); +} + +const base::TimeDelta GetDefaultCollectionRate(base::TimeDelta default_rate) { + return GetDefaultRate(default_rate, kDefaultCollectionRateForTesting); +} + +const base::TimeDelta GetDefaultEventCheckingRate( + base::TimeDelta default_rate) { + return GetDefaultRate(default_rate, kDefaultEventCheckingRateForTesting); +} + +} // namespace reporting::metrics
diff --git a/chrome/browser/chromeos/reporting/metric_default_utils.h b/chrome/browser/chromeos/reporting/metric_default_utils.h new file mode 100644 index 0000000..d5369cb --- /dev/null +++ b/chrome/browser/chromeos/reporting/metric_default_utils.h
@@ -0,0 +1,64 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_REPORTING_METRIC_DEFAULT_UTILS_H_ +#define CHROME_BROWSER_CHROMEOS_REPORTING_METRIC_DEFAULT_UTILS_H_ + +#include "base/time/time.h" + +namespace reporting::metrics { + +// Default audio telemetry collection rate. +constexpr base::TimeDelta kDefaultAudioTelemetryCollectionRate = + base::Minutes(10); + +// Default metric collection rate used for testing purposes. +constexpr base::TimeDelta kDefaultCollectionRateForTesting = base::Minutes(2); + +// Default event checking rate for testing purposes. +constexpr base::TimeDelta kDefaultEventCheckingRateForTesting = + base::Minutes(1); + +// Default network telemetry collection rate. +constexpr base::TimeDelta kDefaultNetworkTelemetryCollectionRate = + base::Minutes(60); + +// Default network telemetry event checking rate. +constexpr base::TimeDelta kDefaultNetworkTelemetryEventCheckingRate = + base::Minutes(10); + +// Default record upload frequency. +constexpr base::TimeDelta kDefaultReportUploadFrequency = base::Hours(3); + +// Default record upload frequency used for testing purposes. +constexpr base::TimeDelta kDefaultReportUploadFrequencyForTesting = + base::Minutes(5); + +// Metric reporting manager initialization delay. +constexpr base::TimeDelta kInitDelay = base::Minutes(1); + +// Initial metric reporting upload delay. +constexpr base::TimeDelta kInitialUploadDelay = base::Minutes(3); + +// Default value for reporting device audio status. +constexpr bool kReportDeviceAudioStatusDefaultValue = true; + +// Default value for reporting device network status. +constexpr bool kReportDeviceNetworkStatusDefaultValue = true; + +// Default value for reporting device peripheral status. +constexpr bool kReportDevicePeripheralsDefaultValue = false; + +// Returns the default report upload frequency for the current environment. +const base::TimeDelta GetDefaultReportUploadFrequency(); + +// Returns the default metric collection rate for the current environment. +const base::TimeDelta GetDefaultCollectionRate(base::TimeDelta default_rate); + +// Returns the default event checking rate for the current environment. +const base::TimeDelta GetDefaultEventCheckingRate(base::TimeDelta default_rate); + +} // namespace reporting::metrics + +#endif // CHROME_BROWSER_CHROMEOS_REPORTING_METRIC_DEFAULT_UTILS_H_
diff --git a/chrome/browser/commerce/shopping_service_factory.cc b/chrome/browser/commerce/shopping_service_factory.cc index 70c871f3..afc83af 100644 --- a/chrome/browser/commerce/shopping_service_factory.cc +++ b/chrome/browser/commerce/shopping_service_factory.cc
@@ -7,8 +7,10 @@ #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h" #include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h" +#include "chrome/browser/persisted_state_db/session_proto_db_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/identity_manager_factory.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" #include "components/commerce/core/shopping_service.h" #include "components/prefs/pref_service.h" #include "content/public/browser/storage_partition.h" @@ -42,6 +44,9 @@ DependsOn(BookmarkModelFactory::GetInstance()); DependsOn(OptimizationGuideKeyedServiceFactory::GetInstance()); DependsOn(IdentityManagerFactory::GetInstance()); + DependsOn(SessionProtoDBFactory< + commerce_subscription_db::CommerceSubscriptionContentProto>:: + GetInstance()); } KeyedService* ShoppingServiceFactory::BuildServiceInstanceFor( @@ -52,7 +57,10 @@ OptimizationGuideKeyedServiceFactory::GetForProfile(profile), profile->GetPrefs(), IdentityManagerFactory::GetForProfile(profile), profile->GetDefaultStoragePartition() - ->GetURLLoaderFactoryForBrowserProcess()); + ->GetURLLoaderFactoryForBrowserProcess(), + SessionProtoDBFactory<commerce_subscription_db:: + CommerceSubscriptionContentProto>::GetInstance() + ->GetForProfile(context)); } bool ShoppingServiceFactory::ServiceIsCreatedWithBrowserContext() const {
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index 5d6907c..c65d151 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc
@@ -1699,7 +1699,7 @@ browser_->tab_strip_model()->AddWebContents( OwnedMainWebContents::TakeWebContents( std::move(owned_main_web_contents_)), - -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, TabStripModel::ADD_ACTIVE); + -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, AddTabTypes::ADD_ACTIVE); OverrideAndSyncDevToolsRendererPrefs(); }
diff --git a/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc b/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc index dcd13db..c41b33c2 100644 --- a/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc +++ b/chrome/browser/extensions/api/autofill_private/autofill_private_api.cc
@@ -278,7 +278,7 @@ personal_data->AddProfile(profile); } - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -337,7 +337,7 @@ address_components.Set("components", std::move(rows)); address_components.Set("languageCode", language_code); - return RespondNow(OneArgument(base::Value(std::move(address_components)))); + return RespondNow(WithArguments(std::move(address_components))); } //////////////////////////////////////////////////////////////////////////////// @@ -414,7 +414,7 @@ if (use_existing_card) { // Only updates when the card info changes. if (existing_card && existing_card->Compare(credit_card) == 0) - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); // Record when nickname is updated. if (credit_card.HasNonEmptyValidNickname() && @@ -434,7 +434,7 @@ } } - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -453,7 +453,7 @@ personal_data->RemoveByGUID(parameters->guid); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -477,7 +477,7 @@ RemoveDuplicatePhoneNumberAtIndex(params->index_of_new_number, params->country_code, phone_numbers); - return RespondNow(OneArgument(base::Value(std::move(phone_numbers)))); + return RespondNow(WithArguments(std::move(phone_numbers))); } //////////////////////////////////////////////////////////////////////////////// @@ -496,7 +496,7 @@ personal_data->ResetFullServerCard(parameters->guid); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -554,7 +554,7 @@ local_card_migration_manager->GetMigratableCreditCards(); local_card_migration_manager->AttemptToOfferLocalCardMigration( /*is_from_settings_page=*/true); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -570,7 +570,7 @@ return RespondNow(Error(kErrorDataUnavailable)); personal_data->LogServerCardLinkClicked(); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -596,7 +596,7 @@ credit_card_access_manager->OnSettingsPageFIDOAuthToggled( parameters->enabled); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -650,7 +650,7 @@ virtual_card_enrollment_manager->InitVirtualCardEnroll( *card, autofill::VirtualCardEnrollmentSource::kSettingsPage); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } //////////////////////////////////////////////////////////////////////////////// @@ -692,7 +692,7 @@ virtual_card_enrollment_manager->Unenroll( card->instrument_id(), /*virtual_card_enrollment_update_response_callback=*/absl::nullopt); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } } // namespace extensions
diff --git a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc index d1d68db9b..8e3b369 100644 --- a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc +++ b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc
@@ -340,7 +340,7 @@ if (cut && HasPermanentNodes(nodes)) return Error(bookmark_keys::kModifySpecialError); bookmarks::CopyToClipboard(model, nodes, cut); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -395,7 +395,7 @@ highest_index = parent_node->children().size(); bookmarks::PasteFromClipboard(model, parent_node, highest_index); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -406,7 +406,7 @@ PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) - return OneArgument(base::Value(false)); + return WithArguments(false); BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(GetProfile()); @@ -414,7 +414,7 @@ if (!parent_node) return Error(bookmark_keys::kNoParentError); bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); - return OneArgument(base::Value(can_paste)); + return WithArguments(can_paste); } ExtensionFunction::ResponseValue @@ -434,7 +434,7 @@ if (!CanBeModified(parent_node, &error)) return Error(error); model->SortChildren(parent_node); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -463,7 +463,7 @@ GetProfile(), {std::move(nodes), params->drag_node_index, web_contents, source, gfx::Point(params->x, params->y)}); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -502,7 +502,7 @@ GetProfile(), *drag_data, drop_parent, drop_index, copy); router->ClearBookmarkNodeData(); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -556,7 +556,7 @@ return Error(error); } - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -566,7 +566,7 @@ BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> Undo(); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -576,7 +576,7 @@ BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> Redo(); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -604,7 +604,7 @@ if (!result) return Error(error); - return NoArguments(); + return WithArguments(); } ExtensionFunction::ResponseValue @@ -678,7 +678,7 @@ first_tab = false; } - return NoArguments(); + return WithArguments(); } WEB_CONTENTS_USER_DATA_KEY_IMPL(BookmarkManagerPrivateDragEventRouter);
diff --git a/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc b/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc index 1f60641..e7f5a97 100644 --- a/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc +++ b/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc
@@ -14,7 +14,6 @@ #include "base/bind.h" #include "base/strings/stringprintf.h" #include "base/task/thread_pool.h" -#include "base/values.h" #include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/account_reconcilor_factory.h" @@ -161,15 +160,13 @@ // REMOVE_SITE_DATA in browsing_data_remover.h, the former for the unprotected // web, the latter for protected web data. There is no UI control for // extension data. - base::Value origin_types(base::Value::Type::DICTIONARY); - origin_types.SetBoolKey( - extension_browsing_data_api_constants::kUnprotectedWebKey, - isDataTypeSelected(BrowsingDataType::COOKIES, tab)); - origin_types.SetBoolKey( - extension_browsing_data_api_constants::kProtectedWebKey, - isDataTypeSelected(BrowsingDataType::HOSTED_APPS_DATA, tab)); - origin_types.SetBoolKey(extension_browsing_data_api_constants::kExtensionsKey, - false); + base::Value::Dict origin_types; + origin_types.Set(extension_browsing_data_api_constants::kUnprotectedWebKey, + isDataTypeSelected(BrowsingDataType::COOKIES, tab)); + origin_types.Set(extension_browsing_data_api_constants::kProtectedWebKey, + isDataTypeSelected(BrowsingDataType::HOSTED_APPS_DATA, tab)); + origin_types.Set(extension_browsing_data_api_constants::kExtensionsKey, + false); // Fill deletion time period. int period_pref = @@ -183,14 +180,14 @@ since = time.ToJsTime(); } - base::Value options(base::Value::Type::DICTIONARY); - options.SetKey(extension_browsing_data_api_constants::kOriginTypesKey, - std::move(origin_types)); - options.SetDoubleKey(extension_browsing_data_api_constants::kSinceKey, since); + base::Value::Dict options; + options.Set(extension_browsing_data_api_constants::kOriginTypesKey, + std::move(origin_types)); + options.Set(extension_browsing_data_api_constants::kSinceKey, since); // Fill dataToRemove and dataRemovalPermitted. - base::Value selected(base::Value::Type::DICTIONARY); - base::Value permitted(base::Value::Type::DICTIONARY); + base::Value::Dict selected; + base::Value::Dict permitted; bool delete_site_data = isDataTypeSelected(BrowsingDataType::COOKIES, tab) || @@ -237,23 +234,23 @@ extension_browsing_data_api_constants::kPasswordsKey, isDataTypeSelected(BrowsingDataType::PASSWORDS, tab)); - base::Value result(base::Value::Type::DICTIONARY); - result.SetKey(extension_browsing_data_api_constants::kOptionsKey, - std::move(options)); - result.SetKey(extension_browsing_data_api_constants::kDataToRemoveKey, - std::move(selected)); - result.SetKey(extension_browsing_data_api_constants::kDataRemovalPermittedKey, - std::move(permitted)); - return RespondNow(OneArgument(std::move(result))); + base::Value::Dict result; + result.Set(extension_browsing_data_api_constants::kOptionsKey, + std::move(options)); + result.Set(extension_browsing_data_api_constants::kDataToRemoveKey, + std::move(selected)); + result.Set(extension_browsing_data_api_constants::kDataRemovalPermittedKey, + std::move(permitted)); + return RespondNow(WithArguments(std::move(result))); } -void BrowsingDataSettingsFunction::SetDetails(base::Value* selected_dict, - base::Value* permitted_dict, +void BrowsingDataSettingsFunction::SetDetails(base::Value::Dict* selected_dict, + base::Value::Dict* permitted_dict, const char* data_type, bool is_selected) { bool is_permitted = IsRemovalPermitted(MaskForKey(data_type), prefs_); - selected_dict->SetBoolKey(data_type, is_selected && is_permitted); - permitted_dict->SetBoolKey(data_type, is_permitted); + selected_dict->Set(data_type, is_selected && is_permitted); + permitted_dict->Set(data_type, is_permitted); } BrowsingDataRemoverFunction::BrowsingDataRemoverFunction() = default; @@ -270,7 +267,7 @@ return; synced_data_deletion_.reset(); observation_.Reset(); - Respond(NoArguments()); + Respond(WithArguments()); Release(); // Balanced in StartRemoving. } @@ -282,13 +279,13 @@ // Grab the initial |options| parameter, and parse out the arguments. EXTENSION_FUNCTION_VALIDATE(args().size() >= 1); EXTENSION_FUNCTION_VALIDATE(args()[0].is_dict()); - const base::Value& options = args()[0]; + const base::Value::Dict& options = args()[0].GetDict(); EXTENSION_FUNCTION_VALIDATE(ParseOriginTypeMask(options, &origin_type_mask_)); // If |ms_since_epoch| isn't set, default it to 0. double ms_since_epoch = - options.FindDoubleKey(extension_browsing_data_api_constants::kSinceKey) + options.FindDouble(extension_browsing_data_api_constants::kSinceKey) .value_or(0); // base::Time takes a double that represents seconds since epoch. JavaScript @@ -298,9 +295,9 @@ EXTENSION_FUNCTION_VALIDATE(GetRemovalMask(&removal_mask_)); - const base::Value* origins = - options.FindListKey(extension_browsing_data_api_constants::kOriginsKey); - const base::Value* exclude_origins = options.FindListKey( + const base::Value::List* origins = + options.FindList(extension_browsing_data_api_constants::kOriginsKey); + const base::Value::List* exclude_origins = options.FindList( extension_browsing_data_api_constants::kExcludeOriginsKey); // Check that only |origins| or |excludeOrigins| can be set. @@ -402,29 +399,27 @@ } bool BrowsingDataRemoverFunction::ParseOriginTypeMask( - const base::Value& options, + const base::Value::Dict& options, uint64_t* origin_type_mask) { - DCHECK(options.is_dict()); - // Parse the |options| dictionary to generate the origin set mask. Default to // UNPROTECTED_WEB if the developer doesn't specify anything. *origin_type_mask = content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB; const base::Value* origin_type_dict = - options.FindKey(extension_browsing_data_api_constants::kOriginTypesKey); + options.Find(extension_browsing_data_api_constants::kOriginTypesKey); if (!origin_type_dict) return true; if (!origin_type_dict->is_dict()) return false; - const base::Value* option = nullptr; + const base::Value::Dict& origin_type = origin_type_dict->GetDict(); // The developer specified something! Reset to 0 and parse the dictionary. *origin_type_mask = 0; // Unprotected web. - option = origin_type_dict->FindKey( + const base::Value* option = origin_type.Find( extension_browsing_data_api_constants::kUnprotectedWebKey); if (option) { if (!option->is_bool()) @@ -437,8 +432,8 @@ } // Protected web. - option = origin_type_dict->FindKey( - extension_browsing_data_api_constants::kProtectedWebKey); + option = + origin_type.Find(extension_browsing_data_api_constants::kProtectedWebKey); if (option) { if (!option->is_bool()) return false; @@ -450,8 +445,8 @@ } // Extensions. - option = origin_type_dict->FindKey( - extension_browsing_data_api_constants::kExtensionsKey); + option = + origin_type.Find(extension_browsing_data_api_constants::kExtensionsKey); if (option) { if (!option->is_bool()) return false; @@ -464,12 +459,12 @@ return true; } -bool BrowsingDataRemoverFunction::ParseOrigins(const base::Value& list_value, - std::vector<url::Origin>* result, - ResponseValue* error_response) { - DCHECK(list_value.is_list()); - result->reserve(list_value.GetListDeprecated().size()); - for (const auto& value : list_value.GetListDeprecated()) { +bool BrowsingDataRemoverFunction::ParseOrigins( + const base::Value::List& list_value, + std::vector<url::Origin>* result, + ResponseValue* error_response) { + result->reserve(list_value.size()); + for (const auto& value : list_value) { if (!value.is_string()) { *error_response = BadMessage(); return false;
diff --git a/chrome/browser/extensions/api/browsing_data/browsing_data_api.h b/chrome/browser/extensions/api/browsing_data/browsing_data_api.h index aa309af..fd7ec810 100644 --- a/chrome/browser/extensions/api/browsing_data/browsing_data_api.h +++ b/chrome/browser/extensions/api/browsing_data/browsing_data_api.h
@@ -76,8 +76,8 @@ // indicating whether the data type is both selected and permitted to be // removed; and a value in the |permitted_dict| with the |data_type| as a // key, indicating only whether the data type is permitted to be removed. - void SetDetails(base::Value* selected_dict, - base::Value* permitted_dict, + void SetDetails(base::Value::Dict* selected_dict, + base::Value::Dict* permitted_dict, const char* data_type, bool is_selected); @@ -127,13 +127,13 @@ // that can be used with the BrowsingDataRemover. // Returns true if parsing was successful. // Pre-condition: `options` is a dictionary. - bool ParseOriginTypeMask(const base::Value& options, + bool ParseOriginTypeMask(const base::Value::Dict& options, uint64_t* origin_type_mask); // Parses the developer-provided list of origins into |result|. // Returns whether or not parsing was successful. In case of parse failure, // |error_response| will contain the error response. - bool ParseOrigins(const base::Value& list_value, + bool ParseOrigins(const base::Value::List& list_value, std::vector<url::Origin>* result, ResponseValue* error_response);
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.cc b/chrome/browser/extensions/api/content_settings/content_settings_api.cc index 9a649523..9d738a4e8 100644 --- a/chrome/browser/extensions/api/content_settings/content_settings_api.cc +++ b/chrome/browser/extensions/api/content_settings/content_settings_api.cc
@@ -112,7 +112,7 @@ store->ClearContentSettingsForExtensionAndContentType(extension_id(), scope, content_type); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } ExtensionFunction::ResponseAction @@ -171,13 +171,13 @@ content_settings::CookieSettings::QueryReason::kSetting) : map->GetContentSetting(primary_url, secondary_url, content_type); - base::Value result(base::Value::Type::DICTIONARY); + base::Value::Dict result; std::string setting_string = content_settings::ContentSettingToString(setting); DCHECK(!setting_string.empty()); - result.SetStringKey(ContentSettingsStore::kContentSettingKey, setting_string); + result.Set(ContentSettingsStore::kContentSettingKey, setting_string); - return RespondNow(OneArgument(std::move(result))); + return RespondNow(WithArguments(std::move(result))); } ExtensionFunction::ResponseAction @@ -302,7 +302,7 @@ secondary_pattern, content_type, setting, scope); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } ExtensionFunction::ResponseAction @@ -311,7 +311,7 @@ // plugins have been deprecated since Chrome 87, there are no resource // identifiers for existing settings (but we retain the function for // backwards and potential forwards compatibility). - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } } // namespace extensions
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc index 755f6b25..43eb3bc 100644 --- a/chrome/browser/extensions/api/cookies/cookies_api.cc +++ b/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -14,7 +14,6 @@ #include "base/json/json_writer.h" #include "base/lazy_instance.h" #include "base/time/time.h" -#include "base/values.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" @@ -118,17 +117,18 @@ const net::CookieChangeInfo& change) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - std::unique_ptr<base::ListValue> args(new base::ListValue()); - base::Value dict(base::Value::Type::DICTIONARY); - dict.SetBoolKey(cookies_api_constants::kRemovedKey, - change.cause != net::CookieChangeCause::INSERTED); + base::Value::List args; + base::Value::Dict dict; + dict.Set(cookies_api_constants::kRemovedKey, + change.cause != net::CookieChangeCause::INSERTED); Profile* profile = otr ? profile_->GetPrimaryOTRProfile(/*create_if_needed=*/true) : profile_->GetOriginalProfile(); api::cookies::Cookie cookie = cookies_helpers::CreateCookie( change.cookie, cookies_helpers::GetStoreIdFromProfile(profile)); - dict.SetKey(cookies_api_constants::kCookieKey, std::move(*cookie.ToValue())); + dict.Set(cookies_api_constants::kCookieKey, + base::Value::FromUniquePtrValue(cookie.ToValue())); // Map the internal cause to an external string. std::string cause_dict_entry; @@ -159,9 +159,9 @@ case net::CookieChangeCause::UNKNOWN_DELETION: NOTREACHED(); } - dict.SetStringKey(cookies_api_constants::kCauseKey, cause_dict_entry); + dict.Set(cookies_api_constants::kCauseKey, cause_dict_entry); - args->Append(std::move(dict)); + args.Append(std::move(dict)); DispatchEvent(profile, events::COOKIES_ON_CHANGED, api::cookies::OnChanged::kEventName, std::move(args), @@ -215,17 +215,16 @@ MaybeStartListening(); } -void CookiesEventRouter::DispatchEvent( - content::BrowserContext* context, - events::HistogramValue histogram_value, - const std::string& event_name, - std::unique_ptr<base::ListValue> event_args, - const GURL& cookie_domain) { - EventRouter* router = context ? EventRouter::Get(context) : NULL; +void CookiesEventRouter::DispatchEvent(content::BrowserContext* context, + events::HistogramValue histogram_value, + const std::string& event_name, + base::Value::List event_args, + const GURL& cookie_domain) { + EventRouter* router = context ? EventRouter::Get(context) : nullptr; if (!router) return; - auto event = std::make_unique<Event>( - histogram_value, event_name, std::move(event_args->GetList()), context); + auto event = std::make_unique<Event>(histogram_value, event_name, + std::move(event_args), context); event->event_url = cookie_domain; router->BroadcastEvent(std::move(event)); } @@ -279,7 +278,7 @@ } // The cookie doesn't exist; return null. - Respond(OneArgument(base::Value())); + Respond(WithArguments(base::Value())); } CookiesGetAllFunction::CookiesGetAllFunction() { @@ -336,7 +335,7 @@ ArgumentList(api::cookies::GetAll::Results::Create(match_vector)); } else { // TODO(devlin): When can |extension()| be null for this function? - response = NoArguments(); + response = WithArguments(); } Respond(std::move(response)); } @@ -355,7 +354,7 @@ ArgumentList(api::cookies::GetAll::Results::Create(match_vector)); } else { // TODO(devlin): When can |extension()| be null for this function? - response = NoArguments(); + response = WithArguments(); } Respond(std::move(response)); } @@ -497,7 +496,7 @@ } } - Respond(value ? std::move(value) : NoArguments()); + Respond(value ? std::move(value) : WithArguments()); } CookiesRemoveFunction::CookiesRemoveFunction() {
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.h b/chrome/browser/extensions/api/cookies/cookies_api.h index 33f64d5b..c0a27017 100644 --- a/chrome/browser/extensions/api/cookies/cookies_api.h +++ b/chrome/browser/extensions/api/cookies/cookies_api.h
@@ -13,6 +13,7 @@ #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" +#include "base/values.h" #include "chrome/browser/ui/browser_list_observer.h" #include "chrome/common/extensions/api/cookies.h" #include "extensions/browser/browser_context_keyed_api_factory.h" @@ -79,7 +80,7 @@ void DispatchEvent(content::BrowserContext* context, events::HistogramValue histogram_value, const std::string& event_name, - std::unique_ptr<base::ListValue> event_args, + base::Value::List event_args, const GURL& cookie_domain); raw_ptr<Profile> profile_;
diff --git a/chrome/browser/extensions/api/cryptotoken_private/cryptotoken_private_api.cc b/chrome/browser/extensions/api/cryptotoken_private/cryptotoken_private_api.cc index 299a7cb9..6fad739 100644 --- a/chrome/browser/extensions/api/cryptotoken_private/cryptotoken_private_api.cc +++ b/chrome/browser/extensions/api/cryptotoken_private/cryptotoken_private_api.cc
@@ -122,7 +122,7 @@ } if (origin_url == app_id_url) { - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } // Fetch the eTLD+1 of both. @@ -143,7 +143,7 @@ "Could not find an eTLD for appId *", params->app_id_url))); } if (origin_etldp1 == app_id_etldp1) { - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } // For legacy purposes, allow google.com origins to assert certain // gstatic.com appIds. @@ -151,10 +151,10 @@ if (origin_etldp1 == kGoogleDotCom) { for (const char* id : kGoogleGstaticAppIds) { if (params->app_id_url == id) - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } } - return RespondNow(OneArgument(base::Value(false))); + return RespondNow(WithArguments(false)); } CryptotokenPrivateIsAppIdHashInEnterpriseContextFunction:: @@ -205,7 +205,7 @@ for (const auto& entry : permit_attestation) { if (entry.GetString() == app_id) - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } // If the origin is blocked, reject attestation. @@ -213,14 +213,14 @@ device::fido_filter::Operation::MAKE_CREDENTIAL, origin.Serialize(), /*device=*/absl::nullopt, /*id=*/absl::nullopt) == device::fido_filter::Action::NO_ATTESTATION) { - return RespondNow(OneArgument(base::Value(false))); + return RespondNow(WithArguments(false)); } // If prompting is disabled, allow attestation because that is the historical // behavior. if (!base::FeatureList::IsEnabled( ::features::kSecurityKeyAttestationPrompt)) { - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } #if BUILDFLAG(IS_WIN) @@ -236,7 +236,7 @@ device::WinWebAuthnApi::GetDefault()->IsAvailable() && device::WinWebAuthnApi::GetDefault()->Version() >= WEBAUTHN_API_VERSION_2) { - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } #endif // BUILDFLAG(IS_WIN) @@ -272,7 +272,7 @@ } void CryptotokenPrivateCanAppIdGetAttestationFunction::Complete(bool result) { - Respond(OneArgument(base::Value(result))); + Respond(WithArguments(result)); } CryptotokenPrivateCanMakeU2fApiRequestFunction:: @@ -294,7 +294,7 @@ if (!ash::ProfileHelper::IsRegularProfile( Profile::FromBrowserContext(browser_context()))) { DCHECK_EQ(params->options.tab_id, api::tabs::TAB_ID_NONE); - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } #endif @@ -336,7 +336,7 @@ // (crbug.com/1257293). if (!base::FeatureList::IsEnabled(device::kU2fPermissionPrompt) || u2f_api_origin_trial_enabled) { - return RespondNow(OneArgument(base::Value(true))); + return RespondNow(WithArguments(true)); } permissions::PermissionRequestManager* permission_request_manager = @@ -361,7 +361,7 @@ } void CryptotokenPrivateCanMakeU2fApiRequestFunction::Complete(bool result) { - Respond(OneArgument(base::Value(result))); + Respond(WithArguments(result)); } ExtensionFunction::ResponseAction @@ -378,7 +378,7 @@ page_load_metrics::MetricsWebContentsObserver::RecordFeatureUsage( frame, blink::mojom::WebFeature::kU2FCryptotokenRegister); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } ExtensionFunction::ResponseAction @@ -394,7 +394,7 @@ page_load_metrics::MetricsWebContentsObserver::RecordFeatureUsage( frame, blink::mojom::WebFeature::kU2FCryptotokenSign); - return RespondNow(NoArguments()); + return RespondNow(WithArguments()); } } // namespace api
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index 3c12e5cd..a4ece96 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -836,7 +836,7 @@ result.Append(SerializeTarget(host)); } - return RespondNow(OneArgument(base::Value(std::move(result)))); + return RespondNow(WithArguments(std::move(result))); } } // namespace extensions
diff --git a/chrome/browser/extensions/api/language_settings_private/language_settings_private_api.cc b/chrome/browser/extensions/api/language_settings_private/language_settings_private_api.cc index 2bb375b..00869095 100644 --- a/chrome/browser/extensions/api/language_settings_private/language_settings_private_api.cc +++ b/chrome/browser/extensions/api/language_settings_private/language_settings_private_api.cc
@@ -681,7 +681,6 @@ CreateTranslatePrefsForBrowserContext(browser_context()); std::string chrome_language = language_code; - translate_prefs->AddToLanguageList(language_code, false); if (language_code == translate_prefs->GetRecentTargetLanguage()) { return RespondNow(NoArguments());
diff --git a/chrome/browser/extensions/api/language_settings_private/language_settings_private_api_unittest.cc b/chrome/browser/extensions/api/language_settings_private/language_settings_private_api_unittest.cc index 72f8e925..328574d 100644 --- a/chrome/browser/extensions/api/language_settings_private/language_settings_private_api_unittest.cc +++ b/chrome/browser/extensions/api/language_settings_private/language_settings_private_api_unittest.cc
@@ -264,11 +264,6 @@ api_test_utils::RunFunctionAndReturnSingleResult(function.get(), "[\"af\"]", profile()); ASSERT_EQ(translate_prefs_->GetRecentTargetLanguage(), "af"); - - std::vector<std::string> content_languages_after; - translate_prefs_->GetLanguageList(&content_languages_after); - ASSERT_EQ(std::vector<std::string>({"en-US", "en", "af"}), - content_languages_after); } TEST_F(LanguageSettingsPrivateApiTest, GetNeverTranslateLanguagesListTest) {
diff --git a/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chrome/browser/extensions/api/sessions/sessions_apitest.cc index 87664f6..1b210e5 100644 --- a/chrome/browser/extensions/api/sessions/sessions_apitest.cc +++ b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
@@ -40,7 +40,7 @@ #include "components/sync/protocol/model_type_state.pb.h" #include "components/sync/protocol/session_specifics.pb.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/engine/mock_model_type_worker.h" +#include "components/sync/test/mock_model_type_worker.h" #include "components/sync_sessions/session_store.h" #include "components/sync_sessions/session_sync_service.h" #include "content/public/test/browser_test.h"
diff --git a/chrome/browser/extensions/api/storage/settings_apitest.cc b/chrome/browser/extensions/api/storage/settings_apitest.cc index fa3996c..25e0302a 100644 --- a/chrome/browser/extensions/api/storage/settings_apitest.cc +++ b/chrome/browser/extensions/api/storage/settings_apitest.cc
@@ -29,9 +29,9 @@ #include "components/sync/model/sync_change_processor.h" #include "components/sync/model/sync_error_factory.h" #include "components/sync/model/syncable_service.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/version_info/channel.h" #include "content/public/test/browser_test.h" #include "extensions/browser/api/storage/backend_task_runner.h"
diff --git a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc index dbf8a92..ff22cc8 100644 --- a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc +++ b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
@@ -22,8 +22,8 @@ #include "chrome/test/base/testing_profile.h" #include "components/sync/model/sync_change_processor.h" #include "components/sync/model/sync_error_factory.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/value_store/test_value_store_factory.h" #include "components/value_store/testing_value_store.h" #include "content/public/test/browser_task_environment.h"
diff --git a/chrome/browser/extensions/api/tab_groups/tab_groups_api.cc b/chrome/browser/extensions/api/tab_groups/tab_groups_api.cc index ba27802..0fac333 100644 --- a/chrome/browser/extensions/api/tab_groups/tab_groups_api.cc +++ b/chrome/browser/extensions/api/tab_groups/tab_groups_api.cc
@@ -316,7 +316,7 @@ // Attach tabs in consecutive indices, to insert them in the same order. target_tab_strip->InsertWebContentsAt(new_index + i, std::move(web_contents), - TabStripModel::ADD_NONE, *group); + AddTabTypes::ADD_NONE, *group); } return true;
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc index 1e23d1ed..df2d317 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.cc +++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -367,7 +367,7 @@ target_index = target_tab_strip->count(); return target_tab_strip->InsertWebContentsAt( - target_index, std::move(web_contents), TabStripModel::ADD_NONE); + target_index, std::move(web_contents), AddTabTypes::ADD_NONE); } // This function sets the state of the browser window to a "locked" @@ -794,7 +794,7 @@ if (!target_tab_strip) return RespondNow(Error(tabs_constants::kTabStripNotEditableError)); target_tab_strip->InsertWebContentsAt( - urls.size(), std::move(detached_tab), TabStripModel::ADD_NONE); + urls.size(), std::move(detached_tab), AddTabTypes::ADD_NONE); } } // Create a new tab if the created window is still empty. Don't create a new
diff --git a/chrome/browser/extensions/api/tabs/tabs_apitest.cc b/chrome/browser/extensions/api/tabs/tabs_apitest.cc index 5c75d63..7dc16b8b 100644 --- a/chrome/browser/extensions/api/tabs/tabs_apitest.cc +++ b/chrome/browser/extensions/api/tabs/tabs_apitest.cc
@@ -482,7 +482,8 @@ content::test::PrerenderTestHelper prerender_helper_; }; -IN_PROC_BROWSER_TEST_F(ExtensionApiTabPrerenderingTest, Prerendering) { +// TODO(crbug.com/1352966): Flaky on multiple platforms. +IN_PROC_BROWSER_TEST_F(ExtensionApiTabPrerenderingTest, DISABLED_Prerendering) { ASSERT_TRUE(RunExtensionTest("tabs/prerendering")) << message_; }
diff --git a/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chrome/browser/extensions/api/web_request/web_request_apitest.cc index de2382a2..03d6fd97 100644 --- a/chrome/browser/extensions/api/web_request/web_request_apitest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
@@ -333,8 +333,18 @@ } // namespace +using ContextType = ExtensionBrowserTest::ContextType; + class ExtensionWebRequestApiTest : public ExtensionApiTest { public: + explicit ExtensionWebRequestApiTest( + ContextType context_type = ContextType::kFromManifest) + : ExtensionApiTest(context_type) {} + ExtensionWebRequestApiTest(const ExtensionWebRequestApiTest&) = delete; + ExtensionWebRequestApiTest& operator=(const ExtensionWebRequestApiTest&) = + delete; + ~ExtensionWebRequestApiTest() override = default; + void SetUpOnMainThread() override { ExtensionApiTest::SetUpOnMainThread(); host_resolver()->AddRule("*", "127.0.0.1"); @@ -348,12 +358,12 @@ kOriginTrialPublicKeyForTesting); } - void RunPermissionTest( - const char* extension_directory, - bool load_extension_with_incognito_permission, - bool wait_for_extension_loaded_in_incognito, - const char* expected_content_regular_window, - const char* exptected_content_incognito_window); + void RunPermissionTest(const char* extension_directory, + bool load_extension_with_incognito_permission, + bool wait_for_extension_loaded_in_incognito, + const char* expected_content_regular_window, + const char* exptected_content_incognito_window, + ContextType context_type); mojo::PendingRemote<network::mojom::URLLoaderFactory> CreateURLLoaderFactory() { @@ -1030,7 +1040,8 @@ bool load_extension_with_incognito_permission, bool wait_for_extension_loaded_in_incognito, const char* expected_content_regular_window, - const char* exptected_content_incognito_window) { + const char* exptected_content_incognito_window, + ContextType context_type) { ResultCatcher catcher; catcher.RestrictToBrowserContext(browser()->profile()); ResultCatcher catcher_incognito; @@ -1043,7 +1054,8 @@ ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("webrequest_permissions") .AppendASCII(extension_directory), - {.allow_in_incognito = load_extension_with_incognito_permission})); + {.allow_in_incognito = load_extension_with_incognito_permission, + .context_type = context_type})); // Test that navigation in regular window is properly redirected. EXPECT_TRUE(listener.WaitUntilSatisfied()); @@ -1082,33 +1094,55 @@ EXPECT_EQ(exptected_content_incognito_window, body); } -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +class ExtensionWebRequestApiTestWithContextType + : public ExtensionWebRequestApiTest, + public testing::WithParamInterface<ContextType> { + public: + ExtensionWebRequestApiTestWithContextType() + : ExtensionWebRequestApiTest(GetParam()) {} + ExtensionWebRequestApiTestWithContextType( + const ExtensionWebRequestApiTestWithContextType&) = delete; + ExtensionWebRequestApiTestWithContextType& operator=( + const ExtensionWebRequestApiTestWithContextType&) = delete; + ~ExtensionWebRequestApiTestWithContextType() override = default; +}; + +INSTANTIATE_TEST_SUITE_P(PersistentBackground, + ExtensionWebRequestApiTestWithContextType, + ::testing::Values(ContextType::kPersistentBackground)); + +INSTANTIATE_TEST_SUITE_P(ServiceWorker, + ExtensionWebRequestApiTestWithContextType, + ::testing::Values(ContextType::kServiceWorker)); + +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestDeclarativePermissionSpanning1) { // Test spanning with incognito permission. ASSERT_TRUE(StartEmbeddedTestServer()); - RunPermissionTest("spanning", true, false, "redirected1", "redirected1"); + RunPermissionTest("spanning", true, false, "redirected1", "redirected1", + GetParam()); } -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestDeclarativePermissionSpanning2) { // Test spanning without incognito permission. ASSERT_TRUE(StartEmbeddedTestServer()); - RunPermissionTest("spanning", false, false, "redirected1", ""); + RunPermissionTest("spanning", false, false, "redirected1", "", GetParam()); } - -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestDeclarativePermissionSplit1) { // Test split with incognito permission. ASSERT_TRUE(StartEmbeddedTestServer()); - RunPermissionTest("split", true, true, "redirected1", "redirected2"); + RunPermissionTest("split", true, true, "redirected1", "redirected2", + GetParam()); } -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestDeclarativePermissionSplit2) { // Test split without incognito permission. ASSERT_TRUE(StartEmbeddedTestServer()); - RunPermissionTest("split", false, false, "redirected1", ""); + RunPermissionTest("split", false, false, "redirected1", "", GetParam()); } // TODO(crbug.com/238179): Cure these flaky tests. @@ -1128,7 +1162,7 @@ << message_; } -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, DeclarativeSendMessage) { ASSERT_TRUE(StartEmbeddedTestServer()); ASSERT_TRUE(RunExtensionTest("webrequest_sendmessage")) << message_; @@ -1137,7 +1171,8 @@ // Check that reloading an extension that runs in incognito split mode and // has two active background pages with registered events does not crash the // browser. Regression test for http://crbug.com/224094 -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, IncognitoSplitModeReload) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + IncognitoSplitModeReload) { ASSERT_TRUE(StartEmbeddedTestServer()); // Wait for rules to be set up. ExtensionTestMessageListener listener("done"); @@ -1163,7 +1198,8 @@ EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied()); } -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, ExtensionRequests) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + ExtensionRequests) { ASSERT_TRUE(StartEmbeddedTestServer()); ExtensionTestMessageListener listener_main1("web_request_status1", ReplyBehavior::kWillReply); @@ -1180,10 +1216,12 @@ EXPECT_TRUE(listener_main2.WaitUntilSatisfied()); // Perform some network activity in an app and another extension. + ASSERT_TRUE( + LoadExtension(test_data_dir_.AppendASCII("webrequest_extensions/app"), + {.context_type = ContextType::kFromManifest})); ASSERT_TRUE(LoadExtension( - test_data_dir_.AppendASCII("webrequest_extensions/app"))); - ASSERT_TRUE(LoadExtension( - test_data_dir_.AppendASCII("webrequest_extensions/extension"))); + test_data_dir_.AppendASCII("webrequest_extensions/extension"), + {.context_type = ContextType::kFromManifest})); EXPECT_TRUE(listener_app.WaitUntilSatisfied()); EXPECT_TRUE(listener_extension.WaitUntilSatisfied()); @@ -1268,7 +1306,7 @@ } // Tests that WebRequest works with runtime host permissions. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestWithWithheldPermissions) { content::SetupCrossSiteRedirector(embedded_test_server()); ASSERT_TRUE(embedded_test_server()->Start()); @@ -1389,7 +1427,7 @@ // Test that extensions with granted runtime host permissions to a tab can // intercept cross-origin requests from that tab. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestWithheldPermissionsCrossOriginRequests) { content::SetupCrossSiteRedirector(embedded_test_server()); ASSERT_TRUE(embedded_test_server()->Start()); @@ -1439,7 +1477,7 @@ // Tests behavior when an extension has withheld access to a request's URL, but // not the initiator's (tab's) URL. Regression test for // https://crbug.com/891586. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WithheldHostPermissionsForCrossOriginWithoutInitiator) { content::SetupCrossSiteRedirector(embedded_test_server()); ASSERT_TRUE(embedded_test_server()->Start()); @@ -1505,7 +1543,7 @@ // Verify that requests to clientsX.google.com are protected properly. // First test requests from a standard renderer and then a request from the // browser process. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestClientsGoogleComProtection) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -1597,7 +1635,7 @@ } // Verify that requests for PAC scripts are protected properly. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestPacRequestProtection) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -1645,7 +1683,7 @@ // Checks that the Dice response header is protected for Gaia URLs, but not // other URLs. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestDiceHeaderProtection) { // Load an extension that registers a listener for webRequest events, and // wait until it is initialized. @@ -1844,7 +1882,7 @@ } // Test behavior when intercepting requests from a browser-initiated url fetch. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, WebRequestURLLoaderInterception) { // Create an extension that intercepts (and blocks) requests to example.com. TestExtensionDir test_dir; @@ -2011,7 +2049,8 @@ // Test that extensions need host permissions to both the request url and // initiator to intercept a request. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, InitiatorAccessRequired) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + InitiatorAccessRequired) { ASSERT_TRUE(StartEmbeddedTestServer()); ExtensionTestMessageListener listener("ready"); @@ -2172,15 +2211,19 @@ } // Test fixture which sets a custom NTP Page. -class NTPInterceptionWebRequestAPITest : public ExtensionApiTest { +class NTPInterceptionWebRequestAPITest + : public ExtensionApiTest, + public testing::WithParamInterface<ContextType> { public: NTPInterceptionWebRequestAPITest() - : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} + : ExtensionApiTest(GetParam()), + https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} NTPInterceptionWebRequestAPITest(const NTPInterceptionWebRequestAPITest&) = delete; NTPInterceptionWebRequestAPITest& operator=( const NTPInterceptionWebRequestAPITest&) = delete; + ~NTPInterceptionWebRequestAPITest() override = default; // ExtensionApiTest override: void SetUpOnMainThread() override { @@ -2203,9 +2246,17 @@ net::EmbeddedTestServer https_test_server_; }; +INSTANTIATE_TEST_SUITE_P(PersistentBackground, + NTPInterceptionWebRequestAPITest, + ::testing::Values(ContextType::kPersistentBackground)); + +INSTANTIATE_TEST_SUITE_P(ServiceWorker, + NTPInterceptionWebRequestAPITest, + ::testing::Values(ContextType::kServiceWorker)); + // Ensures that requests made by the NTP Instant renderer are hidden from the // Web Request API. Regression test for crbug.com/797461. -IN_PROC_BROWSER_TEST_F(NTPInterceptionWebRequestAPITest, +IN_PROC_BROWSER_TEST_P(NTPInterceptionWebRequestAPITest, NTPRendererRequestsHidden) { // Loads an extension which tries to intercept requests to // "fake_ntp_script.js", which will be loaded as part of the NTP renderer. @@ -2265,15 +2316,17 @@ // the WebUI NTP can't be intercepted by extensions. class WebUiNtpInterceptionWebRequestAPITest : public ExtensionApiTest, - public OneGoogleBarServiceObserver { + public OneGoogleBarServiceObserver, + public testing::WithParamInterface<ContextType> { public: WebUiNtpInterceptionWebRequestAPITest() - : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} - + : ExtensionApiTest(GetParam()), + https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} WebUiNtpInterceptionWebRequestAPITest( const WebUiNtpInterceptionWebRequestAPITest&) = delete; WebUiNtpInterceptionWebRequestAPITest& operator=( const WebUiNtpInterceptionWebRequestAPITest&) = delete; + ~WebUiNtpInterceptionWebRequestAPITest() override = default; // ExtensionApiTest override: void SetUp() override { @@ -2346,7 +2399,15 @@ base::Lock lock_; }; -IN_PROC_BROWSER_TEST_F(WebUiNtpInterceptionWebRequestAPITest, +INSTANTIATE_TEST_SUITE_P(PersistentBackground, + WebUiNtpInterceptionWebRequestAPITest, + ::testing::Values(ContextType::kPersistentBackground)); + +INSTANTIATE_TEST_SUITE_P(ServiceWorker, + WebUiNtpInterceptionWebRequestAPITest, + ::testing::Values(ContextType::kServiceWorker)); + +IN_PROC_BROWSER_TEST_P(WebUiNtpInterceptionWebRequestAPITest, OneGoogleBarRequestsHidden) { // Loads an extension which tries to intercept requests to the OneGoogleBar. ExtensionTestMessageListener listener("ready", ReplyBehavior::kWillReply); @@ -2398,9 +2459,29 @@ << message_; } +class WebRequestApiTestWithManagementPolicy + : public ExtensionApiTestWithManagementPolicy, + public testing::WithParamInterface<ContextType> { + public: + WebRequestApiTestWithManagementPolicy() + : ExtensionApiTestWithManagementPolicy(GetParam()) {} + ~WebRequestApiTestWithManagementPolicy() override = default; + WebRequestApiTestWithManagementPolicy( + const WebRequestApiTestWithManagementPolicy&) = delete; + WebRequestApiTestWithManagementPolicy& operator=( + const WebRequestApiTestWithManagementPolicy&) = delete; +}; + +INSTANTIATE_TEST_SUITE_P(PersistentBackground, + WebRequestApiTestWithManagementPolicy, + ::testing::Values(ContextType::kPersistentBackground)); +INSTANTIATE_TEST_SUITE_P(ServiceWorker, + WebRequestApiTestWithManagementPolicy, + ::testing::Values(ContextType::kServiceWorker)); + // Tests that the webRequest events aren't dispatched when the request initiator // is protected by policy. -IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy, +IN_PROC_BROWSER_TEST_P(WebRequestApiTestWithManagementPolicy, InitiatorProtectedByPolicy) { // We expect that no request will be hidden or modification blocked. This // means that the request to example.com will be seen by the extension. @@ -2479,7 +2560,7 @@ // Tests that the webRequest events aren't dispatched when the URL of the // request is protected by policy. -IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy, +IN_PROC_BROWSER_TEST_P(WebRequestApiTestWithManagementPolicy, UrlProtectedByPolicy) { // Host protected by policy. const std::string protected_domain = "example.com"; @@ -2532,7 +2613,7 @@ // navigation. This replicates most of the tests from // WebRequestWithWithheldPermissions with a protected host. Granting a tab // specific permission shouldn't bypass our policy. -IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy, +IN_PROC_BROWSER_TEST_P(WebRequestApiTestWithManagementPolicy, WebRequestProtectedByPolicy) { // Host protected by policy. const std::string protected_domain = "example.com"; @@ -2597,7 +2678,8 @@ // A test fixture which mocks the Time::Now() function to ensure that the // default clock returns monotonically increasing time. -class ExtensionWebRequestMockedClockTest : public ExtensionWebRequestApiTest { +class ExtensionWebRequestMockedClockTest + : public ExtensionWebRequestApiTestWithContextType { public: ExtensionWebRequestMockedClockTest() : scoped_time_clock_override_(&ExtensionWebRequestMockedClockTest::Now, @@ -2619,9 +2701,16 @@ base::subtle::ScopedTimeClockOverrides scoped_time_clock_override_; }; +INSTANTIATE_TEST_SUITE_P(PersistentBackground, + ExtensionWebRequestMockedClockTest, + ::testing::Values(ContextType::kPersistentBackground)); +INSTANTIATE_TEST_SUITE_P(ServiceWorker, + ExtensionWebRequestMockedClockTest, + ::testing::Values(ContextType::kServiceWorker)); + // Tests that we correctly dispatch the OnActionIgnored event on an extension // if the extension's proposed redirect is ignored. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestMockedClockTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestMockedClockTest, OnActionIgnored_Redirect) { ASSERT_TRUE(StartEmbeddedTestServer()); @@ -2703,7 +2792,8 @@ } // Regression test for http://crbug.com/1074282. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, StaleHeadersAfterRedirect) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + StaleHeadersAfterRedirect) { TestExtensionDir test_dir; test_dir.WriteManifest(R"({ "name": "Web Request Stale Headers Test", @@ -2782,7 +2872,8 @@ 0); } -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, ChangeHeaderUMAs) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + ChangeHeaderUMAs) { using RequestHeaderType = extension_web_request_api_helpers::RequestHeaderType; using ResponseHeaderType = @@ -2878,7 +2969,8 @@ ResponseHeaderType::kNone, 1); } -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, RemoveHeaderUMAs) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + RemoveHeaderUMAs) { using RequestHeaderType = extension_web_request_api_helpers::RequestHeaderType; using ResponseHeaderType = @@ -2949,12 +3041,29 @@ ResponseHeaderType::kNone, 1); } -// The parameter is for opt_extraInfoSpec passed to addEventListener. -// 'blocking' and 'requestHeaders' if it's false, and 'extraHeaders' in addition -// to them if it's true. -class ServiceWorkerWebRequestApiTest : public testing::WithParamInterface<bool>, - public ExtensionApiTest { +struct SWTestParams { + SWTestParams(bool extra_info_spec, ContextType context_type) + : extra_info_spec(extra_info_spec), context_type(context_type) {} + + // This parameter is for opt_extraInfoSpec passed to addEventListener. + // 'blocking' and 'requestHeaders' if it's false, and 'extraHeaders' in + // addition to them if it's true. + bool extra_info_spec; + ContextType context_type; +}; + +class ServiceWorkerWebRequestApiTest + : public testing::WithParamInterface<SWTestParams>, + public ExtensionApiTest { public: + ServiceWorkerWebRequestApiTest() + : ExtensionApiTest(GetParam().context_type) {} + ~ServiceWorkerWebRequestApiTest() override = default; + ServiceWorkerWebRequestApiTest(const ServiceWorkerWebRequestApiTest&) = + delete; + ServiceWorkerWebRequestApiTest& operator=( + const ServiceWorkerWebRequestApiTest&) = delete; + // The options passed as opt_extraInfoSpec to addEventListener. enum class ExtraInfoSpec { // 'blocking', 'requestHeaders' @@ -2964,7 +3073,8 @@ }; static ExtraInfoSpec GetExtraInfoSpec() { - return GetParam() ? ExtraInfoSpec::kExtraHeaders : ExtraInfoSpec::kDefault; + return GetParam().extra_info_spec ? ExtraInfoSpec::kExtraHeaders + : ExtraInfoSpec::kDefault; } void InstallRequestHeaderModifyingExtension() { @@ -3046,9 +3156,25 @@ } }; -INSTANTIATE_TEST_SUITE_P(All, - ServiceWorkerWebRequestApiTest, - ::testing::Bool()); +INSTANTIATE_TEST_SUITE_P( + PersistentBackgroundWithExtraHeaders, + ServiceWorkerWebRequestApiTest, + ::testing::Values(SWTestParams(true, ContextType::kPersistentBackground))); + +INSTANTIATE_TEST_SUITE_P( + PersistentBackground, + ServiceWorkerWebRequestApiTest, + ::testing::Values(SWTestParams(false, ContextType::kPersistentBackground))); + +INSTANTIATE_TEST_SUITE_P( + ServiceWorkerWithExtraHeaders, + ServiceWorkerWebRequestApiTest, + ::testing::Values(SWTestParams(true, ContextType::kServiceWorker))); + +INSTANTIATE_TEST_SUITE_P( + ServiceWorker, + ServiceWorkerWebRequestApiTest, + ::testing::Values(SWTestParams(false, ContextType::kServiceWorker))); IN_PROC_BROWSER_TEST_P(ServiceWorkerWebRequestApiTest, ServiceWorkerFetch) { RunServiceWorkerFetchTest("fetch_event_respond_with_fetch.js"); @@ -3370,7 +3496,7 @@ // Ensure we don't strip off initiator incorrectly in web request events when // both the normal and incognito contexts are active. Regression test for // crbug.com/934398. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, Initiator_SpanningIncognito) { embedded_test_server()->ServeFilesFromSourceDirectory("chrome/test/data"); ASSERT_TRUE(embedded_test_server()->Start()); @@ -3428,7 +3554,8 @@ // Ensure we don't strip off initiator incorrectly in web request events when // both the normal and incognito contexts are active. Regression test for // crbug.com/934398. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, Initiator_SplitIncognito) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + Initiator_SplitIncognito) { embedded_test_server()->ServeFilesFromSourceDirectory("chrome/test/data"); ASSERT_TRUE(embedded_test_server()->Start()); @@ -3483,7 +3610,7 @@ // Regression test for http://crbug.com/971206. The responseHeaders should still // be present in onBeforeRedirect even for HSTS upgrade. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, ExtraHeadersWithHSTSUpgrade) { net::EmbeddedTestServer https_test_server( net::EmbeddedTestServer::TYPE_HTTPS); @@ -3555,7 +3682,8 @@ } // Regression test for https://crbug.com/1019614. -IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, HSTSUpgradeAfterRedirect) { +IN_PROC_BROWSER_TEST_P(ExtensionWebRequestApiTestWithContextType, + HSTSUpgradeAfterRedirect) { net::EmbeddedTestServer https_test_server( net::EmbeddedTestServer::TYPE_HTTPS); https_test_server.ServeFilesFromDirectory( @@ -3606,10 +3734,29 @@ EXPECT_EQ(final_url, web_contents->GetLastCommittedURL()); } +struct SWBTestParams { + SWBTestParams(bool extra_info_spec, ContextType context_type) + : extra_info_spec(extra_info_spec), context_type(context_type) {} + + // The parameter is for opt_extraInfoSpec passed to addEventListener. + // 'blocking' if it's false, and 'extraHeaders' in addition to them + // if it's true. + bool extra_info_spec; + ContextType context_type; +}; + class SubresourceWebBundlesWebRequestApiTest - : public testing::WithParamInterface<bool>, + : public testing::WithParamInterface<SWBTestParams>, public ExtensionApiTest { public: + SubresourceWebBundlesWebRequestApiTest() + : ExtensionApiTest(GetParam().context_type) {} + ~SubresourceWebBundlesWebRequestApiTest() override = default; + SubresourceWebBundlesWebRequestApiTest( + const SubresourceWebBundlesWebRequestApiTest&) = delete; + SubresourceWebBundlesWebRequestApiTest& operator=( + const SubresourceWebBundlesWebRequestApiTest&) = delete; + void SetUp() override { feature_list_.InitWithFeatures({features::kSubresourceWebBundles}, {}); ExtensionApiTest::SetUp(); @@ -3625,7 +3772,8 @@ }; static ExtraInfoSpec GetExtraInfoSpec() { - return GetParam() ? ExtraInfoSpec::kExtraHeaders : ExtraInfoSpec::kDefault; + return GetParam().extra_info_spec ? ExtraInfoSpec::kExtraHeaders + : ExtraInfoSpec::kDefault; } bool TryLoadScript(const std::string& script_src) { @@ -3727,9 +3875,26 @@ base::test::ScopedFeatureList feature_list_; }; -INSTANTIATE_TEST_SUITE_P(All, - SubresourceWebBundlesWebRequestApiTest, - ::testing::Bool()); +INSTANTIATE_TEST_SUITE_P( + PersistentBackgroundWithExtraHeaders, + SubresourceWebBundlesWebRequestApiTest, + ::testing::Values(SWBTestParams(true, ContextType::kPersistentBackground))); + +INSTANTIATE_TEST_SUITE_P( + PersistentBackground, + SubresourceWebBundlesWebRequestApiTest, + ::testing::Values(SWBTestParams(false, + ContextType::kPersistentBackground))); + +INSTANTIATE_TEST_SUITE_P( + ServiceWorkerWithExtraHeaders, + SubresourceWebBundlesWebRequestApiTest, + ::testing::Values(SWBTestParams(true, ContextType::kServiceWorker))); + +INSTANTIATE_TEST_SUITE_P( + ServiceWorker, + SubresourceWebBundlesWebRequestApiTest, + ::testing::Values(SWBTestParams(false, ContextType::kServiceWorker))); // Ensure web request listeners can intercept requests for a web bundle and its // subresources. @@ -4408,10 +4573,24 @@ kOnHeadersReceived, }; +struct RITestParams { + RITestParams(RedirectType redirect_type, ContextType context_type) + : redirect_type(redirect_type), context_type(context_type) {} + + RedirectType redirect_type; + ContextType context_type; +}; + class RedirectInfoWebRequestApiTest - : public testing::WithParamInterface<RedirectType>, + : public testing::WithParamInterface<RITestParams>, public ExtensionApiTest { public: + RedirectInfoWebRequestApiTest() : ExtensionApiTest(GetParam().context_type) {} + ~RedirectInfoWebRequestApiTest() override = default; + RedirectInfoWebRequestApiTest(const RedirectInfoWebRequestApiTest&) = delete; + RedirectInfoWebRequestApiTest& operator=( + const RedirectInfoWebRequestApiTest&) = delete; + void SetUpOnMainThread() override { ExtensionApiTest::SetUpOnMainThread(); host_resolver()->AddRule("*", "127.0.0.1"); @@ -4428,9 +4607,8 @@ "background": { "scripts": ["background.js"], "persistent": true }, "permissions": ["<all_urls>", "webRequest", "webRequestBlocking"] })"); - test_dir.WriteFile( - FILE_PATH_LITERAL("background.js"), - base::StringPrintf(R"( + test_dir.WriteFile(FILE_PATH_LITERAL("background.js"), + base::StringPrintf(R"( chrome.webRequest.%s.addListener(function(details) { if (details.type == '%s' && details.url.includes('hello.html')) { @@ -4441,10 +4619,11 @@ }, {urls: ['*://original.test/*']}, ['blocking']); chrome.test.sendMessage('ready'); )", - GetParam() == RedirectType::kOnBeforeRequest - ? "onBeforeRequest" - : "onHeadersReceived", - resource_type.c_str())); + GetParam().redirect_type == + RedirectType::kOnBeforeRequest + ? "onBeforeRequest" + : "onHeadersReceived", + resource_type.c_str())); ExtensionTestMessageListener listener("ready"); const Extension* extension = LoadExtension(test_dir.UnpackedPath()); ASSERT_TRUE(extension); @@ -4455,10 +4634,29 @@ TestExtensionDir test_dir_; }; -INSTANTIATE_TEST_SUITE_P(RedirectMode, - RedirectInfoWebRequestApiTest, - ::testing::Values(RedirectType::kOnBeforeRequest, - RedirectType::kOnHeadersReceived)); +INSTANTIATE_TEST_SUITE_P( + PersistentBackgroundOnBeforeRequest, + RedirectInfoWebRequestApiTest, + ::testing::Values(RITestParams(RedirectType::kOnBeforeRequest, + ContextType::kPersistentBackground))); + +INSTANTIATE_TEST_SUITE_P( + PersistentBackgroundOnHeadersReceived, + RedirectInfoWebRequestApiTest, + ::testing::Values(RITestParams(RedirectType::kOnHeadersReceived, + ContextType::kPersistentBackground))); + +INSTANTIATE_TEST_SUITE_P( + ServiceWorkerOnBeforeRequest, + RedirectInfoWebRequestApiTest, + ::testing::Values(RITestParams(RedirectType::kOnBeforeRequest, + ContextType::kServiceWorker))); + +INSTANTIATE_TEST_SUITE_P( + ServiceWorkerOnHeadersReceived, + RedirectInfoWebRequestApiTest, + ::testing::Values(RITestParams(RedirectType::kOnHeadersReceived, + ContextType::kServiceWorker))); // Test that a main frame request redirected by an extension has the correct // site_for_cookies and network_isolation_key parameters. @@ -4668,10 +4866,15 @@ blink::IdentifiableSurface::Type::kExtensionCancelRequest)); } -class ProxyCORSWebRequestApiTest : public ExtensionApiTest { +class ProxyCORSWebRequestApiTest + : public ExtensionApiTest, + public testing::WithParamInterface<ContextType> { public: - ProxyCORSWebRequestApiTest() = default; + ProxyCORSWebRequestApiTest() : ExtensionApiTest(GetParam()) {} ~ProxyCORSWebRequestApiTest() override = default; + ProxyCORSWebRequestApiTest(const ProxyCORSWebRequestApiTest&) = delete; + ProxyCORSWebRequestApiTest& operator=(const ProxyCORSWebRequestApiTest&) = + delete; protected: class ProceedLoginDialog : public content::NotificationObserver { @@ -4807,10 +5010,18 @@ net::EmbeddedTestServer proxy_cors_server_; }; +INSTANTIATE_TEST_SUITE_P(PersistentBackground, + ProxyCORSWebRequestApiTest, + ::testing::Values(ContextType::kPersistentBackground)); + +INSTANTIATE_TEST_SUITE_P(ServiceWorker, + ProxyCORSWebRequestApiTest, + ::testing::Values(ContextType::kServiceWorker)); + // Regression test for crbug.com/1212625 // Test that CORS preflight request which requires proxy auth completes // successfully instead of being cancelled after proxy auth required response. -IN_PROC_BROWSER_TEST_F(ProxyCORSWebRequestApiTest, +IN_PROC_BROWSER_TEST_P(ProxyCORSWebRequestApiTest, PreflightCompletesSuccessfully) { ProceedLoginDialog login_dialog(kCORSProxyUser, kCORSProxyPass); ExtensionTestMessageListener ready_listener("ready");
diff --git a/chrome/browser/extensions/extension_action_runner.cc b/chrome/browser/extensions/extension_action_runner.cc index 74d39f61..4f53bc8 100644 --- a/chrome/browser/extensions/extension_action_runner.cc +++ b/chrome/browser/extensions/extension_action_runner.cc
@@ -164,11 +164,9 @@ SitePermissionsHelper::SiteAccess::kOnClick; })); - // Running the action a single time does not update permissions. - constexpr bool update_permissions = false; std::vector<ExtensionId> extension_ids = GetExtensionIds(extensions); ShowReloadPageBubble( - extension_ids, update_permissions, + extension_ids, base::BindOnce(&ExtensionActionRunner:: OnReloadPageBubbleAcceptedForGrantTabPermissions, weak_factory_.GetWeakPtr(), extension_ids, url)); @@ -191,10 +189,9 @@ // confidence on blocking the extension. Also, this scenario should not be // that common and therefore hopefully is not too noisy. if (revoking_permissions || PageNeedsRefreshToRun(extension)) { - constexpr bool update_permissions = true; - std::vector<ExtensionId> extension_ids{extension->id()}; + std::vector<ExtensionId> extension_ids; ShowReloadPageBubble( - extension_ids, update_permissions, + extension_ids, base::BindOnce( &ExtensionActionRunner:: OnReloadPageBubbleAcceptedForExtensionSiteAccessChange, @@ -299,10 +296,9 @@ } if (refresh_required) { - std::vector<extensions::ExtensionId> extension_ids(action_ids.begin(), - action_ids.end()); + std::vector<extensions::ExtensionId> extension_ids; ShowReloadPageBubble( - extension_ids, true, + extension_ids, base::BindOnce(&ExtensionActionRunner:: OnReloadPageBubbleAcceptedForUserSiteSettingsChange, weak_factory_.GetWeakPtr(), origin, new_site_settings)); @@ -519,7 +515,6 @@ void ExtensionActionRunner::ShowReloadPageBubble( const std::vector<ExtensionId>& extension_ids, - bool update_permissions, base::OnceClosure callback) { // For testing, simulate the bubble being accepted by directly invoking the // callback, or rejected by skipping the callback. @@ -540,8 +535,7 @@ if (!extensions_container) return; - ShowReloadPageDialog(browser, extension_ids, update_permissions, - std::move(callback)); + ShowReloadPageDialog(browser, extension_ids, std::move(callback)); } void ExtensionActionRunner::OnReloadPageBubbleAcceptedForGrantTabPermissions(
diff --git a/chrome/browser/extensions/extension_action_runner.h b/chrome/browser/extensions/extension_action_runner.h index bb9495d..b13c113b 100644 --- a/chrome/browser/extensions/extension_action_runner.h +++ b/chrome/browser/extensions/extension_action_runner.h
@@ -192,7 +192,6 @@ // action for the given |extension_ids|. |callback| is invoked when the // bubble is closed. void ShowReloadPageBubble(const std::vector<ExtensionId>& extension_ids, - bool update_permissions, base::OnceClosure callback); // Called when the reload page bubble is accepted. Grants one time site access
diff --git a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc index 834b279..3528f44 100644 --- a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
@@ -26,8 +26,8 @@ #include "components/sync/base/client_tag_hash.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/extension_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_utils.h"
diff --git a/chrome/browser/extensions/extension_service_sync_unittest.cc b/chrome/browser/extensions/extension_service_sync_unittest.cc index 2f90ec7..65d6b8f0 100644 --- a/chrome/browser/extensions/extension_service_sync_unittest.cc +++ b/chrome/browser/extensions/extension_service_sync_unittest.cc
@@ -40,9 +40,9 @@ #include "components/sync/protocol/app_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/extension_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/variations/variations_associated_data.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/storage_partition.h"
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc index c7eac1c..87e14fc 100644 --- a/chrome/browser/extensions/extension_tab_util.cc +++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -280,10 +280,10 @@ index = *params.index; index = base::clamp(index, -1, browser->tab_strip_model()->count()); - int add_types = active ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; - add_types |= TabStripModel::ADD_FORCE_INDEX; + int add_types = active ? AddTabTypes::ADD_ACTIVE : AddTabTypes::ADD_NONE; + add_types |= AddTabTypes::ADD_FORCE_INDEX; if (pinned) - add_types |= TabStripModel::ADD_PINNED; + add_types |= AddTabTypes::ADD_PINNED; NavigateParams navigate_params(browser, url, ui::PAGE_TRANSITION_LINK); navigate_params.disposition = active ? WindowOpenDisposition::NEW_FOREGROUND_TAB
diff --git a/chrome/browser/extensions/extension_with_management_policy_apitest.cc b/chrome/browser/extensions/extension_with_management_policy_apitest.cc index 0631ad3..2a2e14cf 100644 --- a/chrome/browser/extensions/extension_with_management_policy_apitest.cc +++ b/chrome/browser/extensions/extension_with_management_policy_apitest.cc
@@ -8,8 +8,11 @@ #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/http_request.h" -ExtensionApiTestWithManagementPolicy::ExtensionApiTestWithManagementPolicy() {} -ExtensionApiTestWithManagementPolicy::~ExtensionApiTestWithManagementPolicy() {} +ExtensionApiTestWithManagementPolicy::ExtensionApiTestWithManagementPolicy( + ContextType context_type) + : ExtensionApiTest(context_type) {} +ExtensionApiTestWithManagementPolicy::~ExtensionApiTestWithManagementPolicy() = + default; void ExtensionApiTestWithManagementPolicy::SetUpInProcessBrowserTestFixture() { extensions::ExtensionApiTest::SetUpInProcessBrowserTestFixture();
diff --git a/chrome/browser/extensions/extension_with_management_policy_apitest.h b/chrome/browser/extensions/extension_with_management_policy_apitest.h index 1343500..690aba17 100644 --- a/chrome/browser/extensions/extension_with_management_policy_apitest.h +++ b/chrome/browser/extensions/extension_with_management_policy_apitest.h
@@ -23,7 +23,8 @@ class ExtensionApiTestWithManagementPolicy : public extensions::ExtensionApiTest { public: - ExtensionApiTestWithManagementPolicy(); + explicit ExtensionApiTestWithManagementPolicy( + ContextType context_type = ContextType::kFromManifest); ExtensionApiTestWithManagementPolicy( const ExtensionApiTestWithManagementPolicy&) = delete;
diff --git a/chrome/browser/extensions/external_pref_loader_unittest.cc b/chrome/browser/extensions/external_pref_loader_unittest.cc index 9fc8fca..55918033 100644 --- a/chrome/browser/extensions/external_pref_loader_unittest.cc +++ b/chrome/browser/extensions/external_pref_loader_unittest.cc
@@ -17,8 +17,8 @@ #include "chrome/test/base/testing_profile.h" #include "components/prefs/pref_service.h" #include "components/sync/driver/test_sync_service.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/pref_model_associator.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/browser/browser_task_traits.h"
diff --git a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc index 5a43159..d0b97a51 100644 --- a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc +++ b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc
@@ -30,8 +30,8 @@ #include "components/sync/base/command_line_switches.h" #include "components/sync/base/pref_names.h" #include "components/sync/model/sync_change_processor.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/pref_service_syncable.h" #include "components/user_manager/scoped_user_manager.h" #include "content/public/browser/notification_service.h"
diff --git a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedProcessScopeDependencyProvider.java b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedProcessScopeDependencyProvider.java index bad6c4a..b89bcf6b 100644 --- a/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedProcessScopeDependencyProvider.java +++ b/chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/FeedProcessScopeDependencyProvider.java
@@ -159,7 +159,19 @@ @Override public ProcessScopeDependencyProvider.FeatureStateProvider getFeatureStateProvider() { - return ChromeFeatureList::isEnabled; + return new ProcessScopeDependencyProvider.FeatureStateProvider() { + @Override + public boolean isFeatureActive(String featureName) { + return ChromeFeatureList.isEnabled(featureName); + } + + @Override + public boolean getBooleanParameterValue( + String featureName, String paramName, boolean defaultValue) { + return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean( + featureName, paramName, defaultValue); + } + }; } /**
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index 2b9d6939..859c08c4 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -34,11 +34,6 @@ "expiry_milestone": 110 }, { - "name": "access-code-cast-device-duration", - "owners": [ "gbj@google.com", "cros-edu-team@google.com" ], - "expiry_milestone": 105 - }, - { "name": "accessible-pdf-form", "owners": [ "asku@microsoft.com", "mohitb@microsoft.com" ], "expiry_milestone": 105 @@ -639,6 +634,11 @@ "expiry_milestone": 120 }, { + "name": "binding-manager-use-not-perceptible-binding", + "owners": ["ckitagawa", "yfriedman"], + "expiry_milestone": 109 + }, + { "name": "biometric-authentication-for-filling", "owners": ["sygiet@google.com", "vsemeniuk@google.com"], "expiry_milestone": 111 @@ -1707,13 +1707,13 @@ }, { "name": "enable-cast-streaming-av1", - "owners": [ "jophba@google.com", "openscreen-eng@google.com" ], - "expiry_milestone": 105 + "owners": [ "jophba", "openscreen-eng" ], + "expiry_milestone": 120 }, { "name": "enable-cast-streaming-vp9", - "owners": [ "jophba@google.com", "openscreen-eng@google.com" ], - "expiry_milestone": 105 + "owners": [ "jophba", "openscreen-eng" ], + "expiry_milestone": 120 }, { "name": "enable-cbd-sign-out", @@ -2601,8 +2601,8 @@ }, { "name": "enable-openscreen-cast-streaming-session", - "owners": [ "jophba@google.com", "openscreen-eng@google.com" ], - "expiry_milestone": 105 + "owners": [ "jophba", "openscreen-eng" ], + "expiry_milestone": 120 }, { "name": "enable-os-feedback", @@ -6427,7 +6427,7 @@ { "name": "use-multiple-overlays", "owners": [ "khaslett", "//components/viz/OWNERS" ], - "expiry_milestone": 104 + "expiry_milestone": 110 }, { "name": "use-passthrough-command-decoder",
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index e69a4f3..325005864 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -3280,6 +3280,12 @@ const char kBackGestureRefactorAndroidDescription[] = "Enable Back Gesture Refactor."; +const char kBindingManagerUseNotPerceptibleBindingName[] = + "Reduced background renderer binding"; +const char kBindingManagerUseNotPerceptibleBindingDescription[] = + "When enabled, uses a not perceptible binding for background renderers " + "used in the current session if able."; + const char kBulkTabRestoreAndroidName[] = "Recent Tabs Bulk Restore"; const char kBulkTabRestoreAndroidDescription[] = "Enables restoration of bulk tab closures (e.g. close all tabs, close "
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index abe221e..73259f1 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -1849,6 +1849,9 @@ extern const char kBackGestureRefactorAndroidName[]; extern const char kBackGestureRefactorAndroidDescription[]; +extern const char kBindingManagerUseNotPerceptibleBindingName[]; +extern const char kBindingManagerUseNotPerceptibleBindingDescription[]; + extern const char kBulkTabRestoreAndroidName[]; extern const char kBulkTabRestoreAndroidDescription[];
diff --git a/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinator.java b/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinator.java index a8d2aa75..7f6ddc3f 100644 --- a/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinator.java +++ b/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersCoordinator.java
@@ -198,6 +198,11 @@ if (!mDelegate.isSeparateActivity()) { mToolbar.getMenu().removeItem(R.id.close_menu_id); } + + if (!mDelegate.areTabGroupsEnabled()) { + mToolbar.getMenu().removeItem(R.id.selection_mode_open_in_tab_group); + } + mToolbar.setInfoMenuItem(R.id.info_menu_id); mDelegate.shouldShowPrivacyDisclaimerSupplier().addObserver( (show) -> mToolbar.updateInfoMenuItem(true, show));
diff --git a/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersDelegate.java b/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersDelegate.java index 39bae38..a70f9c4 100644 --- a/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersDelegate.java +++ b/chrome/browser/history_clusters/java/src/org/chromium/chrome/browser/history_clusters/HistoryClustersDelegate.java
@@ -97,4 +97,9 @@ * that it should remove the HistoryClusters UI. */ default void onOptOut() {} + + /** Whether tab group creation is enabled. */ + default boolean areTabGroupsEnabled() { + return true; + } }
diff --git a/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.cc b/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.cc index 22a41bf..5c95bba 100644 --- a/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.cc +++ b/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.cc
@@ -62,10 +62,5 @@ namespace switches { constexpr char kDiscoveryEndpointSwitch[] = "access-code-cast-url"; -// This value is hardcoded in chrome/browser/flag-metadata.json -- please ensure -// that file is updated if this value is changed. -constexpr char kAccessCodeCastDeviceDurationSwitch[] = - "access-code-cast-device-duration"; - } // namespace switches } // namespace media_router
diff --git a/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.h b/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.h index c822881..fe33b4f 100644 --- a/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.h +++ b/chrome/browser/media/router/discovery/access_code/access_code_cast_constants.h
@@ -45,10 +45,6 @@ // Specifies the URL from which to obtain cast discovery information. extern const char kDiscoveryEndpointSwitch[]; -// Specifies and overwrites the duration that should be set for the -// kAccessCodeCastDeviceDuration. -extern const char kAccessCodeCastDeviceDurationSwitch[]; - } // namespace switches } // namespace media_router
diff --git a/chrome/browser/metrics/majority_age_user_metrics_provider_browsertest.cc b/chrome/browser/metrics/majority_age_user_metrics_provider_browsertest.cc index 8b40700..37e84bf 100644 --- a/chrome/browser/metrics/majority_age_user_metrics_provider_browsertest.cc +++ b/chrome/browser/metrics/majority_age_user_metrics_provider_browsertest.cc
@@ -19,7 +19,7 @@ #include "components/metrics/demographics/demographic_metrics_test_utils.h" #include "components/metrics/demographics/user_demographics.h" #include "components/metrics/metrics_service.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "content/public/test/browser_test.h" #include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h" #include "third_party/metrics_proto/system_profile.pb.h"
diff --git a/chrome/browser/metrics/tab_stats/tab_stats_tracker_unittest.cc b/chrome/browser/metrics/tab_stats/tab_stats_tracker_unittest.cc index 3a362c44..46398231 100644 --- a/chrome/browser/metrics/tab_stats/tab_stats_tracker_unittest.cc +++ b/chrome/browser/metrics/tab_stats/tab_stats_tracker_unittest.cc
@@ -82,7 +82,7 @@ std::unique_ptr<content::WebContents> tab = test_harness->CreateTestWebContents(); tab_strip_model->InsertWebContentsAt( - tab_strip_model->count(), std::move(tab), TabStripModel::ADD_ACTIVE); + tab_strip_model->count(), std::move(tab), AddTabTypes::ADD_ACTIVE); } EXPECT_EQ(tab_stats_data_store()->tab_stats().total_tab_count, static_cast<size_t>(tab_strip_model->count()));
diff --git a/chrome/browser/metrics/testing/sync_metrics_test_utils.cc b/chrome/browser/metrics/testing/sync_metrics_test_utils.cc index 723e510..a54e228 100644 --- a/chrome/browser/metrics/testing/sync_metrics_test_utils.cc +++ b/chrome/browser/metrics/testing/sync_metrics_test_utils.cc
@@ -10,7 +10,7 @@ #include "chrome/browser/sync/test/integration/sync_service_impl_harness.h" #include "components/signin/public/identity_manager/account_info.h" #include "components/signin/public/identity_manager/identity_manager.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" namespace metrics { namespace test {
diff --git a/chrome/browser/metrics/testing/sync_metrics_test_utils.h b/chrome/browser/metrics/testing/sync_metrics_test_utils.h index 6c695b5..a35e89d 100644 --- a/chrome/browser/metrics/testing/sync_metrics_test_utils.h +++ b/chrome/browser/metrics/testing/sync_metrics_test_utils.h
@@ -6,7 +6,7 @@ #define CHROME_BROWSER_METRICS_TESTING_SYNC_METRICS_TEST_UTILS_H_ #include "base/memory/weak_ptr.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" // Helpers to support sync in metrics browser tests.
diff --git a/chrome/browser/metrics/ukm_browsertest.cc b/chrome/browser/metrics/ukm_browsertest.cc index a6d4b6b..b85a6806 100644 --- a/chrome/browser/metrics/ukm_browsertest.cc +++ b/chrome/browser/metrics/ukm_browsertest.cc
@@ -39,7 +39,7 @@ #include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service_impl.h" #include "components/sync/driver/sync_token_status.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include "components/ukm/ukm_recorder_observer.h" #include "components/ukm/ukm_service.h" #include "components/ukm/ukm_test_helper.h"
diff --git a/chrome/browser/new_tab_page/new_tab_page_util.cc b/chrome/browser/new_tab_page/new_tab_page_util.cc index 8dcf182..7119ef2d 100644 --- a/chrome/browser/new_tab_page/new_tab_page_util.cc +++ b/chrome/browser/new_tab_page/new_tab_page_util.cc
@@ -61,3 +61,13 @@ return IsOsSupportedForCart() && IsInUS(); } } + +bool IsModuleFreEnabled() { + if (base::FeatureList::GetInstance()->IsFeatureOverridden( + ntp_features::kNtpModulesFirstRunExperience.name)) { + return base::FeatureList::IsEnabled( + ntp_features::kNtpModulesFirstRunExperience); + } else { + return IsInUS(); + } +}
diff --git a/chrome/browser/new_tab_page/new_tab_page_util.h b/chrome/browser/new_tab_page/new_tab_page_util.h index 7a6a1457..8d6a74e 100644 --- a/chrome/browser/new_tab_page/new_tab_page_util.h +++ b/chrome/browser/new_tab_page/new_tab_page_util.h
@@ -7,5 +7,6 @@ bool IsRecipeTasksModuleEnabled(); bool IsCartModuleEnabled(); +bool IsModuleFreEnabled(); #endif // CHROME_BROWSER_NEW_TAB_PAGE_NEW_TAB_PAGE_UTIL_H_
diff --git a/chrome/browser/new_tab_page/new_tab_page_util_browsertest.cc b/chrome/browser/new_tab_page/new_tab_page_util_browsertest.cc index b0819ef..ea31c85d 100644 --- a/chrome/browser/new_tab_page/new_tab_page_util_browsertest.cc +++ b/chrome/browser/new_tab_page/new_tab_page_util_browsertest.cc
@@ -21,7 +21,8 @@ public: NewTabPageUtilEnableFlagBrowserTest() { features_.InitWithFeatures({ntp_features::kNtpRecipeTasksModule, - ntp_features::kNtpChromeCartModule}, + ntp_features::kNtpChromeCartModule, + ntp_features::kNtpModulesFirstRunExperience}, {}); } }; @@ -29,8 +30,10 @@ class NewTabPageUtilDisableFlagBrowserTest : public NewTabPageUtilBrowserTest { public: NewTabPageUtilDisableFlagBrowserTest() { - features_.InitWithFeatures({}, {ntp_features::kNtpRecipeTasksModule, - ntp_features::kNtpChromeCartModule}); + features_.InitWithFeatures({}, + {ntp_features::kNtpRecipeTasksModule, + ntp_features::kNtpChromeCartModule, + ntp_features::kNtpModulesFirstRunExperience}); } }; @@ -88,3 +91,25 @@ g_browser_process->variations_service()->OverrideStoredPermanentCountry("us"); EXPECT_FALSE(IsCartModuleEnabled()); } + +IN_PROC_BROWSER_TEST_F(NewTabPageUtilBrowserTest, EnableFreByToT) { + auto locale = std::make_unique<ScopedBrowserLocale>("en-US"); + g_browser_process->variations_service()->OverrideStoredPermanentCountry("us"); + EXPECT_TRUE(IsModuleFreEnabled()); +} + +IN_PROC_BROWSER_TEST_F(NewTabPageUtilBrowserTest, DisableFreByToT) { + auto locale = std::make_unique<ScopedBrowserLocale>("en-US"); + g_browser_process->variations_service()->OverrideStoredPermanentCountry("ca"); + EXPECT_FALSE(IsModuleFreEnabled()); +} + +IN_PROC_BROWSER_TEST_F(NewTabPageUtilEnableFlagBrowserTest, EnableFreByFlag) { + EXPECT_TRUE(IsModuleFreEnabled()); +} + +IN_PROC_BROWSER_TEST_F(NewTabPageUtilDisableFlagBrowserTest, DisableFreByFlag) { + auto locale = std::make_unique<ScopedBrowserLocale>("en-US"); + g_browser_process->variations_service()->OverrideStoredPermanentCountry("us"); + EXPECT_FALSE(IsModuleFreEnabled()); +}
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc index ce85ecfac..62a7fbef 100644 --- a/chrome/browser/password_manager/password_manager_browsertest.cc +++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -3236,7 +3236,7 @@ // factories hear about such frames, this would crash. tab_strip_model->AddWebContents(std::move(detached_web_contents), -1, ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); } IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
diff --git a/chrome/browser/persisted_state_db/BUILD.gn b/chrome/browser/persisted_state_db/BUILD.gn index 70afb2c..0e38dca 100644 --- a/chrome/browser/persisted_state_db/BUILD.gn +++ b/chrome/browser/persisted_state_db/BUILD.gn
@@ -20,6 +20,7 @@ deps = [ "//base:base", + "//components/commerce/core:commerce_subscription_db_content_proto", "//components/commerce/core:persisted_state_db_content_proto", "//components/keyed_service/content", "//components/leveldb_proto", @@ -30,7 +31,6 @@ if (is_android) { deps += [ "//chrome/browser/tab:jni_headers", - "//components/commerce/core:commerce_subscription_db_content_proto", "//components/commerce/core:merchant_signal_db_proto", ] } else {
diff --git a/chrome/browser/persisted_state_db/session_proto_db_factory.cc b/chrome/browser/persisted_state_db/session_proto_db_factory.cc index a21a2aa..b7ce3b8 100644 --- a/chrome/browser/persisted_state_db/session_proto_db_factory.cc +++ b/chrome/browser/persisted_state_db/session_proto_db_factory.cc
@@ -23,6 +23,23 @@ return GetPersistedStateSessionProtoDBFactory(); } +SessionProtoDBFactory< + commerce_subscription_db::CommerceSubscriptionContentProto>* +GetCommerceSubscriptionSessionProtoDBFactory() { + static base::NoDestructor<SessionProtoDBFactory< + commerce_subscription_db::CommerceSubscriptionContentProto>> + instance; + return instance.get(); +} + +template <> +SessionProtoDBFactory< + commerce_subscription_db::CommerceSubscriptionContentProto>* +SessionProtoDBFactory< + commerce_subscription_db::CommerceSubscriptionContentProto>::GetInstance() { + return GetCommerceSubscriptionSessionProtoDBFactory(); +} + #if !BUILDFLAG(IS_ANDROID) SessionProtoDBFactory<cart_db::ChromeCartContentProto>* GetChromeCartSessionProtoDBFactory() { @@ -53,23 +70,6 @@ } #else -SessionProtoDBFactory< - commerce_subscription_db::CommerceSubscriptionContentProto>* -GetCommerceSubscriptionSessionProtoDBFactory() { - static base::NoDestructor<SessionProtoDBFactory< - commerce_subscription_db::CommerceSubscriptionContentProto>> - instance; - return instance.get(); -} - -template <> -SessionProtoDBFactory< - commerce_subscription_db::CommerceSubscriptionContentProto>* -SessionProtoDBFactory< - commerce_subscription_db::CommerceSubscriptionContentProto>::GetInstance() { - return GetCommerceSubscriptionSessionProtoDBFactory(); -} - SessionProtoDBFactory<merchant_signal_db::MerchantSignalContentProto>* GetMerchantSignalSessionProtoDBFactory() { static base::NoDestructor<
diff --git a/chrome/browser/persisted_state_db/session_proto_db_factory.h b/chrome/browser/persisted_state_db/session_proto_db_factory.h index 80b2d8c..b1f14626 100644 --- a/chrome/browser/persisted_state_db/session_proto_db_factory.h +++ b/chrome/browser/persisted_state_db/session_proto_db_factory.h
@@ -7,6 +7,7 @@ #include "base/no_destructor.h" #include "build/build_config.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/session_proto_db/session_proto_db.h" @@ -17,7 +18,6 @@ #include "components/commerce/core/proto/cart_db_content.pb.h" #include "components/commerce/core/proto/coupon_db_content.pb.h" #else -#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" #include "components/commerce/core/proto/merchant_signal_db_content.pb.h" #endif @@ -38,13 +38,14 @@ SessionProtoDBFactory<coupon_db::CouponContentProto>* GetCouponSessionProtoDBFactory(); #else -SessionProtoDBFactory< - commerce_subscription_db::CommerceSubscriptionContentProto>* -GetCommerceSubscriptionSessionProtoDBFactory(); SessionProtoDBFactory<merchant_signal_db::MerchantSignalContentProto>* GetMerchantSignalSessionProtoDBFactory(); #endif +SessionProtoDBFactory< + commerce_subscription_db::CommerceSubscriptionContentProto>* +GetCommerceSubscriptionSessionProtoDBFactory(); + // Factory to create a ProtoDB per browsing session (BrowserContext) and per // proto. Incognito is currently not supported and the factory will return // nullptr for an incognito profile. @@ -109,6 +110,13 @@ context, proto_database_provider, context->GetPath().AppendASCII(kPersistedStateDBFolder), leveldb_proto::ProtoDbType::PERSISTED_STATE_DATABASE); + } else if (std::is_base_of< + commerce_subscription_db::CommerceSubscriptionContentProto, + T>::value) { + return new SessionProtoDB<T>( + context, proto_database_provider, + context->GetPath().AppendASCII(kCommerceSubscriptionDBFolder), + leveldb_proto::ProtoDbType::COMMERCE_SUBSCRIPTION_DATABASE); #if !BUILDFLAG(IS_ANDROID) } else if (std::is_base_of<cart_db::ChromeCartContentProto, T>::value) { return new SessionProtoDB<T>( @@ -121,13 +129,6 @@ context->GetPath().AppendASCII(kCouponDBFolder), leveldb_proto::ProtoDbType::COUPON_DATABASE); #else - } else if (std::is_base_of< - commerce_subscription_db::CommerceSubscriptionContentProto, - T>::value) { - return new SessionProtoDB<T>( - context, proto_database_provider, - context->GetPath().AppendASCII(kCommerceSubscriptionDBFolder), - leveldb_proto::ProtoDbType::COMMERCE_SUBSCRIPTION_DATABASE); } else if (std::is_base_of<merchant_signal_db::MerchantSignalContentProto, T>::value) { return new SessionProtoDB<T>(
diff --git a/chrome/browser/preferences/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceKeys.java b/chrome/browser/preferences/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceKeys.java index e58b7945..8128a2e4 100644 --- a/chrome/browser/preferences/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceKeys.java +++ b/chrome/browser/preferences/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceKeys.java
@@ -248,6 +248,12 @@ */ public static final String DEFAULT_ENABLED_DESKTOP_SITE_GLOBAL_SETTING_SHOW_MESSAGE = "Chrome.RequestDesktopSiteGlobalSetting.DefaultEnabledShowMessage"; + /** + * Indicates whether an opt-in message was shown for the desktop site global setting based on + * device conditions. + */ + public static final String DESKTOP_SITE_GLOBAL_SETTING_OPT_IN_MESSAGE_SHOWN = + "Chrome.RequestDesktopSiteGlobalSetting.OptInMessageShown"; public static final String DOWNLOAD_AUTO_RESUMPTION_ATTEMPT_LEFT = "ResumptionAttemptLeft"; public static final String DOWNLOAD_FOREGROUND_SERVICE_OBSERVERS = "ForegroundServiceObservers"; @@ -1026,6 +1032,7 @@ DEFAULT_BROWSER_PROMO_SESSION_COUNT, DEFAULT_ENABLED_DESKTOP_SITE_GLOBAL_SETTING, DEFAULT_ENABLED_DESKTOP_SITE_GLOBAL_SETTING_SHOW_MESSAGE, + DESKTOP_SITE_GLOBAL_SETTING_OPT_IN_MESSAGE_SHOWN, DOWNLOAD_INTERSTITIAL_DOWNLOAD_PENDING_REMOVAL, EXPLORE_OFFLINE_CONTENT_AVAILABILITY_STATUS, FEED_ARTICLES_LIST_VISIBLE,
diff --git a/chrome/browser/privacy_budget/privacy_budget_browsertest.cc b/chrome/browser/privacy_budget/privacy_budget_browsertest.cc index 8cbf63c9..1a6b7fd 100644 --- a/chrome/browser/privacy_budget/privacy_budget_browsertest.cc +++ b/chrome/browser/privacy_budget/privacy_budget_browsertest.cc
@@ -36,7 +36,7 @@ #include "chrome/test/base/chrome_test_utils.h" #include "components/metrics_services_manager/metrics_services_manager.h" #include "components/prefs/pref_service.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "components/ukm/test_ukm_recorder.h" #include "components/ukm/ukm_test_helper.h" #include "components/unified_consent/unified_consent_service.h"
diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc index fd45f6a9..dfb28cd 100644 --- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
@@ -120,6 +120,7 @@ #include "chrome/common/chrome_features.h" #include "components/breadcrumbs/core/breadcrumbs_status.h" #include "components/captive_portal/core/buildflags.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" #include "components/commerce/core/proto/persisted_state_db_content.pb.h" #include "components/optimization_guide/core/optimization_guide_switches.h" #include "components/optimization_guide/machine_learning_tflite_buildflags.h" @@ -144,7 +145,6 @@ #include "chrome/browser/commerce/merchant_viewer/merchant_viewer_data_manager_factory.h" #include "chrome/browser/media/android/cdm/media_drm_origin_id_manager_factory.h" #include "components/commerce/core/commerce_feature_list.h" -#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" #include "components/commerce/core/proto/merchant_signal_db_content.pb.h" #else #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" @@ -473,10 +473,8 @@ SessionProtoDBFactory<cart_db::ChromeCartContentProto>::GetInstance(); SessionProtoDBFactory<coupon_db::CouponContentProto>::GetInstance(); #endif -#if BUILDFLAG(IS_ANDROID) SessionProtoDBFactory<commerce_subscription_db:: CommerceSubscriptionContentProto>::GetInstance(); -#endif #if BUILDFLAG(IS_ANDROID) SessionProtoDBFactory< merchant_signal_db::MerchantSignalContentProto>::GetInstance();
diff --git a/chrome/browser/profiles/profile_keyed_service_browsertest.cc b/chrome/browser/profiles/profile_keyed_service_browsertest.cc index 3f5aaf7..ae956d8 100644 --- a/chrome/browser/profiles/profile_keyed_service_browsertest.cc +++ b/chrome/browser/profiles/profile_keyed_service_browsertest.cc
@@ -380,6 +380,7 @@ "SendTabToSelfSyncService", "SerialConnectionManager", "SessionDataService", + "SessionProtoDBFactory", "SessionSyncService", "SessionsAPI", "SettingsOverridesAPI",
diff --git a/chrome/browser/resource_coordinator/tab_activity_watcher_browsertest.cc b/chrome/browser/resource_coordinator/tab_activity_watcher_browsertest.cc index 987aa8a..9dabe11 100644 --- a/chrome/browser/resource_coordinator/tab_activity_watcher_browsertest.cc +++ b/chrome/browser/resource_coordinator/tab_activity_watcher_browsertest.cc
@@ -389,7 +389,7 @@ // reactivating the tab, but to the user, it never leaves the foreground, so // we don't log a foregrounded event for it. browser_2->tab_strip_model()->InsertWebContentsAt( - 1, std::move(owned_dragged_contents), TabStripModel::ADD_NONE); + 1, std::move(owned_dragged_contents), AddTabTypes::ADD_NONE); dragged_contents->WasShown(); browser_2->tab_strip_model()->ActivateTabAt( 1, TabStripUserGestureDetails(
diff --git a/chrome/browser/resource_coordinator/tab_metrics_logger_unittest.cc b/chrome/browser/resource_coordinator/tab_metrics_logger_unittest.cc index 203e60f..8bbe59f 100644 --- a/chrome/browser/resource_coordinator/tab_metrics_logger_unittest.cc +++ b/chrome/browser/resource_coordinator/tab_metrics_logger_unittest.cc
@@ -496,7 +496,7 @@ FakeBrowserWindow::CreateBrowserWithFakeWindowForParams(params); created_browser->window()->Activate(); created_browser->tab_strip_model()->InsertWebContentsAt( - 0, std::move(dragged_tab), TabStripModel::ADD_ACTIVE); + 0, std::move(dragged_tab), AddTabTypes::ADD_ACTIVE); WindowFeatures created_browser_metrics{WindowMetricsEvent::TYPE_TABBED, WindowMetricsEvent::SHOW_STATE_NORMAL,
diff --git a/chrome/browser/resources/settings/languages_page/languages.ts b/chrome/browser/resources/settings/languages_page/languages.ts index 2a5f00a8..cf03ac7 100644 --- a/chrome/browser/resources/settings/languages_page/languages.ts +++ b/chrome/browser/resources/settings/languages_page/languages.ts
@@ -879,8 +879,7 @@ } /** - * Sets the translate target language and adds it to the content languages if - * not already there. + * Sets the translate target language. */ setTranslateTargetLanguage(languageCode: string) { this.languageSettingsPrivate_.setTranslateTargetLanguage(languageCode);
diff --git a/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.html b/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.html index 2c0d271c..d6229f7 100644 --- a/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.html +++ b/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.html
@@ -16,6 +16,7 @@ box-sizing: border-box; color: currentColor; display: grid; + font-size: var(--mwb-primary-text-font-size); grid-template-areas: 'arrow icon title'; grid-template-columns: var(--row-icon-width) var(--row-icon-width) auto; height: var(--row-height); @@ -215,4 +216,4 @@ </template> </div> </template> -</div> \ No newline at end of file +</div>
diff --git a/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.ts b/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.ts index 3ed19ad..02294ba 100644 --- a/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.ts +++ b/chrome/browser/resources/side_panel/bookmarks/bookmark_folder.ts
@@ -49,7 +49,8 @@ open_: { type: Boolean, value: false, - computed: 'computeIsOpen_(openFolders, folder.id)', + computed: + 'computeIsOpen_(openFolders, folder.id, folder.children.length)', }, openFolders: Array, @@ -169,7 +170,8 @@ private computeIsOpen_() { return Boolean(this.openFolders) && - this.openFolders.includes(this.folder.id); + this.openFolders.includes(this.folder.id) && this.folder.children && + this.folder.children.length > 0; } private getFocusableRows_(): HTMLElement[] {
diff --git a/chrome/browser/resources/side_panel/reading_list/app.html b/chrome/browser/resources/side_panel/reading_list/app.html index 92aaa3d..8a37478 100644 --- a/chrome/browser/resources/side_panel/reading_list/app.html +++ b/chrome/browser/resources/side_panel/reading_list/app.html
@@ -33,6 +33,7 @@ var(--cr-hover-background-color)); --hover-border-color: var(--border-color); border-radius: 4px; + font-size: var(--mwb-primary-text-font-size); margin: 16px 16px 0 16px; padding: 8px; transition: background-color 300ms cubic-bezier(0.4, 0, 0.2, 1);
diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service_sync_browsertest.cc b/chrome/browser/safe_browsing/chrome_password_protection_service_sync_browsertest.cc index 5f26d45..d45e85d 100644 --- a/chrome/browser/safe_browsing/chrome_password_protection_service_sync_browsertest.cc +++ b/chrome/browser/safe_browsing/chrome_password_protection_service_sync_browsertest.cc
@@ -36,7 +36,7 @@ #include "components/signin/public/identity_manager/identity_test_utils.h" #include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_user_settings.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include "content/public/browser/web_contents.h" #include "content/public/test/browser_test.h" #include "content/public/test/browser_test_utils.h"
diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc index 45ccede..cc36b62 100644 --- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc +++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
@@ -25,8 +25,8 @@ #include "components/sync/model/sync_error_factory.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/search_engine_specifics.pb.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/url_formatter/url_formatter.h" #include "content/public/test/browser_task_environment.h"
diff --git a/chrome/browser/send_tab_to_self/desktop_notification_handler_unittest.cc b/chrome/browser/send_tab_to_self/desktop_notification_handler_unittest.cc index 9dd646c..d079d46 100644 --- a/chrome/browser/send_tab_to_self/desktop_notification_handler_unittest.cc +++ b/chrome/browser/send_tab_to_self/desktop_notification_handler_unittest.cc
@@ -20,7 +20,7 @@ #include "components/send_tab_to_self/send_tab_to_self_sync_service.h" #include "components/send_tab_to_self/test_send_tab_to_self_model.h" #include "components/sync/base/model_type.h" -#include "components/sync/test/model/fake_model_type_controller_delegate.h" +#include "components/sync/test/fake_model_type_controller_delegate.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 6672a448..b0160b94 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc
@@ -891,9 +891,9 @@ whats_new::StartWhatsNewFetch(browser); continue; } - int add_types = TabStripModel::ADD_FORCE_INDEX; + int add_types = AddTabTypes::ADD_FORCE_INDEX; if (is_first_tab) - add_types |= TabStripModel::ADD_ACTIVE; + add_types |= AddTabTypes::ADD_ACTIVE; NavigateParams params(browser, url, ui::PAGE_TRANSITION_AUTO_TOPLEVEL); params.disposition = is_first_tab ? WindowOpenDisposition::NEW_FOREGROUND_TAB
diff --git a/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/crow/CrowBridge.java b/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/crow/CrowBridge.java index 82fd17645..9726133 100644 --- a/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/crow/CrowBridge.java +++ b/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/crow/CrowBridge.java
@@ -41,13 +41,22 @@ * Returns the publication ID for a hostname; empty string if host is not on the allowlist. * @param host The hostname to check against the allowlist. */ - static String getPublicationIDForHost(String host) { - return CrowBridgeJni.get().getPublicationIDForHost(host); + static String getPublicationIDFromAllowlist(String host) { + return CrowBridgeJni.get().getPublicationIDFromAllowlist(host); + } + + /** + * Returns whether |host| is on the denylist. + * @param host The hostname to check against the denylist. + */ + static boolean denylistContainsHost(String host) { + return CrowBridgeJni.get().denylistContainsHost(host); } @NativeMethods interface Natives { void getRecentVisitCountsToHost(GURL url, int numDays, Callback<int[]> callback); - String getPublicationIDForHost(String host); + String getPublicationIDFromAllowlist(String host); + boolean denylistContainsHost(String host); } }
diff --git a/chrome/browser/share/core/crow/crow_configuration.cc b/chrome/browser/share/core/crow/crow_configuration.cc index 884a53f..2696884 100644 --- a/chrome/browser/share/core/crow/crow_configuration.cc +++ b/chrome/browser/share/core/crow/crow_configuration.cc
@@ -54,11 +54,24 @@ domains_.insert(std::make_pair(host, publisher.publication_id())); } } + + denied_hosts_.clear(); + for (const std::string& host : config->denied_hosts()) { + denied_hosts_.insert(host); + } } -std::string CrowConfiguration::GetPublicationID(const std::string& host) const { +std::string CrowConfiguration::GetPublicationIDFromAllowlist( + const std::string& host) const { AutoLock lock(lock_); + return domains_.count(host) > 0 ? domains_.at(host) : ""; } +bool CrowConfiguration::DenylistContainsHost(const std::string& host) const { + AutoLock lock(lock_); + + return denied_hosts_.count(host) > 0; +} + } // namespace crow
diff --git a/chrome/browser/share/core/crow/crow_configuration.h b/chrome/browser/share/core/crow/crow_configuration.h index 07812e65..bd52517b 100644 --- a/chrome/browser/share/core/crow/crow_configuration.h +++ b/chrome/browser/share/core/crow/crow_configuration.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_SHARE_CORE_CROW_CROW_CONFIGURATION_H_ #define CHROME_BROWSER_SHARE_CORE_CROW_CROW_CONFIGURATION_H_ +#include <set> #include <string> #include "base/containers/flat_map.h" @@ -27,20 +28,29 @@ // Read data from an serialized protobuf and update the internal list. void PopulateFromBinaryPb(const std::string& binary_pb); - // Returns the Publication ID for 'host', or the empty string. - std::string GetPublicationID(const std::string& host) const; + // Returns the Publication ID for 'host' if present in the component data + // allowlist, or the empty string if it is not present. + // Note that hosts may also be enabled via a Java-side bloom filter, + // and might be present in the component Denylist (see DenylistContainsHost), + // though we do not intend to have a host in both lists simultaneously. + std::string GetPublicationIDFromAllowlist(const std::string& host) const; + + // Returns whether |host| is explicitly in the feature's denylist. + bool DenylistContainsHost(const std::string& host) const; protected: CrowConfiguration(); private: - // The latest targets we've committed. Starts out null. - // Protected by lock_. + // Hostname/Publisher ID mappings. Protected by |lock_|. base::flat_map<std::string, std::string> domains_; + // Hostname/Publisher ID mappings. Protected by |lock_|. + std::set<std::string> denied_hosts_; + mutable base::Lock lock_; - FRIEND_TEST_ALL_PREFIXES(CrowConfigurationTest, Update); + FRIEND_TEST_ALL_PREFIXES(CrowConfigurationTest, UpdateAllowlist); friend struct CrowConfigurationSingletonTrait; };
diff --git a/chrome/browser/share/core/crow/crow_configuration_unittest.cc b/chrome/browser/share/core/crow/crow_configuration_unittest.cc index a03b664..0e28582 100644 --- a/chrome/browser/share/core/crow/crow_configuration_unittest.cc +++ b/chrome/browser/share/core/crow/crow_configuration_unittest.cc
@@ -27,7 +27,12 @@ NiceMock<MockCrowConfiguration> config_; }; -TEST_F(CrowConfigurationTest, Update) { +TEST_F(CrowConfigurationTest, GetPublicationIDBeforeUpdate) { + // Calls to GetPublicatoinID before data arrives simply return 'no.' + EXPECT_EQ(config_.GetPublicationIDFromAllowlist("pub2.tld"), ""); +} + +TEST_F(CrowConfigurationTest, UpdateAllowlist) { crow::mojom::CrowConfiguration proto; ::crow::mojom::Publisher* publisher1 = proto.add_publisher(); publisher1->set_publication_id("Pub1"); @@ -44,6 +49,32 @@ EXPECT_EQ(config_.domains_["pub1.tld"], "Pub1"); EXPECT_EQ(config_.domains_["blog.pub1.tld"], "Pub1"); EXPECT_EQ(config_.domains_["pub2.tld"], "Pub2"); + EXPECT_EQ(config_.GetPublicationIDFromAllowlist("pub1.tld"), "Pub1"); + EXPECT_EQ(config_.GetPublicationIDFromAllowlist("blog.pub1.tld"), "Pub1"); + EXPECT_EQ(config_.GetPublicationIDFromAllowlist("pub2.tld"), "Pub2"); +} + +TEST_F(CrowConfigurationTest, UpdateWithDenylist) { + // Both allowlist and denylist are populated; allowlist should + // not have an effect on denylist checks though a host overlaps. + crow::mojom::CrowConfiguration proto; + ::crow::mojom::Publisher* publisher1 = proto.add_publisher(); + publisher1->set_publication_id("Pub1"); + publisher1->add_host("pub1.tld"); + publisher1->add_host("blog.pub1.tld"); + + ::crow::mojom::Publisher* publisher2 = proto.add_publisher(); + publisher2->set_publication_id("Pub2"); + publisher2->add_host("pub2.tld"); + + proto.add_denied_hosts("pub2.tld"); + proto.add_denied_hosts("getrichquick.scam"); + + config_.PopulateFromBinaryPb(proto.SerializeAsString()); + + EXPECT_FALSE(config_.DenylistContainsHost("pub1.tld")); + EXPECT_TRUE(config_.DenylistContainsHost("pub2.tld")); + EXPECT_TRUE(config_.DenylistContainsHost("getrichquick.scam")); } } // namespace crow
diff --git a/chrome/browser/share/crow_bridge.cc b/chrome/browser/share/crow_bridge.cc index 9f1a47e..3aed23a 100644 --- a/chrome/browser/share/crow_bridge.cc +++ b/chrome/browser/share/crow_bridge.cc
@@ -62,13 +62,22 @@ } static base::android::ScopedJavaLocalRef<jstring> -JNI_CrowBridge_GetPublicationIDForHost( +JNI_CrowBridge_GetPublicationIDFromAllowlist( JNIEnv* env, const base::android::JavaParamRef<jstring>& host) { std::string publication_id = - crow::CrowConfiguration::GetInstance()->GetPublicationID( + crow::CrowConfiguration::GetInstance()->GetPublicationIDFromAllowlist( base::android::ConvertJavaStringToUTF8(env, host)); base::android::ScopedJavaLocalRef<jstring> j_publication_id = base::android::ConvertUTF8ToJavaString(env, publication_id); return j_publication_id; } + +static jboolean JNI_CrowBridge_DenylistContainsHost( + JNIEnv* env, + const base::android::JavaParamRef<jstring>& host) { + bool on_denylist = + crow::CrowConfiguration::GetInstance()->DenylistContainsHost( + base::android::ConvertJavaStringToUTF8(env, host)); + return on_denylist; +}
diff --git a/chrome/browser/share/proto/crow_configuration.proto b/chrome/browser/share/proto/crow_configuration.proto index f6fed07..cb96d7fb 100644 --- a/chrome/browser/share/proto/crow_configuration.proto +++ b/chrome/browser/share/proto/crow_configuration.proto
@@ -11,10 +11,14 @@ // Information about an allowlisted hostname. // A wire-compatible proto is maintained in the server code base. message CrowConfiguration { + // List of allowed publisher ID/host mappings. repeated Publisher publisher = 1; // Allowed locales. Feature is initially en-US. repeated string allowed_country_codes = 2; + + // Disallowed hostnames, takes priority over |publisher.host|. + repeated string denied_hosts = 3; } message Publisher {
diff --git a/chrome/browser/sharing/sharing_message_bridge_impl_unittest.cc b/chrome/browser/sharing/sharing_message_bridge_impl_unittest.cc index 72a2831..28c92f2 100644 --- a/chrome/browser/sharing/sharing_message_bridge_impl_unittest.cc +++ b/chrome/browser/sharing/sharing_message_bridge_impl_unittest.cc
@@ -14,7 +14,7 @@ #include "components/sync/model/metadata_batch.h" #include "components/sync/model/metadata_change_list.h" #include "components/sync/model/model_type_sync_bridge.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "net/base/network_change_notifier.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/site_isolation/site_per_process_text_input_browsertest.cc b/chrome/browser/site_isolation/site_per_process_text_input_browsertest.cc index c32c9aa7..74d226c 100644 --- a/chrome/browser/site_isolation/site_per_process_text_input_browsertest.cc +++ b/chrome/browser/site_isolation/site_per_process_text_input_browsertest.cc
@@ -1315,7 +1315,7 @@ active_contents()->GetBrowserContext(), nullptr)); content::WebContents* raw_new_contents = new_contents.get(); browser()->tab_strip_model()->InsertWebContentsAt(1, std::move(new_contents), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_EQ(active_contents(), raw_new_contents); // Simple page with 1 cross origin (out-of-process) <iframe>. @@ -1383,7 +1383,7 @@ active_contents()->GetBrowserContext(), nullptr)); content::WebContents* raw_new_contents = new_contents.get(); browser()->tab_strip_model()->InsertWebContentsAt(1, std::move(new_contents), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_EQ(active_contents(), raw_new_contents); // Simple page with no <iframe>s.
diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc index cf4ad22..40ad465 100644 --- a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc +++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
@@ -31,8 +31,8 @@ #include "components/sync/model/sync_error_factory.h" #include "components/sync/protocol/dictionary_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_utils.h" #include "net/test/embedded_test_server/default_handlers.h"
diff --git a/chrome/browser/spellchecker/spellcheck_service.cc b/chrome/browser/spellchecker/spellcheck_service.cc index db3c802..bbc3ea68 100644 --- a/chrome/browser/spellchecker/spellcheck_service.cc +++ b/chrome/browser/spellchecker/spellcheck_service.cc
@@ -120,7 +120,7 @@ // load a non-existent Hunspell dictionary, and so that Hunspell // spellchecking isn't broken because of the failed load. ListPrefUpdate update(prefs, spellcheck::prefs::kSpellCheckDictionaries); - update->EraseListValueIf([](const base::Value& entry) { + update->GetList().EraseIf([](const base::Value& entry) { return spellcheck::GetCorrespondingSpellCheckLanguage(entry.GetString()) .empty(); }); @@ -191,8 +191,7 @@ PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); std::set<std::string> spellcheck_dictionaries; for (const auto& value : - prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries) - ->GetListDeprecated()) { + prefs->GetValueList(spellcheck::prefs::kSpellCheckDictionaries)) { const std::string* dictionary = value.GetIfString(); if (dictionary) spellcheck_dictionaries.insert(*dictionary); @@ -330,8 +329,8 @@ PrefService* prefs) { // Ensure that spellcheck is enabled for the first language in the // accept languages list. - base::Value user_dictionaries = - prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries)->Clone(); + base::Value::List user_dictionaries = + prefs->GetValueList(spellcheck::prefs::kSpellCheckDictionaries).Clone(); std::vector<std::string> user_languages = base::SplitString(prefs->GetString(language::prefs::kAcceptLanguages), ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); @@ -353,7 +352,7 @@ } bool first_user_language_spellchecked = false; - for (const auto& dictionary_value : user_dictionaries.GetListDeprecated()) { + for (const auto& dictionary_value : user_dictionaries) { first_user_language_spellchecked = base::Contains(dictionary_value.GetString(), first_user_language); if (first_user_language_spellchecked) @@ -361,9 +360,10 @@ } if (!first_user_language_spellchecked) { - user_dictionaries.Insert(user_dictionaries.GetListDeprecated().begin(), + user_dictionaries.Insert(user_dictionaries.begin(), base::Value(first_user_language)); - prefs->Set(spellcheck::prefs::kSpellCheckDictionaries, user_dictionaries); + prefs->SetList(spellcheck::prefs::kSpellCheckDictionaries, + std::move(user_dictionaries)); } } #endif // BUILDFLAG(IS_WIN) @@ -654,7 +654,7 @@ // When following object goes out of scope, preference change observers will // be notified (even if there is no preference change). ListPrefUpdate update(prefs, spellcheck::prefs::kSpellCheckDictionaries); - update->EraseListValueIf([this](const base::Value& entry) { + update->GetList().EraseIf([this](const base::Value& entry) { const std::string dictionary_name = entry.GetString(); return (!UsesWindowsDictionary(dictionary_name) && spellcheck::GetCorrespondingSpellCheckLanguage(dictionary_name)
diff --git a/chrome/browser/ssl/security_state_tab_helper_browsertest.cc b/chrome/browser/ssl/security_state_tab_helper_browsertest.cc index c64343f..7e5dc12d 100644 --- a/chrome/browser/ssl/security_state_tab_helper_browsertest.cc +++ b/chrome/browser/ssl/security_state_tab_helper_browsertest.cc
@@ -1211,7 +1211,7 @@ content::WebContents* raw_new_contents = new_contents.get(); browser()->tab_strip_model()->InsertWebContentsAt(0, std::move(new_contents), - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); CheckSecurityInfoForSecure(raw_new_contents, security_state::SECURE, false, false, false, false /* expect cert status error */);
diff --git a/chrome/browser/supervised_user/supervised_user_settings_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_settings_service_unittest.cc index afbf024..5abef2b 100644 --- a/chrome/browser/supervised_user/supervised_user_settings_service_unittest.cc +++ b/chrome/browser/supervised_user/supervised_user_settings_service_unittest.cc
@@ -17,9 +17,9 @@ #include "components/sync/model/sync_change.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/managed_user_setting_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/sync/android/fake_server_helper_android.cc b/chrome/browser/sync/android/fake_server_helper_android.cc index 2caac71..bf92c67 100644 --- a/chrome/browser/sync/android/fake_server_helper_android.cc +++ b/chrome/browser/sync/android/fake_server_helper_android.cc
@@ -23,12 +23,12 @@ #include "components/sync/nigori/nigori_test_utils.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/fake_server/bookmark_entity_builder.h" -#include "components/sync/test/fake_server/entity_builder_factory.h" -#include "components/sync/test/fake_server/fake_server.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" -#include "components/sync/test/fake_server/fake_server_verifier.h" +#include "components/sync/test/bookmark_entity_builder.h" +#include "components/sync/test/entity_builder_factory.h" +#include "components/sync/test/fake_server.h" +#include "components/sync/test/fake_server_network_resources.h" +#include "components/sync/test/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_verifier.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/android/gurl_android.h"
diff --git a/chrome/browser/sync/test/integration/ash_custom_passphrase_sharing_sync_test.cc b/chrome/browser/sync/test/integration/ash_custom_passphrase_sharing_sync_test.cc index e5868da..e62ad44 100644 --- a/chrome/browser/sync/test/integration/ash_custom_passphrase_sharing_sync_test.cc +++ b/chrome/browser/sync/test/integration/ash_custom_passphrase_sharing_sync_test.cc
@@ -31,7 +31,7 @@ #include "components/sync/nigori/cryptographer_impl.h" #include "components/sync/nigori/nigori_test_utils.h" #include "components/sync/protocol/os_preference_specifics.pb.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_nigori_helper.h" #include "content/public/test/browser_test.h" #include "mojo/public/cpp/bindings/remote.h"
diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.cc b/chrome/browser/sync/test/integration/bookmarks_helper.cc index 2445f85e..ca38c7bf 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc
@@ -49,7 +49,7 @@ #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/sync_entity.pb.h" #include "components/sync/protocol/unique_position.pb.h" -#include "components/sync/test/fake_server/entity_builder_factory.h" +#include "components/sync/test/entity_builder_factory.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h"
diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.h b/chrome/browser/sync/test/integration/bookmarks_helper.h index 3930e50..75bbc78 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.h +++ b/chrome/browser/sync/test/integration/bookmarks_helper.h
@@ -26,7 +26,7 @@ #include "components/bookmarks/browser/bookmark_test_util.h" #include "components/sync/engine/loopback_server/loopback_server_entity.h" #include "components/sync/engine/nigori/cryptographer.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "testing/gmock/include/gmock/gmock.h" #include "third_party/skia/include/core/SkColor.h" #include "url/gurl.h"
diff --git a/chrome/browser/sync/test/integration/device_info_helper.cc b/chrome/browser/sync/test/integration/device_info_helper.cc index b5cfda6..4070f6c 100644 --- a/chrome/browser/sync/test/integration/device_info_helper.cc +++ b/chrome/browser/sync/test/integration/device_info_helper.cc
@@ -4,7 +4,7 @@ #include "chrome/browser/sync/test/integration/device_info_helper.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" ServerDeviceInfoMatchChecker::ServerDeviceInfoMatchChecker( const Matcher& matcher)
diff --git a/chrome/browser/sync/test/integration/enable_disable_test.cc b/chrome/browser/sync/test/integration/enable_disable_test.cc index 763fa58..6dc07780 100644 --- a/chrome/browser/sync/test/integration/enable_disable_test.cc +++ b/chrome/browser/sync/test/integration/enable_disable_test.cc
@@ -20,8 +20,8 @@ #include "components/sync/driver/glue/sync_transport_data_prefs.h" #include "components/sync/driver/sync_service_impl.h" #include "components/sync/engine/cycle/entity_change_metric_recording.h" -#include "components/sync/test/fake_server/bookmark_entity_builder.h" -#include "components/sync/test/fake_server/entity_builder_factory.h" +#include "components/sync/test/bookmark_entity_builder.h" +#include "components/sync/test/entity_builder_factory.h" #include "content/public/test/browser_test.h" namespace {
diff --git a/chrome/browser/sync/test/integration/encryption_helper.h b/chrome/browser/sync/test/integration/encryption_helper.h index 4d72c91..d3316bd 100644 --- a/chrome/browser/sync/test/integration/encryption_helper.h +++ b/chrome/browser/sync/test/integration/encryption_helper.h
@@ -15,7 +15,7 @@ #include "chrome/browser/sync/test/integration/status_change_checker.h" #include "components/sync/base/passphrase_enums.h" #include "components/sync/driver/trusted_vault_client.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" // Checker used to block until a Nigori with a given passphrase type is // available on the server.
diff --git a/chrome/browser/sync/test/integration/fake_server_invalidation_sender.h b/chrome/browser/sync/test/integration/fake_server_invalidation_sender.h index 198d5b14..62f7c103 100644 --- a/chrome/browser/sync/test/integration/fake_server_invalidation_sender.h +++ b/chrome/browser/sync/test/integration/fake_server_invalidation_sender.h
@@ -6,7 +6,7 @@ #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SENDER_H_ #include "components/sync/base/model_type.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" namespace invalidation { class FCMNetworkHandler;
diff --git a/chrome/browser/sync/test/integration/fake_server_match_status_checker.h b/chrome/browser/sync/test/integration/fake_server_match_status_checker.h index 3fe0169..f547bad0 100644 --- a/chrome/browser/sync/test/integration/fake_server_match_status_checker.h +++ b/chrome/browser/sync/test/integration/fake_server_match_status_checker.h
@@ -10,7 +10,7 @@ #include "base/memory/raw_ptr.h" #include "chrome/browser/sync/test/integration/status_change_checker.h" #include "components/sync/base/model_type.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" namespace fake_server {
diff --git a/chrome/browser/sync/test/integration/invalidations/fake_server_sync_invalidation_sender.h b/chrome/browser/sync/test/integration/invalidations/fake_server_sync_invalidation_sender.h index 1a171f6..3b9cf7215 100644 --- a/chrome/browser/sync/test/integration/invalidations/fake_server_sync_invalidation_sender.h +++ b/chrome/browser/sync/test/integration/invalidations/fake_server_sync_invalidation_sender.h
@@ -9,7 +9,7 @@ #include "components/sync/base/model_type.h" #include "components/sync/invalidations/fcm_registration_token_observer.h" #include "components/sync/protocol/sync_invalidations_payload.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" namespace syncer { class FCMHandler;
diff --git a/chrome/browser/sync/test/integration/password_manager_sync_test.cc b/chrome/browser/sync/test/integration/password_manager_sync_test.cc index b216381..3127a1c 100644 --- a/chrome/browser/sync/test/integration/password_manager_sync_test.cc +++ b/chrome/browser/sync/test/integration/password_manager_sync_test.cc
@@ -36,7 +36,7 @@ #include "components/prefs/pref_service.h" #include "components/signin/public/identity_manager/account_info.h" #include "components/sync/driver/sync_service_impl.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_nigori_helper.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browsing_data_remover.h" #include "content/public/test/browser_test.h"
diff --git a/chrome/browser/sync/test/integration/preferences_helper.h b/chrome/browser/sync/test/integration/preferences_helper.h index 8cd88c3..3f4308c8 100644 --- a/chrome/browser/sync/test/integration/preferences_helper.h +++ b/chrome/browser/sync/test/integration/preferences_helper.h
@@ -22,7 +22,7 @@ #include "chrome/browser/sync/test/integration/status_change_checker.h" #include "components/prefs/json_pref_store.h" #include "components/sync/protocol/preference_specifics.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" class PrefChangeRegistrar; class PrefService;
diff --git a/chrome/browser/sync/test/integration/quiesce_status_change_checker.cc b/chrome/browser/sync/test/integration/quiesce_status_change_checker.cc index bd08eb8..a6c7d15 100644 --- a/chrome/browser/sync/test/integration/quiesce_status_change_checker.cc +++ b/chrome/browser/sync/test/integration/quiesce_status_change_checker.cc
@@ -13,7 +13,7 @@ #include "components/sync/driver/sync_service_impl.h" #include "components/sync/engine/cycle/sync_cycle_snapshot.h" #include "components/sync/protocol/data_type_progress_marker.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" namespace {
diff --git a/chrome/browser/sync/test/integration/session_hierarchy_match_checker.h b/chrome/browser/sync/test/integration/session_hierarchy_match_checker.h index e964b91..9d761b4 100644 --- a/chrome/browser/sync/test/integration/session_hierarchy_match_checker.h +++ b/chrome/browser/sync/test/integration/session_hierarchy_match_checker.h
@@ -6,8 +6,8 @@ #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSION_HIERARCHY_MATCH_CHECKER_H_ #include "chrome/browser/sync/test/integration/single_client_status_change_checker.h" -#include "components/sync/test/fake_server/fake_server_verifier.h" -#include "components/sync/test/fake_server/sessions_hierarchy.h" +#include "components/sync/test/fake_server_verifier.h" +#include "components/sync/test/sessions_hierarchy.h" // Checker to block until the FakeServer records a SessionsHierarchy identical // to the SessionsHierarchy specified in the constructor.
diff --git a/chrome/browser/sync/test/integration/sessions_helper.cc b/chrome/browser/sync/test/integration/sessions_helper.cc index 6943bae..7005ac4 100644 --- a/chrome/browser/sync/test/integration/sessions_helper.cc +++ b/chrome/browser/sync/test/integration/sessions_helper.cc
@@ -170,7 +170,7 @@ test()->GetBrowser(to_browser_index)->tab_strip_model(); target_strip->InsertWebContentsAt(target_strip->count(), std::move(detached_contents), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); } void NavigateTab(int browser_index, const GURL& url) {
diff --git a/chrome/browser/sync/test/integration/single_client_arc_package_sync_test.cc b/chrome/browser/sync/test/integration/single_client_arc_package_sync_test.cc index 4f5dab7f..8f2d7af 100644 --- a/chrome/browser/sync/test/integration/single_client_arc_package_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_arc_package_sync_test.cc
@@ -13,7 +13,7 @@ #include "components/sync/driver/sync_service.h" #include "components/sync/protocol/arc_package_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "content/public/test/browser_test.h" namespace arc {
diff --git a/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc b/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc index e0839bd..e2bedab9 100644 --- a/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_bookmarks_sync_test.cc
@@ -42,10 +42,10 @@ #include "components/sync/protocol/bookmark_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/fake_server/bookmark_entity_builder.h" -#include "components/sync/test/fake_server/entity_builder_factory.h" -#include "components/sync/test/fake_server/fake_server.h" -#include "components/sync/test/fake_server/fake_server_verifier.h" +#include "components/sync/test/bookmark_entity_builder.h" +#include "components/sync/test/entity_builder_factory.h" +#include "components/sync/test/fake_server.h" +#include "components/sync/test/fake_server_verifier.h" #include "components/sync_bookmarks/switches.h" #include "components/sync_device_info/fake_device_info_sync_service.h" #include "components/undo/bookmark_undo_service.h"
diff --git a/chrome/browser/sync/test/integration/single_client_custom_passphrase_sync_test.cc b/chrome/browser/sync/test/integration/single_client_custom_passphrase_sync_test.cc index a93d9e7..42102ddc 100644 --- a/chrome/browser/sync/test/integration/single_client_custom_passphrase_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_custom_passphrase_sync_test.cc
@@ -18,7 +18,7 @@ #include "components/sync/engine/nigori/nigori.h" #include "components/sync/nigori/cryptographer_impl.h" #include "components/sync/nigori/nigori_test_utils.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_nigori_helper.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_launcher.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/sync/test/integration/single_client_device_info_sync_test.cc b/chrome/browser/sync/test/integration/single_client_device_info_sync_test.cc index 1ff3108..76206eb 100644 --- a/chrome/browser/sync/test/integration/single_client_device_info_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_device_info_sync_test.cc
@@ -23,7 +23,7 @@ #include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync_entity.pb.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "components/sync_device_info/device_info.h" #include "components/sync_device_info/device_info_sync_service.h" #include "components/sync_device_info/device_info_tracker.h"
diff --git a/chrome/browser/sync/test/integration/single_client_extensions_sync_test.cc b/chrome/browser/sync/test/integration/single_client_extensions_sync_test.cc index 417fc46..b822d55 100644 --- a/chrome/browser/sync/test/integration/single_client_extensions_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_extensions_sync_test.cc
@@ -8,7 +8,7 @@ #include "chrome/browser/sync/test/integration/sync_test.h" #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h" #include "components/sync/driver/sync_service_impl.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "content/public/test/browser_test.h" namespace {
diff --git a/chrome/browser/sync/test/integration/single_client_history_delete_directives_sync_test.cc b/chrome/browser/sync/test/integration/single_client_history_delete_directives_sync_test.cc index 60b8826e..a303367 100644 --- a/chrome/browser/sync/test/integration/single_client_history_delete_directives_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_history_delete_directives_sync_test.cc
@@ -19,7 +19,7 @@ #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/history_delete_directive_specifics.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "content/public/test/browser_test.h" namespace {
diff --git a/chrome/browser/sync/test/integration/single_client_nigori_sync_test.cc b/chrome/browser/sync/test/integration/single_client_nigori_sync_test.cc index 747816b7..01352a9 100644 --- a/chrome/browser/sync/test/integration/single_client_nigori_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_nigori_sync_test.cc
@@ -43,7 +43,7 @@ #include "components/sync/engine/nigori/nigori.h" #include "components/sync/nigori/cryptographer_impl.h" #include "components/sync/nigori/nigori_test_utils.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_nigori_helper.h" #include "components/sync/trusted_vault/fake_security_domains_server.h" #include "components/sync/trusted_vault/securebox.h" #include "components/sync/trusted_vault/trusted_vault_connection.h"
diff --git a/chrome/browser/sync/test/integration/single_client_offer_sync_test.cc b/chrome/browser/sync/test/integration/single_client_offer_sync_test.cc index c1d2d7c6..d669475 100644 --- a/chrome/browser/sync/test/integration/single_client_offer_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_offer_sync_test.cc
@@ -16,7 +16,7 @@ #include "components/sync/base/model_type.h" #include "components/sync/driver/sync_service.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "content/public/test/browser_test.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/sync/test/integration/single_client_passwords_sync_test.cc b/chrome/browser/sync/test/integration/single_client_passwords_sync_test.cc index 1a57477..e26b417 100644 --- a/chrome/browser/sync/test/integration/single_client_passwords_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_passwords_sync_test.cc
@@ -25,7 +25,7 @@ #include "components/sync/driver/sync_service_impl.h" #include "components/sync/engine/cycle/entity_change_metric_recording.h" #include "components/sync/nigori/cryptographer_impl.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_nigori_helper.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_launcher.h" #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h"
diff --git a/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc b/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc index d0328e18..7a78da1 100644 --- a/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc
@@ -45,7 +45,7 @@ #include "components/sync/protocol/session_specifics.pb.h" #include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/fake_server/sessions_hierarchy.h" +#include "components/sync/test/sessions_hierarchy.h" #include "components/sync_sessions/session_store.h" #include "components/sync_sessions/session_sync_service.h" #include "components/sync_sessions/session_sync_test_helper.h"
diff --git a/chrome/browser/sync/test/integration/single_client_sharing_message_sync_test.cc b/chrome/browser/sync/test/integration/single_client_sharing_message_sync_test.cc index 54d0916..90ab15c 100644 --- a/chrome/browser/sync/test/integration/single_client_sharing_message_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_sharing_message_sync_test.cc
@@ -16,7 +16,7 @@ #include "chrome/browser/sync/test/integration/sync_service_impl_harness.h" #include "chrome/browser/sync/test/integration/sync_test.h" #include "components/sync/driver/sync_token_status.h" -#include "components/sync/test/fake_server/fake_server_http_post_provider.h" +#include "components/sync/test/fake_server_http_post_provider.h" #include "content/public/test/browser_test.h" namespace {
diff --git a/chrome/browser/sync/test/integration/single_client_sync_invalidations_test.cc b/chrome/browser/sync/test/integration/single_client_sync_invalidations_test.cc index 93a2d453..48214ad8 100644 --- a/chrome/browser/sync/test/integration/single_client_sync_invalidations_test.cc +++ b/chrome/browser/sync/test/integration/single_client_sync_invalidations_test.cc
@@ -23,8 +23,8 @@ #include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync_entity.pb.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/fake_server/bookmark_entity_builder.h" -#include "components/sync/test/fake_server/entity_builder_factory.h" +#include "components/sync/test/bookmark_entity_builder.h" +#include "components/sync/test/entity_builder_factory.h" #include "components/sync_device_info/device_info_sync_service.h" #include "components/sync_device_info/device_info_tracker.h" #include "components/sync_device_info/device_info_util.h"
diff --git a/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc b/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc index ce47009..bdaa3a9a 100644 --- a/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc
@@ -43,7 +43,7 @@ #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "components/webdata/common/web_data_service_consumer.h" #include "content/public/test/browser_test.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/sync/test/integration/single_client_web_apps_sync_test.cc b/chrome/browser/sync/test/integration/single_client_web_apps_sync_test.cc index 172b266..621f6da 100644 --- a/chrome/browser/sync/test/integration/single_client_web_apps_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_web_apps_sync_test.cc
@@ -20,7 +20,7 @@ #include "components/sync/protocol/app_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/extension_specifics.pb.h" -#include "components/sync/test/fake_server/fake_server_verifier.h" +#include "components/sync/test/fake_server_verifier.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/sync/test/integration/single_client_wifi_configuration_sync_test.cc b/chrome/browser/sync/test/integration/single_client_wifi_configuration_sync_test.cc index 45d3b27c..2edaca4 100644 --- a/chrome/browser/sync/test/integration/single_client_wifi_configuration_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_wifi_configuration_sync_test.cc
@@ -20,7 +20,7 @@ #include "components/sync/nigori/cryptographer_impl.h" #include "components/sync/nigori/nigori_test_utils.h" #include "components/sync/protocol/wifi_configuration_specifics.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "content/public/test/browser_test.h" #include "mojo/public/cpp/bindings/remote.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc b/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc index 697167a0..4236891 100644 --- a/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc +++ b/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc
@@ -9,7 +9,7 @@ #include "chrome/browser/sync/test/integration/sync_test.h" #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h" #include "components/sync/driver/sync_service_impl.h" -#include "components/sync/test/fake_server/fake_server_http_post_provider.h" +#include "components/sync/test/fake_server_http_post_provider.h" #include "content/public/test/browser_test.h" #include "content/public/test/network_connection_change_simulator.h" #include "net/base/network_change_notifier.h"
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc index b22d054..68c0229 100644 --- a/chrome/browser/sync/test/integration/sync_test.cc +++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -83,7 +83,7 @@ #include "components/sync/engine/sync_scheduler_impl.h" #include "components/sync/invalidations/fcm_handler.h" #include "components/sync/invalidations/sync_invalidations_service_impl.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/network_service_instance.h" #include "content/public/browser/storage_partition.h"
diff --git a/chrome/browser/sync/test/integration/sync_test.h b/chrome/browser/sync/test/integration/sync_test.h index 9858c4e..25caaa4 100644 --- a/chrome/browser/sync/test/integration/sync_test.h +++ b/chrome/browser/sync/test/integration/sync_test.h
@@ -25,7 +25,7 @@ #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/sync/base/model_type.h" #include "components/sync/base/user_selectable_type.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "net/base/net_errors.h" #include "net/http/http_status_code.h" #include "services/network/test/test_url_loader_factory.h"
diff --git a/chrome/browser/sync/test/integration/two_client_polling_sync_test.cc b/chrome/browser/sync/test/integration/two_client_polling_sync_test.cc index a647ec7a..973e0e2 100644 --- a/chrome/browser/sync/test/integration/two_client_polling_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_polling_sync_test.cc
@@ -14,7 +14,7 @@ #include "components/sync/driver/sync_service_impl.h" #include "components/sync/engine/polling_constants.h" #include "components/sync/protocol/client_commands.pb.h" -#include "components/sync/test/fake_server/sessions_hierarchy.h" +#include "components/sync/test/sessions_hierarchy.h" #include "content/public/test/browser_test.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc b/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc index e1ddbb95..824e5c1 100644 --- a/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc
@@ -18,8 +18,8 @@ #include "chrome/browser/sync/test/integration/sync_service_impl_harness.h" #include "chrome/browser/sync/test/integration/sync_test.h" #include "components/sync/engine/cycle/sync_cycle_snapshot.h" -#include "components/sync/test/fake_server/fake_server_verifier.h" -#include "components/sync/test/fake_server/sessions_hierarchy.h" +#include "components/sync/test/fake_server_verifier.h" +#include "components/sync/test/sessions_hierarchy.h" #include "content/public/test/browser_test.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/sync/test/integration/two_client_wallet_sync_test.cc b/chrome/browser/sync/test/integration/two_client_wallet_sync_test.cc index 6811caaf..63383333 100644 --- a/chrome/browser/sync/test/integration/two_client_wallet_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_wallet_sync_test.cc
@@ -12,7 +12,7 @@ #include "components/autofill/core/browser/test_autofill_clock.h" #include "components/autofill/core/common/autofill_util.h" #include "components/sync/driver/sync_service_impl.h" -#include "components/sync/test/fake_server/fake_server_http_post_provider.h" +#include "components/sync/test/fake_server_http_post_provider.h" #include "content/public/test/browser_test.h" #include "net/base/network_change_notifier.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/browser/sync/test/integration/user_events_helper.cc b/chrome/browser/sync/test/integration/user_events_helper.cc index 48cbcccc..7197264 100644 --- a/chrome/browser/sync/test/integration/user_events_helper.cc +++ b/chrome/browser/sync/test/integration/user_events_helper.cc
@@ -6,7 +6,7 @@ #include "base/ranges/algorithm.h" #include "chrome/browser/sync/test/integration/single_client_status_change_checker.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "testing/gtest/include/gtest/gtest.h" using fake_server::FakeServer;
diff --git a/chrome/browser/sync/test/lacros/sync_custom_passphrase_sharing_lacros_browsertest.cc b/chrome/browser/sync/test/lacros/sync_custom_passphrase_sharing_lacros_browsertest.cc index 6c888bdc..23a358f 100644 --- a/chrome/browser/sync/test/lacros/sync_custom_passphrase_sharing_lacros_browsertest.cc +++ b/chrome/browser/sync/test/lacros/sync_custom_passphrase_sharing_lacros_browsertest.cc
@@ -18,7 +18,7 @@ #include "components/sync/chromeos/lacros/fake_sync_mojo_service.h" #include "components/sync/engine/nigori/nigori.h" #include "components/sync/nigori/nigori_test_utils.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_nigori_helper.h" #include "content/public/test/browser_test.h" #include "mojo/public/cpp/bindings/remote.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/themes/theme_syncable_service_unittest.cc b/chrome/browser/themes/theme_syncable_service_unittest.cc index 230cb37..654113b8 100644 --- a/chrome/browser/themes/theme_syncable_service_unittest.cc +++ b/chrome/browser/themes/theme_syncable_service_unittest.cc
@@ -30,9 +30,9 @@ #include "components/sync/model/sync_error.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/theme_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "content/public/test/browser_task_environment.h" #include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_registry.h"
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index c16932d..800ff89 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -1901,8 +1901,7 @@ assert(is_chromeos) sources += [ "supervised_user/parent_permission_dialog.h", - "views/supervised_user/extension_install_blocked_by_parent_dialog_view.cc", - "views/supervised_user/extension_install_blocked_by_parent_dialog_view.h", + "views/supervised_user/extension_install_blocked_by_parent_dialog.cc", "views/supervised_user/parent_permission_dialog_view.cc", "views/supervised_user/parent_permission_dialog_view.h", ]
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd index 529e7cc..0db40bb 100644 --- a/chrome/browser/ui/android/strings/android_chrome_strings.grd +++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -3866,6 +3866,9 @@ <message name="IDS_RDS_GLOBAL_DEFAULT_ON_MESSAGE_BUTTON" desc="Text on the button reflecting an opt-out of the default setting update."> Update settings </message> + <message name="IDS_RDS_GLOBAL_OPT_IN_MESSAGE_TITLE" desc="Title of the message shown for the user to opt in to the desktop site global setting based on device conditions."> + Request desktop sites by default? + </message> <!-- Accessibility -->
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_RDS_GLOBAL_OPT_IN_MESSAGE_TITLE.png.sha1 b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_RDS_GLOBAL_OPT_IN_MESSAGE_TITLE.png.sha1 new file mode 100644 index 0000000..fdea14a --- /dev/null +++ b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_RDS_GLOBAL_OPT_IN_MESSAGE_TITLE.png.sha1
@@ -0,0 +1 @@ +621fcf59609aede986fb4e036d65fd4d1a4ce09f \ No newline at end of file
diff --git a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java index 91831ed..6ca8e94 100644 --- a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java +++ b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarPhone.java
@@ -744,13 +744,13 @@ private int getBoundsAfterAccountingForRightButtons() { if (mStartSurfaceScrollFraction == 1.0f) return mToolbarSidePadding; - int toolbarButtonsContainerWidth = mToolbarButtonsContainer.getWidth(); + int toolbarButtonsContainerWidth = mToolbarButtonsContainer.getMeasuredWidth(); - // If the button container changed but there's no optional button animation running then we - // must have shown the optional button without an animation, use measuredWidth() to take - // into account the optional button's space. - if (mToolbarButtonsContainer.isDirty() && !mOptionalButtonAnimationRunning) { - toolbarButtonsContainerWidth = mToolbarButtonsContainer.getMeasuredWidth(); + // MeasuredWidth() represents the desired width of the container which is accurate most + // time, except during the optional button animations, where the MeasuredWidth changes + // instantly to the final size and Width() represents the actual size at that frame. + if (mOptionalButtonAnimationRunning) { + toolbarButtonsContainerWidth = mToolbarButtonsContainer.getWidth(); } return Math.max(mToolbarSidePadding, toolbarButtonsContainerWidth);
diff --git a/chrome/browser/ui/app_list/app_list_sort_unittest.cc b/chrome/browser/ui/app_list/app_list_sort_unittest.cc index 23ba5c7..63fc7ca 100644 --- a/chrome/browser/ui/app_list/app_list_sort_unittest.cc +++ b/chrome/browser/ui/app_list/app_list_sort_unittest.cc
@@ -16,8 +16,8 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "components/crx_file/id_util.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" using crx_file::id_util::GenerateId;
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service_unittest.cc b/chrome/browser/ui/app_list/app_list_syncable_service_unittest.cc index b353c434..01f9844f 100644 --- a/chrome/browser/ui/app_list/app_list_syncable_service_unittest.cc +++ b/chrome/browser/ui/app_list/app_list_syncable_service_unittest.cc
@@ -44,9 +44,9 @@ #include "components/sync/model/sync_error_factory.h" #include "components/sync/protocol/app_list_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "extensions/common/constants.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc index 967b8162..d5c5e9a 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
@@ -93,8 +93,8 @@ #include "components/sync/model/sync_data.h" #include "components/sync/protocol/arc_package_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/test_utils.h"
diff --git a/chrome/browser/ui/app_list/chrome_app_list_model_updater_browsertest.cc b/chrome/browser/ui/app_list/chrome_app_list_model_updater_browsertest.cc index 2446e4e6..b7edc27 100644 --- a/chrome/browser/ui/app_list/chrome_app_list_model_updater_browsertest.cc +++ b/chrome/browser/ui/app_list/chrome_app_list_model_updater_browsertest.cc
@@ -41,8 +41,8 @@ #include "components/app_constants/constants.h" #include "components/session_manager/core/session_manager.h" #include "components/sync/model/string_ordinal.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "content/public/test/browser_test.h" #include "extensions/browser/extension_system.h"
diff --git a/chrome/browser/ui/ash/app_access_notifier.cc b/chrome/browser/ui/ash/app_access_notifier.cc index 5e7c99a..f4da269 100644 --- a/chrome/browser/ui/ash/app_access_notifier.cc +++ b/chrome/browser/ui/ash/app_access_notifier.cc
@@ -14,7 +14,6 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" -#include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_manager.h" #include "components/account_id/account_id.h" @@ -36,13 +35,10 @@ } apps::AppRegistryCache* GetActiveUserAppRegistryCache() { - auto* manager = user_manager::UserManager::Get(); - const user_manager::User* active_user = manager->GetActiveUser(); - if (!active_user) + Profile* profile = ProfileManager::GetActiveUserProfile(); + if (!profile) return nullptr; - auto account_id = active_user->GetAccountId(); - Profile* profile = ash::ProfileHelper::Get()->GetProfileByUser(active_user); apps::AppServiceProxy* proxy = apps::AppServiceProxyFactory::GetForProfile(profile); return &proxy->AppRegistryCache(); @@ -70,6 +66,19 @@ return absl::nullopt; } +void LaunchApp(const std::string& app_id) { + // TODO(crbug/1351250): Finish this function. +} + +// Launch the native settings page of the app with `app_id`. +void LaunchAppSettings(const std::string& app_id) { + Profile* profile = ProfileManager::GetActiveUserProfile(); + if (!profile) + return; + apps::AppServiceProxyFactory::GetForProfile(profile)->OpenNativeSettings( + app_id); +} + } // namespace AppAccessNotifier::AppAccessNotifier() { @@ -109,10 +118,15 @@ if (ash::features::IsPrivacyIndicatorsEnabled()) { auto app_id = update.AppId(); + + auto launch_app = base::BindRepeating(&LaunchApp, app_id); + auto launch_settings = base::BindRepeating(&LaunchAppSettings, app_id); ash::ModifyPrivacyIndicatorsNotification( app_id, GetAppShortNameFromAppId(app_id, GetActiveUserAppRegistryCache()), - camera_is_used, microphone_is_used); + camera_is_used, microphone_is_used, + base::MakeRefCounted<ash::PrivacyIndicatorsNotificationDelegate>( + launch_app, launch_settings)); } if (microphone_is_used) {
diff --git a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_browsertest.cc b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_browsertest.cc index 2e24f27..7505045 100644 --- a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_browsertest.cc +++ b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_browsertest.cc
@@ -1544,7 +1544,7 @@ std::unique_ptr<content::WebContents> detached_tab = tab_strip_model1->DetachWebContentsAtForInsertion(1); tab_strip_model2->InsertWebContentsAt(1, std::move(detached_tab), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_EQ(1, tab_strip_model1->count()); EXPECT_EQ(2, tab_strip_model2->count()); EXPECT_EQ(ash::STATUS_RUNNING, shelf_model()->items()[browser_index].status);
diff --git a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc index e534f77..95ef496 100644 --- a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc +++ b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc
@@ -140,8 +140,8 @@ #include "components/sync/driver/test_sync_service.h" #include "components/sync/protocol/app_list_specifics.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/pref_model_associator.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/user_manager/fake_user_manager.h"
diff --git a/chrome/browser/ui/ash/system_web_apps/system_web_app_delegate_ui_impl.cc b/chrome/browser/ui/ash/system_web_apps/system_web_app_delegate_ui_impl.cc index a956c32..2e5f4eb 100644 --- a/chrome/browser/ui/ash/system_web_apps/system_web_app_delegate_ui_impl.cc +++ b/chrome/browser/ui/ash/system_web_apps/system_web_app_delegate_ui_impl.cc
@@ -76,7 +76,7 @@ NavigateParams nav_params(browser, url, ui::PAGE_TRANSITION_AUTO_BOOKMARK); // TODO(crbug.com/1308961): Migrate to use PWA pinned home tab when ready. if (ShouldPinTab(url)) { - nav_params.tabstrip_add_types |= TabStripModel::ADD_PINNED; + nav_params.tabstrip_add_types |= AddTabTypes::ADD_PINNED; } web_contents = web_app::NavigateWebAppUsingParams(params.app_id, nav_params);
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc index a94c1a2..22478d6 100644 --- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc +++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
@@ -34,7 +34,7 @@ // the page does. content::NavigationEntry* entry = web_contents->GetController().GetLastCommittedEntry(); - if (!entry) + if (!entry || entry->IsInitialEntry()) entry = web_contents->GetController().GetVisibleEntry(); if (!entry) return false;
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index ecf7d1e..8333a86 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc
@@ -132,6 +132,7 @@ #include "chrome/browser/ui/tab_dialogs.h" #include "chrome/browser/ui/tab_helpers.h" #include "chrome/browser/ui/tab_modal_confirm_dialog.h" +#include "chrome/browser/ui/tabs/tab_enums.h" #include "chrome/browser/ui/tabs/tab_group.h" #include "chrome/browser/ui/tabs/tab_group_model.h" #include "chrome/browser/ui/tabs/tab_menu_model.h" @@ -1567,7 +1568,7 @@ NavigateParams nav_params(this, params.url, params.transition); nav_params.FillNavigateParamsFromOpenURLParams(params); nav_params.source_contents = source; - nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; + nav_params.tabstrip_add_types = AddTabTypes::ADD_NONE; if (params.user_gesture) nav_params.window_action = NavigateParams::SHOW_WINDOW; bool is_popup =
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 0c55b60..7bb9847d 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc
@@ -1167,7 +1167,7 @@ extensions_tab_helper->SetExtensionApp(extension_app); model->AddWebContents(std::move(app_contents), 0, - ui::PageTransitionFromInt(0), TabStripModel::ADD_NONE); + ui::PageTransitionFromInt(0), AddTabTypes::ADD_NONE); model->SetTabPinned(0, true); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index d86609c..0eb899a 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc
@@ -78,6 +78,7 @@ #include "chrome/browser/ui/status_bubble.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h" #include "chrome/browser/ui/tab_dialogs.h" +#include "chrome/browser/ui/tabs/tab_enums.h" #include "chrome/browser/ui/tabs/tab_group.h" #include "chrome/browser/ui/tabs/tab_group_model.h" #include "chrome/browser/ui/tabs/tab_strip_user_gesture_details.h" @@ -233,7 +234,7 @@ // The page transition below is only for the purpose of inserting the tab. new_browser->tab_strip_model()->AddWebContents(std::move(contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); } bool GetTabURLAndTitleToSave(content::WebContents* web_contents, @@ -305,8 +306,8 @@ browser->tab_strip_model()->AddWebContents( std::move(new_tab), -1, ui::PAGE_TRANSITION_LINK, (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB) - ? TabStripModel::ADD_ACTIVE - : TabStripModel::ADD_NONE, + ? AddTabTypes::ADD_ACTIVE + : AddTabTypes::ADD_NONE, group); return raw_new_tab; } @@ -317,7 +318,7 @@ Browser::Create(Browser::CreateParams(browser->profile(), true)); new_browser->tab_strip_model()->AddWebContents(std::move(new_tab), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); new_browser->window()->Show(); return raw_new_tab; } @@ -656,7 +657,7 @@ // should be inherited, in which case the group is inherited instead of the // opener. params.tabstrip_add_types = - TabStripModel::ADD_FORCE_INDEX | TabStripModel::ADD_INHERIT_OPENER; + AddTabTypes::ADD_FORCE_INDEX | AddTabTypes::ADD_INHERIT_OPENER; params.input_start = location_bar->GetMatchSelectionTimestamp(); params.is_using_https_as_default_scheme = location_bar->IsInputTypedUrlWithoutScheme(); @@ -739,8 +740,8 @@ // TODO(asvitkine): This is invoked programmatically from several places. // Audit the code and change it so that the histogram only gets collected for // user-initiated commands. - UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND, - TabStripModel::NEW_TAB_ENUM_COUNT); + UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", NewTabTypes::NEW_TAB_COMMAND, + NewTabTypes::NEW_TAB_ENUM_COUNT); // Notify IPH that new tab was opened. auto* reopen_tab_iph = @@ -908,12 +909,12 @@ browser->tab_strip_model()->DetachWebContentsAtForInsertion( adjusted_index); - int add_types = pinned ? TabStripModel::ADD_PINNED : 0; + int add_types = pinned ? AddTabTypes::ADD_PINNED : 0; // The last tab made active takes precedence, so activate the last active // tab, with a fallback for the first tab (i == 0) if the active tab isn’t // in the set of tabs being moved. if (i == 0 || tab_indices[i] == active_index) - add_types = add_types | TabStripModel::ADD_ACTIVE; + add_types = add_types | AddTabTypes::ADD_ACTIVE; new_browser->tab_strip_model()->AddWebContents(std::move(contents_move), -1, ui::PAGE_TRANSITION_TYPED, @@ -947,9 +948,8 @@ TabStripModel* tab_strip_model = browser->tab_strip_model(); const int contents_index = tab_strip_model->GetIndexOfWebContents(contents); pinned = tab_strip_model->IsTabPinned(contents_index); - int add_types = TabStripModel::ADD_ACTIVE | - TabStripModel::ADD_INHERIT_OPENER | - (pinned ? TabStripModel::ADD_PINNED : 0); + int add_types = AddTabTypes::ADD_ACTIVE | AddTabTypes::ADD_INHERIT_OPENER | + (pinned ? AddTabTypes::ADD_PINNED : 0); const auto old_group = tab_strip_model->GetTabGroupForTab(contents_index); tab_strip_model->InsertWebContentsAt( contents_index + 1, std::move(contents_dupe), add_types, old_group); @@ -983,8 +983,8 @@ std::unique_ptr<WebContents> contents_move = source->tab_strip_model()->DetachWebContentsAtForInsertion( adjusted_index); - int add_types = TabStripModel::ADD_ACTIVE | - (pinned ? TabStripModel::ADD_PINNED : 0); + int add_types = + AddTabTypes::ADD_ACTIVE | (pinned ? AddTabTypes::ADD_PINNED : 0); target->tab_strip_model()->AddWebContents( std::move(contents_move), -1, ui::PAGE_TRANSITION_TYPED, add_types); }
diff --git a/chrome/browser/ui/browser_finder.h b/chrome/browser/ui/browser_finder.h index f885be0..ad7a184 100644 --- a/chrome/browser/ui/browser_finder.h +++ b/chrome/browser/ui/browser_finder.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_BROWSER_FINDER_H_ #include <stddef.h> +#include <vector> #include "ui/display/types/display_constants.h" #include "ui/gfx/native_widget_types.h"
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 61d1840..5fa25383 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc
@@ -400,7 +400,7 @@ // Disposition trumps add types. ADD_ACTIVE is a default, so we need to // remove it if disposition implies the tab is going to open in the // background. - params->tabstrip_add_types &= ~TabStripModel::ADD_ACTIVE; + params->tabstrip_add_types &= ~AddTabTypes::ADD_ACTIVE; break; case WindowOpenDisposition::NEW_PICTURE_IN_PICTURE: @@ -418,7 +418,7 @@ } case WindowOpenDisposition::NEW_FOREGROUND_TAB: case WindowOpenDisposition::SINGLETON_TAB: - params->tabstrip_add_types |= TabStripModel::ADD_ACTIVE; + params->tabstrip_add_types |= AddTabTypes::ADD_ACTIVE; break; default: @@ -801,7 +801,7 @@ if (params->source_contents && (params->disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB || params->disposition == WindowOpenDisposition::NEW_WINDOW) && - (params->tabstrip_add_types & TabStripModel::ADD_INHERIT_OPENER)) + (params->tabstrip_add_types & AddTabTypes::ADD_INHERIT_OPENER)) params->source_contents->Focus(); if (params->source_contents == contents_to_navigate_or_insert) { @@ -816,7 +816,7 @@ // If some non-default value is set for the index, we should tell the // TabStripModel to respect it. if (params->tabstrip_index != -1) - params->tabstrip_add_types |= TabStripModel::ADD_FORCE_INDEX; + params->tabstrip_add_types |= AddTabTypes::ADD_FORCE_INDEX; // Maybe notify that an open operation has been done from a gesture. // TODO(crbug.com/1129028): preferably pipe this information through the
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index 10b3507..9ab15d8 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -1109,7 +1109,7 @@ NavigateParams params(MakeNavigateParams()); params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; params.tabstrip_index = 0; - params.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; + params.tabstrip_add_types = AddTabTypes::ADD_FORCE_INDEX; Navigate(¶ms); // Navigate() should have inserted a new tab at slot 0 in the tabstrip.
diff --git a/chrome/browser/ui/browser_navigator_params.h b/chrome/browser/ui/browser_navigator_params.h index 4d0d4a0..324a311 100644 --- a/chrome/browser/ui/browser_navigator_params.h +++ b/chrome/browser/ui/browser_navigator_params.h
@@ -13,6 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/time/time.h" #include "build/build_config.h" +#include "chrome/browser/ui/tabs/tab_enums.h" #include "content/public/browser/global_request_id.h" #include "content/public/browser/reload_type.h" #include "content/public/browser/render_frame_host.h" @@ -171,10 +172,10 @@ // NEW_BACKGROUND_TAB target browser is an app browser NEW_FOREGROUND_TAB // OFF_THE_RECORD target browser profile is incog. NEW_FOREGROUND_TAB // - // If disposition is NEW_BACKGROUND_TAB, TabStripModel::ADD_ACTIVE is + // If disposition is NEW_BACKGROUND_TAB, AddTabTypes::ADD_ACTIVE is // removed from |tabstrip_add_types| automatically. // If disposition is one of NEW_WINDOW, NEW_POPUP, NEW_FOREGROUND_TAB or - // SINGLETON_TAB, then TabStripModel::ADD_ACTIVE is automatically added to + // SINGLETON_TAB, then AddTabTypes::ADD_ACTIVE is automatically added to // |tabstrip_add_types|. WindowOpenDisposition disposition = WindowOpenDisposition::CURRENT_TAB; @@ -261,7 +262,7 @@ // A bitmask of values defined in TabStripModel::AddTabTypes. Helps // determine where to insert a new tab and whether or not it should be // selected, among other properties. - int tabstrip_add_types = TabStripModel::ADD_ACTIVE; + int tabstrip_add_types = AddTabTypes::ADD_ACTIVE; #endif // The profile that is initiating the navigation. If there is a non-NULL
diff --git a/chrome/browser/ui/browser_tab_strip_model_delegate.cc b/chrome/browser/ui/browser_tab_strip_model_delegate.cc index e019674d..27a8cba 100644 --- a/chrome/browser/ui/browser_tab_strip_model_delegate.cc +++ b/chrome/browser/ui/browser_tab_strip_model_delegate.cc
@@ -82,7 +82,7 @@ // Enforce that there is an active tab in the strip at all times by forcing // the first web contents to be marked as active. if (i == 0) - item.add_types |= TabStripModel::ADD_ACTIVE; + item.add_types |= AddTabTypes::ADD_ACTIVE; content::WebContents* raw_web_contents = item.web_contents.get(); new_model->InsertWebContentsAt(
diff --git a/chrome/browser/ui/browser_tabrestore.cc b/chrome/browser/ui/browser_tabrestore.cc index 094f6f9e..4e328f35 100644 --- a/chrome/browser/ui/browser_tabrestore.cc +++ b/chrome/browser/ui/browser_tabrestore.cc
@@ -142,11 +142,11 @@ bool from_session_restore) { TabStripModel* const tab_strip_model = browser->tab_strip_model(); - int add_types = select ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; + int add_types = select ? AddTabTypes::ADD_ACTIVE : AddTabTypes::ADD_NONE; if (pin) { tab_index = std::min(tab_index, tab_strip_model->IndexOfFirstNonPinnedTab()); - add_types |= TabStripModel::ADD_PINNED; + add_types |= AddTabTypes::ADD_PINNED; } const absl::optional<tab_groups::TabGroupId> surrounding_group = @@ -293,7 +293,7 @@ int insertion_index = tab_strip->active_index(); tab_strip->InsertWebContentsAt( insertion_index + 1, std::move(web_contents), - TabStripModel::ADD_ACTIVE | TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_ACTIVE | AddTabTypes::ADD_INHERIT_OPENER); tab_strip->CloseWebContentsAt(insertion_index, TabCloseTypes::CLOSE_NONE); LoadRestoredTabIfVisible(browser, raw_web_contents);
diff --git a/chrome/browser/ui/commander/entity_match_unittest.cc b/chrome/browser/ui/commander/entity_match_unittest.cc index b8f4d3d1..7a1d3abd 100644 --- a/chrome/browser/ui/commander/entity_match_unittest.cc +++ b/chrome/browser/ui/commander/entity_match_unittest.cc
@@ -248,7 +248,7 @@ CreateTabs({u"A", u"B", u"C"}); browser()->tab_strip_model()->InsertWebContentsAt( 1, content::WebContentsTester::CreateTestWebContents(profile(), nullptr), - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); content::WebContentsTester::For( browser()->tab_strip_model()->GetWebContentsAt(1)) ->SetIsCurrentlyAudible(true);
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc index 70b270d..96c14b5 100644 --- a/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc +++ b/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc
@@ -923,7 +923,7 @@ std::unique_ptr<content::WebContents> owned_wc = browser()->tab_strip_model()->DetachWebContentsAtForInsertion(0); second_browser->tab_strip_model()->InsertWebContentsAt( - 0, std::move(owned_wc), TabStripModel::ADD_ACTIVE); + 0, std::move(owned_wc), AddTabTypes::ADD_ACTIVE); EXPECT_FALSE(browser()->window()->IsFullscreen()); EXPECT_FALSE(second_browser->window()->IsFullscreen()); EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(tab)); @@ -939,7 +939,7 @@ owned_wc = second_browser->tab_strip_model()->DetachWebContentsAtForInsertion(0); browser()->tab_strip_model()->InsertWebContentsAt(0, std::move(owned_wc), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_FALSE(browser()->window()->IsFullscreen()); EXPECT_FALSE(second_browser->window()->IsFullscreen()); EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(tab));
diff --git a/chrome/browser/ui/extensions/application_launch.cc b/chrome/browser/ui/extensions/application_launch.cc index 243035b..7968e85 100644 --- a/chrome/browser/ui/extensions/application_launch.cc +++ b/chrome/browser/ui/extensions/application_launch.cc
@@ -221,9 +221,9 @@ extensions::GetLaunchType(ExtensionPrefs::Get(profile), extension); UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); - int add_type = TabStripModel::ADD_ACTIVE; + int add_type = AddTabTypes::ADD_ACTIVE; if (launch_type == extensions::LAUNCH_TYPE_PINNED) - add_type |= TabStripModel::ADD_PINNED; + add_type |= AddTabTypes::ADD_PINNED; ui::PageTransition transition = ui::PAGE_TRANSITION_AUTO_BOOKMARK; NavigateParams params(browser, url, transition); @@ -244,12 +244,12 @@ disposition, transition, false)); // Reset existing_tab as OpenURL() may have clobbered it. existing_tab = browser->tab_strip_model()->GetActiveWebContents(); - if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { + if (params.tabstrip_add_types & AddTabTypes::ADD_PINNED) { model->SetTabPinned(tab_index, true); // Pinning may have moved the tab. tab_index = model->GetIndexOfWebContents(existing_tab); } - if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) { + if (params.tabstrip_add_types & AddTabTypes::ADD_ACTIVE) { model->ActivateTabAt( tab_index, TabStripUserGestureDetails( TabStripUserGestureDetails::GestureType::kOther));
diff --git a/chrome/browser/ui/extensions/extensions_dialogs.h b/chrome/browser/ui/extensions/extensions_dialogs.h index 0a2e532..064bbe2 100644 --- a/chrome/browser/ui/extensions/extensions_dialogs.h +++ b/chrome/browser/ui/extensions/extensions_dialogs.h
@@ -55,13 +55,11 @@ base::OnceCallback<void(bool)> callback); // Shows a dialog when extensions require a refresh for their action -// to be run or blocked. The dialog content is based on whether caller -// `is_updating_permissions`. When the dialog is accepted, `callback` is +// to be run or blocked. When the dialog is accepted, `callback` is // invoked. void ShowReloadPageDialog( Browser* browser, const std::vector<extensions::ExtensionId>& extension_ids, - bool is_updating_permissions, base::OnceClosure callback); // Shows a dialog with a warning to the user that their settings have been
diff --git a/chrome/browser/ui/managed_ui.cc b/chrome/browser/ui/managed_ui.cc index 63b40b1..d472aa2 100644 --- a/chrome/browser/ui/managed_ui.cc +++ b/chrome/browser/ui/managed_ui.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/managed_ui.h" +#include "base/feature_list.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" @@ -13,6 +14,7 @@ #include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/webui/management/management_ui_handler.h" #include "chrome/grit/generated_resources.h" #include "components/policy/core/browser/webui/policy_data_utils.h" @@ -78,29 +80,36 @@ #if !BUILDFLAG(IS_ANDROID) std::u16string GetManagedUiMenuItemLabel(Profile* profile) { - absl::optional<std::string> account_manager = - GetAccountManagerIdentity(profile); + absl::optional<std::string> manager = GetAccountManagerIdentity(profile); + if (!manager && + base::FeatureList::IsEnabled(features::kFlexOrgManagementDisclosure)) { + manager = GetDeviceManagerIdentity(); + } int string_id = IDS_MANAGED; std::vector<std::u16string> replacements; - if (account_manager) { + + if (manager) { string_id = IDS_MANAGED_BY; - replacements.push_back(base::UTF8ToUTF16(*account_manager)); + replacements.push_back(base::UTF8ToUTF16(*manager)); } return l10n_util::GetStringFUTF16(string_id, replacements, nullptr); } std::u16string GetManagedUiWebUILabel(Profile* profile) { - absl::optional<std::string> account_manager = - GetAccountManagerIdentity(profile); + absl::optional<std::string> manager = GetAccountManagerIdentity(profile); + if (!manager && + base::FeatureList::IsEnabled(features::kFlexOrgManagementDisclosure)) { + manager = GetDeviceManagerIdentity(); + } int string_id = IDS_MANAGED_WITH_HYPERLINK; std::vector<std::u16string> replacements; replacements.push_back(base::UTF8ToUTF16(chrome::kChromeUIManagementURL)); - if (account_manager) { + if (manager) { string_id = IDS_MANAGED_BY_WITH_HYPERLINK; - replacements.push_back(base::UTF8ToUTF16(*account_manager)); + replacements.push_back(base::UTF8ToUTF16(*manager)); } return l10n_util::GetStringFUTF16(string_id, replacements, nullptr); @@ -149,7 +158,9 @@ #endif absl::optional<std::string> GetAccountManagerIdentity(Profile* profile) { - if (!policy::ManagementServiceFactory::GetForProfile(profile)->IsManaged()) + if (!policy::ManagementServiceFactory::GetForProfile(profile) + ->HasManagementAuthority( + policy::EnterpriseManagementAuthority::CLOUD)) return absl::nullopt; const absl::optional<std::string> managed_by =
diff --git a/chrome/browser/ui/signin_reauth_view_controller.cc b/chrome/browser/ui/signin_reauth_view_controller.cc index 17f00ef3..37e1909c 100644 --- a/chrome/browser/ui/signin_reauth_view_controller.cc +++ b/chrome/browser/ui/signin_reauth_view_controller.cc
@@ -352,6 +352,6 @@ nav_params.window_action = NavigateParams::SHOW_WINDOW; nav_params.trusted_source = false; nav_params.user_gesture = true; - nav_params.tabstrip_add_types |= TabStripModel::ADD_INHERIT_OPENER; + nav_params.tabstrip_add_types |= AddTabTypes::ADD_INHERIT_OPENER; Navigate(&nav_params); }
diff --git a/chrome/browser/ui/signin_view_controller.cc b/chrome/browser/ui/signin_view_controller.cc index 5183ad8..7701831 100644 --- a/chrome/browser/ui/signin_view_controller.cc +++ b/chrome/browser/ui/signin_view_controller.cc
@@ -75,7 +75,7 @@ params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; params.window_action = NavigateParams::SHOW_WINDOW; params.user_gesture = false; - params.tabstrip_add_types |= TabStripModel::ADD_INHERIT_OPENER; + params.tabstrip_add_types |= AddTabTypes::ADD_INHERIT_OPENER; content::WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
diff --git a/chrome/browser/ui/singleton_tabs.cc b/chrome/browser/ui/singleton_tabs.cc index 9396744..0949fad 100644 --- a/chrome/browser/ui/singleton_tabs.cc +++ b/chrome/browser/ui/singleton_tabs.cc
@@ -63,7 +63,7 @@ params.disposition = WindowOpenDisposition::SINGLETON_TAB; params.window_action = NavigateParams::SHOW_WINDOW; params.user_gesture = true; - params.tabstrip_add_types |= TabStripModel::ADD_INHERIT_OPENER; + params.tabstrip_add_types |= AddTabTypes::ADD_INHERIT_OPENER; return params; }
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index 9849f42..66d8732 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
@@ -281,11 +281,10 @@ continue; } - int add_types = - first_tab ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; - add_types |= TabStripModel::ADD_FORCE_INDEX; + int add_types = first_tab ? AddTabTypes::ADD_ACTIVE : AddTabTypes::ADD_NONE; + add_types |= AddTabTypes::ADD_FORCE_INDEX; if (tabs[i].type == StartupTab::Type::kPinned) - add_types |= TabStripModel::ADD_PINNED; + add_types |= AddTabTypes::ADD_PINNED; NavigateParams params(browser, tabs[i].url, ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
diff --git a/chrome/browser/ui/tabs/tab_enums.h b/chrome/browser/ui/tabs/tab_enums.h index 60f656b..87b7aec 100644 --- a/chrome/browser/ui/tabs/tab_enums.h +++ b/chrome/browser/ui/tabs/tab_enums.h
@@ -52,4 +52,53 @@ }; +// Constants used when adding tabs. +enum AddTabTypes { + // Used to indicate nothing special should happen to the newly inserted tab. + ADD_NONE = 0, + + // The tab should be active. + ADD_ACTIVE = 1 << 0, + + // The tab should be pinned. + ADD_PINNED = 1 << 1, + + // If not set the insertion index of the WebContents is left up to the Order + // Controller associated, so the final insertion index may differ from the + // specified index. Otherwise the index supplied is used. + ADD_FORCE_INDEX = 1 << 2, + + // If set the newly inserted tab's opener is set to the active tab. If not + // set the tab may still inherit the opener under certain situations. + ADD_INHERIT_OPENER = 1 << 3, +}; + +// Enumerates different ways to open a new tab. Does not apply to opening +// existing links or searches in a new tab, only to brand new empty tabs. +// KEEP IN SYNC WITH THE NewTabType ENUM IN enums.xml. +// NEW VALUES MUST BE APPENDED AND AVOID CHANGING ANY PRE-EXISTING VALUES. +enum NewTabTypes { + // New tab was opened using the new tab button on the tab strip. + NEW_TAB_BUTTON = 0, + + // New tab was opened using the menu command - either through the keyboard + // shortcut, or by opening the menu and selecting the command. Applies to + // both app menu and the menu bar's File menu (on platforms that have one). + NEW_TAB_COMMAND = 1, + + // New tab was opened through the context menu on the tab strip. + NEW_TAB_CONTEXT_MENU = 2, + + // New tab was opened through the new tab button in the toolbar for the + // WebUI touch-optimized tab strip. + NEW_TAB_BUTTON_IN_TOOLBAR_FOR_TOUCH = 3, + + // New tab was opened through the new tab button inside of the WebUI tab + // strip. + NEW_TAB_BUTTON_IN_WEBUI_TAB_STRIP = 4, + + // Number of enum entries, used for UMA histogram reporting macros. + NEW_TAB_ENUM_COUNT = 5, +}; + #endif // CHROME_BROWSER_UI_TABS_TAB_ENUMS_H_
diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index 3a1e8d1c..7942ad2 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc
@@ -1347,9 +1347,8 @@ switch (command_id) { case CommandNewTabToRight: { base::RecordAction(UserMetricsAction("TabContextMenu_NewTab")); - UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", - TabStripModel::NEW_TAB_CONTEXT_MENU, - TabStripModel::NEW_TAB_ENUM_COUNT); + UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", NewTabTypes::NEW_TAB_CONTEXT_MENU, + NewTabTypes::NEW_TAB_ENUM_COUNT); delegate()->AddTabAt(GURL(), context_index + 1, true, GetTabGroupForTab(context_index)); break;
diff --git a/chrome/browser/ui/tabs/tab_strip_model.h b/chrome/browser/ui/tabs/tab_strip_model.h index 68345ba..bca3156 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.h +++ b/chrome/browser/ui/tabs/tab_strip_model.h
@@ -91,55 +91,6 @@ //////////////////////////////////////////////////////////////////////////////// class TabStripModel : public TabGroupController { public: - // Constants used when adding tabs. - enum AddTabTypes { - // Used to indicate nothing special should happen to the newly inserted tab. - ADD_NONE = 0, - - // The tab should be active. - ADD_ACTIVE = 1 << 0, - - // The tab should be pinned. - ADD_PINNED = 1 << 1, - - // If not set the insertion index of the WebContents is left up to the Order - // Controller associated, so the final insertion index may differ from the - // specified index. Otherwise the index supplied is used. - ADD_FORCE_INDEX = 1 << 2, - - // If set the newly inserted tab's opener is set to the active tab. If not - // set the tab may still inherit the opener under certain situations. - ADD_INHERIT_OPENER = 1 << 3, - }; - - // Enumerates different ways to open a new tab. Does not apply to opening - // existing links or searches in a new tab, only to brand new empty tabs. - // KEEP IN SYNC WITH THE NewTabType ENUM IN enums.xml. - // NEW VALUES MUST BE APPENDED AND AVOID CHANGING ANY PRE-EXISTING VALUES. - enum NewTab { - // New tab was opened using the new tab button on the tab strip. - NEW_TAB_BUTTON = 0, - - // New tab was opened using the menu command - either through the keyboard - // shortcut, or by opening the menu and selecting the command. Applies to - // both app menu and the menu bar's File menu (on platforms that have one). - NEW_TAB_COMMAND = 1, - - // New tab was opened through the context menu on the tab strip. - NEW_TAB_CONTEXT_MENU = 2, - - // New tab was opened through the new tab button in the toolbar for the - // WebUI touch-optimized tab strip. - NEW_TAB_BUTTON_IN_TOOLBAR_FOR_TOUCH = 3, - - // New tab was opened through the new tab button inside of the WebUI tab - // strip. - NEW_TAB_BUTTON_IN_WEBUI_TAB_STRIP = 4, - - // Number of enum entries, used for UMA histogram reporting macros. - NEW_TAB_ENUM_COUNT = 5, - }; - // Enumerates different types of tab activation. Mainly used for // comparison between classic tab strip and WebUI tab strip. // KEEP IN SYNC WITH THE TabActivationTypes ENUM IN enums.xml.
diff --git a/chrome/browser/ui/tabs/tab_strip_model_stats_recorder_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_stats_recorder_unittest.cc index cfd087b..2f9411f 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_stats_recorder_unittest.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_stats_recorder_unittest.cc
@@ -37,13 +37,13 @@ std::unique_ptr<WebContents> contents1 = CreateTestWebContents(); WebContents* raw_contents1 = contents1.get(); tabstrip.InsertWebContentsAt(0, std::move(contents1), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Deactivate the first tab by inserting new tab. std::unique_ptr<WebContents> contents2 = CreateTestWebContents(); WebContents* raw_contents2 = contents2.get(); tabstrip.InsertWebContentsAt(1, std::move(contents2), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); tester.ExpectUniqueSample( "Tabs.StateTransfer.Target_Active", @@ -101,15 +101,15 @@ // Create a tab in strip 1. tabstrip1.InsertWebContentsAt(0, CreateTestWebContents(), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Create a tab in strip 2. tabstrip2.InsertWebContentsAt(0, CreateTestWebContents(), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Create another tab in strip 1. tabstrip1.InsertWebContentsAt(1, CreateTestWebContents(), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); tester.ExpectUniqueSample( "Tabs.StateTransfer.Target_Active", @@ -117,7 +117,7 @@ // Create another tab in strip 2. tabstrip2.InsertWebContentsAt(1, CreateTestWebContents(), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); tester.ExpectUniqueSample( "Tabs.StateTransfer.Target_Active", @@ -125,7 +125,7 @@ // Move the first tab in strip 1 to strip 2 tabstrip2.InsertWebContentsAt(2, tabstrip1.DetachWebContentsAtForInsertion(0), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); tester.ExpectUniqueSample( "Tabs.StateTransfer.Target_Active", @@ -172,12 +172,12 @@ std::unique_ptr<WebContents> contents0 = CreateTestWebContents(); WebContents* raw_contents0 = contents0.get(); tabstrip.InsertWebContentsAt(0, std::move(contents0), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Add 9 more tabs and activate them for (int i = 1; i < 10; ++i) { tabstrip.InsertWebContentsAt(1, CreateTestWebContents(), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); } // Reactivate the first tab @@ -210,11 +210,11 @@ std::unique_ptr<WebContents> contents2 = CreateTestWebContents(); WebContents* raw_contents2 = contents2.get(); tabstrip.InsertWebContentsAt(0, std::move(contents0), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); tabstrip.InsertWebContentsAt(1, std::move(contents1), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); tabstrip.InsertWebContentsAt(2, std::move(contents2), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Switch between tabs {0,1} for 5 times, then switch to tab 2 for (int i = 0; i < 5; ++i) {
diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc index 458d3c0..f9a8b04 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
@@ -509,7 +509,7 @@ content::WebContents* raw_contents2 = contents2.get(); { tabstrip.InsertWebContentsAt(1, std::move(contents2), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_EQ(2, tabstrip.count()); EXPECT_EQ(4, observer.GetStateCount()); @@ -533,7 +533,7 @@ WebContents* raw_contents3 = contents3.get(); { tabstrip.InsertWebContentsAt(2, std::move(contents3), - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); EXPECT_EQ(3, tabstrip.count()); EXPECT_EQ(1, observer.GetStateCount()); @@ -605,7 +605,7 @@ std::unique_ptr<WebContents> contents4 = CreateWebContentsWithID(4); WebContents* raw_contents4 = contents4.get(); tabstrip.InsertWebContentsAt(3, std::move(contents4), - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); // detach and delete the tab tabstrip.DetachAndDeleteWebContentsAt(3); @@ -754,15 +754,15 @@ // We use |InsertWebContentsAt| here instead of |AppendWebContents| so that // openership relationships are preserved. tabstrip.InsertWebContentsAt(tabstrip.count(), std::move(contents1), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); tabstrip.InsertWebContentsAt(tabstrip.count(), std::move(contents2), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); tabstrip.InsertWebContentsAt(tabstrip.count(), std::move(contents3), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); tabstrip.InsertWebContentsAt(tabstrip.count(), std::move(contents4), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); tabstrip.InsertWebContentsAt(tabstrip.count(), std::move(contents5), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); // All the tabs should have the same opener. for (int i = 1; i < tabstrip.count(); ++i) @@ -818,13 +818,13 @@ std::unique_ptr<WebContents> contents3) { tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip), std::move(contents1), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip), std::move(contents2), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); tabstrip->InsertWebContentsAt(GetInsertionIndex(tabstrip), std::move(contents3), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); } static bool IsSiteInContentSettingExceptionList( @@ -916,7 +916,7 @@ EXPECT_EQ(1, insert_index); tabstrip.InsertWebContentsAt( insert_index, std::move(fg_link_contents), - TabStripModel::ADD_ACTIVE | TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_ACTIVE | AddTabTypes::ADD_INHERIT_OPENER); EXPECT_EQ(1, tabstrip.active_index()); EXPECT_EQ(raw_fg_link_contents, tabstrip.GetActiveWebContents()); @@ -932,7 +932,7 @@ EXPECT_EQ(tabstrip.count(), insert_index); // We break the opener relationship... tabstrip.InsertWebContentsAt(insert_index, std::move(fg_nonlink_contents), - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); // Now select it, so that GestureType != kNone causes the opener // relationship to be forgotten... tabstrip.ActivateTabAt(tabstrip.count() - 1, @@ -971,7 +971,7 @@ // Open a link in a new background tab. tabstrip.InsertWebContentsAt(GetInsertionIndex(&tabstrip), CreateWebContentsWithID(11), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); EXPECT_EQ("1 11 2 3", GetTabStripStateString(tabstrip)); EXPECT_EQ(1, GetID(tabstrip.GetActiveWebContents())); EXPECT_EQ(1, tabstrip.GetIndexOfLastWebContentsOpenedBy(raw_opener1, 0)); @@ -995,7 +995,7 @@ // Open another link in a new background tab. tabstrip.InsertWebContentsAt(GetInsertionIndex(&tabstrip), CreateWebContentsWithID(12), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); // Tab 12 should be next to 1, and considered opened by it. EXPECT_EQ("1 12 2 11 3", GetTabStripStateString(tabstrip)); EXPECT_EQ(1, GetID(tabstrip.GetActiveWebContents())); @@ -1025,7 +1025,7 @@ std::unique_ptr<WebContents> child11 = CreateWebContentsWithID(11); WebContents* raw_child11 = child11.get(); tabstrip.InsertWebContentsAt(GetInsertionIndex(&tabstrip), std::move(child11), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); EXPECT_EQ("1 11 2", GetTabStripStateString(tabstrip)); EXPECT_EQ(1, GetID(tabstrip.GetActiveWebContents())); EXPECT_EQ(1, tabstrip.GetIndexOfLastWebContentsOpenedBy(raw_opener1, 0)); @@ -1039,7 +1039,7 @@ // Open a link in a new background grandchild tab. tabstrip.InsertWebContentsAt(GetInsertionIndex(&tabstrip), CreateWebContentsWithID(111), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); EXPECT_EQ("1 11 111 2", GetTabStripStateString(tabstrip)); EXPECT_EQ(11, GetID(tabstrip.GetActiveWebContents())); // The grandchild tab should be counted by GetIndexOfLastWebContentsOpenedBy @@ -1056,7 +1056,7 @@ // Open another link in a new background child tab (a sibling of child11). tabstrip.InsertWebContentsAt(GetInsertionIndex(&tabstrip), CreateWebContentsWithID(12), - TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_INHERIT_OPENER); EXPECT_EQ("1 11 111 12 2", GetTabStripStateString(tabstrip)); EXPECT_EQ(1, GetID(tabstrip.GetActiveWebContents())); // opener1 has three adjacent descendants (11, 111, 12) @@ -1298,12 +1298,12 @@ tabstrip.AppendWebContents(std::move(opener), true); std::unique_ptr<WebContents> other_contents = CreateWebContents(); tabstrip.InsertWebContentsAt(1, std::move(other_contents), - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); ASSERT_EQ(2, tabstrip.count()); std::unique_ptr<WebContents> opened_contents = CreateWebContents(); tabstrip.InsertWebContentsAt( 2, std::move(opened_contents), - TabStripModel::ADD_ACTIVE | TabStripModel::ADD_INHERIT_OPENER); + AddTabTypes::ADD_ACTIVE | AddTabTypes::ADD_INHERIT_OPENER); ASSERT_EQ(2, tabstrip.active_index()); tabstrip.CloseWebContentsAt(2, TabCloseTypes::CLOSE_NONE); @@ -1645,13 +1645,13 @@ WebContents* raw_homepage_contents = homepage_contents.get(); tabstrip.AddWebContents(std::move(homepage_contents), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Open some other tab, by user typing. std::unique_ptr<WebContents> typed_page_contents = CreateWebContents(); WebContents* raw_typed_page_contents = typed_page_contents.get(); tabstrip.AddWebContents(std::move(typed_page_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); EXPECT_EQ(2, tabstrip.count()); @@ -1665,15 +1665,15 @@ std::unique_ptr<WebContents> middle_click_contents1 = CreateWebContents(); WebContents* raw_middle_click_contents1 = middle_click_contents1.get(); tabstrip.AddWebContents(std::move(middle_click_contents1), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); std::unique_ptr<WebContents> middle_click_contents2 = CreateWebContents(); WebContents* raw_middle_click_contents2 = middle_click_contents2.get(); tabstrip.AddWebContents(std::move(middle_click_contents2), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); std::unique_ptr<WebContents> middle_click_contents3 = CreateWebContents(); WebContents* raw_middle_click_contents3 = middle_click_contents3.get(); tabstrip.AddWebContents(std::move(middle_click_contents3), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); EXPECT_EQ(5, tabstrip.count()); @@ -1719,13 +1719,13 @@ WebContents* raw_homepage_contents = homepage_contents.get(); tabstrip.AddWebContents(std::move(homepage_contents), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Open some other tab, by user typing. std::unique_ptr<WebContents> typed_page_contents = CreateWebContents(); WebContents* raw_typed_page_contents = typed_page_contents.get(); tabstrip.AddWebContents(std::move(typed_page_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); EXPECT_EQ(2, tabstrip.count()); @@ -1738,7 +1738,7 @@ std::unique_ptr<WebContents> left_click_contents = CreateWebContents(); WebContents* raw_left_click_contents = left_click_contents.get(); tabstrip.AddWebContents(std::move(left_click_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_ACTIVE); // Verify the state meets our expectations. EXPECT_EQ(3, tabstrip.count()); @@ -1773,13 +1773,13 @@ WebContents* raw_homepage_contents = homepage_contents.get(); tabstrip.AddWebContents(std::move(homepage_contents), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Open some other tab, by user typing. std::unique_ptr<WebContents> typed_page_contents = CreateWebContents(); WebContents* raw_typed_page_contents = typed_page_contents.get(); tabstrip.AddWebContents(std::move(typed_page_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); EXPECT_EQ(2, tabstrip.count()); @@ -1792,7 +1792,7 @@ std::unique_ptr<WebContents> new_blank_contents = CreateWebContents(); WebContents* raw_new_blank_contents = new_blank_contents.get(); tabstrip.AddWebContents(std::move(new_blank_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); // Verify the state of the tabstrip. EXPECT_EQ(3, tabstrip.count()); @@ -1805,13 +1805,12 @@ WebContents* raw_background_blank_contents1 = background_blank_contents1.get(); tabstrip.AddWebContents(std::move(background_blank_contents1), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_NONE); std::unique_ptr<WebContents> background_blank_contents2 = CreateWebContents(); WebContents* raw_background_blank_contents2 = background_blank_contents2.get(); tabstrip.AddWebContents(std::move(background_blank_contents2), -1, - ui::PAGE_TRANSITION_GENERATED, - TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_GENERATED, AddTabTypes::ADD_NONE); EXPECT_EQ(5, tabstrip.count()); EXPECT_EQ(raw_homepage_contents, tabstrip.GetWebContentsAt(0)); EXPECT_EQ(raw_typed_page_contents, tabstrip.GetWebContentsAt(1)); @@ -1835,13 +1834,13 @@ WebContents* raw_homepage_contents = homepage_contents.get(); tabstrip.AddWebContents(std::move(homepage_contents), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Open a blank new tab. std::unique_ptr<WebContents> typed_page_contents = CreateWebContents(); WebContents* raw_typed_page_contents = typed_page_contents.get(); tabstrip.AddWebContents(std::move(typed_page_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); EXPECT_EQ(2, tabstrip.count()); @@ -1855,15 +1854,15 @@ std::unique_ptr<WebContents> middle_click_contents1 = CreateWebContents(); WebContents* raw_middle_click_contents1 = middle_click_contents1.get(); tabstrip.AddWebContents(std::move(middle_click_contents1), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); std::unique_ptr<WebContents> middle_click_contents2 = CreateWebContents(); WebContents* raw_middle_click_contents2 = middle_click_contents2.get(); tabstrip.AddWebContents(std::move(middle_click_contents2), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); std::unique_ptr<WebContents> middle_click_contents3 = CreateWebContents(); WebContents* raw_middle_click_contents3 = middle_click_contents3.get(); tabstrip.AddWebContents(std::move(middle_click_contents3), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); // Break out of the context by selecting a tab in a different context. EXPECT_EQ(raw_typed_page_contents, tabstrip.GetWebContentsAt(4)); @@ -1907,7 +1906,7 @@ std::unique_ptr<WebContents> homepage_contents = CreateWebContents(); tabstrip.AddWebContents(std::move(homepage_contents), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); ASSERT_EQ(1, tabstrip.count()); tab_groups::TabGroupId group_id = tabstrip.AddToNewGroup({0}); ASSERT_EQ(tabstrip.GetTabGroupForTab(0), group_id); @@ -1916,7 +1915,7 @@ // Open a tab by simulating a link that opens in a new tab. std::unique_ptr<WebContents> contents = CreateWebContents(); tabstrip.AddWebContents(std::move(contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_EQ(2, tabstrip.count()); EXPECT_EQ(tabstrip.GetTabGroupForTab(1), group_id); @@ -1938,11 +1937,11 @@ std::unique_ptr<WebContents> contents1 = CreateWebContents(); tabstrip.AddWebContents(std::move(contents1), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); std::unique_ptr<WebContents> contents2 = CreateWebContents(); tabstrip.AddWebContents(std::move(contents2), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); ASSERT_EQ(2, tabstrip.count()); tab_groups::TabGroupId group_id = tabstrip.AddToNewGroup({0, 1}); ASSERT_EQ(tabstrip.GetTabGroupForTab(0), group_id); @@ -1954,7 +1953,7 @@ WebContents* raw_contents = contents.get(); tabstrip.AddWebContents( std::move(contents), 1, ui::PAGE_TRANSITION_FIRST, - TabStripModel::ADD_ACTIVE | TabStripModel::ADD_FORCE_INDEX); + AddTabTypes::ADD_ACTIVE | AddTabTypes::ADD_FORCE_INDEX); EXPECT_EQ(3, tabstrip.count()); ASSERT_EQ(1, tabstrip.GetIndexOfWebContents(raw_contents)); EXPECT_EQ(tabstrip.GetTabGroupForTab(1), group_id); @@ -1971,11 +1970,11 @@ // Open the Home Page. tabstrip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Open some other tab, by user typing. tabstrip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); // The selected tab should still be the first. EXPECT_EQ(0, tabstrip.active_index()); @@ -2001,17 +2000,17 @@ WebContents* raw_page_a_contents = page_a_contents.get(); strip.AddWebContents(std::move(page_a_contents), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Simulate middle click to open page A.A and A.B std::unique_ptr<WebContents> page_a_a_contents = CreateWebContents(); WebContents* raw_page_a_a_contents = page_a_a_contents.get(); strip.AddWebContents(std::move(page_a_a_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); std::unique_ptr<WebContents> page_a_b_contents = CreateWebContents(); WebContents* raw_page_a_b_contents = page_a_b_contents.get(); strip.AddWebContents(std::move(page_a_b_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); // Select page A.A strip.ActivateTabAt(1, TabStripUserGestureDetails( @@ -2022,7 +2021,7 @@ std::unique_ptr<WebContents> page_a_a_a_contents = CreateWebContents(); WebContents* raw_page_a_a_a_contents = page_a_a_a_contents.get(); strip.AddWebContents(std::move(page_a_a_a_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); EXPECT_EQ(raw_page_a_a_a_contents, strip.GetWebContentsAt(2)); @@ -2055,12 +2054,12 @@ // Open page A strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Open pages B, C and D in the background from links on page A... for (int i = 0; i < 3; ++i) { strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); } // Switch to page B's tab. @@ -2071,7 +2070,7 @@ std::unique_ptr<WebContents> new_contents = CreateWebContents(); WebContents* raw_new_contents = new_contents.get(); strip.AddWebContents(std::move(new_contents), -1, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_EQ(4, strip.GetIndexOfWebContents(raw_new_contents)); EXPECT_EQ(4, strip.active_index()); @@ -2088,7 +2087,7 @@ std::unique_ptr<WebContents> page_e_contents = CreateWebContents(); WebContents* raw_page_e_contents = page_e_contents.get(); strip.AddWebContents(std::move(page_e_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); EXPECT_EQ(4, strip.GetIndexOfWebContents(raw_page_e_contents)); EXPECT_EQ(4, strip.active_index()); @@ -2106,7 +2105,7 @@ WebContents* raw_page_f_contents = page_f_contents.get(); strip.AddWebContents(std::move(page_f_contents), -1, ui::PAGE_TRANSITION_AUTO_BOOKMARK, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); EXPECT_EQ(4, strip.GetIndexOfWebContents(raw_page_f_contents)); EXPECT_EQ(4, strip.active_index()); @@ -2130,7 +2129,7 @@ // Open page A strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Open pages B, C and D in the background from links on page A... std::unique_ptr<WebContents> page_c_contents = CreateWebContents(); @@ -2138,18 +2137,18 @@ std::unique_ptr<WebContents> page_d_contents = CreateWebContents(); WebContents* raw_page_d_contents = page_d_contents.get(); strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); strip.AddWebContents(std::move(page_c_contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); strip.AddWebContents(std::move(page_d_contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); // Open page E in a different opener tree from page A. std::unique_ptr<WebContents> page_e_contents = CreateWebContents(); WebContents* raw_page_e_contents = page_e_contents.get(); strip.AddWebContents(std::move(page_e_contents), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); // Tell the TabStripModel that we are navigating page D via a link click. strip.ActivateTabAt(3, TabStripUserGestureDetails( @@ -2182,18 +2181,18 @@ // opened. strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); std::unique_ptr<WebContents> page_c_contents = CreateWebContents(); WebContents* raw_page_c_contents = page_c_contents.get(); std::unique_ptr<WebContents> page_d_contents = CreateWebContents(); WebContents* raw_page_d_contents = page_d_contents.get(); strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); strip.AddWebContents(std::move(page_c_contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); strip.AddWebContents(std::move(page_d_contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); strip.ActivateTabAt(2, TabStripUserGestureDetails( TabStripUserGestureDetails::GestureType::kOther)); @@ -2208,7 +2207,7 @@ content::WebContentsTester::For(raw_new_tab_contents) ->NavigateAndCommit(GURL("chrome://newtab")); strip.AddWebContents(std::move(new_tab_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); // The opener should still be remembered after one navigation. content::NavigationSimulator::CreateBrowserInitiated( @@ -2226,7 +2225,7 @@ // Open a new tab again. strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Now select the first tab. strip.ActivateTabAt(0, TabStripUserGestureDetails( @@ -2250,7 +2249,7 @@ new_tab_contents = CreateWebContents(); raw_new_tab_contents = new_tab_contents.get(); strip.AddWebContents(std::move(new_tab_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); content::WebContentsTester::For(raw_new_tab_contents) ->NavigateAndCommit(GURL("http://example.org")); @@ -2506,7 +2505,7 @@ // up after them. { tabstrip.InsertWebContentsAt(1, std::move(contents4), - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); ASSERT_EQ(1, observer.GetStateCount()); State state(raw_contents4, 2, MockTabStripModelObserver::INSERT); @@ -2529,7 +2528,7 @@ std::unique_ptr<WebContents> first_contents = CreateWebContents(); WebContents* raw_first_contents = first_contents.get(); strip.AddWebContents(std::move(first_contents), -1, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); MockTabStripModelObserver observer; strip.AddObserver(&observer); @@ -2556,7 +2555,7 @@ std::unique_ptr<WebContents> third_contents = CreateWebContents(); WebContents* raw_third_contents = third_contents.get(); strip.AddWebContents(std::move(third_contents), 1, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); observer.ClearStates(); @@ -2858,22 +2857,22 @@ WebContents* raw_page_a_contents = page_a_contents.get(); strip.AddWebContents(std::move(page_a_contents), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); std::unique_ptr<WebContents> page_a1_contents = CreateWebContents(); WebContents* raw_page_a1_contents = page_a1_contents.get(); strip.AddWebContents(std::move(page_a1_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); // Likewise, open pages B and B1. std::unique_ptr<WebContents> page_b_contents = CreateWebContents(); WebContents* raw_page_b_contents = page_b_contents.get(); strip.AddWebContents(std::move(page_b_contents), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); std::unique_ptr<WebContents> page_b1_contents = CreateWebContents(); WebContents* raw_page_b1_contents = page_b1_contents.get(); strip.AddWebContents(std::move(page_b1_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); EXPECT_EQ(raw_page_a_contents, strip.GetWebContentsAt(0)); EXPECT_EQ(raw_page_a1_contents, strip.GetWebContentsAt(1)); @@ -2887,7 +2886,7 @@ std::unique_ptr<WebContents> page_b2_contents = CreateWebContents(); WebContents* raw_page_b2_contents = page_b2_contents.get(); strip.AddWebContents(std::move(page_b2_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); EXPECT_EQ(raw_page_b_contents, strip.GetWebContentsAt(0)); EXPECT_EQ(raw_page_b2_contents, strip.GetWebContentsAt(1)); EXPECT_EQ(raw_page_a_contents, strip.GetWebContentsAt(2)); @@ -2903,7 +2902,7 @@ std::unique_ptr<WebContents> page_a2_contents = CreateWebContents(); WebContents* raw_page_a2_contents = page_a2_contents.get(); strip.AddWebContents(std::move(page_a2_contents), -1, - ui::PAGE_TRANSITION_LINK, TabStripModel::ADD_NONE); + ui::PAGE_TRANSITION_LINK, AddTabTypes::ADD_NONE); EXPECT_EQ(raw_page_b_contents, strip.GetWebContentsAt(0)); EXPECT_EQ(raw_page_b2_contents, strip.GetWebContentsAt(1)); EXPECT_EQ(raw_page_a_contents, strip.GetWebContentsAt(2)); @@ -3197,10 +3196,10 @@ // Open two pages, pinned. strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE | TabStripModel::ADD_PINNED); + AddTabTypes::ADD_ACTIVE | AddTabTypes::ADD_PINNED); strip.AddWebContents(CreateWebContents(), -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, - TabStripModel::ADD_ACTIVE | TabStripModel::ADD_PINNED); + AddTabTypes::ADD_ACTIVE | AddTabTypes::ADD_PINNED); // Activate the first tab (a). strip.ActivateTabAt(0, TabStripUserGestureDetails( @@ -3213,9 +3212,9 @@ std::unique_ptr<WebContents> page_d_contents = CreateWebContents(); WebContents* raw_page_d_contents = page_d_contents.get(); strip.AddWebContents(std::move(page_c_contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); strip.AddWebContents(std::move(page_d_contents), -1, ui::PAGE_TRANSITION_LINK, - TabStripModel::ADD_NONE); + AddTabTypes::ADD_NONE); EXPECT_EQ(2, strip.GetIndexOfWebContents(raw_page_c_contents)); EXPECT_EQ(3, strip.GetIndexOfWebContents(raw_page_d_contents)); @@ -3739,7 +3738,7 @@ EXPECT_EQ(1u, observer.group_updates().size()); EXPECT_EQ(2, observer.group_update(group).contents_update_count); - strip.InsertWebContentsAt(1, CreateWebContents(), TabStripModel::ADD_NONE, + strip.InsertWebContentsAt(1, CreateWebContents(), AddTabTypes::ADD_NONE, group); EXPECT_EQ(1u, observer.group_updates().size()); @@ -3757,7 +3756,7 @@ strip.AppendWebContents(CreateWebContents(), false); strip.AddToNewGroup({0, 1}); - strip.InsertWebContentsAt(2, CreateWebContents(), TabStripModel::ADD_NONE); + strip.InsertWebContentsAt(2, CreateWebContents(), AddTabTypes::ADD_NONE); // The newly added tab should not be in the group. EXPECT_TRUE(strip.GetTabGroupForTab(0).has_value()); @@ -3778,7 +3777,7 @@ absl::optional<tab_groups::TabGroupId> group = strip.GetTabGroupForTab(0); strip.InsertWebContentsAt(1, CreateWebContentsWithID(2), - TabStripModel::ADD_NONE, group); + AddTabTypes::ADD_NONE, group); EXPECT_EQ(strip.GetTabGroupForTab(0), group); EXPECT_EQ(strip.GetTabGroupForTab(1), group); @@ -3795,7 +3794,7 @@ auto group = strip.AddToNewGroup({1}); strip.AddWebContents(CreateWebContentsWithID(3), 2, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_NONE, group); + AddTabTypes::ADD_NONE, group); EXPECT_EQ("0 1 3 2", GetTabStripStateString(strip)); EXPECT_EQ(group, strip.GetTabGroupForTab(2)); @@ -3807,7 +3806,7 @@ TabStripModel strip(&delegate, profile()); strip.AppendWebContents(CreateWebContents(), true); strip.AddToNewGroup({0}); - strip.InsertWebContentsAt(1, CreateWebContents(), TabStripModel::ADD_NONE, + strip.InsertWebContentsAt(1, CreateWebContents(), AddTabTypes::ADD_NONE, strip.GetTabGroupForTab(0)); strip.RemoveFromGroup({1}); @@ -3825,8 +3824,7 @@ auto group = strip.AddToNewGroup({0, 1}); strip.AddWebContents(CreateWebContentsWithID(3), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_NONE, - group); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_NONE, group); EXPECT_EQ("0 1 3 2", GetTabStripStateString(strip)); strip.CloseAllTabs(); @@ -3839,7 +3837,7 @@ auto group = strip.AddToNewGroup({0, 1}); strip.AddWebContents(CreateWebContentsWithID(3), 3, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_NONE, group); + AddTabTypes::ADD_NONE, group); EXPECT_EQ("0 1 3 2", GetTabStripStateString(strip)); strip.CloseAllTabs(); @@ -3852,7 +3850,7 @@ auto group = strip.AddToNewGroup({1, 2}); strip.AddWebContents(CreateWebContentsWithID(3), 0, ui::PAGE_TRANSITION_TYPED, - TabStripModel::ADD_NONE, group); + AddTabTypes::ADD_NONE, group); EXPECT_EQ("0 3 1 2", GetTabStripStateString(strip)); strip.CloseAllTabs(); @@ -4358,7 +4356,7 @@ ->SetLastCommittedURL(url); tabstrip.AddWebContents(std::move(new_tab_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); // Validate if the mute site menu item shows up and the site is unmuted EXPECT_TRUE(tabstrip.IsContextMenuCommandEnabled( @@ -4394,7 +4392,7 @@ ->SetLastCommittedURL(url); tabstrip.AddWebContents(std::move(new_tab_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); // Validate if the mute site menu item shows up and the site is unmuted EXPECT_TRUE(tabstrip.IsContextMenuCommandEnabled( @@ -4444,7 +4442,7 @@ ->SetLastCommittedURL(url); tabstrip.AddWebContents(std::move(new_tab_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); // Validate if the mute site menu item shows up and the site is unmuted EXPECT_TRUE(tabstrip.IsContextMenuCommandEnabled( @@ -4490,7 +4488,7 @@ ->SetLastCommittedURL(url); tabstrip.AddWebContents(std::move(new_tab_contents), -1, - ui::PAGE_TRANSITION_TYPED, TabStripModel::ADD_ACTIVE); + ui::PAGE_TRANSITION_TYPED, AddTabTypes::ADD_ACTIVE); settings->SetDefaultContentSetting(ContentSettingsType::SOUND, ContentSetting::CONTENT_SETTING_BLOCK);
diff --git a/chrome/browser/ui/ui_features.cc b/chrome/browser/ui/ui_features.cc index 64215ff..8ca4da4 100644 --- a/chrome/browser/ui/ui_features.cc +++ b/chrome/browser/ui/ui_features.cc
@@ -16,6 +16,17 @@ const base::Feature kAllowWindowDragUsingSystemDragDrop{ "AllowWindowDragUsingSystemDragDrop", base::FEATURE_DISABLED_BY_DEFAULT}; +// Enables showing the email of the flex org admin that setup CBCM in the +// management disclosures. + +#if BUILDFLAG(IS_CHROMEOS) +extern const base::Feature kFlexOrgManagementDisclosure{ + "FlexOrgManagementDisclosure", base::FEATURE_DISABLED_BY_DEFAULT}; +#else +extern const base::Feature kFlexOrgManagementDisclosure{ + "FlexOrgManagementDisclosure", base::FEATURE_ENABLED_BY_DEFAULT}; +#endif // BUILDFLAG(IS_CHROMEOS) + // Enables Chrome Labs menu in the toolbar. See https://crbug.com/1145666 const base::Feature kChromeLabs{"ChromeLabs", base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/chrome/browser/ui/ui_features.h b/chrome/browser/ui/ui_features.h index 475d71e..30e33b20 100644 --- a/chrome/browser/ui/ui_features.h +++ b/chrome/browser/ui/ui_features.h
@@ -24,6 +24,8 @@ // interactive_ui_tests pass on Wayland. extern const base::Feature kAllowWindowDragUsingSystemDragDrop; +extern const base::Feature kFlexOrgManagementDisclosure; + extern const base::Feature kChromeLabs; #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
diff --git a/chrome/browser/ui/views/autofill/payments/local_card_migration_browsertest.cc b/chrome/browser/ui/views/autofill/payments/local_card_migration_browsertest.cc index 46f8019..21e7bd7b 100644 --- a/chrome/browser/ui/views/autofill/payments/local_card_migration_browsertest.cc +++ b/chrome/browser/ui/views/autofill/payments/local_card_migration_browsertest.cc
@@ -69,8 +69,8 @@ #include "components/prefs/pref_registry_simple.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_test_utils.h" -#include "components/sync/test/fake_server/fake_server.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server.h" +#include "components/sync/test/fake_server_network_resources.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/test/browser_test.h" #include "content/public/test/browser_test_utils.h"
diff --git a/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc b/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc index 1410fcc..c944e09 100644 --- a/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc +++ b/chrome/browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc
@@ -65,8 +65,8 @@ #include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_test_utils.h" #include "components/sync/driver/sync_service_impl.h" -#include "components/sync/test/fake_server/fake_server.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server.h" +#include "components/sync/test/fake_server_network_resources.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/test/browser_test.h"
diff --git a/chrome/browser/ui/views/extensions/extensions_dialogs_utils.cc b/chrome/browser/ui/views/extensions/extensions_dialogs_utils.cc index 09471fe..e4e91e9 100644 --- a/chrome/browser/ui/views/extensions/extensions_dialogs_utils.cc +++ b/chrome/browser/ui/views/extensions/extensions_dialogs_utils.cc
@@ -27,21 +27,20 @@ : nullptr; } -// Returns the extensions button when multiple `extension_ids` are given. -// Otherwise returns the action view corresponding to the single extension if it -// exists, or the extensions menu button. +// Returns the action view corresponding to the extension if a single +// extension is specified in extension_ids ; otherwise, returns the +// extensions button. views::View* GetDialogAnchorView( ExtensionsToolbarContainer* container, const std::vector<extensions::ExtensionId>& extension_ids) { DCHECK(container); - DCHECK(!extension_ids.empty()); - if (extension_ids.size() > 1) { - return container->GetExtensionsButton(); + if (extension_ids.size() == 1) { + views::View* const action_view = container->GetViewForId(extension_ids[0]); + return action_view ? action_view : container->GetExtensionsButton(); } - views::View* const action_view = container->GetViewForId(extension_ids[0]); - return action_view ? action_view : container->GetExtensionsButton(); + return container->GetExtensionsButton(); } } // namespace @@ -108,14 +107,14 @@ views::Widget* widget = views::BubbleDialogDelegate::CreateBubble(std::move(bubble)); - if (extension_ids.size() > 1) { - // Show the widget using the default dialog anchor view. - widget->Show(); - } else { + if (extension_ids.size() == 1) { // Show the widget using the anchor view of the specific extension (which // the container may need to popup out). // TODO(emiliapaz): Consider moving showing the widget for extension to the // utils to declutter the container file. container->ShowWidgetForExtension(widget, extension_ids[0]); + } else { + // Show the widget using the default dialog anchor view. + widget->Show(); } }
diff --git a/chrome/browser/ui/views/extensions/reload_page_dialog_view.cc b/chrome/browser/ui/views/extensions/reload_page_dialog_view.cc index 54cebc4a..1279379 100644 --- a/chrome/browser/ui/views/extensions/reload_page_dialog_view.cc +++ b/chrome/browser/ui/views/extensions/reload_page_dialog_view.cc
@@ -26,19 +26,19 @@ void ShowReloadPageDialog( Browser* browser, const std::vector<extensions::ExtensionId>& extension_ids, - bool is_updating_permissions, base::OnceClosure callback) { - ShowReloadPageDialogView(browser, extension_ids, is_updating_permissions, - std::move(callback)); + ShowReloadPageDialogView(browser, extension_ids, std::move(callback)); } } // namespace extensions namespace { -std::u16string GetTitle(const std::vector<ToolbarActionViewController*> actions, - bool is_updating_permissions) { - if (is_updating_permissions) { +// TODO(emiliapaz): Rename the string ids from `BLOCKED_ACTIONS` TO +// `RELOAD_PAGE` to avoid confusion. +std::u16string GetTitle( + const std::vector<ToolbarActionViewController*> actions) { + if (actions.size() == 0) { return l10n_util::GetStringUTF16( IDS_EXTENSION_BLOCKED_ACTION_BUBBLE_UPDATE_PERMISSIONS_TITLE); } @@ -57,7 +57,6 @@ void ShowReloadPageDialogView( Browser* browser, const std::vector<extensions::ExtensionId>& extension_ids, - bool is_updating_permissions, base::OnceClosure callback) { ExtensionsToolbarContainer* const container = GetExtensionsToolbarContainer(browser); @@ -71,7 +70,7 @@ actions.push_back(container->GetActionForId(extension_id)); } - dialog_builder.SetTitle(GetTitle(actions, is_updating_permissions)) + dialog_builder.SetTitle(GetTitle(actions)) .AddOkButton(base::BindOnce(std::move(callback)), l10n_util::GetStringUTF16( IDS_EXTENSION_BLOCKED_ACTION_BUBBLE_OK_BUTTON)); @@ -80,7 +79,7 @@ browser->tab_strip_model()->GetActiveWebContents(); if (extension_ids.size() == 1) { dialog_builder.SetIcon(GetIcon(actions[0], web_contents)); - } else { + } else if (extension_ids.size() > 1) { for (auto* action : actions) { dialog_builder.AddMenuItem( GetIcon(action, web_contents), action->GetActionName(),
diff --git a/chrome/browser/ui/views/extensions/reload_page_dialog_view.h b/chrome/browser/ui/views/extensions/reload_page_dialog_view.h index 37dcc6ef..a504314 100644 --- a/chrome/browser/ui/views/extensions/reload_page_dialog_view.h +++ b/chrome/browser/ui/views/extensions/reload_page_dialog_view.h
@@ -10,10 +10,11 @@ class Browser; +// TODO(emiliapaz): We do not need to have a separate `Show` method in views +// code anymore. Inline this inside `ShowReloadPageDialog`. static void ShowReloadPageDialogView( Browser* browser, const std::vector<extensions::ExtensionId>& extension_ids, - bool is_updating_permissions, base::OnceClosure callback); #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_RELOAD_PAGE_DIALOG_VIEW_H_
diff --git a/chrome/browser/ui/views/extensions/reload_page_dialog_view_browsertest.cc b/chrome/browser/ui/views/extensions/reload_page_dialog_view_browsertest.cc index fa69f9db..b20447c 100644 --- a/chrome/browser/ui/views/extensions/reload_page_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/extensions/reload_page_dialog_view_browsertest.cc
@@ -12,9 +12,8 @@ // DialogBrowserTest: void ShowUi(const std::string& name) override { auto extension = InstallExtension("Extension"); - bool show_checkbox = true; extensions::ShowReloadPageDialog(browser(), {extension->id()}, - show_checkbox, base::DoNothing()); + base::DoNothing()); } };
diff --git a/chrome/browser/ui/views/frame/tab_strip_region_view.cc b/chrome/browser/ui/views/frame/tab_strip_region_view.cc index fcd42b61..a9a4d5f 100644 --- a/chrome/browser/ui/views/frame/tab_strip_region_view.cc +++ b/chrome/browser/ui/views/frame/tab_strip_region_view.cc
@@ -115,8 +115,7 @@ const auto control_padding = gfx::Insets::TLBR( 0, 0, 0, GetLayoutConstant(TABSTRIP_REGION_VIEW_CONTROL_PADDING)); - tip_marquee_view_ = AddChildView( - std::make_unique<TipMarqueeView>(views::style::CONTEXT_LABEL)); + tip_marquee_view_ = AddChildView(std::make_unique<TipMarqueeView>()); tip_marquee_view_->SetProperty( views::kFlexBehaviorKey, views::FlexSpecification(
diff --git a/chrome/browser/ui/views/frame/webui_tab_strip_container_view.cc b/chrome/browser/ui/views/frame/webui_tab_strip_container_view.cc index 198cf9e95..6069b368 100644 --- a/chrome/browser/ui/views/frame/webui_tab_strip_container_view.cc +++ b/chrome/browser/ui/views/frame/webui_tab_strip_container_view.cc
@@ -661,8 +661,8 @@ void WebUITabStripContainerView::NewTabButtonPressed(const ui::Event& event) { chrome::ExecuteCommand(browser_view_->browser(), IDC_NEW_TAB); UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", - TabStripModel::NEW_TAB_BUTTON_IN_TOOLBAR_FOR_TOUCH, - TabStripModel::NEW_TAB_ENUM_COUNT); + NewTabTypes::NEW_TAB_BUTTON_IN_TOOLBAR_FOR_TOUCH, + NewTabTypes::NEW_TAB_ENUM_COUNT); } void WebUITabStripContainerView::TabCounterPressed(const ui::Event& event) {
diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view_sync_browsertest.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view_sync_browsertest.cc index ffce9d4..a73cf6a 100644 --- a/chrome/browser/ui/views/page_info/page_info_bubble_view_sync_browsertest.cc +++ b/chrome/browser/ui/views/page_info/page_info_bubble_view_sync_browsertest.cc
@@ -26,7 +26,7 @@ #include "components/strings/grit/components_strings.h" #include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_user_settings.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h"
diff --git a/chrome/browser/ui/views/payments/payment_method_view_controller.cc b/chrome/browser/ui/views/payments/payment_method_view_controller.cc index e42d893da..2b5b9af 100644 --- a/chrome/browser/ui/views/payments/payment_method_view_controller.cc +++ b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
@@ -51,13 +51,12 @@ PaymentRequestItemList* list, base::WeakPtr<PaymentRequestDialogView> dialog, bool selected) - : PaymentRequestItemList::Item( - spec, - state, - list, - selected, - /*clickable=*/true, - /*show_edit_button=*/app->type() == PaymentApp::Type::AUTOFILL), + : PaymentRequestItemList::Item(spec, + state, + list, + selected, + /*clickable=*/true, + /*show_edit_button=*/false), app_(app), dialog_(dialog) { Init(); @@ -69,28 +68,6 @@ ~PaymentMethodListItem() override {} private: - void ShowEditor() { - if (!app_) - return; - - switch (app_->type()) { - case PaymentApp::Type::AUTOFILL: - // TODO(https://crbug.com/1209835): Remove this method entirely. - NOTREACHED() << "Autofill payment app is no longer supported"; - return; - case PaymentApp::Type::UNDEFINED: - // Intentionally fall through. - case PaymentApp::Type::NATIVE_MOBILE_APP: - // Intentionally fall through. - case PaymentApp::Type::SERVICE_WORKER_APP: - // Intentionally fall through. - case PaymentApp::Type::INTERNAL: - // We cannot edit these types of payment apps. - return; - } - NOTREACHED(); - } - // PaymentRequestItemList::Item: std::unique_ptr<views::View> CreateExtraView() override { return app_ ? CreateAppIconView(app_->icon_resource_id(), @@ -156,9 +133,9 @@ return app_ && app_->IsCompleteForPayment(); } - void PerformSelectionFallback() override { ShowEditor(); } + void PerformSelectionFallback() override {} - void EditButtonPressed() override { ShowEditor(); } + void EditButtonPressed() override {} base::WeakPtr<PaymentApp> app_; base::WeakPtr<PaymentRequestDialogView> dialog_;
diff --git a/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc b/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc index fba5fd7..27f3887 100644 --- a/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc +++ b/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc
@@ -374,11 +374,7 @@ } std::u16string PaymentRequestSheetController::GetPrimaryButtonLabel() { - const bool continue_button = - state()->selected_app() && - state()->selected_app()->type() != PaymentApp::Type::AUTOFILL; - return l10n_util::GetStringUTF16( - continue_button ? IDS_PAYMENTS_CONTINUE_BUTTON : IDS_PAYMENTS_PAY_BUTTON); + return l10n_util::GetStringUTF16(IDS_PAYMENTS_CONTINUE_BUTTON); } PaymentRequestSheetController::ButtonCallback
diff --git a/chrome/browser/ui/views/permissions/permission_prompt_bubble_view_browsertest.cc b/chrome/browser/ui/views/permissions/permission_prompt_bubble_view_browsertest.cc index baf784e..c3602bc 100644 --- a/chrome/browser/ui/views/permissions/permission_prompt_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/permissions/permission_prompt_bubble_view_browsertest.cc
@@ -294,7 +294,7 @@ // Drag out into a dragging window. E.g. see steps in [BrowserWindowController // detachTabsToNewWindow:..]. std::vector<TabStripModelDelegate::NewStripContents> contentses(1); - contentses.back().add_types = TabStripModel::ADD_ACTIVE; + contentses.back().add_types = AddTabTypes::ADD_ACTIVE; contentses.back().web_contents = strip->DetachWebContentsAtForInsertion(0); Browser* dragging_browser = strip->delegate()->CreateNewStripWithContents( std::move(contentses), gfx::Rect(100, 100, 640, 480), false); @@ -305,7 +305,7 @@ std::unique_ptr<content::WebContents> removed_contents = drag_strip->DetachWebContentsAtForInsertion(0); strip->InsertWebContentsAt(0, std::move(removed_contents), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // Clear the request. There should be no crash. test_api_->SimulateWebContentsDestroyed();
diff --git a/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc b/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc index c274e564..45fa68b8 100644 --- a/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc +++ b/chrome/browser/ui/views/profiles/profile_menu_view_browsertest.cc
@@ -68,7 +68,7 @@ #include "components/signin/public/identity_manager/primary_account_mutator.h" #include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_user_settings.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include "components/user_education/common/feature_promo_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/test/browser_test.h"
diff --git a/chrome/browser/ui/views/side_search/side_search_browser_controller_interactive_uitest.cc b/chrome/browser/ui/views/side_search/side_search_browser_controller_interactive_uitest.cc index 85f33a3f..46b282f 100644 --- a/chrome/browser/ui/views/side_search/side_search_browser_controller_interactive_uitest.cc +++ b/chrome/browser/ui/views/side_search/side_search_browser_controller_interactive_uitest.cc
@@ -238,7 +238,7 @@ std::unique_ptr<content::WebContents> web_contents = browser2->tab_strip_model()->DetachWebContentsAtForInsertion(0); browser()->tab_strip_model()->InsertWebContentsAt(1, std::move(web_contents), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); ASSERT_EQ(2, browser()->tab_strip_model()->GetTabCount()); ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); @@ -704,7 +704,7 @@ std::unique_ptr<content::WebContents> web_contents = browser2->tab_strip_model()->DetachWebContentsAtForInsertion(2); browser()->tab_strip_model()->InsertWebContentsAt(3, std::move(web_contents), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); // The global panel should now be visibe in browser2 and the contextual panel // should be visible in browser1.
diff --git a/chrome/browser/ui/views/side_search/unified_side_search_controller_interactive_uitest.cc b/chrome/browser/ui/views/side_search/unified_side_search_controller_interactive_uitest.cc index 6a85986e..6ae7ec6 100644 --- a/chrome/browser/ui/views/side_search/unified_side_search_controller_interactive_uitest.cc +++ b/chrome/browser/ui/views/side_search/unified_side_search_controller_interactive_uitest.cc
@@ -159,7 +159,7 @@ std::unique_ptr<content::WebContents> web_contents = browser2->tab_strip_model()->DetachWebContentsAtForInsertion(0); browser()->tab_strip_model()->InsertWebContentsAt(1, std::move(web_contents), - TabStripModel::ADD_ACTIVE); + AddTabTypes::ADD_ACTIVE); ASSERT_EQ(2, browser()->tab_strip_model()->GetTabCount()); ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
diff --git a/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog.cc b/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog.cc new file mode 100644 index 0000000..09d67185 --- /dev/null +++ b/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog.cc
@@ -0,0 +1,79 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <string> +#include <utility> + +#include "chrome/browser/ui/extensions/extensions_dialogs.h" +#include "chrome/grit/chromium_strings.h" +#include "chrome/grit/generated_resources.h" +#include "chromeos/ui/vector_icons/vector_icons.h" +#include "components/constrained_window/constrained_window_views.h" +#include "components/strings/grit/components_strings.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/web_contents.h" +#include "extensions/common/extension.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/models/dialog_model.h" +#include "ui/base/models/image_model.h" +#include "ui/gfx/paint_vector_icon.h" + +namespace { + +std::u16string GetExtensionType(const extensions::Extension* extension) { + return l10n_util::GetStringUTF16( + extension->is_app() + ? IDS_PARENT_PERMISSION_PROMPT_EXTENSION_TYPE_APP + : IDS_PARENT_PERMISSION_PROMPT_EXTENSION_TYPE_EXTENSION); +} + +std::u16string GetTitle( + extensions::ExtensionInstalledBlockedByParentDialogAction action, + std::u16string extension_type) { + int title_id = + action == extensions::ExtensionInstalledBlockedByParentDialogAction::kAdd + ? IDS_EXTENSION_INSTALL_BLOCKED_BY_PARENT_PROMPT_TITLE + : IDS_EXTENSION_ENABLE_BLOCKED_BY_PARENT_PROMPT_TITLE; + return l10n_util::GetStringFUTF16(title_id, extension_type); +} + +std::u16string GetBodyText( + extensions::ExtensionInstalledBlockedByParentDialogAction action, + std::u16string extension_type) { + int body_id = + action == extensions::ExtensionInstalledBlockedByParentDialogAction::kAdd + ? IDS_EXTENSION_INSTALL_BLOCKED_BY_PARENT_PROMPT_MESSAGE + : IDS_EXTENSION_ENABLE_BLOCKED_BY_PARENT_PROMPT_MESSAGE; + return l10n_util::GetStringFUTF16(body_id, extension_type); +} + +} // namespace + +namespace extensions { + +void ShowExtensionInstallBlockedByParentDialog( + ExtensionInstalledBlockedByParentDialogAction action, + const extensions::Extension* extension, + content::WebContents* web_contents, + base::OnceClosure done_callback) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + std::u16string extension_type = GetExtensionType(extension); + + auto dialog_model = + ui::DialogModel::Builder() + .SetTitle(GetTitle(action, extension_type)) + .SetIcon(ui::ImageModel::FromImageSkia(gfx::CreateVectorIcon( + chromeos::kNotificationSupervisedUserIcon, ui::kColorIcon))) + .AddBodyText( + ui::DialogModelLabel(GetBodyText(action, extension_type))) + .AddOkButton(base::DoNothing(), l10n_util::GetStringUTF16(IDS_OK)) + .SetDialogDestroyingCallback(std::move(done_callback)) + .Build(); + + gfx::NativeWindow parent_window = + web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr; + constrained_window::ShowBrowserModal(std::move(dialog_model), parent_window); +} + +} // namespace extensions
diff --git a/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view_browsertest.cc b/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_browsertest.cc similarity index 96% rename from chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view_browsertest.cc rename to chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_browsertest.cc index 54e7062..424149fa 100644 --- a/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_browsertest.cc
@@ -1,4 +1,4 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. +// Copyright 2022 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
diff --git a/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.cc b/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.cc deleted file mode 100644 index 8640d47f..0000000 --- a/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.cc +++ /dev/null
@@ -1,153 +0,0 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.h" - -#include <string> -#include <utility> - -#include "base/bind.h" -#include "base/i18n/message_formatter.h" -#include "chrome/browser/ui/views/chrome_layout_provider.h" -#include "chrome/browser/ui/views/chrome_typography.h" -#include "chrome/common/extensions/extension_constants.h" -#include "chrome/grit/chromium_strings.h" -#include "chrome/grit/generated_resources.h" -#include "chromeos/ui/vector_icons/vector_icons.h" -#include "components/constrained_window/constrained_window_views.h" -#include "components/strings/grit/components_strings.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/web_contents.h" -#include "extensions/common/constants.h" -#include "extensions/common/extension.h" -#include "third_party/skia/include/core/SkColor.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/metadata/metadata_impl_macros.h" -#include "ui/gfx/geometry/insets.h" -#include "ui/gfx/paint_vector_icon.h" -#include "ui/views/border.h" -#include "ui/views/controls/label.h" -#include "ui/views/layout/box_layout.h" -#include "ui/views/layout/fill_layout.h" - -namespace extensions { - -void ShowExtensionInstallBlockedByParentDialog( - ExtensionInstalledBlockedByParentDialogAction action, - const extensions::Extension* extension, - content::WebContents* web_contents, - base::OnceClosure done_callback) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - auto dialog = std::make_unique<ExtensionInstallBlockedByParentDialogView>( - action, extension, std::move(done_callback)); - gfx::NativeWindow parent_window = - web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr; - views::Widget* widget = - parent_window ? constrained_window::CreateBrowserModalDialogViews( - dialog.release(), parent_window) - : views::DialogDelegate::CreateDialogWidget( - dialog.release(), nullptr, nullptr); - widget->Show(); -} - -} // namespace extensions - -ExtensionInstallBlockedByParentDialogView:: - ExtensionInstallBlockedByParentDialogView( - extensions::ExtensionInstalledBlockedByParentDialogAction action, - const extensions::Extension* extension, - base::OnceClosure done_callback) - : extension_(extension), - action_(action), - done_callback_(std::move(done_callback)) { - SetButtons(ui::DIALOG_BUTTON_CANCEL); - SetDefaultButton(ui::DIALOG_BUTTON_CANCEL); - SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, l10n_util::GetStringUTF16(IDS_OK)); - set_draggable(true); - - SetModalType(ui::MODAL_TYPE_WINDOW); - set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric( - views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH)); - - SetShowIcon(true); - ConfigureTitle(); - CreateContents(); -} - -ExtensionInstallBlockedByParentDialogView:: - ~ExtensionInstallBlockedByParentDialogView() { - if (done_callback_) - std::move(done_callback_).Run(); -} - -void ExtensionInstallBlockedByParentDialogView::OnThemeChanged() { - views::DialogDelegateView::OnThemeChanged(); - SetIcon(gfx::CreateVectorIcon(chromeos::kNotificationSupervisedUserIcon, - GetColorProvider()->GetColor(ui::kColorIcon))); -} - -void ExtensionInstallBlockedByParentDialogView::ConfigureTitle() { - std::u16string title_string; - switch (action_) { - case extensions::ExtensionInstalledBlockedByParentDialogAction::kAdd: - // The user is trying to add/install the extension/app - title_string = l10n_util::GetStringFUTF16( - IDS_EXTENSION_INSTALL_BLOCKED_BY_PARENT_PROMPT_TITLE, - GetExtensionTypeString()); - break; - case extensions::ExtensionInstalledBlockedByParentDialogAction::kEnable: - // The user is trying to enable the extension/app - title_string = l10n_util::GetStringFUTF16( - IDS_EXTENSION_ENABLE_BLOCKED_BY_PARENT_PROMPT_TITLE, - GetExtensionTypeString()); - break; - } - SetTitle(title_string); -} - -void ExtensionInstallBlockedByParentDialogView::CreateContents() { - SetLayoutManager(std::make_unique<views::FillLayout>()); - - std::u16string body_string; - switch (action_) { - case extensions::ExtensionInstalledBlockedByParentDialogAction::kAdd: - // The user is trying to add/install the extension/app - body_string = l10n_util::GetStringFUTF16( - IDS_EXTENSION_INSTALL_BLOCKED_BY_PARENT_PROMPT_MESSAGE, - GetExtensionTypeString()); - break; - case extensions::ExtensionInstalledBlockedByParentDialogAction::kEnable: - // The user is trying to enable the extension/app - body_string = l10n_util::GetStringFUTF16( - IDS_EXTENSION_ENABLE_BLOCKED_BY_PARENT_PROMPT_MESSAGE, - GetExtensionTypeString()); - break; - } - - const ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); - const gfx::Insets content_insets = provider->GetDialogInsetsForContentType( - views::DialogContentType::kText, views::DialogContentType::kText); - - set_margins(gfx::Insets::TLBR(content_insets.top(), content_insets.left(), - content_insets.bottom(), - content_insets.right())); - - auto* message_body_label = AddChildView(std::make_unique<views::Label>( - body_string, views::style::CONTEXT_DIALOG_BODY_TEXT)); - message_body_label->SetMultiLine(true); - message_body_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); -} - -std::u16string -ExtensionInstallBlockedByParentDialogView::GetExtensionTypeString() const { - return l10n_util::GetStringUTF16( - extension_->is_app() - ? IDS_PARENT_PERMISSION_PROMPT_EXTENSION_TYPE_APP - : IDS_PARENT_PERMISSION_PROMPT_EXTENSION_TYPE_EXTENSION); -} - -BEGIN_METADATA(ExtensionInstallBlockedByParentDialogView, - views::DialogDelegateView) -ADD_READONLY_PROPERTY_METADATA(std::u16string, ExtensionTypeString) -END_METADATA
diff --git a/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.h b/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.h deleted file mode 100644 index 72544c20..0000000 --- a/chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.h +++ /dev/null
@@ -1,59 +0,0 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_VIEWS_SUPERVISED_USER_EXTENSION_INSTALL_BLOCKED_BY_PARENT_DIALOG_VIEW_H_ -#define CHROME_BROWSER_UI_VIEWS_SUPERVISED_USER_EXTENSION_INSTALL_BLOCKED_BY_PARENT_DIALOG_VIEW_H_ - -#include <string> - -#include "base/callback_forward.h" -#include "base/memory/raw_ptr.h" -#include "chrome/browser/ui/extensions/extensions_dialogs.h" -#include "ui/base/metadata/metadata_header_macros.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/views/controls/button/button.h" -#include "ui/views/window/dialog_delegate.h" - -namespace extensions { -class Extension; -} // namespace extensions - -// Modal dialog that shows when a child user attempts to install an extension -// but blocked by their parent. -// TODO(pbos): Replace DialogDelegateView with View and use a separate -// DialogDelegate. This no longer overrides any DialogDelegateView methods. -class ExtensionInstallBlockedByParentDialogView - : public views::DialogDelegateView { - public: - METADATA_HEADER(ExtensionInstallBlockedByParentDialogView); - // Constructor for dialog shown when a parent blocks extension/app - // installation for a child. Do not call this directly. Instead, - // use ShowExtensionInstallBlockedByParentDialog in browser_dialogs.h. - // |action| is used to determine the strings to display in the dialog. - // |extension| is used to customize the dialog for the extension type. - // |window| is the window the dialog will modally attach to. - // |done_callback| will be called when the dialog is dismissed by the user. - ExtensionInstallBlockedByParentDialogView( - extensions::ExtensionInstalledBlockedByParentDialogAction action, - const extensions::Extension* extension, - base::OnceClosure done_callback); - ExtensionInstallBlockedByParentDialogView( - const ExtensionInstallBlockedByParentDialogView&) = delete; - ExtensionInstallBlockedByParentDialogView operator=( - const ExtensionInstallBlockedByParentDialogView&) = delete; - ~ExtensionInstallBlockedByParentDialogView() override; - - void OnThemeChanged() override; - - private: - void ConfigureTitle(); - void CreateContents(); - std::u16string GetExtensionTypeString() const; - - raw_ptr<const extensions::Extension> extension_ = nullptr; - extensions::ExtensionInstalledBlockedByParentDialogAction action_; - base::OnceClosure done_callback_; -}; - -#endif // CHROME_BROWSER_UI_VIEWS_SUPERVISED_USER_EXTENSION_INSTALL_BLOCKED_BY_PARENT_DIALOG_VIEW_H_
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 0eb31ee..343a299 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -1316,9 +1316,9 @@ base::AutoReset<bool> setter(&is_mutating_, true); for (size_t i = first_tab_index(); i < drag_data_.size(); ++i) { - int add_types = TabStripModel::ADD_NONE; + int add_types = AddTabTypes::ADD_NONE; if (drag_data_[i].pinned) - add_types |= TabStripModel::ADD_PINNED; + add_types |= AddTabTypes::ADD_PINNED; // We should have owned_contents here, this CHECK is used to gather data // for https://crbug.com/677806. @@ -1893,7 +1893,7 @@ // somehow. source_context_->GetTabStripModel()->InsertWebContentsAt( target_index, std::move(detached_web_contents), - (data->pinned ? TabStripModel::ADD_PINNED : 0)); + (data->pinned ? AddTabTypes::ADD_PINNED : 0)); } else { // The Tab was moved within the TabDragContext where the drag // was initiated. Move it back to the starting location. @@ -1917,7 +1917,7 @@ // We need to put it back into the source TabDragContext. source_context_->GetTabStripModel()->InsertWebContentsAt( target_index, std::move(data->owned_contents), - (data->pinned ? TabStripModel::ADD_PINNED : 0)); + (data->pinned ? AddTabTypes::ADD_PINNED : 0)); } TabStripModel* source_model = source_context_->GetTabStripModel(); source_model->UpdateGroupForDragRevert( @@ -1975,8 +1975,8 @@ // for https://crbug.com/677806. CHECK(drag_data_[i].owned_contents); item.web_contents = std::move(drag_data_[i].owned_contents); - item.add_types = drag_data_[i].pinned ? TabStripModel::ADD_PINNED - : TabStripModel::ADD_NONE; + item.add_types = drag_data_[i].pinned ? AddTabTypes::ADD_PINNED + : AddTabTypes::ADD_NONE; contentses.push_back(std::move(item)); }
diff --git a/chrome/browser/ui/views/tabs/tab_hover_card_controller.cc b/chrome/browser/ui/views/tabs/tab_hover_card_controller.cc index 19e16f1..b87ab1f 100644 --- a/chrome/browser/ui/views/tabs/tab_hover_card_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_hover_card_controller.cc
@@ -199,8 +199,7 @@ event_monitor_ = views::EventMonitor::CreateWindowMonitor( this, controller_->tab_strip_->GetWidget()->GetNativeWindow(), {ui::ET_KEY_PRESSED, ui::ET_KEY_RELEASED, ui::ET_MOUSE_PRESSED, - ui::ET_MOUSE_RELEASED, ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_END, - ui::ET_MOUSEWHEEL}); + ui::ET_MOUSE_RELEASED, ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_END}); } ~EventSniffer() override = default;
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 940b036..e082c82 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -1892,8 +1892,8 @@ new_tab_button_pressed_start_time_ = base::TimeTicks::Now(); base::RecordAction(base::UserMetricsAction("NewTab_Button")); - UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_BUTTON, - TabStripModel::NEW_TAB_ENUM_COUNT); + UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", NewTabTypes::NEW_TAB_BUTTON, + NewTabTypes::NEW_TAB_ENUM_COUNT); if (event.IsMouseEvent()) { // Prevent the hover card from popping back in immediately. This forces a // normal fade-in.
diff --git a/chrome/browser/ui/views/tabs/tab_strip_scroll_container.cc b/chrome/browser/ui/views/tabs/tab_strip_scroll_container.cc index 76e02e42..6568013 100644 --- a/chrome/browser/ui/views/tabs/tab_strip_scroll_container.cc +++ b/chrome/browser/ui/views/tabs/tab_strip_scroll_container.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/tabs/tab_strip_scroll_container.h" +#include "base/bind.h" #include "base/memory/raw_ptr.h" #include "cc/paint/paint_shader.h" #include "chrome/app/vector_icons/vector_icons.h" @@ -185,6 +186,10 @@ views::FlexSpecification(base::BindRepeating( &TabScrollContainerFlexRule, base::Unretained(tab_strip_)))); + on_contents_scrolled_subscription_ = scroll_view->AddContentsScrolledCallback( + base::BindRepeating(&TabStripScrollContainer::OnContentsScrolledCallback, + base::Unretained(this))); + std::unique_ptr<views::View> scroll_button_container = std::make_unique<views::View>(); views::FlexLayout* scroll_button_layout = @@ -225,6 +230,24 @@ PreferredSizeChanged(); } +void TabStripScrollContainer::OnContentsScrolledCallback() { + views::Widget* root_widget = tab_strip_->GetWidget(); + std::set<views::Widget*> children_widgets; + views::Widget::GetAllOwnedWidgets(root_widget->GetNativeView(), + &children_widgets); + + for (auto* child_widget : children_widgets) { + views::BubbleDialogDelegate* bdd = + child_widget->widget_delegate()->AsBubbleDialogDelegate(); + if (bdd) { + views::View* anchor_view = bdd->GetAnchorView(); + if (this->Contains(anchor_view)) { + child_widget->Hide(); + } + } + } +} + int TabStripScrollContainer::GetTabStripAvailableWidth() const { return overflow_view_->GetAvailableSize(scroll_view_).width().value(); }
diff --git a/chrome/browser/ui/views/tabs/tab_strip_scroll_container.h b/chrome/browser/ui/views/tabs/tab_strip_scroll_container.h index 7f805c2b0..151a40b 100644 --- a/chrome/browser/ui/views/tabs/tab_strip_scroll_container.h +++ b/chrome/browser/ui/views/tabs/tab_strip_scroll_container.h
@@ -33,6 +33,8 @@ bool IsRectInWindowCaption(const gfx::Rect& rect); + void OnContentsScrolledCallback(); + raw_ptr<views::ImageButton> GetLeadingScrollButtonForTesting() { return leading_scroll_button_; } @@ -50,6 +52,9 @@ // Scrolls the tabstrip towards the last tab in the tabstrip. void ScrollTowardsTrailingTab(); + // Subscription for scrolling of content view + base::CallbackListSubscription on_contents_scrolled_subscription_; + void FrameColorsChanged(); // views::View
diff --git a/chrome/browser/ui/views/tabs/tab_strip_scroll_container_unittest.cc b/chrome/browser/ui/views/tabs/tab_strip_scroll_container_unittest.cc new file mode 100644 index 0000000..f884ac95 --- /dev/null +++ b/chrome/browser/ui/views/tabs/tab_strip_scroll_container_unittest.cc
@@ -0,0 +1,66 @@ +// Copyright (c) 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/views/tabs/tab_strip_scroll_container.h" +#include <cstddef> +#include <memory> +#include "chrome/browser/ui/views/tabs/tab_strip.h" +#include "chrome/test/views/chrome_views_test_base.h" +#include "fake_base_tab_strip_controller.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/views/bubble/bubble_border.h" + +class TabStripScrollContainerTest : public ChromeViewsTestBase { + public: + TabStripScrollContainerTest() = default; + + void SetUp() override { + ChromeViewsTestBase::SetUp(); + + auto controller = std::make_unique<FakeBaseTabStripController>(); + controller_ = controller.get(); + auto tab_strip = std::make_unique<TabStrip>(std::move(controller)); + + tab_strip_ = tab_strip.get(); + controller_->set_tab_strip(tab_strip_); + root_widget_ = CreateTestWidget(); + root_widget_->Show(); + + // root_widget_ takes ownership of the content_view + tab_strip_scroll_container_ = root_widget_->SetContentsView( + std::make_unique<TabStripScrollContainer>(std::move(tab_strip))); + } + + void TearDown() override { + root_widget_.reset(); + ChromeViewsTestBase::TearDown(); + } + + ~TabStripScrollContainerTest() override = default; + + protected: + raw_ptr<FakeBaseTabStripController> controller_ = nullptr; + raw_ptr<TabStripScrollContainer> tab_strip_scroll_container_ = nullptr; + raw_ptr<TabStrip> tab_strip_ = nullptr; + std::unique_ptr<views::Widget> root_widget_; +}; + +TEST_F(TabStripScrollContainerTest, AnchoredWidgetHidesOnScroll) { + // set up the child widget + views::Widget::InitParams params = + CreateParams(views::Widget::InitParams::TYPE_BUBBLE); + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + params.bounds = gfx::Rect(0, 0, 400, 400); + params.delegate = new views::BubbleDialogDelegate( + tab_strip_, views::BubbleBorder::Arrow::LEFT_TOP); + std::unique_ptr<views::Widget> widget_ = CreateTestWidget(std::move(params)); + widget_->Show(); + views::Widget::ReparentNativeView(widget_->GetNativeView(), + root_widget_->GetNativeView()); + + EXPECT_TRUE(widget_->IsVisible()); + tab_strip_scroll_container_->OnContentsScrolledCallback(); + EXPECT_FALSE(widget_->IsVisible()); +}
diff --git a/chrome/browser/ui/views/user_education/tip_marquee_view.cc b/chrome/browser/ui/views/user_education/tip_marquee_view.cc index c4eefe7..ca428b82f 100644 --- a/chrome/browser/ui/views/user_education/tip_marquee_view.cc +++ b/chrome/browser/ui/views/user_education/tip_marquee_view.cc
@@ -119,7 +119,7 @@ } private: - void OnAccept() { marquee_->ClearTip(); } + void OnAccept() { marquee_->ClearAndHideTip(); } const raw_ptr<TipMarqueeView> marquee_; }; @@ -137,9 +137,9 @@ const std::string test_type = command_line->GetSwitchValueASCII(kTipMarqueeViewTestSwitch); if (test_type == kTipMarqueeViewTestTypeSimple) { - marquee->SetTip(kTipMarqueeViewTestText); + marquee->SetAndShowTip(kTipMarqueeViewTestText); } else if (test_type == kTipMarqueeViewTestTypeLearnMore) { - marquee->SetTip( + marquee->SetAndShowTip( kTipMarqueeViewTestText, base::BindRepeating(&ShowTestTipMarqueeViewLearnMoreBubble)); } else { @@ -183,7 +183,7 @@ private: void OnAccept() { LOG(WARNING) << "OnAccept()"; - tip_marquee_view_->ClearTip(); + tip_marquee_view_->ClearAndHideTip(); } const raw_ptr<TipMarqueeView> tip_marquee_view_; @@ -198,10 +198,10 @@ constexpr int TipMarqueeView::kTipMarqueeIconPadding; constexpr int TipMarqueeView::kTipMarqueeIconTotalWidth; -TipMarqueeView::TipMarqueeView(int text_context, int text_style) { +TipMarqueeView::TipMarqueeView() { tip_text_label_ = AddChildView(std::make_unique<views::StyledLabel>()); - tip_text_label_->SetTextContext(text_context); - tip_text_label_->SetDefaultTextStyle(text_style); + tip_text_label_->SetTextContext(views::style::CONTEXT_LABEL); + tip_text_label_->SetDefaultTextStyle(views::style::STYLE_PRIMARY); // TODO(dfried): Figure out how to set elide behavior. // tip_text_label_->SetElideBehavior(gfx::ElideBehavior::ELIDE_TAIL); @@ -215,7 +215,7 @@ TipMarqueeView::~TipMarqueeView() = default; -bool TipMarqueeView::SetTip( +bool TipMarqueeView::SetAndShowTip( const std::u16string& tip_text, LearnMoreLinkClickedCallback learn_more_link_clicked_callback) { tip_text_ = tip_text; @@ -239,7 +239,7 @@ return !collapsed_; } -void TipMarqueeView::ClearTip() { +void TipMarqueeView::ClearAndHideTip() { if (show_tip_widget_) show_tip_widget_->Close(); tip_text_label_->SetText(std::u16string()); @@ -322,7 +322,7 @@ void TipMarqueeView::LinkClicked() { if (!learn_more_link_clicked_callback_) { - ClearTip(); + ClearAndHideTip(); return; } if (GetProperty(views::kAnchoredDialogKey))
diff --git a/chrome/browser/ui/views/user_education/tip_marquee_view.h b/chrome/browser/ui/views/user_education/tip_marquee_view.h index 9c4abd7..898b7ad 100644 --- a/chrome/browser/ui/views/user_education/tip_marquee_view.h +++ b/chrome/browser/ui/views/user_education/tip_marquee_view.h
@@ -36,12 +36,8 @@ using LearnMoreLinkClickedCallback = base::RepeatingCallback<void(TipMarqueeView*)>; - // Constructs a tip marquee view which will display text with the given - // display parameters (see views::Label::Label() for usage). - // TODO(crbug.com/1351405): Add setters for text_context and text_style for - // better compatibility with ViewBuilder. - explicit TipMarqueeView(int text_context = views::style::CONTEXT_LABEL, - int text_style = views::style::STYLE_PRIMARY); + // Constructs a tip marquee view which will display text + TipMarqueeView(); ~TipMarqueeView() override; // Sets the tip and shows the view if there is adequate space. |tip_text| will @@ -51,12 +47,13 @@ // // Returns true if there is sufficient space in the parent view's layout to // display the fully expanded tip text and (if applicable) Learn More link. - bool SetTip(const std::u16string& tip_text, - LearnMoreLinkClickedCallback learn_more_link_clicked_callback = - LearnMoreLinkClickedCallback()); + bool SetAndShowTip( + const std::u16string& tip_text, + LearnMoreLinkClickedCallback learn_more_link_clicked_callback = + LearnMoreLinkClickedCallback()); // Clears the tip and hides the view. - void ClearTip(); + void ClearAndHideTip(); // views::View: gfx::Size GetMinimumSize() const override;
diff --git a/chrome/browser/ui/views/user_education/tip_marquee_view_browsertest.cc b/chrome/browser/ui/views/user_education/tip_marquee_view_browsertest.cc index e8be8d0..67bf40f 100644 --- a/chrome/browser/ui/views/user_education/tip_marquee_view_browsertest.cc +++ b/chrome/browser/ui/views/user_education/tip_marquee_view_browsertest.cc
@@ -28,14 +28,14 @@ IN_PROC_BROWSER_TEST_F(TipMarqueeViewBrowserTest, VisibilityChangesOnSetAndClearTip) { - tip_marquee_view()->SetTip(u"Tip Text"); + tip_marquee_view()->SetAndShowTip(u"Tip Text"); EXPECT_TRUE(tip_marquee_view()->GetVisible()); - tip_marquee_view()->ClearTip(); + tip_marquee_view()->ClearAndHideTip(); EXPECT_FALSE(tip_marquee_view()->GetVisible()); } IN_PROC_BROWSER_TEST_F(TipMarqueeViewBrowserTest, TipStartsExpanded) { - tip_marquee_view()->SetTip(u"Tip Text"); + tip_marquee_view()->SetAndShowTip(u"Tip Text"); RunScheduledLayouts(); EXPECT_EQ(tip_marquee_view()->GetPreferredSize(), tip_marquee_view()->size()); }
diff --git a/chrome/browser/ui/views/user_education/tip_marquee_view_unittest.cc b/chrome/browser/ui/views/user_education/tip_marquee_view_unittest.cc index bc197a32..2256e1d9 100644 --- a/chrome/browser/ui/views/user_education/tip_marquee_view_unittest.cc +++ b/chrome/browser/ui/views/user_education/tip_marquee_view_unittest.cc
@@ -75,8 +75,7 @@ views::MinimumFlexSizeRule::kPreferred, views::MaximumFlexSizeRule::kUnbounded)), views::Builder<TipMarqueeView>( - std::make_unique<TipMarqueeView>( - views::style::CONTEXT_DIALOG_TITLE)) + std::make_unique<TipMarqueeView>()) .CopyAddressTo(&marquee_) .SetProperty( views::kFlexBehaviorKey, @@ -125,29 +124,29 @@ } TEST_F(TipMarqueeViewTest, VisibleWhenTipSet) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); EXPECT_TRUE(marquee_->GetVisible()); } TEST_F(TipMarqueeViewTest, ClearTipHidesView) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); EXPECT_TRUE(marquee_->GetVisible()); EXPECT_EQ(marquee_->GetPreferredSize(), marquee_->size()); - marquee_->ClearTip(); + marquee_->ClearAndHideTip(); RunScheduledLayout(marquee_); EXPECT_FALSE(marquee_->GetVisible()); } TEST_F(TipMarqueeViewTest, TipStartsExpanded) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); EXPECT_GT(marquee_->width(), marquee_->GetMinimumSize().width()); } TEST_F(TipMarqueeViewTest, TipCollapsesWhenNotEnoughSpace) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); gfx::Size spacer_size = spacer_->size(); spacer_size.Enlarge(1, 0); @@ -157,7 +156,7 @@ } TEST_F(TipMarqueeViewTest, TipCollapsesAndExpandsWhenIconIsClicked) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); // This location should be comfortably inside the icon area. @@ -179,7 +178,7 @@ } TEST_F(TipMarqueeViewTest, TipDoesNotExpandWhenInsufficientSpace) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); gfx::Size spacer_size = spacer_->size(); spacer_size.Enlarge(1, 0); @@ -196,7 +195,7 @@ TEST_F(TipMarqueeViewTest, ClickLearnMoreLink) { LearnMoreCallback callback; - marquee_->SetTip(u"Tip Text", callback.Callback()); + marquee_->SetAndShowTip(u"Tip Text", callback.Callback()); RunScheduledLayout(marquee_); EXPECT_GT(marquee_->width(), marquee_->GetMinimumSize().width()); @@ -209,7 +208,7 @@ TEST_F(TipMarqueeViewTest, ClickNotInLearnMoreLinkHasNoEffect) { LearnMoreCallback callback; - marquee_->SetTip(u"Tip Text", callback.Callback()); + marquee_->SetAndShowTip(u"Tip Text", callback.Callback()); RunScheduledLayout(marquee_); EXPECT_GT(marquee_->width(), marquee_->GetMinimumSize().width()); @@ -223,7 +222,7 @@ TEST_F(TipMarqueeViewTest, ClickWhenForcedCollapsedCallsLearnMore) { LearnMoreCallback callback; - marquee_->SetTip(u"Tip Text", callback.Callback()); + marquee_->SetAndShowTip(u"Tip Text", callback.Callback()); RunScheduledLayout(marquee_); gfx::Size spacer_size = spacer_->size(); spacer_size.Enlarge(1, 0); @@ -239,7 +238,7 @@ } TEST_F(TipMarqueeViewTest, ClickWhenForcedCollapsedDisplaysOverflow) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); gfx::Size spacer_size = spacer_->size(); spacer_size.Enlarge(1, 0); @@ -256,7 +255,7 @@ } TEST_F(TipMarqueeViewTest, OverflowBubbleCancelDoesNotDismissTip) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); gfx::Size spacer_size = spacer_->size(); spacer_size.Enlarge(1, 0); @@ -279,7 +278,7 @@ } TEST_F(TipMarqueeViewTest, OverflowBubbleGotItDismissesTip) { - marquee_->SetTip(u"Tip Text"); + marquee_->SetAndShowTip(u"Tip Text"); RunScheduledLayout(marquee_); gfx::Size spacer_size = spacer_->size(); spacer_size.Enlarge(1, 0);
diff --git a/chrome/browser/ui/web_applications/web_app_launch_utils.cc b/chrome/browser/ui/web_applications/web_app_launch_utils.cc index 0823d1d..d6a9163 100644 --- a/chrome/browser/ui/web_applications/web_app_launch_utils.cc +++ b/chrome/browser/ui/web_applications/web_app_launch_utils.cc
@@ -32,6 +32,7 @@ #include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/tabs/tab_enums.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/web_applications/app_browser_controller.h" #include "chrome/browser/ui/web_applications/web_app_browser_controller.h" @@ -111,16 +112,16 @@ /*index=*/0, source_tabstrip->DetachWebContentsAtForInsertion( source_tabstrip->GetIndexOfWebContents(contents)), - (TabStripModel::ADD_INHERIT_OPENER | TabStripModel::ADD_ACTIVE | - TabStripModel::ADD_PINNED)); + (AddTabTypes::ADD_INHERIT_OPENER | AddTabTypes::ADD_ACTIVE | + AddTabTypes::ADD_PINNED)); target_tabstrip->DetachAndDeleteWebContentsAt(1); } else { target_tabstrip->InsertWebContentsAt( /*index=*/0, source_tabstrip->DetachWebContentsAtForInsertion( source_tabstrip->GetIndexOfWebContents(contents)), - (TabStripModel::ADD_INHERIT_OPENER | TabStripModel::ADD_ACTIVE | - TabStripModel::ADD_PINNED)); + (AddTabTypes::ADD_INHERIT_OPENER | AddTabTypes::ADD_ACTIVE | + AddTabTypes::ADD_PINNED)); } } else { MaybeAddPinnedHomeTab(target_browser, app_id); @@ -309,7 +310,7 @@ NavigateParams home_tab_nav_params(browser, pinned_home_tab_url.value(), ui::PAGE_TRANSITION_AUTO_BOOKMARK); home_tab_nav_params.disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB; - home_tab_nav_params.tabstrip_add_types |= TabStripModel::ADD_PINNED; + home_tab_nav_params.tabstrip_add_types |= AddTabTypes::ADD_PINNED; Navigate(&home_tab_nav_params); } }
diff --git a/chrome/browser/ui/webui/management/management_ui_handler.cc b/chrome/browser/ui/webui/management/management_ui_handler.cc index 09d77ffb..01ff530 100644 --- a/chrome/browser/ui/webui/management/management_ui_handler.cc +++ b/chrome/browser/ui/webui/management/management_ui_handler.cc
@@ -15,6 +15,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/callback_helpers.h" +#include "base/feature_list.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/user_metrics.h" #include "base/strings/string_util.h" @@ -30,6 +31,7 @@ #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/managed_ui.h" +#include "chrome/browser/ui/ui_features.h" #include "chrome/common/pref_names.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h" #include "components/strings/grit/components_strings.h" @@ -495,7 +497,14 @@ } std::string GetAccountManager(Profile* profile) { - return chrome::GetAccountManagerIdentity(profile).value_or(std::string()); + absl::optional<std::string> manager = + chrome::GetAccountManagerIdentity(profile); + if (!manager && + base::FeatureList::IsEnabled(features::kFlexOrgManagementDisclosure)) { + manager = chrome::GetDeviceManagerIdentity(); + } + + return manager.value_or(std::string()); } } // namespace
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc index 49ce3ee..cfc0fb5 100644 --- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc +++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
@@ -205,9 +205,7 @@ source->AddBoolean( "modulesDragAndDropEnabled", base::FeatureList::IsEnabled(ntp_features::kNtpModulesDragAndDrop)); - source->AddBoolean("modulesFirstRunExperienceEnabled", - base::FeatureList::IsEnabled( - ntp_features::kNtpModulesFirstRunExperience)); + source->AddBoolean("modulesFirstRunExperienceEnabled", IsModuleFreEnabled()); source->AddBoolean("modulesLoadEnabled", base::FeatureList::IsEnabled( ntp_features::kNtpModulesLoad)); source->AddInteger("modulesLoadTimeout",
diff --git a/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc b/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc index a685018..990d469a 100644 --- a/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc +++ b/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc
@@ -19,9 +19,8 @@ #include "ui/base/webui/web_ui_util.h" CustomizeChromeUI::CustomizeChromeUI(content::WebUI* web_ui) - : ui::MojoBubbleWebUIController(web_ui) { - Profile* profile = Profile::FromWebUI(web_ui); - + : ui::MojoBubbleWebUIController(web_ui), + profile_(Profile::FromWebUI(web_ui)) { content::WebUIDataSource* source = content::WebUIDataSource::Create( chrome::kChromeUICustomizeChromeSidePanelHost); @@ -36,7 +35,7 @@ kSidePanelCustomizeChromeResourcesSize), IDR_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_HTML); - content::WebUIDataSource::Add(profile, source); + content::WebUIDataSource::Add(profile_, source); } CustomizeChromeUI::~CustomizeChromeUI() = default;
diff --git a/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc b/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc index 884cb3e..a70bb4a 100644 --- a/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc +++ b/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc
@@ -69,12 +69,12 @@ source_browser->tab_strip_model()->DetachWebContentsAtForInsertion( from_index); - int add_types = TabStripModel::ADD_NONE; + int add_types = AddTabTypes::ADD_NONE; if (was_active) { - add_types |= TabStripModel::ADD_ACTIVE; + add_types |= AddTabTypes::ADD_ACTIVE; } if (was_pinned) { - add_types |= TabStripModel::ADD_PINNED; + add_types |= AddTabTypes::ADD_PINNED; } target_browser->tab_strip_model()->InsertWebContentsAt(
diff --git a/chrome/browser/unified_consent/unified_consent_browsertest.cc b/chrome/browser/unified_consent/unified_consent_browsertest.cc index 2b4f672..49cb381 100644 --- a/chrome/browser/unified_consent/unified_consent_browsertest.cc +++ b/chrome/browser/unified_consent/unified_consent_browsertest.cc
@@ -16,7 +16,7 @@ #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_profile.h" #include "components/embedder_support/pref_names.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include "components/unified_consent/unified_consent_metrics.h" #include "components/unified_consent/unified_consent_service.h" #include "content/public/test/browser_test.h"
diff --git a/chrome/browser/web_applications/test/fake_web_app_database_factory.cc b/chrome/browser/web_applications/test/fake_web_app_database_factory.cc index 4906698f..05f5a07 100644 --- a/chrome/browser/web_applications/test/fake_web_app_database_factory.cc +++ b/chrome/browser/web_applications/test/fake_web_app_database_factory.cc
@@ -12,7 +12,7 @@ #include "chrome/browser/web_applications/web_app_helpers.h" #include "components/sync/model/model_error.h" #include "components/sync/model/model_type_store.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/model_type_store_test_util.h" namespace web_app {
diff --git a/chrome/browser/web_applications/test/fake_web_app_provider.cc b/chrome/browser/web_applications/test/fake_web_app_provider.cc index edf2b63..0b88e94 100644 --- a/chrome/browser/web_applications/test/fake_web_app_provider.cc +++ b/chrome/browser/web_applications/test/fake_web_app_provider.cc
@@ -36,7 +36,7 @@ #include "chrome/common/chrome_switches.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/core/keyed_service.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "testing/gmock/include/gmock/gmock.h" namespace web_app {
diff --git a/chrome/browser/web_applications/test/fake_web_app_provider.h b/chrome/browser/web_applications/test/fake_web_app_provider.h index e5f8f9f4..47c39665 100644 --- a/chrome/browser/web_applications/test/fake_web_app_provider.h +++ b/chrome/browser/web_applications/test/fake_web_app_provider.h
@@ -10,7 +10,7 @@ #include "base/callback.h" #include "base/callback_list.h" #include "chrome/browser/web_applications/web_app_provider.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "testing/gmock/include/gmock/gmock.h" class KeyedService;
diff --git a/chrome/browser/web_applications/test/fake_web_app_registry_controller.h b/chrome/browser/web_applications/test/fake_web_app_registry_controller.h index ec3fdc93..284f6017 100644 --- a/chrome/browser/web_applications/test/fake_web_app_registry_controller.h +++ b/chrome/browser/web_applications/test/fake_web_app_registry_controller.h
@@ -16,7 +16,7 @@ #include "chrome/browser/web_applications/web_app_install_manager.h" #include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_sync_install_delegate.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "testing/gmock/include/gmock/gmock.h" #include "url/gurl.h"
diff --git a/chrome/browser/xsurface/android/java/src/org/chromium/chrome/browser/xsurface/ProcessScopeDependencyProvider.java b/chrome/browser/xsurface/android/java/src/org/chromium/chrome/browser/xsurface/ProcessScopeDependencyProvider.java index df92764..293854f 100644 --- a/chrome/browser/xsurface/android/java/src/org/chromium/chrome/browser/xsurface/ProcessScopeDependencyProvider.java +++ b/chrome/browser/xsurface/android/java/src/org/chromium/chrome/browser/xsurface/ProcessScopeDependencyProvider.java
@@ -51,7 +51,9 @@ * Provides experimental feature state to xsurface implementations. */ public interface FeatureStateProvider { - boolean isFeatureActive(String experimentName); + boolean isFeatureActive(String featureName); + boolean getBooleanParameterValue( + String featureName, String paramName, boolean defaultValue); } /** @@ -60,7 +62,18 @@ * The returned function must be called on the UI thread. */ default FeatureStateProvider getFeatureStateProvider() { - return (var experimentName) -> false; + return new FeatureStateProvider() { + @Override + public boolean isFeatureActive(String featureName) { + return false; + } + + @Override + public boolean getBooleanParameterValue( + String featureName, String paramName, boolean defaultValue) { + return false; + } + }; } /** @see {Log.e} */
diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index 7dc1260..e8ba5fd 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt
@@ -1 +1 @@ -chrome-linux-main-1660564771-0162c672cc18dc700d5279da121b9097f9b1d326.profdata +chrome-linux-main-1660586298-d8ee82923629a44e5ca8bcf8bc5fd33e4ba3bb83.profdata
diff --git a/chrome/build/mac-arm.pgo.txt b/chrome/build/mac-arm.pgo.txt index 22ae63a..0b134289 100644 --- a/chrome/build/mac-arm.pgo.txt +++ b/chrome/build/mac-arm.pgo.txt
@@ -1 +1 @@ -chrome-mac-arm-main-1660564771-f67dbb6e4559dd1a2b75aed6b6254eba9cb45a0c.profdata +chrome-mac-arm-main-1660586298-2836e78d4fbda95205a30dedbe1f118d9ae71008.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index 4e3b6d1..34c0cba 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1660564771-0dfbb6f26ed526e39e653609383d0b45cf159265.profdata +chrome-win32-main-1660586298-c914d01b1b949f2a28c615a53b3d3a0ba7009a6f.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index a9dd78d3..61d822d 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1660575473-e4baa6f015ca20ad94ecceb481649a23ceb2d3e6.profdata +chrome-win64-main-1660586298-d90bc9394f8c202fb20a0cf42c5530141aab9f10.profdata
diff --git a/chrome/chrome_cleaner/logging/scoped_timed_task_logger_unittest.cc b/chrome/chrome_cleaner/logging/scoped_timed_task_logger_unittest.cc index 60314c4b..18fa7ba3 100644 --- a/chrome/chrome_cleaner/logging/scoped_timed_task_logger_unittest.cc +++ b/chrome/chrome_cleaner/logging/scoped_timed_task_logger_unittest.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/check.h" #include "base/logging.h" +#include "base/test/bind.h" #include "chrome/chrome_cleaner/test/test_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -53,11 +54,9 @@ active_logging_messages_ = nullptr; } - void timer_callback(const base::TimeDelta&) { callback_called_ = true; } - + private: std::vector<std::string> logging_messages_; static std::vector<std::string>* active_logging_messages_; - bool callback_called_ = false; }; std::vector<std::string>* ScopedTimedTaskLoggerTest::active_logging_messages_ = @@ -66,11 +65,12 @@ } // namespace TEST_F(ScopedTimedTaskLoggerTest, CallbackCalled) { + bool callback_called = false; { - ScopedTimedTaskLogger timer(base::BindOnce( - &ScopedTimedTaskLoggerTest::timer_callback, base::Unretained(this))); + ScopedTimedTaskLogger timer(base::BindLambdaForTesting( + [&](const base::TimeDelta&) { callback_called = true; })); } - EXPECT_TRUE(callback_called_); + EXPECT_TRUE(callback_called); } TEST_F(ScopedTimedTaskLoggerTest, NoLog) {
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 1a8ff807..c7cf4053 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -3499,7 +3499,7 @@ if (enable_extensions) { sources += [ "../browser/supervised_user/supervised_user_extension_browsertest.cc", - "../browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view_browsertest.cc", + "../browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_browsertest.cc", "../browser/ui/views/supervised_user/parent_permission_dialog_view_browsertest.cc", ] } @@ -8653,6 +8653,7 @@ "../browser/ui/views/tabs/tab_hover_card_controller_unittest.cc", "../browser/ui/views/tabs/tab_hover_card_metrics_unittest.cc", "../browser/ui/views/tabs/tab_strip_layout_unittest.cc", + "../browser/ui/views/tabs/tab_strip_scroll_container_unittest.cc", "../browser/ui/views/tabs/tab_strip_unittest.cc", "../browser/ui/views/tabs/tab_unittest.cc", "../browser/ui/views/toolbar/chrome_labs_bubble_view_model_unittest.cc",
diff --git a/chrome/test/DEPS b/chrome/test/DEPS index c318374..6244da4 100644 --- a/chrome/test/DEPS +++ b/chrome/test/DEPS
@@ -66,7 +66,7 @@ "+components/storage_monitor", "+components/subresource_filter/content/browser", "+components/federated_learning", - "+components/sync/test/model", + "+components/sync/test", "+components/sync_preferences", "+components/unified_consent", "+components/update_client",
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index e9b84eaf..5ea886b 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc
@@ -81,8 +81,8 @@ #include "components/security_interstitials/content/stateful_ssl_host_state_delegate.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_test_utils.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/user_prefs/user_prefs.h"
diff --git a/chrome/test/data/extensions/api_test/webrequest_sendmessage/manifest.json b/chrome/test/data/extensions/api_test/webrequest_sendmessage/manifest.json index 8608e51..ce12728 100644 --- a/chrome/test/data/extensions/api_test/webrequest_sendmessage/manifest.json +++ b/chrome/test/data/extensions/api_test/webrequest_sendmessage/manifest.json
@@ -5,6 +5,7 @@ "description": "Tests the SendMessageToExtension feature of declarative webRequest API.", "permissions": ["declarativeWebRequest", "<all_urls>"], "background": { - "scripts": ["background.js"] + "scripts": ["background.js"], + "persistent": true } }
diff --git a/chrome/test/data/webui/chromeos/os_feedback_ui/file_attachment_test.js b/chrome/test/data/webui/chromeos/os_feedback_ui/file_attachment_test.js index 95ddc38..7c95590 100644 --- a/chrome/test/data/webui/chromeos/os_feedback_ui/file_attachment_test.js +++ b/chrome/test/data/webui/chromeos/os_feedback_ui/file_attachment_test.js
@@ -5,7 +5,10 @@ import 'chrome://resources/mojo/mojo/public/mojom/base/big_buffer.mojom-lite.js'; import 'chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-lite.js'; +import {FakeFeedbackServiceProvider} from 'chrome://os-feedback/fake_feedback_service_provider.js'; +import {FeedbackAppPreSubmitAction} from 'chrome://os-feedback/feedback_types.js'; import {FileAttachmentElement} from 'chrome://os-feedback/file_attachment.js'; +import {setFeedbackServiceProviderForTesting} from 'chrome://os-feedback/mojo_interface_provider.js'; import {mojoString16ToString} from 'chrome://resources/ash/common/mojo_utils.js'; import {getDeepActiveElement} from 'chrome://resources/js/util.m.js'; @@ -21,8 +24,13 @@ /** @type {?FileAttachmentElement} */ let page = null; + /** @type {?FakeFeedbackServiceProvider} */ + let feedbackServiceProvider; + setup(() => { document.body.innerHTML = ''; + feedbackServiceProvider = new FakeFeedbackServiceProvider(); + setFeedbackServiceProviderForTesting(feedbackServiceProvider); }); teardown(() => { @@ -59,6 +67,17 @@ return element.textContent.trim(); } + /** + * @param {number} callCounts + * @param {FeedbackAppPreSubmitAction} action + * @private + */ + function verifyRecordPreSubmitActionCallCount(callCounts, action) { + assertEquals( + callCounts, + feedbackServiceProvider.getRecordPreSubmitActionCallCount(action)); + } + // Test the page is loaded with expected HTML elements. test('elementLoaded', async () => { await initializePage(); @@ -301,6 +320,8 @@ // focus on the close dialog icon button. test('selectedImagePreviewDialog', async () => { await initializePage(); + verifyRecordPreSubmitActionCallCount( + 0, FeedbackAppPreSubmitAction.kViewedImage); const fakeData = [12, 11, 99]; /** @type {!File} */ @@ -328,6 +349,9 @@ imageButton.click(); await imageClickPromise; + verifyRecordPreSubmitActionCallCount( + 1, FeedbackAppPreSubmitAction.kViewedImage); + // The preview dialog's title should be set properly. assertEquals('fake.png', getElementContent('#modalDialogTitleText'));
diff --git a/chrome/test/data/webui/chromeos/os_feedback_ui/share_data_page_test.js b/chrome/test/data/webui/chromeos/os_feedback_ui/share_data_page_test.js index 3ff1de4..0d47b306 100644 --- a/chrome/test/data/webui/chromeos/os_feedback_ui/share_data_page_test.js +++ b/chrome/test/data/webui/chromeos/os_feedback_ui/share_data_page_test.js
@@ -594,31 +594,39 @@ }); /** - * Test that feedbackServiceProvider.openMetricsDialog is called - * when #histogramsLink ("metrics") link is clicked. + * Test that openMetricsDialog and recordPreSubmitAction are called when + * #histogramsLink ("metrics") link is clicked. */ test('openMetricsDialog', async () => { await initializePage(); assertEquals(0, feedbackServiceProvider.getOpenMetricsDialogCallCount()); + verifyRecordPreSubmitActionCallCount( + 0, FeedbackAppPreSubmitAction.kViewedMetrics); getElement('#histogramsLink').click(); assertEquals(1, feedbackServiceProvider.getOpenMetricsDialogCallCount()); + verifyRecordPreSubmitActionCallCount( + 1, FeedbackAppPreSubmitAction.kViewedMetrics); }); /** - * Test that feedbackServiceProvider.openSystemInfoDialog is called - * when #sysInfoLink ("system and app info") link is clicked. + * Test that openSystemInfoDialog and recordPreSubmitAction are called when + * #sysInfoLink ("system and app info") link is clicked. */ test('openSystemInfoDialog', async () => { await initializePage(); assertEquals(0, feedbackServiceProvider.getOpenSystemInfoDialogCallCount()); + verifyRecordPreSubmitActionCallCount( + 0, FeedbackAppPreSubmitAction.kViewedSystemAndAppInfo); getElement('#sysInfoLink').click(); assertEquals(1, feedbackServiceProvider.getOpenSystemInfoDialogCallCount()); + verifyRecordPreSubmitActionCallCount( + 1, FeedbackAppPreSubmitAction.kViewedSystemAndAppInfo); }); /**
diff --git a/chrome/test/webapps/file_reading.py b/chrome/test/webapps/file_reading.py index d329ce9..f5d0a58 100755 --- a/chrome/test/webapps/file_reading.py +++ b/chrome/test/webapps/file_reading.py
@@ -19,6 +19,7 @@ from models import ActionType from models import ActionsByName from models import CoverageTest +from models import EnumsByType from models import PartialAndFullCoverageByBaseName from models import TestIdsByPlatform from models import TestIdsByPlatformSet @@ -67,6 +68,61 @@ return output +def expand_wildcards_in_action(action: str, enums: EnumsByType) -> List[str]: + """ + Takes an action string that could contain enum wildcards, and returns the + list of all combinations of actions with all wildcards fully expanded. + + Example input: + - action: 'Action(EnumType::All, EnumType::All)' + - enums: {'EnumType': EnumType('EnumType', ['Value1', 'Value2'])} + Example output: + - ['Action(Value1, Value1)', 'Action(Value1, Value2)', + 'Action(Value2, Value1)', 'Action(Value2, Value2)'] + """ + if "::All" not in action: + return [action] + output: List[str] = [] + for type, enum in enums.items(): + wildcard_str = type + "::All" + if wildcard_str in action: + prefix = action[:action.index(wildcard_str)] + postfix = action[action.index(wildcard_str) + len(wildcard_str):] + for value in enum.values: + output.extend( + expand_wildcards_in_action(prefix + value + postfix, + enums)) + return output + + +def expand_tests_from_action_parameter_wildcards(enums: EnumsByType, + actions: List[str] + ) -> List[List[str]]: + """ + Takes a list of actions for a test that could contain argument wildcards. + Returns a list of tests the expand out all combination of argument + wildcards. + Example input: + - actions: ['Action1(EnumType::All), Action2(EnumType::All)'] + - enums: {'EnumType': EnumType('EnumType', ['Value1', 'Value2'])} + Example output: + - [['Action1(Value1)', 'Action2(Value1)'], + ['Action1(Value1)', 'Action2(Value2)'], + ['Action1(Value2)', 'Action2(Value1)'], + ['Action1(Value2)', 'Action2(Value2)']] + """ + if not actions: + return [[]] + current_elements: List[str] = expand_wildcards_in_action(actions[0], enums) + output: List[List[str]] = [] + following_output = expand_tests_from_action_parameter_wildcards( + enums, actions[1:]) + for following_list in following_output: + for element in current_elements: + output.append([element] + following_list) + return output + + def resolve_bash_style_replacement(output_action_str: str, argument_values: List[str]): for i, arg in enumerate(argument_values): @@ -159,10 +215,10 @@ return actions_base_name_to_coverage -def read_enums_file(enums_file_lines: List[str]) -> Dict[str, ArgEnum]: +def read_enums_file(enums_file_lines: List[str]) -> EnumsByType: """Reads the enums markdown file. """ - enums_by_type: Dict[str, ArgEnum] = {} + enums_by_type: EnumsByType = {} for i, row in enumerate_markdown_file_lines_to_table_rows( enums_file_lines): if len(row) < MIN_COLUMNS_ENUMS_FILE: @@ -321,13 +377,19 @@ for human_friendly_action_name in output_unresolved_action_names: bash_replaced_name = resolve_bash_style_replacement( human_friendly_action_name, arg_combination) + + # Handle any wildcards in the actions + wildcart_expanded_actions = expand_wildcards_in_action( + bash_replaced_name, enums_by_type) + # Output actions for parameterized actions are not allowed to # use 'defaults', and the action author must explicitly # populate all arguments with bash-style replacements or static # values. - output_canonical_action_names.append( - human_friendly_name_to_canonical_action_name( - bash_replaced_name, {})) + for action_name in wildcart_expanded_actions: + output_canonical_action_names.append( + human_friendly_name_to_canonical_action_name( + action_name, {})) if name in actions_by_name: raise ValueError(f"Cannot add duplicate action {name} on row " @@ -374,6 +436,7 @@ def read_unprocessed_coverage_tests_file( coverage_file_lines: List[str], actions_by_name: ActionsByName, + enums_by_type: EnumsByType, action_base_name_to_default_arg: Dict[str, str]) -> List[CoverageTest]: """Reads the coverage tests markdown file. @@ -402,21 +465,30 @@ platforms = TestPlatform.get_platforms_from_chars(row[0]) if len(platforms) == 0: raise ValueError(f"Row {i} has invalid platforms: {row[0]}") - actions = [] - for action_name in row[1:]: - action_name = action_name.strip() - if action_name == "": - continue - action_name = human_friendly_name_to_canonical_action_name( - action_name, action_base_name_to_default_arg) - if action_name not in actions_by_name: - missing_actions.append(action_name) - logging.error(f"Could not find action on row {i!r}: " - f"{action_name}") - continue - actions.append(actions_by_name[action_name]) - coverage_test = CoverageTest(actions, platforms) - required_coverage_tests.append(coverage_test) + # Filter out all blank actions. + original_action_strs = [ + action_str for action_str in row[1:] if action_str.strip() + ] + # If any of the actions had parameter wildcards (like + # "WindowOption::All"), then this expands those into multiple tests. + expanded_tests = expand_tests_from_action_parameter_wildcards( + enums_by_type, original_action_strs) + for test_actions in expanded_tests: + actions: List[Action] = [] + for action_name in test_actions: + action_name = action_name.strip() + if action_name == "": + continue + action_name = human_friendly_name_to_canonical_action_name( + action_name, action_base_name_to_default_arg) + if action_name not in actions_by_name: + missing_actions.append(action_name) + logging.error(f"Could not find action on row {i!r}: " + f"{action_name}") + continue + actions.append(actions_by_name[action_name]) + coverage_test = CoverageTest(actions, platforms) + required_coverage_tests.append(coverage_test) if missing_actions: raise ValueError(f"Actions missing from actions dictionary: " f"{', '.join(missing_actions)}")
diff --git a/chrome/test/webapps/file_reading_unittest.py b/chrome/test/webapps/file_reading_unittest.py index 246891f1..4495560 100755 --- a/chrome/test/webapps/file_reading_unittest.py +++ b/chrome/test/webapps/file_reading_unittest.py
@@ -9,6 +9,7 @@ import unittest from file_reading import enumerate_all_argument_combinations +from file_reading import expand_tests_from_action_parameter_wildcards from file_reading import enumerate_markdown_file_lines_to_table_rows from file_reading import human_friendly_name_to_canonical_action_name from file_reading import get_tests_in_browsertest @@ -173,9 +174,10 @@ with open(coverage_filename) as f: coverage_tsv = f.readlines() coverage_tests = read_unprocessed_coverage_tests_file( - coverage_tsv, actions, action_base_name_to_default_param) + coverage_tsv, actions, enums, + action_base_name_to_default_param) - self.assertEqual(len(coverage_tests), 4) + self.assertEqual(6, len(coverage_tests)) def test_browsertest_detection(self): browsertest_filename = os.path.join(TEST_DATA_DIR, "tests_default.cc") @@ -190,6 +192,26 @@ {TestPlatform.LINUX, TestPlatform.CHROME_OS, TestPlatform.MAC}, tests_and_platforms) + def test_action_param_expansion(self): + enum_map: Dict[str, ArgEnum] = { + "EnumType": ArgEnum("EnumType", ["Value1", "Value2"], None) + } + actions: List[str] = [ + "Action1(EnumType::All)", "Action2(EnumType::All, EnumType::All)" + ] + + combinations = expand_tests_from_action_parameter_wildcards( + enum_map, actions) + expected = [['Action1(Value1)', 'Action2(Value1, Value1)'], + ['Action1(Value2)', 'Action2(Value1, Value1)'], + ['Action1(Value1)', 'Action2(Value1, Value2)'], + ['Action1(Value2)', 'Action2(Value1, Value2)'], + ['Action1(Value1)', 'Action2(Value2, Value1)'], + ['Action1(Value2)', 'Action2(Value2, Value1)'], + ['Action1(Value1)', 'Action2(Value2, Value2)'], + ['Action1(Value2)', 'Action2(Value2, Value2)']] + self.assertCountEqual(combinations, expected) + if __name__ == '__main__': unittest.main()
diff --git a/chrome/test/webapps/generate_framework_tests_and_coverage.py b/chrome/test/webapps/generate_framework_tests_and_coverage.py index dfb5af6..154929b 100755 --- a/chrome/test/webapps/generate_framework_tests_and_coverage.py +++ b/chrome/test/webapps/generate_framework_tests_and_coverage.py
@@ -68,7 +68,7 @@ actions_csv, enums, platform_supported_actions) required_coverage_tests = read_unprocessed_coverage_tests_file( - coverage_required_file.readlines(), actions, + coverage_required_file.readlines(), actions, enums, action_base_name_to_default_param) required_coverage_tests = expand_parameterized_tests(
diff --git a/chrome/test/webapps/generate_framework_tests_and_coverage_unittest.py b/chrome/test/webapps/generate_framework_tests_and_coverage_unittest.py index 9befa97..33c7e0b9 100755 --- a/chrome/test/webapps/generate_framework_tests_and_coverage_unittest.py +++ b/chrome/test/webapps/generate_framework_tests_and_coverage_unittest.py
@@ -69,8 +69,10 @@ as coverage_file, \ open(expected_coverage_filename, "r", \ encoding="utf-8") as expected_file: - self.assertListEqual(list(coverage_file.readlines()), - list(expected_file.readlines())) + self.assertListEqual( + list(expected_file.readlines()), + list(coverage_file.readlines()), + f"file: {expected_coverage_filename}") if __name__ == '__main__':
diff --git a/chrome/test/webapps/graph_analysis_unittest.py b/chrome/test/webapps/graph_analysis_unittest.py index 7dcbb298..0eb44f3a 100755 --- a/chrome/test/webapps/graph_analysis_unittest.py +++ b/chrome/test/webapps/graph_analysis_unittest.py
@@ -47,7 +47,7 @@ actions_file.readlines(), enums, platform_supported_actions) required_coverage_tests = read_unprocessed_coverage_tests_file( - coverage_file.readlines(), actions, + coverage_file.readlines(), actions, enums, action_base_name_to_default_param) required_coverage_tests = expand_parameterized_tests(
diff --git a/chrome/test/webapps/models.py b/chrome/test/webapps/models.py index fe78a75..1978fe8 100755 --- a/chrome/test/webapps/models.py +++ b/chrome/test/webapps/models.py
@@ -314,5 +314,6 @@ CoverageTestsByPlatformSet = Dict[FrozenSet[TestPlatform], List[CoverageTest]] CoverageTestsByPlatform = Dict[TestPlatform, List[CoverageTest]] ActionsByName = Dict[str, Action] +EnumsByType = Dict[str, ArgEnum] PartialAndFullCoverageByBaseName = Dict[ str, Tuple[Set[TestPlatform], Set[TestPlatform]]]
diff --git a/chrome/test/webapps/test_analysis_unittest.py b/chrome/test/webapps/test_analysis_unittest.py index a0d45800..7277eb27 100755 --- a/chrome/test/webapps/test_analysis_unittest.py +++ b/chrome/test/webapps/test_analysis_unittest.py
@@ -12,6 +12,7 @@ from file_reading import read_platform_supported_actions from file_reading import read_unprocessed_coverage_tests_file from models import Action +from models import EnumsByType from models import ActionsByName from models import ActionType from models import CoverageTest @@ -80,6 +81,7 @@ actions: ActionsByName = {} action_base_name_to_default_param = {} + enums: EnumsByType = {} with open(actions_filename, "r", encoding="utf-8") as f, \ open(supported_actions_filename, "r", encoding="utf-8") \ as supported_actions_file, \ @@ -95,7 +97,8 @@ coverage_tests: List[CoverageTest] = [] with open(coverage_filename, "r", encoding="utf-8") as f: coverage_tests = read_unprocessed_coverage_tests_file( - f.readlines(), actions, action_base_name_to_default_param) + f.readlines(), actions, enums, + action_base_name_to_default_param) coverage_tests = expand_parameterized_tests(coverage_tests) # Compare with expected @@ -104,7 +107,8 @@ "expected_processed_coverage.md") with open(processed_filename, "r", encoding="utf-8") as f: expected_processed_tests = read_unprocessed_coverage_tests_file( - f.readlines(), actions, action_base_name_to_default_param) + f.readlines(), actions, enums, + action_base_name_to_default_param) # Hack for easy comparison and printing: transform coverage tests into # a Tuple[List[str], Set[TestPlatform]].
diff --git a/chrome/test/webapps/test_data/expected_coverage_cros.tsv b/chrome/test/webapps/test_data/expected_coverage_cros.tsv index b917547..8d86ca5 100644 --- a/chrome/test/webapps/test_data/expected_coverage_cros.tsv +++ b/chrome/test/webapps/test_data/expected_coverage_cros.tsv
@@ -1,9 +1,11 @@ # This is a generated file. -# Full coverage: 31%, with partial coverage: 31% +# Full coverage: 70%, with partial coverage: 70% state_change_a_Chicken🌕 check_a_Chicken🌕 state_change_a_Chicken🌕 check_b_Chicken_Green🌕 state_change_b_Chicken_Green🌑 check_a_Chicken🌑 state_change_b_Chicken_Green🌑 check_b_Chicken_Green🌑 -state_change_a_Dog🌑 check_b_Dog_Red🌑 +state_change_a_Dog🌕 check_b_Dog_Red🌕 state_change_a_Chicken🌕 state_change_b_Chicken_Red🌑 check_a_Chicken🌑 -state_change_a_Dog🌑 state_change_a_Chicken🌑 check_b_Chicken_Green🌑 +state_change_a_Dog🌕 state_change_a_Chicken🌕 check_b_Chicken_Green🌕 +state_change_a_Dog🌕 check_a_Chicken🌕 +state_change_a_Dog🌕 check_a_Dog🌕
diff --git a/chrome/test/webapps/test_data/expected_coverage_linux.tsv b/chrome/test/webapps/test_data/expected_coverage_linux.tsv index 479f956f..07a8e9e9 100644 --- a/chrome/test/webapps/test_data/expected_coverage_linux.tsv +++ b/chrome/test/webapps/test_data/expected_coverage_linux.tsv
@@ -5,3 +5,5 @@ state_change_b_Chicken_Green🌕 check_a_Chicken🌕 state_change_b_Chicken_Green🌕 check_b_Chicken_Green🌕 state_change_a_Dog🌕 check_b_Dog_Red🌕 +state_change_a_Dog🌕 check_a_Chicken🌕 +state_change_a_Dog🌕 check_a_Dog🌕
diff --git a/chrome/test/webapps/test_data/expected_coverage_mac.tsv b/chrome/test/webapps/test_data/expected_coverage_mac.tsv index e4604cc..8c00f47 100644 --- a/chrome/test/webapps/test_data/expected_coverage_mac.tsv +++ b/chrome/test/webapps/test_data/expected_coverage_mac.tsv
@@ -5,3 +5,5 @@ state_change_b_Chicken_Green🌕 check_a_Chicken🌓 state_change_b_Chicken_Green🌕 check_b_Chicken_Green🌓 state_change_a_Dog🌕 check_b_Dog_Red🌓 +state_change_a_Dog🌕 check_a_Chicken🌓 +state_change_a_Dog🌕 check_a_Dog🌓
diff --git a/chrome/test/webapps/test_data/expected_coverage_win.tsv b/chrome/test/webapps/test_data/expected_coverage_win.tsv index 4602df7..6b99c7ab 100644 --- a/chrome/test/webapps/test_data/expected_coverage_win.tsv +++ b/chrome/test/webapps/test_data/expected_coverage_win.tsv
@@ -1,7 +1,9 @@ # This is a generated file. -# Full coverage: 60%, with partial coverage: 60% +# Full coverage: 71%, with partial coverage: 71% state_change_a_Chicken🌑 check_a_Chicken🌑 state_change_a_Chicken🌑 check_b_Chicken_Green🌑 state_change_b_Chicken_Green🌕 check_a_Chicken🌕 state_change_b_Chicken_Green🌕 check_b_Chicken_Green🌕 state_change_a_Dog🌕 check_b_Dog_Red🌕 +state_change_a_Dog🌕 check_a_Chicken🌕 +state_change_a_Dog🌕 check_a_Dog🌕
diff --git a/chrome/test/webapps/test_data/expected_processed_coverage.md b/chrome/test/webapps/test_data/expected_processed_coverage.md index 1c8bfc1..d8342e6 100644 --- a/chrome/test/webapps/test_data/expected_processed_coverage.md +++ b/chrome/test/webapps/test_data/expected_processed_coverage.md
@@ -13,3 +13,7 @@ # Generated from the fourth test: | C | state_change_a(Dog) | state_change_a(Chicken) | check_b(Chicken, Green) | + +# Generated from fifth test +| MWLC | state_change_a(Dog) | check_a(Dog) | +| MWLC | state_change_a(Dog) | check_a(Chicken) | \ No newline at end of file
diff --git a/chrome/test/webapps/test_data/expected_test_txt/tests_default_cros.txt b/chrome/test/webapps/test_data/expected_test_txt/tests_default_cros.txt index 24b9258..24134f1 100644 --- a/chrome/test/webapps/test_data/expected_test_txt/tests_default_cros.txt +++ b/chrome/test/webapps/test_data/expected_test_txt/tests_default_cros.txt
@@ -1,10 +1,12 @@ -IN_PROC_BROWSER_TEST_F(TestNameCros, WebAppIntegration_3Dog_2DogRed_3Chicken_2ChickenGreen) { +IN_PROC_BROWSER_TEST_F(TestNameCros, WebAppIntegration_3Dog_2DogRed_1Chicken_1Dog_3Chicken_2ChickenGreen) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webaps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.StateChangeA(Animal::kDog); helper_.CheckB(Animal::kDog, Color::kRed); + helper_.CheckA(Animal::kChicken); + helper_.CheckA(Animal::kDog); helper_.StateChangeA(Animal::kChicken); helper_.CheckB(Animal::kChicken, Color::kGreen); } \ No newline at end of file
diff --git a/chrome/test/webapps/test_data/expected_test_txt/tests_default_mac_win_linux.txt b/chrome/test/webapps/test_data/expected_test_txt/tests_default_mac_win_linux.txt index 1a30ab01..ddab5a08 100644 --- a/chrome/test/webapps/test_data/expected_test_txt/tests_default_mac_win_linux.txt +++ b/chrome/test/webapps/test_data/expected_test_txt/tests_default_mac_win_linux.txt
@@ -7,11 +7,13 @@ helper_.CheckA(Animal::kChicken); helper_.CheckB(Animal::kChicken, Color::kGreen); } -IN_PROC_BROWSER_TEST_F(TestNameMacWinLinux, WebAppIntegration_3Dog_2DogRed) { +IN_PROC_BROWSER_TEST_F(TestNameMacWinLinux, WebAppIntegration_3Dog_2DogRed_1Chicken_1Dog) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webaps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.StateChangeA(Animal::kDog); helper_.CheckB(Animal::kDog, Color::kRed); + helper_.CheckA(Animal::kChicken); + helper_.CheckA(Animal::kDog); } \ No newline at end of file
diff --git a/chrome/test/webapps/test_data/test_unprocessed_coverage.md b/chrome/test/webapps/test_data/test_unprocessed_coverage.md index b7e8b60..866e9f9 100644 --- a/chrome/test/webapps/test_data/test_unprocessed_coverage.md +++ b/chrome/test/webapps/test_data/test_unprocessed_coverage.md
@@ -8,3 +8,6 @@ # Tests only for ChromeOS | C | state_change_a | state_change_b(Chicken, Red) | check_a | | C | state_change_a(Dog) | state_change_a(Chicken) | check_b(Chicken, Green) | + +# This test should generate 2 processed tests: +| MWLC | changes(Dog) | check_a(Animal::All) | \ No newline at end of file
diff --git a/chrome/test/webapps/test_data/tests_change_b_mac_win_linux.cc b/chrome/test/webapps/test_data/tests_change_b_mac_win_linux.cc index fc81961..6a3ea26 100644 --- a/chrome/test/webapps/test_data/tests_change_b_mac_win_linux.cc +++ b/chrome/test/webapps/test_data/tests_change_b_mac_win_linux.cc
@@ -13,11 +13,14 @@ helper_.CheckB(Animal::kChicken, Color::kGreen); } -IN_PROC_BROWSER_TEST_F(TestNameMacWinLinux, WebAppIntegration_3Dog_2DogRed) { +IN_PROC_BROWSER_TEST_F(TestNameMacWinLinux, + WebAppIntegration_3Dog_2DogRed_1Chicken_1Dog) { // Test contents are generated by script. Please do not modify! // See `docs/webapps/why-is-this-test-failing.md` or // `docs/webapps/integration-testing-framework` for more info. // Sheriffs: Disabling this test is supported. helper_.StateChangeA(Animal::kDog); helper_.CheckB(Animal::kDog, Color::kRed); + helper_.CheckA(Animal::kChicken); + helper_.CheckA(Animal::kDog); }
diff --git a/chrome/updater/app/app_server.cc b/chrome/updater/app/app_server.cc index 60e4fad..ad24bd4d 100644 --- a/chrome/updater/app/app_server.cc +++ b/chrome/updater/app/app_server.cc
@@ -82,12 +82,11 @@ if (!local_prefs->GetQualified()) { global_prefs = nullptr; prefs_ = local_prefs; + config_ = base::MakeRefCounted<Configurator>(prefs_, external_constants_); return IsInternalService() ? base::BindOnce(&AppServer::ActiveDutyInternal, this, MakeQualifyingUpdateServiceInternal( - base::MakeRefCounted<Configurator>( - prefs_, external_constants_), - local_prefs)) + config_, local_prefs)) : base::BindOnce(&AppServer::ActiveDuty, this, MakeInactiveUpdateService()); } @@ -106,10 +105,9 @@ server_starts_ = global_prefs->CountServerStarts(); prefs_ = global_prefs; - return base::BindOnce( - &AppServer::ActiveDuty, this, - base::MakeRefCounted<UpdateServiceImpl>( - base::MakeRefCounted<Configurator>(prefs_, external_constants_))); + config_ = base::MakeRefCounted<Configurator>(prefs_, external_constants_); + return base::BindOnce(&AppServer::ActiveDuty, this, + base::MakeRefCounted<UpdateServiceImpl>(config_)); } void AppServer::Uninitialize() {
diff --git a/chrome/updater/app/app_server.h b/chrome/updater/app/app_server.h index 3ff6fad..78b21fc 100644 --- a/chrome/updater/app/app_server.h +++ b/chrome/updater/app/app_server.h
@@ -9,6 +9,7 @@ #include "base/callback_forward.h" #include "base/memory/scoped_refptr.h" #include "chrome/updater/app/app.h" +#include "chrome/updater/configurator.h" #include "chrome/updater/external_constants.h" #include "chrome/updater/prefs.h" @@ -37,6 +38,8 @@ scoped_refptr<const UpdaterPrefs> prefs() const { return prefs_; } + scoped_refptr<Configurator> config() const { return config_; } + // Overrides of App. void Uninitialize() override; @@ -81,6 +84,7 @@ base::OnceClosure first_task_; scoped_refptr<ExternalConstants> external_constants_; scoped_refptr<UpdaterPrefs> prefs_; + scoped_refptr<Configurator> config_; // If true, this version of the updater should uninstall itself during // shutdown.
diff --git a/chrome/updater/app/server/win/com_classes_legacy.cc b/chrome/updater/app/server/win/com_classes_legacy.cc index d64d0ca..deefd66 100644 --- a/chrome/updater/app/server/win/com_classes_legacy.cc +++ b/chrome/updater/app/server/win/com_classes_legacy.cc
@@ -44,6 +44,7 @@ #include "chrome/updater/policy/manager.h" #include "chrome/updater/policy/service.h" #include "chrome/updater/prefs.h" +#include "chrome/updater/refresh_dm_policies_task.h" #include "chrome/updater/update_service.h" #include "chrome/updater/updater_scope.h" #include "chrome/updater/updater_version.h" @@ -916,9 +917,16 @@ return S_OK; } -// TODO(crbug.com/1293203): Implement this method. STDMETHODIMP PolicyStatusImpl::refreshPolicies() { - return E_NOTIMPL; + AppServerSingletonInstance()->main_task_runner()->PostTask( + FROM_HERE, + base::BindOnce(&RefreshDMPoliciesTask::Run, + base::MakeRefCounted<RefreshDMPoliciesTask>( + AppServerSingletonInstance()->config(), + AppServerSingletonInstance()->main_task_runner()), + base::DoNothing())); + + return S_OK; } STDMETHODIMP PolicyStatusImpl::get_lastCheckPeriodMinutes(
diff --git a/chrome/updater/app/server/win/server.h b/chrome/updater/app/server/win/server.h index 0c7ab67d..4a5e0c2 100644 --- a/chrome/updater/app/server/win/server.h +++ b/chrome/updater/app/server/win/server.h
@@ -13,12 +13,12 @@ #include "base/task/sequenced_task_runner.h" #include "chrome/updater/app/app.h" #include "chrome/updater/app/app_server.h" +#include "chrome/updater/configurator.h" #include "chrome/updater/update_service.h" #include "chrome/updater/update_service_internal.h" namespace updater { -class Configurator; struct RegistrationRequest; // The COM objects involved in this server are free threaded. Incoming COM calls @@ -56,6 +56,8 @@ scoped_refptr<const UpdaterPrefs> prefs() const { return AppServer::prefs(); } + scoped_refptr<Configurator> config() const { return AppServer::config(); } + // Handles COM factory unregistration then triggers program shutdown. This // function runs on a COM RPC thread when the WRL module is destroyed. void Stop();
diff --git a/chrome/updater/check_for_updates_task.cc b/chrome/updater/check_for_updates_task.cc index 3881801..bd7f95f 100644 --- a/chrome/updater/check_for_updates_task.cc +++ b/chrome/updater/check_for_updates_task.cc
@@ -44,7 +44,8 @@ base::Time::NowFromSystemTime() - persisted_data->GetLastChecked(); if (time_since_update.is_positive() && time_since_update < check_delay) { VLOG(0) << "Skipping checking for updates: last update was " - << time_since_update.InMinutes() << " minutes ago."; + << time_since_update.InMinutes() + << " minutes ago. check_delay == " << check_delay.InMinutes(); return true; }
diff --git a/chrome/updater/configurator.cc b/chrome/updater/configurator.cc index 1f648f7..c069461 100644 --- a/chrome/updater/configurator.cc +++ b/chrome/updater/configurator.cc
@@ -14,6 +14,7 @@ #include "base/enterprise_util.h" #include "base/memory/scoped_refptr.h" #include "base/rand_util.h" +#include "base/time/time.h" #include "base/version.h" #include "build/build_config.h" #include "chrome/updater/activity.h" @@ -46,12 +47,6 @@ namespace updater { -namespace { - -const int kDelayOneMinute = 60; - -} // namespace - Configurator::Configurator(scoped_refptr<UpdaterPrefs> prefs, scoped_refptr<ExternalConstants> external_constants) : prefs_(prefs), @@ -77,7 +72,7 @@ int Configurator::NextCheckDelay() const { int minutes = 0; CHECK(policy_service_->GetLastCheckPeriodMinutes(nullptr, &minutes)); - return minutes * kDelayOneMinute; + return base::Minutes(minutes).InSeconds(); } int Configurator::OnDemandDelay() const {
diff --git a/chrome/updater/constants.cc b/chrome/updater/constants.cc index 276c34a..a5a9ab5 100644 --- a/chrome/updater/constants.cc +++ b/chrome/updater/constants.cc
@@ -34,6 +34,7 @@ const char kCrashHandlerSwitch[] = "crash-handler"; const char kUpdateSwitch[] = "update"; const char kInstallSwitch[] = "install"; +const char kRuntimeSwitch[] = "runtime"; const char kUninstallSwitch[] = "uninstall"; const char kUninstallSelfSwitch[] = "uninstall-self"; const char kUninstallIfUnusedSwitch[] = "uninstall-if-unused";
diff --git a/chrome/updater/constants.h b/chrome/updater/constants.h index ec530c71..dc2dcbc 100644 --- a/chrome/updater/constants.h +++ b/chrome/updater/constants.h
@@ -79,6 +79,7 @@ // Installs the updater. extern const char kInstallSwitch[]; +extern const char kRuntimeSwitch[]; // Contains the meta installer tag. The tag is a string of arguments, separated // by a delimiter (in this case, the delimiter is =). The tag is typically @@ -205,6 +206,10 @@ // to complete. constexpr base::TimeDelta kWaitForAppInstaller = base::Minutes(15); +// The default last check period is 4.5 hours. +constexpr base::TimeDelta kDefaultLastCheckPeriod = + base::Hours(4) + base::Minutes(30); + #if BUILDFLAG(IS_WIN) // How often the installer progress from registry is sampled. This value may // be changed to provide a smoother progress experience (crbug.com/1067475).
diff --git a/chrome/updater/policy/manager.cc b/chrome/updater/policy/manager.cc index ae2bfbf..99902a8 100644 --- a/chrome/updater/policy/manager.cc +++ b/chrome/updater/policy/manager.cc
@@ -7,16 +7,11 @@ #include <string> #include <vector> +#include "base/time/time.h" #include "chrome/updater/constants.h" namespace updater { -namespace { - -const int kDelayOneHour = 60 * 60; - -} // namespace - UpdatesSuppressedTimes::UpdatesSuppressedTimes() = default; UpdatesSuppressedTimes::~UpdatesSuppressedTimes() = default; @@ -106,7 +101,7 @@ } bool DefaultValuesPolicyManager::GetLastCheckPeriodMinutes(int* minutes) const { - *minutes = 4 * kDelayOneHour + 30; + *minutes = kDefaultLastCheckPeriod.InMinutes(); return true; }
diff --git a/chrome/updater/policy/service_unittest.cc b/chrome/updater/policy/service_unittest.cc index 8a4f607..7605c90 100644 --- a/chrome/updater/policy/service_unittest.cc +++ b/chrome/updater/policy/service_unittest.cc
@@ -126,7 +126,7 @@ int last_check = 0; EXPECT_TRUE(policy_service->GetLastCheckPeriodMinutes(nullptr, &last_check)); - EXPECT_EQ(last_check, 14430); + EXPECT_EQ(last_check, 270); int install_policy = 0; EXPECT_TRUE(policy_service->GetEffectivePolicyForAppInstalls(
diff --git a/chrome/updater/test/integration_tests_win.cc b/chrome/updater/test/integration_tests_win.cc index ae377ac..e6576bc5 100644 --- a/chrome/updater/test/integration_tests_win.cc +++ b/chrome/updater/test/integration_tests_win.cc
@@ -1046,7 +1046,7 @@ Microsoft::WRL::ComPtr<IPolicyStatusValue> policy_status_value; ASSERT_HRESULT_SUCCEEDED( policy_status2->get_lastCheckPeriodMinutes(&policy_status_value)); - ExpectPolicyStatusValues(policy_status_value, L"default", L"14430", + ExpectPolicyStatusValues(policy_status_value, L"default", L"270", VARIANT_FALSE); const base::win::ScopedBstr test_app(L"test1"); @@ -1067,6 +1067,8 @@ test_app.Get(), &policy_status_value)); ExpectPolicyStatusValues(policy_status_value, L"default", L"false", VARIANT_FALSE); + + ASSERT_HRESULT_SUCCEEDED(policy_status2->refreshPolicies()); } int RunVPythonCommand(const base::CommandLine& command_line) {
diff --git a/chrome/updater/updater.cc b/chrome/updater/updater.cc index ac0d3a71..95caa4f 100644 --- a/chrome/updater/updater.cc +++ b/chrome/updater/updater.cc
@@ -159,6 +159,7 @@ if (command_line->HasSwitch(kInstallSwitch) || command_line->HasSwitch(kTagSwitch) || + command_line->HasSwitch(kRuntimeSwitch) || command_line->HasSwitch(kHandoffSwitch)) { return MakeAppInstall()->Run(); } @@ -188,20 +189,14 @@ const char* GetUpdaterCommand(const base::CommandLine* command_line) { // Contains the literals which are associated with specific updater commands. const char* commands[] = { - kWindowsServiceSwitch, - kCrashHandlerSwitch, - kInstallSwitch, - kRecoverSwitch, - kServerSwitch, - kTagSwitch, - kTestSwitch, - kUninstallIfUnusedSwitch, - kUninstallSelfSwitch, - kUninstallSwitch, - kUpdateSwitch, - kWakeSwitch, - kHealthCheckSwitch, - kHandoffSwitch, + kWindowsServiceSwitch, kCrashHandlerSwitch, + kInstallSwitch, kRecoverSwitch, + kServerSwitch, kTagSwitch, + kTestSwitch, kUninstallIfUnusedSwitch, + kUninstallSelfSwitch, kUninstallSwitch, + kUpdateSwitch, kWakeSwitch, + kHealthCheckSwitch, kHandoffSwitch, + kRuntimeSwitch, }; const char** it = std::find_if( std::begin(commands), std::end(commands),
diff --git a/chrome/updater/win/BUILD.gn b/chrome/updater/win/BUILD.gn index 2f5e501..cc1922ca 100644 --- a/chrome/updater/win/BUILD.gn +++ b/chrome/updater/win/BUILD.gn
@@ -56,8 +56,6 @@ } executable("updater") { - configs -= [ "//build/config/compiler:cet_shadow_stack" ] - deps = [ ":updater_executable", ":version_resources", @@ -66,8 +64,6 @@ } executable("updater_test") { - configs -= [ "//build/config/compiler:cet_shadow_stack" ] - deps = [ ":updater_executable", ":version_resources_test",
diff --git a/chrome/updater/win/installer/BUILD.gn b/chrome/updater/win/installer/BUILD.gn index c81be99..5339fc0 100644 --- a/chrome/updater/win/installer/BUILD.gn +++ b/chrome/updater/win/installer/BUILD.gn
@@ -109,7 +109,6 @@ packed_files_rc_file, ] - configs -= [ "//build/config/compiler:cet_shadow_stack" ] configs += [ "//build/config/win:windowed" ] libs = [ "setupapi.lib" ]
diff --git a/chromeos/ash/components/network/network_state_handler.cc b/chromeos/ash/components/network/network_state_handler.cc index 2a6db44..17865589 100644 --- a/chromeos/ash/components/network/network_state_handler.cc +++ b/chromeos/ash/components/network/network_state_handler.cc
@@ -42,6 +42,7 @@ constexpr char kReasonUpdateIPConfig[] = "UpdateIPConfig"; constexpr char kReasonUpdateDeviceIPConfig[] = "UpdateDeviceIPConfig"; constexpr char kReasonTether[] = "Tether Change"; +constexpr char kReasonPortal[] = "Portal State Change"; bool ConnectionStateChanged(const NetworkState* network, const std::string& prev_connection_state) { @@ -571,10 +572,11 @@ << NetworkPathId(service_path) << " = " << portal_state; auto prev_portal_state = network->GetPortalState(); network->set_chrome_portal_state(portal_state); - if (prev_portal_state == network->GetPortalState()) + if (prev_portal_state == network->GetPortalState() || + service_path != default_network_path_) { return; - network_list_sorted_ = false; - OnNetworkConnectionStateChanged(network); + } + NotifyDefaultNetworkChanged(kReasonPortal); } std::string NetworkStateHandler::FormattedHardwareAddressForType( @@ -2073,9 +2075,9 @@ observer.DefaultNetworkChanged(default_network); if (default_network && - (default_network->GetPortalState() != default_network_portal_state_ || + (default_network->shill_portal_state() != default_network_portal_state_ || default_network->proxy_config() != default_network_proxy_config_)) { - default_network_portal_state_ = default_network->GetPortalState(); + default_network_portal_state_ = default_network->shill_portal_state(); default_network_proxy_config_ = default_network->proxy_config().Clone(); NET_LOG(EVENT) << "NOTIFY: PortalStateChanged: " << default_network_portal_state_;
diff --git a/chromeos/ash/components/sync_wifi/wifi_configuration_bridge_unittest.cc b/chromeos/ash/components/sync_wifi/wifi_configuration_bridge_unittest.cc index 9ac9c17..9f9eacc 100644 --- a/chromeos/ash/components/sync_wifi/wifi_configuration_bridge_unittest.cc +++ b/chromeos/ash/components/sync_wifi/wifi_configuration_bridge_unittest.cc
@@ -38,8 +38,8 @@ #include "components/sync/model/metadata_batch.h" #include "components/sync/model/model_type_store.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromeos/tast_control.gni b/chromeos/tast_control.gni index 90db2d5..53c114c 100644 --- a/chromeos/tast_control.gni +++ b/chromeos/tast_control.gni
@@ -103,6 +103,9 @@ # https://crbug.com/1300941 "ui.WebUIJSErrors", + # https://crbug.com/1351699 + "ui.ForceRegion", + # https://crbug.com/1306441 "policy.UserAvatarImage",
diff --git a/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc index 7912eff..e074e8c 100644 --- a/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc +++ b/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc
@@ -33,8 +33,8 @@ #include "components/sync/protocol/autofill_specifics.pb.h" #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/test_matchers.h" #include "components/webdata/common/web_database.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc index 1b7749f9..19385e1d 100644 --- a/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc +++ b/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc
@@ -42,8 +42,8 @@ #include "components/sync/protocol/entity_data.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/webdata/common/web_database.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc index 01ed4da1..d17ada8ac 100644 --- a/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc +++ b/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc
@@ -39,7 +39,7 @@ #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "components/webdata/common/web_database.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc index 9bdf7467..4d6c4bcb 100644 --- a/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc +++ b/components/autofill/core/browser/webdata/autofill_wallet_offer_sync_bridge_unittest.cc
@@ -35,7 +35,7 @@ #include "components/sync/protocol/entity_data.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "components/webdata/common/web_database.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc index 2085d07e..4bbc99b 100644 --- a/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc +++ b/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc
@@ -43,8 +43,8 @@ #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/test_matchers.h" #include "components/webdata/common/web_database.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd index b43bbee3..875fdb12 100644 --- a/components/browser_ui/strings/android/browser_ui_strings.grd +++ b/components/browser_ui/strings/android/browser_ui_strings.grd
@@ -184,6 +184,9 @@ <message name="IDS_OK_GOT_IT" desc="Label of a button by which the user confirms that they read and understood the information or instructions. Used in multiple contexts. [CHAR_LIMIT=20]"> OK, got it </message> + <message name="IDS_YES" desc="Label for a button where the user accepts a disclosure/message. Used in multiple contexts." formatter_data="android_java"> + Yes + </message> <message name="IDS_CANCEL" desc="Label for a cancel button. Used in multiple contexts. [CHAR_LIMIT=20]"> Cancel </message>
diff --git a/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_YES.png.sha1 b/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_YES.png.sha1 new file mode 100644 index 0000000..fdea14a --- /dev/null +++ b/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_YES.png.sha1
@@ -0,0 +1 @@ +621fcf59609aede986fb4e036d65fd4d1a4ce09f \ No newline at end of file
diff --git a/components/commerce/core/BUILD.gn b/components/commerce/core/BUILD.gn index e40f07d..c782ad2 100644 --- a/components/commerce/core/BUILD.gn +++ b/components/commerce/core/BUILD.gn
@@ -79,11 +79,6 @@ proto_in_dir = "//" sources = [ "proto/merchant_signal_db_content.proto" ] } - - proto_library("commerce_subscription_db_content_proto") { - proto_in_dir = "//" - sources = [ "proto/commerce_subscription_db_content.proto" ] - } } else { proto_library("cart_db_content_proto") { proto_in_dir = "//" @@ -101,6 +96,11 @@ sources = [ "proto/persisted_state_db_content.proto" ] } +proto_library("commerce_subscription_db_content_proto") { + proto_in_dir = "//" + sources = [ "proto/commerce_subscription_db_content.proto" ] +} + source_set("commerce_heuristics_data") { sources = [ "commerce_heuristics_data.cc", @@ -159,6 +159,7 @@ ] deps = [ + ":commerce_subscription_db_content_proto", ":feature_list", ":metrics", ":proto", @@ -166,12 +167,14 @@ "//components/bookmarks/browser", "//components/commerce/core/subscriptions:subscriptions", "//components/keyed_service/core", + "//components/leveldb_proto", "//components/optimization_guide/core", "//components/optimization_guide/proto:optimization_guide_proto", "//components/power_bookmarks/core", "//components/power_bookmarks/core:proto", "//components/prefs:prefs", "//components/resources:components_resources_grit", + "//components/session_proto_db:core", "//services/data_decoder/public/cpp", "//services/network/public/cpp:cpp", "//ui/base",
diff --git a/components/commerce/core/DEPS b/components/commerce/core/DEPS index d2034cd2..cd894101 100644 --- a/components/commerce/core/DEPS +++ b/components/commerce/core/DEPS
@@ -6,13 +6,14 @@ "+components/optimization_guide", "+components/power_bookmarks/core", "+components/prefs", + "+components/session_proto_db/session_proto_storage.h", "+third_party/re2", "+components/endpoint_fetcher/endpoint_fetcher.h", "+components/search", "+components/signin/public/identity_manager", "+components/grit/components_resources.h", "+net/base/registry_controlled_domains/registry_controlled_domain.h", - "+net/traffic_annotation/network_traffic_annotation.h", + "+net/traffic_annotation", "+services/data_decoder/public", "+services/network/public/cpp", "+services/network/test",
diff --git a/components/commerce/core/mock_shopping_service.cc b/components/commerce/core/mock_shopping_service.cc index a4897212..01a1e4d8 100644 --- a/components/commerce/core/mock_shopping_service.cc +++ b/components/commerce/core/mock_shopping_service.cc
@@ -7,7 +7,12 @@ namespace commerce { MockShoppingService::MockShoppingService() - : commerce::ShoppingService(nullptr, nullptr, nullptr, nullptr, nullptr) {} + : commerce::ShoppingService(nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr) {} MockShoppingService::~MockShoppingService() = default;
diff --git a/components/commerce/core/shopping_service.cc b/components/commerce/core/shopping_service.cc index 27481f3..d655eab 100644 --- a/components/commerce/core/shopping_service.cc +++ b/components/commerce/core/shopping_service.cc
@@ -18,6 +18,7 @@ #include "components/bookmarks/browser/bookmark_model.h" #include "components/commerce/core/commerce_feature_list.h" #include "components/commerce/core/metrics/metrics_utils.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" #include "components/commerce/core/proto/merchant_trust.pb.h" #include "components/commerce/core/proto/price_tracking.pb.h" #include "components/commerce/core/shopping_bookmark_model_observer.h" @@ -28,6 +29,7 @@ #include "components/optimization_guide/core/new_optimization_guide_decider.h" #include "components/optimization_guide/core/optimization_guide_util.h" #include "components/optimization_guide/proto/hints.pb.h" +#include "components/session_proto_db/session_proto_storage.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "ui/base/resource/resource_bundle.h" @@ -55,7 +57,10 @@ optimization_guide::NewOptimizationGuideDecider* opt_guide, PrefService* pref_service, signin::IdentityManager* identity_manager, - scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) + scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, + SessionProtoStorage< + commerce_subscription_db::CommerceSubscriptionContentProto>* + subscription_proto_db) : opt_guide_(opt_guide), pref_service_(pref_service), weak_ptr_factory_(this) { @@ -77,9 +82,9 @@ opt_guide_->RegisterOptimizationTypes(types); } - if (identity_manager) { + if (identity_manager && subscription_proto_db) { subscriptions_manager_ = std::make_unique<SubscriptionsManager>( - identity_manager, std::move(url_loader_factory)); + identity_manager, std::move(url_loader_factory), subscription_proto_db); } if (bookmark_model) {
diff --git a/components/commerce/core/shopping_service.h b/components/commerce/core/shopping_service.h index e1bcd45f..95b84c9 100644 --- a/components/commerce/core/shopping_service.h +++ b/components/commerce/core/shopping_service.h
@@ -17,6 +17,7 @@ #include "base/scoped_observation.h" #include "base/sequence_checker.h" #include "base/supports_user_data.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" #include "components/keyed_service/core/keyed_service.h" #include "components/optimization_guide/core/optimization_guide_decision.h" #include "services/data_decoder/public/cpp/data_decoder.h" @@ -26,6 +27,9 @@ class PrefRegistrySimple; +template <typename T> +class SessionProtoStorage; + namespace base { class Value; } @@ -142,7 +146,10 @@ optimization_guide::NewOptimizationGuideDecider* opt_guide, PrefService* pref_service, signin::IdentityManager* identity_manager, - scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory); + scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, + SessionProtoStorage< + commerce_subscription_db::CommerceSubscriptionContentProto>* + subscription_proto_db); ~ShoppingService() override; ShoppingService(const ShoppingService&) = delete;
diff --git a/components/commerce/core/shopping_service_test_base.cc b/components/commerce/core/shopping_service_test_base.cc index a4db2b4..2432324 100644 --- a/components/commerce/core/shopping_service_test_base.cc +++ b/components/commerce/core/shopping_service_test_base.cc
@@ -167,7 +167,8 @@ bookmark_model_.get(), opt_guide_.get(), pref_service_.get(), identity_test_env_->identity_manager(), base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( - test_url_loader_factory_.get())); + test_url_loader_factory_.get()), + nullptr); } ShoppingServiceTestBase::~ShoppingServiceTestBase() = default;
diff --git a/components/commerce/core/subscriptions/BUILD.gn b/components/commerce/core/subscriptions/BUILD.gn index b22a320..09016f4 100644 --- a/components/commerce/core/subscriptions/BUILD.gn +++ b/components/commerce/core/subscriptions/BUILD.gn
@@ -16,8 +16,11 @@ deps = [ "//base", + "//components/commerce/core:commerce_subscription_db_content_proto", "//components/commerce/core:feature_list", "//components/endpoint_fetcher:endpoint_fetcher", + "//components/leveldb_proto", + "//components/session_proto_db:core", "//components/signin/public/identity_manager:identity_manager", "//net/traffic_annotation:traffic_annotation", "//services/data_decoder/public/cpp", @@ -28,13 +31,24 @@ source_set("subscriptions_unit_tests") { testonly = true - sources = [ "subscriptions_manager_unittest.cc" ] + sources = [ + "subscriptions_manager_unittest.cc", + "subscriptions_server_proxy_unittest.cc", + "subscriptions_storage_unittest.cc", + ] deps = [ ":subscriptions", "//base/test:test_support", + "//components/commerce/core:commerce_subscription_db_content_proto", "//components/commerce/core:feature_list", + "//components/endpoint_fetcher:endpoint_fetcher", + "//components/leveldb_proto", + "//components/session_proto_db:core", "//components/signin/public/identity_manager:test_support", + "//net/traffic_annotation:test_support", + "//services/data_decoder/public/cpp:test_support", + "//services/network:test_support", "//services/network/public/cpp:cpp", "//testing/gmock", "//testing/gtest",
diff --git a/components/commerce/core/subscriptions/commerce_subscription.cc b/components/commerce/core/subscriptions/commerce_subscription.cc index 606b22a..b26973c 100644 --- a/components/commerce/core/subscriptions/commerce_subscription.cc +++ b/components/commerce/core/subscriptions/commerce_subscription.cc
@@ -6,6 +6,19 @@ #include "components/commerce/core/subscriptions/commerce_subscription.h" +namespace { + +const char kSubscriptionTypePriceTrack[] = "PRICE_TRACK"; +const char kSubscriptionTypeUnspecified[] = "TYPE_UNSPECIFIED"; +const char kSubscriptionIdTypeOfferId[] = "OFFER_ID"; +const char kSubscriptionIdTypeProductClusterId[] = "PRODUCT_CLUSTER_ID"; +const char kSubscriptionIdTypeUnspecified[] = "IDENTIFIER_TYPE_UNSPECIFIED"; +const char kSubscriptionManagementTypeChrome[] = "CHROME_MANAGED"; +const char kSubscriptionManagementTypeUser[] = "USER_MANAGED"; +const char kSubscriptionManagementTypeUnspecified[] = "TYPE_UNSPECIFIED"; + +} // namespace + namespace commerce { UserSeenOffer::UserSeenOffer(std::string offer_id, @@ -39,4 +52,54 @@ const CommerceSubscription&) = default; CommerceSubscription::~CommerceSubscription() = default; +std::string SubscriptionTypeToString(SubscriptionType type) { + if (SubscriptionType::kPriceTrack == type) + return kSubscriptionTypePriceTrack; + else + return kSubscriptionTypeUnspecified; +} + +SubscriptionType StringToSubscriptionType(const std::string& s) { + if (((std::string)kSubscriptionTypePriceTrack) == s) + return SubscriptionType::kPriceTrack; + else + return SubscriptionType::kTypeUnspecified; +} + +std::string SubscriptionIdTypeToString(IdentifierType type) { + if (IdentifierType::kOfferId == type) + return kSubscriptionIdTypeOfferId; + else if (IdentifierType::kProductClusterId == type) + return kSubscriptionIdTypeProductClusterId; + else + return kSubscriptionIdTypeUnspecified; +} + +IdentifierType StringToSubscriptionIdType(const std::string& s) { + if (((std::string)kSubscriptionIdTypeOfferId) == s) + return IdentifierType::kOfferId; + else if (((std::string)kSubscriptionIdTypeProductClusterId) == s) + return IdentifierType::kProductClusterId; + else + return IdentifierType::kIdentifierTypeUnspecified; +} + +std::string SubscriptionManagementTypeToString(ManagementType type) { + if (ManagementType::kChromeManaged == type) + return kSubscriptionManagementTypeChrome; + else if (ManagementType::kUserManaged == type) + return kSubscriptionManagementTypeUser; + else + return kSubscriptionManagementTypeUnspecified; +} + +ManagementType StringToSubscriptionManagementType(const std::string& s) { + if (((std::string)kSubscriptionManagementTypeChrome) == s) + return ManagementType::kChromeManaged; + else if (((std::string)kSubscriptionManagementTypeUser) == s) + return ManagementType::kUserManaged; + else + return ManagementType::kTypeUnspecified; +} + } // namespace commerce
diff --git a/components/commerce/core/subscriptions/commerce_subscription.h b/components/commerce/core/subscriptions/commerce_subscription.h index 48faf532..e0adb2e 100644 --- a/components/commerce/core/subscriptions/commerce_subscription.h +++ b/components/commerce/core/subscriptions/commerce_subscription.h
@@ -9,6 +9,16 @@ #include "third_party/abseil-cpp/absl/types/optional.h" +/** + * To add a new SubscriptionType / IdentifierType / ManagementType: + * 1. Define the type in the enum class in commerce_subscription.h. + * 2. Update the conversion methods between the type and std::string in + * commerce_subscription.cc. + * 3. Add the corresponding entry in {@link + * commerce_subscription_db_content.proto} to ensure the storage works + * correctly. + */ + namespace commerce { // The type of subscription. @@ -74,6 +84,13 @@ absl::optional<UserSeenOffer> user_seen_offer; }; +std::string SubscriptionTypeToString(SubscriptionType type); +SubscriptionType StringToSubscriptionType(const std::string& s); +std::string SubscriptionIdTypeToString(IdentifierType type); +IdentifierType StringToSubscriptionIdType(const std::string& s); +std::string SubscriptionManagementTypeToString(ManagementType type); +ManagementType StringToSubscriptionManagementType(const std::string& s); + } // namespace commerce #endif // COMPONENTS_COMMERCE_CORE_SUBSCRIPTIONS_COMMERCE_SUBSCRIPTION_H_
diff --git a/components/commerce/core/subscriptions/subscriptions_manager.cc b/components/commerce/core/subscriptions/subscriptions_manager.cc index 3080571..ba9357d4 100644 --- a/components/commerce/core/subscriptions/subscriptions_manager.cc +++ b/components/commerce/core/subscriptions/subscriptions_manager.cc
@@ -7,6 +7,7 @@ #include "components/commerce/core/subscriptions/commerce_subscription.h" #include "components/commerce/core/subscriptions/subscriptions_server_proxy.h" #include "components/commerce/core/subscriptions/subscriptions_storage.h" +#include "components/session_proto_db/session_proto_storage.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include <queue> @@ -16,12 +17,16 @@ SubscriptionsManager::SubscriptionsManager( signin::IdentityManager* identity_manager, - scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) - : SubscriptionsManager(identity_manager, - std::make_unique<SubscriptionsServerProxy>( - identity_manager, - std::move(url_loader_factory)), - std::make_unique<SubscriptionsStorage>()) {} + scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, + SessionProtoStorage< + commerce_subscription_db::CommerceSubscriptionContentProto>* + subscription_proto_db) + : SubscriptionsManager( + identity_manager, + std::make_unique<SubscriptionsServerProxy>( + identity_manager, + std::move(url_loader_factory)), + std::make_unique<SubscriptionsStorage>(subscription_proto_db)) {} SubscriptionsManager::SubscriptionsManager( signin::IdentityManager* identity_manager,
diff --git a/components/commerce/core/subscriptions/subscriptions_manager.h b/components/commerce/core/subscriptions/subscriptions_manager.h index 853a44f..d65d918 100644 --- a/components/commerce/core/subscriptions/subscriptions_manager.h +++ b/components/commerce/core/subscriptions/subscriptions_manager.h
@@ -13,6 +13,8 @@ #include "base/check.h" #include "base/memory/scoped_refptr.h" #include "base/scoped_observation.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" +#include "components/session_proto_db/session_proto_storage.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/primary_account_change_event.h" @@ -31,7 +33,10 @@ public: SubscriptionsManager( signin::IdentityManager* identity_manager, - scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory); + scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, + SessionProtoStorage< + commerce_subscription_db::CommerceSubscriptionContentProto>* + subscription_proto_db); // Used for tests. The passed in objects are ordinarily created with // parameters from the non-test constructor. SubscriptionsManager(signin::IdentityManager* identity_manager,
diff --git a/components/commerce/core/subscriptions/subscriptions_manager_unittest.cc b/components/commerce/core/subscriptions/subscriptions_manager_unittest.cc index 2a266035..4ba4c92 100644 --- a/components/commerce/core/subscriptions/subscriptions_manager_unittest.cc +++ b/components/commerce/core/subscriptions/subscriptions_manager_unittest.cc
@@ -103,7 +103,7 @@ class MockSubscriptionsStorage : public SubscriptionsStorage { public: - MockSubscriptionsStorage() = default; + MockSubscriptionsStorage() : SubscriptionsStorage(nullptr) {} MockSubscriptionsStorage(const MockSubscriptionsStorage&) = delete; MockSubscriptionsStorage operator=(const MockSubscriptionsStorage&) = delete; ~MockSubscriptionsStorage() override = default;
diff --git a/components/commerce/core/subscriptions/subscriptions_server_proxy.h b/components/commerce/core/subscriptions/subscriptions_server_proxy.h index 1643037..6c86449 100644 --- a/components/commerce/core/subscriptions/subscriptions_server_proxy.h +++ b/components/commerce/core/subscriptions/subscriptions_server_proxy.h
@@ -58,13 +58,15 @@ virtual void Get(SubscriptionType type, GetSubscriptionsFetcherCallback callback); - private: - std::unique_ptr<EndpointFetcher> CreateEndpointFetcher( + protected: + // This method could be overridden in tests. + virtual std::unique_ptr<EndpointFetcher> CreateEndpointFetcher( const GURL& url, const std::string& http_method, const std::string& post_data, const net::NetworkTrafficAnnotationTag& annotation_tag); + private: // Handle Create or Delete response. void HandleManageSubscriptionsResponses( ManageSubscriptionsFetcherCallback callback,
diff --git a/components/commerce/core/subscriptions/subscriptions_server_proxy_unittest.cc b/components/commerce/core/subscriptions/subscriptions_server_proxy_unittest.cc new file mode 100644 index 0000000..88de090 --- /dev/null +++ b/components/commerce/core/subscriptions/subscriptions_server_proxy_unittest.cc
@@ -0,0 +1,333 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <queue> +#include <string> +#include <unordered_map> + +#include "base/callback.h" +#include "base/check.h" +#include "base/run_loop.h" +#include "base/test/scoped_feature_list.h" +#include "base/test/task_environment.h" +#include "components/commerce/core/commerce_feature_list.h" +#include "components/commerce/core/subscriptions/commerce_subscription.h" +#include "components/commerce/core/subscriptions/subscriptions_server_proxy.h" +#include "components/commerce/core/subscriptions/subscriptions_storage.h" +#include "components/endpoint_fetcher/endpoint_fetcher.h" +#include "components/signin/public/identity_manager/identity_test_environment.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h" +#include "services/network/public/cpp/shared_url_loader_factory.h" +#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" +#include "services/network/test/test_url_loader_factory.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using testing::_; +using testing::InSequence; + +namespace { + +const int64_t kMockTimestamp = 123456; +const std::string kMockId1 = "111"; +const std::string kMockId2 = "222"; +const std::string kMockOfferId = "333"; +const long kMockPrice = 100; +const std::string kMockCountry = "us"; + +const char kGetHttpMethod[] = "GET"; +const char kPostHttpMethod[] = "POST"; +const char kEmptyPostData[] = ""; +const char kServiceUrl[] = + "https://memex-pa.googleapis.com/v1/shopping/subscriptions"; +const char kServiceUrlForGet[] = + "https://memex-pa.googleapis.com/v1/shopping/subscriptions" + "?requestParams.subscriptionType=PRICE_TRACK"; + +const std::string kExpectedPostDataForCreate = + "{\"createShoppingSubscriptionsParams\":{\"subscriptions\":[{" + "\"identifier\":\"111\",\"identifierType\":2,\"managementType\":2,\"type\":" + "1},{\"identifier\":\"222\",\"identifierType\":2,\"managementType\":2," + "\"type\":1,\"userSeenOffer\":{\"countryCode\":\"us\",\"offerId\":\"333\"," + "\"seenPriceMicros\":\"100\"}}]}}"; +const std::string kExpectedPostDataForDelete = + "{\"removeShoppingSubscriptionsParams\":{\"eventTimestampMicros\":[" + "\"123456\"]}}"; +const std::string kResponseSucceeded = "{ \"status\": { \"code\": 0 } }"; +const std::string kResponseFailed = "{ \"status\": { \"code\": 1 } }"; +const std::string kValidGetResponse = + "{\"subscriptions\":[{" + "\"identifier\":\"111\",\"identifierType\":2,\"managementType\":2,\"type\":" + "1,\"eventTimestampMicros\":\"123456\"}]}"; + +// Build a subscription list consisting of two subscriptions. +std::unique_ptr<std::vector<commerce::CommerceSubscription>> +BuildValidSubscriptions() { + auto subscriptions = + std::make_unique<std::vector<commerce::CommerceSubscription>>(); + // The first one has a valid timestamp but doesn't contain a UserSeenOffer. + subscriptions->push_back(commerce::CommerceSubscription( + commerce::SubscriptionType::kPriceTrack, + commerce::IdentifierType::kProductClusterId, kMockId1, + commerce::ManagementType::kUserManaged, kMockTimestamp)); + // The second one contains a UserSeenOffer but doesn't have a valid timestamp. + subscriptions->push_back(commerce::CommerceSubscription( + commerce::SubscriptionType::kPriceTrack, + commerce::IdentifierType::kProductClusterId, kMockId2, + commerce::ManagementType::kUserManaged, + commerce::kUnknownSubscriptionTimestamp, + absl::make_optional<commerce::UserSeenOffer>(kMockOfferId, kMockPrice, + kMockCountry))); + return subscriptions; +} + +// Build an empty subscription list. +std::unique_ptr<std::vector<commerce::CommerceSubscription>> +BuildEmptySubscriptions() { + return std::make_unique<std::vector<commerce::CommerceSubscription>>(); +} + +// TODO(crbug.com/1351599): Move this to the endpoint_fetcher component. +class MockEndpointFetcher : public EndpointFetcher { + public: + explicit MockEndpointFetcher( + const net::NetworkTrafficAnnotationTag& annotation_tag) + : EndpointFetcher(annotation_tag) {} + ~MockEndpointFetcher() override = default; + + MOCK_METHOD(void, Fetch, (EndpointFetcherCallback callback), (override)); + + void MockFetchResponse(std::string response_string) { + ON_CALL(*this, Fetch) + .WillByDefault([response_string](EndpointFetcherCallback callback) { + auto response = std::make_unique<EndpointResponse>(); + response->response = std::move(response_string); + std::move(callback).Run(std::move(response)); + }); + } +}; + +} // namespace + +namespace commerce { + +class SpySubscriptionsServerProxy : public SubscriptionsServerProxy { + public: + SpySubscriptionsServerProxy( + signin::IdentityManager* identity_manager, + scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) + : SubscriptionsServerProxy(identity_manager, + std::move(url_loader_factory)) {} + SpySubscriptionsServerProxy(const SpySubscriptionsServerProxy&) = delete; + SpySubscriptionsServerProxy operator=(const SpySubscriptionsServerProxy&) = + delete; + ~SpySubscriptionsServerProxy() override = default; + + MOCK_METHOD(std::unique_ptr<EndpointFetcher>, + CreateEndpointFetcher, + (const GURL& url, + const std::string& http_method, + const std::string& post_data, + const net::NetworkTrafficAnnotationTag& annotation_tag), + (override)); +}; + +class SubscriptionsServerProxyTest : public testing::Test { + public: + SubscriptionsServerProxyTest() = default; + ~SubscriptionsServerProxyTest() override = default; + + void SetUp() override { + fetcher_ = + std::make_unique<MockEndpointFetcher>(TRAFFIC_ANNOTATION_FOR_TESTS); + scoped_refptr<network::SharedURLLoaderFactory> test_url_loader_factory = + base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( + &test_url_loader_factory_); + server_proxy_ = std::make_unique<SpySubscriptionsServerProxy>( + identity_test_env_.identity_manager(), + std::move(test_url_loader_factory)); + ON_CALL(*server_proxy_, CreateEndpointFetcher).WillByDefault([this]() { + return std::move(fetcher_); + }); + } + + protected: + base::test::TaskEnvironment task_environment_; + signin::IdentityTestEnvironment identity_test_env_; + network::TestURLLoaderFactory test_url_loader_factory_; + data_decoder::test::InProcessDataDecoder in_process_data_decoder_; + std::unique_ptr<MockEndpointFetcher> fetcher_; + std::unique_ptr<SpySubscriptionsServerProxy> server_proxy_; +}; + +TEST_F(SubscriptionsServerProxyTest, TestCreate) { + fetcher_->MockFetchResponse(kResponseSucceeded); + EXPECT_CALL(*server_proxy_, + CreateEndpointFetcher(GURL(kServiceUrl), kPostHttpMethod, + kExpectedPostDataForCreate, _)) + .Times(1); + + bool callback_executed = false; + server_proxy_->Create(BuildValidSubscriptions(), + base::BindOnce( + [](bool* callback_executed, bool succeeded) { + ASSERT_EQ(true, succeeded); + *callback_executed = true; + }, + &callback_executed)); + base::RunLoop().RunUntilIdle(); + ASSERT_EQ(true, callback_executed); +} + +TEST_F(SubscriptionsServerProxyTest, TestCreate_EmptyList) { + fetcher_->MockFetchResponse(kResponseSucceeded); + EXPECT_CALL(*server_proxy_, CreateEndpointFetcher).Times(0); + + base::RunLoop run_loop; + server_proxy_->Create(BuildEmptySubscriptions(), + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(true, succeeded); + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsServerProxyTest, TestCreate_ServerFailed) { + fetcher_->MockFetchResponse(kResponseFailed); + EXPECT_CALL(*server_proxy_, + CreateEndpointFetcher(GURL(kServiceUrl), kPostHttpMethod, + kExpectedPostDataForCreate, _)) + .Times(1); + + base::RunLoop run_loop; + server_proxy_->Create(BuildValidSubscriptions(), + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(false, succeeded); + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsServerProxyTest, TestDelete) { + fetcher_->MockFetchResponse(kResponseSucceeded); + EXPECT_CALL(*server_proxy_, + CreateEndpointFetcher(GURL(kServiceUrl), kPostHttpMethod, + kExpectedPostDataForDelete, _)) + .Times(1); + + base::RunLoop run_loop; + server_proxy_->Delete(BuildValidSubscriptions(), + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(true, succeeded); + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsServerProxyTest, TestDelete_EmptyList) { + fetcher_->MockFetchResponse(kResponseSucceeded); + EXPECT_CALL(*server_proxy_, CreateEndpointFetcher).Times(0); + + base::RunLoop run_loop; + server_proxy_->Delete(BuildEmptySubscriptions(), + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(true, succeeded); + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsServerProxyTest, TestDelete_ServerFailed) { + fetcher_->MockFetchResponse(kResponseFailed); + EXPECT_CALL(*server_proxy_, + CreateEndpointFetcher(GURL(kServiceUrl), kPostHttpMethod, + kExpectedPostDataForDelete, _)) + .Times(1); + + base::RunLoop run_loop; + server_proxy_->Delete(BuildValidSubscriptions(), + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(false, succeeded); + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsServerProxyTest, TestGet) { + fetcher_->MockFetchResponse(kValidGetResponse); + EXPECT_CALL(*server_proxy_, + CreateEndpointFetcher(GURL(kServiceUrlForGet), kGetHttpMethod, + kEmptyPostData, _)) + .Times(1); + + base::RunLoop run_loop; + server_proxy_->Get( + SubscriptionType::kPriceTrack, + base::BindOnce( + [](base::RunLoop* run_loop, + std::unique_ptr<std::vector<CommerceSubscription>> subscriptions) { + ASSERT_EQ(1, static_cast<int>(subscriptions->size())); + auto subscription = (*subscriptions)[0]; + ASSERT_EQ(SubscriptionType::kPriceTrack, subscription.type); + ASSERT_EQ(IdentifierType::kProductClusterId, subscription.id_type); + ASSERT_EQ(ManagementType::kUserManaged, + subscription.management_type); + ASSERT_EQ(kMockId1, subscription.id); + ASSERT_EQ(kMockTimestamp, subscription.timestamp); + + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsServerProxyTest, TestGet_WrongType) { + fetcher_->MockFetchResponse(kValidGetResponse); + EXPECT_CALL(*server_proxy_, CreateEndpointFetcher).Times(0); + + base::RunLoop run_loop; + server_proxy_->Get( + SubscriptionType::kTypeUnspecified, + base::BindOnce( + [](base::RunLoop* run_loop, + std::unique_ptr<std::vector<CommerceSubscription>> subscriptions) { + ASSERT_EQ(0, static_cast<int>(subscriptions->size())); + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsServerProxyTest, TestGet_ServerFailed) { + fetcher_->MockFetchResponse(kResponseFailed); + EXPECT_CALL(*server_proxy_, + CreateEndpointFetcher(GURL(kServiceUrlForGet), kGetHttpMethod, + kEmptyPostData, _)) + .Times(1); + + base::RunLoop run_loop; + server_proxy_->Get( + SubscriptionType::kPriceTrack, + base::BindOnce( + [](base::RunLoop* run_loop, + std::unique_ptr<std::vector<CommerceSubscription>> subscriptions) { + ASSERT_EQ(0, static_cast<int>(subscriptions->size())); + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +} // namespace commerce
diff --git a/components/commerce/core/subscriptions/subscriptions_storage.cc b/components/commerce/core/subscriptions/subscriptions_storage.cc index 494e9788..760acd58 100644 --- a/components/commerce/core/subscriptions/subscriptions_storage.cc +++ b/components/commerce/core/subscriptions/subscriptions_storage.cc
@@ -8,29 +8,222 @@ #include "base/callback.h" #include "base/check.h" +#include "base/logging.h" #include "components/commerce/core/subscriptions/commerce_subscription.h" #include "components/commerce/core/subscriptions/subscriptions_storage.h" +#include "components/session_proto_db/session_proto_storage.h" namespace commerce { -SubscriptionsStorage::SubscriptionsStorage() = default; +SubscriptionsStorage::SubscriptionsStorage( + SessionProtoStorage<CommerceSubscriptionProto>* subscription_proto_db) + : proto_db_(subscription_proto_db), weak_ptr_factory_(this) {} SubscriptionsStorage::~SubscriptionsStorage() = default; -// TODO(crbug.com/1329197): Implement these APIs after ProtoDB is moved to -// //components. void SubscriptionsStorage::GetUniqueNonExistingSubscriptions( std::unique_ptr<std::vector<CommerceSubscription>> subscriptions, - GetLocalSubscriptionsCallback callback) {} + GetLocalSubscriptionsCallback callback) { + CHECK(subscriptions && subscriptions->size() > 0); + SubscriptionType type = (*subscriptions)[0].type; + LoadAllSubscriptionsForType( + type, + base::BindOnce(&SubscriptionsStorage::PerformGetNonExistingSubscriptions, + weak_ptr_factory_.GetWeakPtr(), std::move(subscriptions), + std::move(callback))); +} void SubscriptionsStorage::GetUniqueExistingSubscriptions( std::unique_ptr<std::vector<CommerceSubscription>> subscriptions, - GetLocalSubscriptionsCallback callback) {} + GetLocalSubscriptionsCallback callback) { + CHECK(subscriptions && subscriptions->size() > 0); + SubscriptionType type = (*subscriptions)[0].type; + LoadAllSubscriptionsForType( + type, + base::BindOnce(&SubscriptionsStorage::PerformGetExistingSubscriptions, + weak_ptr_factory_.GetWeakPtr(), std::move(subscriptions), + std::move(callback))); +} void SubscriptionsStorage::UpdateStorage( SubscriptionType type, base::OnceCallback<void(bool)> callback, - std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions) {} + std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions) { + LoadAllSubscriptionsForType( + type, base::BindOnce(&SubscriptionsStorage::PerformUpdateStorage, + weak_ptr_factory_.GetWeakPtr(), std::move(callback), + std::move(remote_subscriptions))); +} -void SubscriptionsStorage::DeleteAll() {} +void SubscriptionsStorage::DeleteAll() { + proto_db_->DeleteAllContent(base::BindOnce([](bool succeeded) { + if (!succeeded) + VLOG(1) << "Fail to delete all subscriptions"; + })); +} + +std::string SubscriptionsStorage::GetSubscriptionKey( + const CommerceSubscription& subscription) { + return SubscriptionTypeToString(subscription.type) + "_" + + SubscriptionIdTypeToString(subscription.id_type) + "_" + + subscription.id; +} + +void SubscriptionsStorage::SaveSubscription(CommerceSubscription subscription, + StorageOperationCallback callback) { + // Get proto types from the object. + SubscriptionTypeProto subscription_type = commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionType_TYPE_UNSPECIFIED; + bool type_parse_succeeded = commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionType_Parse( + SubscriptionTypeToString(subscription.type), &subscription_type); + + TrackingIdTypeProto tracking_id_type = commerce_subscription_db:: + CommerceSubscriptionContentProto_TrackingIdType_IDENTIFIER_TYPE_UNSPECIFIED; + bool id_type_parse_succeeded = commerce_subscription_db:: + CommerceSubscriptionContentProto_TrackingIdType_Parse( + SubscriptionIdTypeToString(subscription.id_type), &tracking_id_type); + + SubscriptionManagementTypeProto management_type = commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionManagementType_MANAGE_TYPE_UNSPECIFIED; + bool management_type_parse_succeeded = commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionManagementType_Parse( + SubscriptionManagementTypeToString(subscription.management_type), + &management_type); + + // TODO(crbug.com/1348024): Record metrics for failed parse. + if (!type_parse_succeeded || !id_type_parse_succeeded || + !management_type_parse_succeeded) { + VLOG(1) << "Fail to get proto type"; + std::move(callback).Run(false); + return; + } + + const std::string& key = GetSubscriptionKey(subscription); + CommerceSubscriptionProto proto; + proto.set_key(key); + proto.set_tracking_id(subscription.id); + proto.set_subscription_type(subscription_type); + proto.set_tracking_id_type(tracking_id_type); + proto.set_management_type(management_type); + proto.set_timestamp(subscription.timestamp); + + proto_db_->InsertContent(key, proto, std::move(callback)); +} + +void SubscriptionsStorage::DeleteSubscription( + CommerceSubscription subscription, + StorageOperationCallback callback) { + proto_db_->DeleteOneEntry(GetSubscriptionKey(subscription), + std::move(callback)); +} + +void SubscriptionsStorage::LoadAllSubscriptionsForType( + SubscriptionType type, + GetLocalSubscriptionsCallback callback) { + proto_db_->LoadContentWithPrefix( + SubscriptionTypeToString(type), + base::BindOnce( + [](base::WeakPtr<SubscriptionsStorage> storage, + GetLocalSubscriptionsCallback callback, bool succeeded, + CommerceSubscriptions data) { + auto subscriptions = + std::make_unique<std::vector<CommerceSubscription>>(); + if (!succeeded) { + VLOG(1) << "Fail to load all subscriptions"; + std::move(callback).Run(std::move(subscriptions)); + return; + } + for (SessionProtoStorage<CommerceSubscriptionProto>::KeyAndValue& + kv : data) { + subscriptions->push_back(storage->GetSubscriptionFromProto(kv)); + } + std::move(callback).Run(std::move(subscriptions)); + }, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); +} + +CommerceSubscription SubscriptionsStorage::GetSubscriptionFromProto( + const SessionProtoStorage<CommerceSubscriptionProto>::KeyAndValue& kv) { + CommerceSubscriptionProto proto = std::move(kv.second); + return CommerceSubscription( + SubscriptionType(proto.subscription_type()), + IdentifierType(proto.tracking_id_type()), proto.tracking_id(), + ManagementType(proto.management_type()), proto.timestamp()); +} + +std::unordered_map<std::string, CommerceSubscription> +SubscriptionsStorage::SubscriptionsListToMap( + std::unique_ptr<std::vector<CommerceSubscription>> subscriptions) { + std::unordered_map<std::string, CommerceSubscription> map; + for (auto& subscription : *subscriptions) { + std::string key = GetSubscriptionKey(subscription); + map.insert(std::make_pair(key, std::move(subscription))); + } + return map; +} + +void SubscriptionsStorage::PerformGetNonExistingSubscriptions( + std::unique_ptr<std::vector<CommerceSubscription>> incoming_subscriptions, + GetLocalSubscriptionsCallback callback, + std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions) { + auto incoming_map = SubscriptionsListToMap(std::move(incoming_subscriptions)); + auto local_map = SubscriptionsListToMap(std::move(local_subscriptions)); + auto subscriptions = std::make_unique<std::vector<CommerceSubscription>>(); + for (auto& kv : incoming_map) { + if (local_map.find(kv.first) == local_map.end()) { + subscriptions->push_back(std::move(kv.second)); + } + } + std::move(callback).Run(std::move(subscriptions)); +} + +void SubscriptionsStorage::PerformGetExistingSubscriptions( + std::unique_ptr<std::vector<CommerceSubscription>> incoming_subscriptions, + GetLocalSubscriptionsCallback callback, + std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions) { + auto incoming_map = SubscriptionsListToMap(std::move(incoming_subscriptions)); + auto local_map = SubscriptionsListToMap(std::move(local_subscriptions)); + auto subscriptions = std::make_unique<std::vector<CommerceSubscription>>(); + for (auto& kv : incoming_map) { + auto it = local_map.find(kv.first); + if (it != local_map.end()) { + // Push local subscription instead of the incoming one to make sure it has + // a valid timestamp. + subscriptions->push_back(std::move(it->second)); + local_map.erase(it); + } + } + std::move(callback).Run(std::move(subscriptions)); +} + +void SubscriptionsStorage::PerformUpdateStorage( + StorageOperationCallback callback, + std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions, + std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions) { + auto remote_map = SubscriptionsListToMap(std::move(remote_subscriptions)); + auto local_map = SubscriptionsListToMap(std::move(local_subscriptions)); + bool all_succeeded = true; + for (auto& kv : local_map) { + if (remote_map.find(kv.first) == remote_map.end()) { + DeleteSubscription(std::move(kv.second), + base::BindOnce( + [](bool* all_succeeded, bool succeeded) { + *all_succeeded = (*all_succeeded) && succeeded; + }, + &all_succeeded)); + } + } + for (auto& kv : remote_map) { + if (local_map.find(kv.first) == local_map.end()) { + SaveSubscription(std::move(kv.second), + base::BindOnce( + [](bool* all_succeeded, bool succeeded) { + *all_succeeded = (*all_succeeded) && succeeded; + }, + &all_succeeded)); + } + } + std::move(callback).Run(all_succeeded); +} } // namespace commerce
diff --git a/components/commerce/core/subscriptions/subscriptions_storage.h b/components/commerce/core/subscriptions/subscriptions_storage.h index 8d997e1..891ea0e2 100644 --- a/components/commerce/core/subscriptions/subscriptions_storage.h +++ b/components/commerce/core/subscriptions/subscriptions_storage.h
@@ -11,18 +11,35 @@ #include "base/callback.h" #include "base/check.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" +#include "components/session_proto_db/session_proto_storage.h" namespace commerce { enum class SubscriptionType; struct CommerceSubscription; +// Used to handle locally fetched subscriptions. using GetLocalSubscriptionsCallback = base::OnceCallback<void( std::unique_ptr<std::vector<CommerceSubscription>>)>; +// Used to handle if storage-related operation succeeds. +using StorageOperationCallback = base::OnceCallback<void(bool)>; + +using CommerceSubscriptionProto = + commerce_subscription_db::CommerceSubscriptionContentProto; +using CommerceSubscriptions = + std::vector<SessionProtoStorage<CommerceSubscriptionProto>::KeyAndValue>; +using SubscriptionManagementTypeProto = commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionManagementType; +using SubscriptionTypeProto = + commerce_subscription_db::CommerceSubscriptionContentProto_SubscriptionType; +using TrackingIdTypeProto = + commerce_subscription_db::CommerceSubscriptionContentProto_TrackingIdType; class SubscriptionsStorage { public: - SubscriptionsStorage(); + explicit SubscriptionsStorage( + SessionProtoStorage<CommerceSubscriptionProto>* subscription_proto_db); SubscriptionsStorage(const SubscriptionsStorage&) = delete; SubscriptionsStorage& operator=(const SubscriptionsStorage&) = delete; virtual ~SubscriptionsStorage(); @@ -45,11 +62,50 @@ // notify |callback| if it completes successfully. virtual void UpdateStorage( SubscriptionType type, - base::OnceCallback<void(bool)> callback, + StorageOperationCallback callback, std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions); // Delete all local subscriptions. virtual void DeleteAll(); + + private: + std::string GetSubscriptionKey(const CommerceSubscription& subscription); + + void SaveSubscription(CommerceSubscription subscription, + StorageOperationCallback callback); + + void DeleteSubscription(CommerceSubscription subscription, + StorageOperationCallback callback); + + void LoadAllSubscriptionsForType(SubscriptionType type, + GetLocalSubscriptionsCallback callback); + + CommerceSubscription GetSubscriptionFromProto( + const SessionProtoStorage<CommerceSubscriptionProto>::KeyAndValue& kv); + + // Convert subscription list to a map keyed by the subscription key to remove + // duplicates and to easily lookup. + std::unordered_map<std::string, CommerceSubscription> SubscriptionsListToMap( + std::unique_ptr<std::vector<CommerceSubscription>> subscriptions); + + void PerformGetNonExistingSubscriptions( + std::unique_ptr<std::vector<CommerceSubscription>> incoming_subscriptions, + GetLocalSubscriptionsCallback callback, + std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions); + + void PerformGetExistingSubscriptions( + std::unique_ptr<std::vector<CommerceSubscription>> incoming_subscriptions, + GetLocalSubscriptionsCallback callback, + std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions); + + void PerformUpdateStorage( + StorageOperationCallback callback, + std::unique_ptr<std::vector<CommerceSubscription>> remote_subscriptions, + std::unique_ptr<std::vector<CommerceSubscription>> local_subscriptions); + + raw_ptr<SessionProtoStorage<CommerceSubscriptionProto>> proto_db_; + + base::WeakPtrFactory<SubscriptionsStorage> weak_ptr_factory_; }; } // namespace commerce
diff --git a/components/commerce/core/subscriptions/subscriptions_storage_unittest.cc b/components/commerce/core/subscriptions/subscriptions_storage_unittest.cc new file mode 100644 index 0000000..9ba972ce --- /dev/null +++ b/components/commerce/core/subscriptions/subscriptions_storage_unittest.cc
@@ -0,0 +1,344 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <queue> +#include <string> +#include <unordered_map> + +#include "base/callback.h" +#include "base/check.h" +#include "base/run_loop.h" +#include "base/test/scoped_feature_list.h" +#include "base/test/task_environment.h" +#include "components/commerce/core/commerce_feature_list.h" +#include "components/commerce/core/proto/commerce_subscription_db_content.pb.h" +#include "components/commerce/core/subscriptions/commerce_subscription.h" +#include "components/commerce/core/subscriptions/subscriptions_storage.h" +#include "components/endpoint_fetcher/endpoint_fetcher.h" +#include "components/session_proto_db/session_proto_storage.h" +#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using testing::_; +using testing::InSequence; + +namespace { + +const int64_t kMockTimestamp1 = 123456; +const int64_t kMockTimestamp2 = 234567; +const int64_t kMockTimestamp3 = 345678; +const std::string kMockId1 = "111"; +const std::string kMockId2 = "222"; +const std::string kMockId3 = "333"; +const std::string kKey1 = "PRICE_TRACK_PRODUCT_CLUSTER_ID_111"; +const std::string kKey2 = "PRICE_TRACK_PRODUCT_CLUSTER_ID_222"; +const std::string kKey3 = "PRICE_TRACK_PRODUCT_CLUSTER_ID_333"; + +std::unique_ptr<std::vector<commerce::CommerceSubscription>> +MockIncomingSubscriptions() { + auto subscriptions = + std::make_unique<std::vector<commerce::CommerceSubscription>>(); + subscriptions->push_back(commerce::CommerceSubscription( + commerce::SubscriptionType::kPriceTrack, + commerce::IdentifierType::kProductClusterId, kMockId1, + commerce::ManagementType::kUserManaged)); + subscriptions->push_back(commerce::CommerceSubscription( + commerce::SubscriptionType::kPriceTrack, + commerce::IdentifierType::kProductClusterId, kMockId2, + commerce::ManagementType::kUserManaged)); + return subscriptions; +} + +std::unique_ptr<std::vector<commerce::CommerceSubscription>> +MockRemoteSubscriptions() { + auto subscriptions = + std::make_unique<std::vector<commerce::CommerceSubscription>>(); + subscriptions->push_back(commerce::CommerceSubscription( + commerce::SubscriptionType::kPriceTrack, + commerce::IdentifierType::kProductClusterId, kMockId1, + commerce::ManagementType::kUserManaged, kMockTimestamp1)); + subscriptions->push_back(commerce::CommerceSubscription( + commerce::SubscriptionType::kPriceTrack, + commerce::IdentifierType::kProductClusterId, kMockId2, + commerce::ManagementType::kUserManaged, kMockTimestamp2)); + return subscriptions; +} + +std::vector< + SessionProtoStorage<commerce::CommerceSubscriptionProto>::KeyAndValue> +MockDbLoadResponse() { + commerce::CommerceSubscriptionProto proto1; + proto1.set_key(kKey2); + proto1.set_tracking_id(kMockId2); + proto1.set_subscription_type( + commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionType_PRICE_TRACK); + proto1.set_tracking_id_type( + commerce_subscription_db:: + CommerceSubscriptionContentProto_TrackingIdType_PRODUCT_CLUSTER_ID); + proto1.set_management_type( + commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionManagementType_USER_MANAGED); + proto1.set_timestamp(kMockTimestamp2); + + commerce::CommerceSubscriptionProto proto2; + proto2.set_key(kKey3); + proto2.set_tracking_id(kMockId3); + proto2.set_subscription_type( + commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionType_PRICE_TRACK); + proto2.set_tracking_id_type( + commerce_subscription_db:: + CommerceSubscriptionContentProto_TrackingIdType_PRODUCT_CLUSTER_ID); + proto2.set_management_type( + commerce_subscription_db:: + CommerceSubscriptionContentProto_SubscriptionManagementType_USER_MANAGED); + proto2.set_timestamp(kMockTimestamp3); + + return std::vector< + SessionProtoStorage<commerce::CommerceSubscriptionProto>::KeyAndValue>{ + {kKey2, proto1}, {kKey3, proto2}}; +} + +class MockProtoStorage + : public SessionProtoStorage<commerce::CommerceSubscriptionProto> { + public: + MockProtoStorage() = default; + ~MockProtoStorage() override = default; + + MOCK_METHOD( + void, + LoadContentWithPrefix, + (const std::string& key_prefix, + SessionProtoStorage<commerce::CommerceSubscriptionProto>::LoadCallback + callback), + (override)); + MOCK_METHOD(void, + InsertContent, + (const std::string& key, + const commerce::CommerceSubscriptionProto& value, + SessionProtoStorage<commerce::CommerceSubscriptionProto>:: + OperationCallback callback), + (override)); + MOCK_METHOD(void, + DeleteOneEntry, + (const std::string& key, + SessionProtoStorage<commerce::CommerceSubscriptionProto>:: + OperationCallback callback), + (override)); + MOCK_METHOD( + void, + DeleteAllContent, + (SessionProtoStorage< + commerce::CommerceSubscriptionProto>::OperationCallback callback), + (override)); + // TODO (crbug.com/1351599): Provide mock version of SessionProtoStorage so we + // don't need to mock all methods here. + MOCK_METHOD(void, + LoadAllEntries, + (SessionProtoStorage< + commerce::CommerceSubscriptionProto>::LoadCallback callback), + (override)); + MOCK_METHOD( + void, + LoadOneEntry, + (const std::string& key, + SessionProtoStorage<commerce::CommerceSubscriptionProto>::LoadCallback + callback), + (override)); + MOCK_METHOD(void, + PerformMaintenance, + (const std::vector<std::string>& keys_to_keep, + const std::string& key_substring_to_match, + SessionProtoStorage<commerce::CommerceSubscriptionProto>:: + OperationCallback callback), + (override)); + MOCK_METHOD(void, + DeleteContentWithPrefix, + (const std::string& key_prefix, + SessionProtoStorage<commerce::CommerceSubscriptionProto>:: + OperationCallback callback), + (override)); + MOCK_METHOD(void, Destroy, (), (const, override)); + + void MockLoadResponse(bool succeeded) { + ON_CALL(*this, LoadContentWithPrefix) + .WillByDefault( + [succeeded]( + const std::string& key_prefix, + SessionProtoStorage<commerce::CommerceSubscriptionProto>:: + LoadCallback callback) { + std::move(callback).Run(succeeded, MockDbLoadResponse()); + }); + } + + void MockOperationResult(bool succeeded) { + ON_CALL(*this, InsertContent) + .WillByDefault( + [succeeded]( + const std::string& key, + const commerce::CommerceSubscriptionProto& value, + SessionProtoStorage<commerce::CommerceSubscriptionProto>:: + OperationCallback callback) { + std::move(callback).Run(succeeded); + }); + ON_CALL(*this, DeleteOneEntry) + .WillByDefault( + [succeeded]( + const std::string& key, + SessionProtoStorage<commerce::CommerceSubscriptionProto>:: + OperationCallback callback) { + std::move(callback).Run(succeeded); + }); + } +}; + +} // namespace + +namespace commerce { + +class SubscriptionsStorageTest : public testing::Test { + public: + SubscriptionsStorageTest() = default; + ~SubscriptionsStorageTest() override = default; + + void SetUp() override { + proto_db_ = std::make_unique<MockProtoStorage>(); + storage_ = std::make_unique<SubscriptionsStorage>(proto_db_.get()); + } + + protected: + base::test::TaskEnvironment task_environment_; + std::unique_ptr<MockProtoStorage> proto_db_; + std::unique_ptr<SubscriptionsStorage> storage_; +}; + +TEST_F(SubscriptionsStorageTest, TestGetUniqueNonExistingSubscriptions) { + proto_db_->MockLoadResponse(true); + EXPECT_CALL(*proto_db_, LoadContentWithPrefix("PRICE_TRACK", _)).Times(1); + + bool callback_executed = false; + storage_->GetUniqueNonExistingSubscriptions( + MockIncomingSubscriptions(), + base::BindOnce( + [](bool* callback_executed, + std::unique_ptr<std::vector<CommerceSubscription>> subscriptions) { + ASSERT_EQ(1, static_cast<int>(subscriptions->size())); + auto subscription = (*subscriptions)[0]; + ASSERT_EQ(SubscriptionType::kPriceTrack, subscription.type); + ASSERT_EQ(IdentifierType::kProductClusterId, subscription.id_type); + ASSERT_EQ(ManagementType::kUserManaged, + subscription.management_type); + ASSERT_EQ(kMockId1, subscription.id); + ASSERT_EQ(kUnknownSubscriptionTimestamp, subscription.timestamp); + + *callback_executed = true; + }, + &callback_executed)); + base::RunLoop().RunUntilIdle(); + ASSERT_EQ(true, callback_executed); +} + +TEST_F(SubscriptionsStorageTest, TestGetUniqueExistingSubscriptions) { + proto_db_->MockLoadResponse(true); + EXPECT_CALL(*proto_db_, LoadContentWithPrefix("PRICE_TRACK", _)).Times(1); + + base::RunLoop run_loop; + storage_->GetUniqueExistingSubscriptions( + MockIncomingSubscriptions(), + base::BindOnce( + [](base::RunLoop* run_loop, + std::unique_ptr<std::vector<CommerceSubscription>> subscriptions) { + ASSERT_EQ(1, static_cast<int>(subscriptions->size())); + auto subscription = (*subscriptions)[0]; + ASSERT_EQ(SubscriptionType::kPriceTrack, subscription.type); + ASSERT_EQ(IdentifierType::kProductClusterId, subscription.id_type); + ASSERT_EQ(ManagementType::kUserManaged, + subscription.management_type); + ASSERT_EQ(kMockId2, subscription.id); + ASSERT_EQ(kMockTimestamp2, subscription.timestamp); + + run_loop->Quit(); + }, + &run_loop)); + run_loop.Run(); +} + +TEST_F(SubscriptionsStorageTest, TestDeleteAll) { + EXPECT_CALL(*proto_db_, DeleteAllContent).Times(1); + storage_->DeleteAll(); +} + +TEST_F(SubscriptionsStorageTest, TestUpdateStorage) { + proto_db_->MockLoadResponse(true); + proto_db_->MockOperationResult(true); + + { + InSequence s; + EXPECT_CALL(*proto_db_, LoadContentWithPrefix("PRICE_TRACK", _)); + EXPECT_CALL(*proto_db_, DeleteOneEntry(kKey3, _)); + EXPECT_CALL(*proto_db_, InsertContent(kKey1, _, _)); + } + + base::RunLoop run_loop; + storage_->UpdateStorage(SubscriptionType::kPriceTrack, + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(true, succeeded); + run_loop->Quit(); + }, + &run_loop), + MockRemoteSubscriptions()); + run_loop.Run(); +} + +TEST_F(SubscriptionsStorageTest, TestUpdateStorage_LoadFailed) { + proto_db_->MockLoadResponse(false); + proto_db_->MockOperationResult(true); + + { + InSequence s; + EXPECT_CALL(*proto_db_, LoadContentWithPrefix("PRICE_TRACK", _)); + EXPECT_CALL(*proto_db_, DeleteOneEntry).Times(0); + EXPECT_CALL(*proto_db_, InsertContent(kKey2, _, _)); + EXPECT_CALL(*proto_db_, InsertContent(kKey1, _, _)); + } + + base::RunLoop run_loop; + storage_->UpdateStorage(SubscriptionType::kPriceTrack, + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(true, succeeded); + run_loop->Quit(); + }, + &run_loop), + MockRemoteSubscriptions()); + run_loop.Run(); +} + +TEST_F(SubscriptionsStorageTest, TestUpdateStorage_OperationFailed) { + proto_db_->MockLoadResponse(true); + proto_db_->MockOperationResult(false); + + { + InSequence s; + EXPECT_CALL(*proto_db_, LoadContentWithPrefix("PRICE_TRACK", _)); + EXPECT_CALL(*proto_db_, DeleteOneEntry(kKey3, _)); + EXPECT_CALL(*proto_db_, InsertContent(kKey1, _, _)); + } + + base::RunLoop run_loop; + storage_->UpdateStorage(SubscriptionType::kPriceTrack, + base::BindOnce( + [](base::RunLoop* run_loop, bool succeeded) { + ASSERT_EQ(false, succeeded); + run_loop->Quit(); + }, + &run_loop), + MockRemoteSubscriptions()); + run_loop.Run(); +} + +} // namespace commerce
diff --git a/components/consent_auditor/consent_auditor_impl_unittest.cc b/components/consent_auditor/consent_auditor_impl_unittest.cc index f2e3d92..6743bcb 100644 --- a/components/consent_auditor/consent_auditor_impl_unittest.cc +++ b/components/consent_auditor/consent_auditor_impl_unittest.cc
@@ -19,7 +19,7 @@ #include "components/consent_auditor/pref_names.h" #include "components/prefs/testing_pref_service.h" #include "components/sync/protocol/user_consent_specifics.pb.h" -#include "components/sync/test/model/fake_model_type_controller_delegate.h" +#include "components/sync/test/fake_model_type_controller_delegate.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/consent_auditor/consent_sync_bridge_impl_unittest.cc b/components/consent_auditor/consent_sync_bridge_impl_unittest.cc index 0baed22..dddf8bc 100644 --- a/components/consent_auditor/consent_sync_bridge_impl_unittest.cc +++ b/components/consent_auditor/consent_sync_bridge_impl_unittest.cc
@@ -15,8 +15,8 @@ #include "components/sync/model/data_batch.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/user_consent_specifics.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/crash/content/browser/crash_metrics_reporter_android.cc b/components/crash/content/browser/crash_metrics_reporter_android.cc index e4363f6..6c1a57b8 100644 --- a/components/crash/content/browser/crash_metrics_reporter_android.cc +++ b/components/crash/content/browser/crash_metrics_reporter_android.cc
@@ -201,16 +201,29 @@ &reported_counts); } break; - case base::android::ChildBindingState::MODERATE: + case base::android::ChildBindingState::VISIBLE: if (intentional_kill || info.normal_termination) { ReportCrashCount( ProcessedCrashCounts:: - kRendererForegroundInvisibleWithModerateBindingKilled, + kRendererForegroundInvisibleWithVisibleBindingKilled, &reported_counts); } else { ReportCrashCount( ProcessedCrashCounts:: - kRendererForegroundInvisibleWithModerateBindingOom, + kRendererForegroundInvisibleWithVisibleBindingOom, + &reported_counts); + } + break; + case base::android::ChildBindingState::NOT_PERCEPTIBLE: + if (intentional_kill || info.normal_termination) { + ReportCrashCount( + ProcessedCrashCounts:: + kRendererForegroundInvisibleWithNotPerceptibleBindingKilled, + &reported_counts); + } else { + ReportCrashCount( + ProcessedCrashCounts:: + kRendererForegroundInvisibleWithNotPerceptibleBindingOom, &reported_counts); } break;
diff --git a/components/crash/content/browser/crash_metrics_reporter_android.h b/components/crash/content/browser/crash_metrics_reporter_android.h index 271ac34a..7b0f686 100644 --- a/components/crash/content/browser/crash_metrics_reporter_android.h +++ b/components/crash/content/browser/crash_metrics_reporter_android.h
@@ -51,7 +51,11 @@ kUtilityForegroundOom = 17, kUtilityCrashAll = 18, kRendererProcessHostShutdown = 19, - kMaxValue = kRendererProcessHostShutdown + kRendererForegroundInvisibleWithVisibleBindingKilled = 20, + kRendererForegroundInvisibleWithVisibleBindingOom = 21, + kRendererForegroundInvisibleWithNotPerceptibleBindingKilled = 22, + kRendererForegroundInvisibleWithNotPerceptibleBindingOom = 23, + kMaxValue = kRendererForegroundInvisibleWithNotPerceptibleBindingOom }; using ReportedCrashTypeSet = base::flat_set<ProcessedCrashCounts>;
diff --git a/components/desks_storage/core/desk_model_wrapper_unittests.cc b/components/desks_storage/core/desk_model_wrapper_unittests.cc index dec3c2a..5e4298541 100644 --- a/components/desks_storage/core/desk_model_wrapper_unittests.cc +++ b/components/desks_storage/core/desk_model_wrapper_unittests.cc
@@ -35,9 +35,9 @@ #include "components/sync/model/metadata_batch.h" #include "components/sync/protocol/entity_data.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" +#include "components/sync/test/test_matchers.h" #include "desk_model_wrapper.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/desks_storage/core/desk_sync_bridge_unittest.cc b/components/desks_storage/core/desk_sync_bridge_unittest.cc index 54f7e10..70f5558 100644 --- a/components/desks_storage/core/desk_sync_bridge_unittest.cc +++ b/components/desks_storage/core/desk_sync_bridge_unittest.cc
@@ -33,9 +33,9 @@ #include "components/sync/model/metadata_batch.h" #include "components/sync/protocol/entity_data.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" +#include "components/sync/test/test_matchers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/desks_storage/core/desk_template_semantics_unittests.cc b/components/desks_storage/core/desk_template_semantics_unittests.cc index 29e0fa6..79aefb10 100644 --- a/components/desks_storage/core/desk_template_semantics_unittests.cc +++ b/components/desks_storage/core/desk_template_semantics_unittests.cc
@@ -13,8 +13,8 @@ #include "components/desks_storage/core/desk_test_util.h" #include "components/services/app_service/public/cpp/app_registry_cache.h" #include "components/sync/protocol/workspace_desk_specifics.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace desks_storage {
diff --git a/components/endpoint_fetcher/endpoint_fetcher.h b/components/endpoint_fetcher/endpoint_fetcher.h index e3e7f5f..319eabe 100644 --- a/components/endpoint_fetcher/endpoint_fetcher.h +++ b/components/endpoint_fetcher/endpoint_fetcher.h
@@ -124,7 +124,7 @@ virtual ~EndpointFetcher(); // TODO(crbug.com/999256) enable cancellation support - void Fetch(EndpointFetcherCallback callback); + virtual void Fetch(EndpointFetcherCallback callback); virtual void PerformRequest(EndpointFetcherCallback endpoint_fetcher_callback, const char* key);
diff --git a/components/exo/wayland/protocol/aura-shell.xml b/components/exo/wayland/protocol/aura-shell.xml index 3baf6de4..8903e28ac 100644 --- a/components/exo/wayland/protocol/aura-shell.xml +++ b/components/exo/wayland/protocol/aura-shell.xml
@@ -778,13 +778,13 @@ The window has been minimized. </description> </entry> - <entry name="snapped_primary" value="102"> + <entry name="snapped_primary" value="102" since="38"> <description summary="window is snapped in primary position"> The window is snapped to the left if the display is in landscape mode and at the top in portrait mode. </description> </entry> - <entry name="snapped_secondary" value="103"> + <entry name="snapped_secondary" value="103" since="38"> <description summary="window is snapped in secondary position"> The window is snapped to the right if the display is in landscape mode and at the bottom in portrait mode.
diff --git a/components/feature_engagement/OWNERS b/components/feature_engagement/OWNERS index 354f99d..52ee613 100644 --- a/components/feature_engagement/OWNERS +++ b/components/feature_engagement/OWNERS
@@ -2,6 +2,7 @@ nyquist@chromium.org shaktisahu@chromium.org +# For mobile platforms: per-file ...event_constants.*=twellington@chromium.org per-file ...feature_configurations.cc=twellington@chromium.org per-file ...feature_constants.*=twellington@chromium.org @@ -9,3 +10,8 @@ per-file ...EventConstants.java=twellington@chromium.org per-file ...FeatureConstants.java=twellington@chromium.org +# For User Education/Feature Engagement on desktop platforms: +per-file ...event_constants.*=dfried@chromium.org +per-file ...feature_configurations.cc=dfried@chromium.org +per-file ...feature_constants.*=dfried@chromium.org +per-file ...feature_list.*=dfried@chromium.org
diff --git a/components/history/core/browser/sync/delete_directive_handler_unittest.cc b/components/history/core/browser/sync/delete_directive_handler_unittest.cc index fd33bd7..708dafe 100644 --- a/components/history/core/browser/sync/delete_directive_handler_unittest.cc +++ b/components/history/core/browser/sync/delete_directive_handler_unittest.cc
@@ -23,8 +23,8 @@ #include "components/sync/model/sync_error_factory.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/history_delete_directive_specifics.pb.h" -#include "components/sync/test/model/fake_sync_change_processor.h" -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/fake_sync_change_processor.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/history/core/browser/sync/history_sync_bridge_unittest.cc b/components/history/core/browser/sync/history_sync_bridge_unittest.cc index 8c8ecfde..93346555 100644 --- a/components/history/core/browser/sync/history_sync_bridge_unittest.cc +++ b/components/history/core/browser/sync/history_sync_bridge_unittest.cc
@@ -20,7 +20,7 @@ #include "components/sync/model/model_type_change_processor.h" #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/history_specifics.pb.h" -#include "components/sync/test/model/forwarding_model_type_change_processor.h" +#include "components/sync/test/forwarding_model_type_change_processor.h" #include "sql/database.h" #include "sql/meta_table.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc b/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc index db1cf30..77120ff 100644 --- a/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc +++ b/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc
@@ -25,7 +25,7 @@ #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/typed_url_specifics.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/messages/android/java/src/org/chromium/components/messages/MessagesMetrics.java b/components/messages/android/java/src/org/chromium/components/messages/MessagesMetrics.java index ad571351..c04254a 100644 --- a/components/messages/android/java/src/org/chromium/components/messages/MessagesMetrics.java +++ b/components/messages/android/java/src/org/chromium/components/messages/MessagesMetrics.java
@@ -151,6 +151,8 @@ return "InvalidMessage"; case MessageIdentifier.DESKTOP_SITE_GLOBAL_DEFAULT_OPT_OUT: return "DesktopSiteGlobalDefaultOptOut"; + case MessageIdentifier.DESKTOP_SITE_GLOBAL_OPT_IN: + return "DesktopSiteGlobalOptIn"; default: return "Unknown"; }
diff --git a/components/messages/android/message_enums.h b/components/messages/android/message_enums.h index 5fd73651..c62feeb 100644 --- a/components/messages/android/message_enums.h +++ b/components/messages/android/message_enums.h
@@ -111,6 +111,7 @@ EXTERNAL_NAVIGATION = 31, FRAMEBUST_BLOCKED = 32, DESKTOP_SITE_GLOBAL_DEFAULT_OPT_OUT = 33, + DESKTOP_SITE_GLOBAL_OPT_IN = 34, // Insert new values before this line. COUNT
diff --git a/components/metrics/demographics/demographic_metrics_test_utils.h b/components/metrics/demographics/demographic_metrics_test_utils.h index 84a6576..3847ad03 100644 --- a/components/metrics/demographics/demographic_metrics_test_utils.h +++ b/components/metrics/demographics/demographic_metrics_test_utils.h
@@ -13,7 +13,7 @@ #include "components/metrics/metrics_service.h" #include "components/network_time/network_time_tracker.h" #include "components/prefs/pref_service.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h" #include "third_party/metrics_proto/user_demographics.pb.h"
diff --git a/components/omnibox/browser/history_fuzzy_provider.cc b/components/omnibox/browser/history_fuzzy_provider.cc index 74ecab3..297e8314 100644 --- a/components/omnibox/browser/history_fuzzy_provider.cc +++ b/components/omnibox/browser/history_fuzzy_provider.cc
@@ -21,6 +21,7 @@ #include "base/metrics/histogram_macros.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/system/sys_info.h" #include "base/time/time.h" #include "base/trace_event/memory_usage_estimator.h" #include "base/trace_event/trace_event.h" @@ -138,6 +139,13 @@ return remaining; } +// Indicates whether to deactivate fuzzy processing due to device performance +// and memory constraints. This prevents loading, updating, and fuzzy search. +bool ShouldBypassForLowEndDevice() { + return OmniboxFieldTrial::kFuzzyUrlSuggestionsLowEndBypass.Get() && + base::SysInfo::IsLowEndDevice(); +} + } // namespace namespace fuzzy { @@ -514,6 +522,14 @@ HistoryFuzzyProvider::HistoryFuzzyProvider(AutocompleteProviderClient* client) : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_FUZZY, client) { + if (ShouldBypassForLowEndDevice()) { + // Note, this early return will prevent loading from database, which saves + // memory and prevents this provider from working to find fuzzy matches. + // See also the early return in `Start` below; `urls_loaded_event_` never + // signals because the signaling task is never run. + return; + } + history_service_observation_.Observe(client->GetHistoryService()); client->GetHistoryService()->ScheduleDBTask( FROM_HERE, @@ -533,6 +549,8 @@ return; } + // Note this will always return early when bypassing for low-end devices; + // see comment in constructor. if (!urls_loaded_event_.IsSignaled()) { return; } @@ -705,6 +723,9 @@ history::HistoryService* history_service, const history::URLRow& url_row, const history::VisitRow& new_visit) { + if (ShouldBypassForLowEndDevice()) { + return; + } DVLOG(1) << "URL Visit: " << url_row.url(); if (root_.TerminalCount() < std::min(OmniboxFieldTrial::MaxNumHQPUrlsIndexedAtStartup(), @@ -716,6 +737,9 @@ void HistoryFuzzyProvider::OnURLsDeleted( history::HistoryService* history_service, const history::DeletionInfo& deletion_info) { + if (ShouldBypassForLowEndDevice()) { + return; + } // Note, this implementation is conservative in terms of user privacy; it // deletes hosts from the trie if any URL with the given host is deleted. if (deletion_info.IsAllHistory()) {
diff --git a/components/omnibox/browser/omnibox_field_trial.cc b/components/omnibox/browser/omnibox_field_trial.cc index 9457e41..ce514aa9 100644 --- a/components/omnibox/browser/omnibox_field_trial.cc +++ b/components/omnibox/browser/omnibox_field_trial.cc
@@ -601,6 +601,12 @@ "FuzzyUrlSuggestionsCounterfactual", false); +const base::FeatureParam<bool> + OmniboxFieldTrial::kFuzzyUrlSuggestionsLowEndBypass( + &omnibox::kOmniboxFuzzyUrlSuggestions, + "FuzzyUrlSuggestionsLowEndBypass", + false); + bool OmniboxFieldTrial::IsExperimentalKeywordModeEnabled() { return base::FeatureList::IsEnabled(omnibox::kExperimentalKeywordMode); }
diff --git a/components/omnibox/browser/omnibox_field_trial.h b/components/omnibox/browser/omnibox_field_trial.h index 50b8953..4d9c821 100644 --- a/components/omnibox/browser/omnibox_field_trial.h +++ b/components/omnibox/browser/omnibox_field_trial.h
@@ -357,6 +357,8 @@ bool IsFuzzyUrlSuggestionsEnabled(); // Indicates whether fuzzy match behavior is counterfactual. extern const base::FeatureParam<bool> kFuzzyUrlSuggestionsCounterfactual; +// Indicates whether to bypass fuzzy processing when `IsLowEndDevice` is true. +extern const base::FeatureParam<bool> kFuzzyUrlSuggestionsLowEndBypass; // Simply a convenient wrapper for testing a flag. Used downstream for an // assortment of keyword mode experiments.
diff --git a/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc b/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc index e6a2551c..3848e20 100644 --- a/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc +++ b/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc
@@ -34,8 +34,8 @@ #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" #include "components/sync/protocol/password_specifics.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/test_matchers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/payments/content/android/java/src/org/chromium/components/payments/BasicCardUtils.java b/components/payments/content/android/java/src/org/chromium/components/payments/BasicCardUtils.java index 4336d4b..3311e5a 100644 --- a/components/payments/content/android/java/src/org/chromium/components/payments/BasicCardUtils.java +++ b/components/payments/content/android/java/src/org/chromium/components/payments/BasicCardUtils.java
@@ -73,22 +73,5 @@ return networksByString; } - /** @return True if the merchant methodDataMap supports basic card payment method. */ - public static boolean merchantSupportsBasicCard(Map<String, PaymentMethodData> methodDataMap) { - if (!PaymentFeatureList.isEnabled(PaymentFeatureList.PAYMENT_REQUEST_BASIC_CARD)) { - return false; - } - assert methodDataMap != null; - PaymentMethodData basicCardData = methodDataMap.get(MethodStrings.BASIC_CARD); - if (basicCardData != null) { - Set<String> basicCardNetworks = convertBasicCardToNetworks(basicCardData); - if (basicCardNetworks != null && !basicCardNetworks.isEmpty()) return true; - } - - // Card issuer networks as payment method names was removed in Chrome 77. - // https://www.chromestatus.com/feature/5725727580225536 - return false; - } - private BasicCardUtils() {} }
diff --git a/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java b/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java index fd577f3..45c571b 100644 --- a/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java +++ b/components/payments/content/android/java/src/org/chromium/components/payments/PaymentFeatureList.java
@@ -25,7 +25,6 @@ "IdentityInCanMakePaymentEventFeature"; public static final String SECURE_PAYMENT_CONFIRMATION = "SecurePaymentConfirmationBrowser"; public static final String SERVICE_WORKER_PAYMENT_APPS = "ServiceWorkerPaymentApps"; - public static final String PAYMENT_REQUEST_BASIC_CARD = "PaymentRequestBasicCard"; public static final String WEB_PAYMENTS = "WebPayments"; public static final String WEB_PAYMENTS_APP_STORE_BILLING = "AppStoreBilling"; public static final String WEB_PAYMENTS_APP_STORE_BILLING_DEBUG = "AppStoreBillingDebug";
diff --git a/components/payments/content/android/java/src/org/chromium/components/payments/PaymentRequestService.java b/components/payments/content/android/java/src/org/chromium/components/payments/PaymentRequestService.java index 9cae37c..42ae155b 100644 --- a/components/payments/content/android/java/src/org/chromium/components/payments/PaymentRequestService.java +++ b/components/payments/content/android/java/src/org/chromium/components/payments/PaymentRequestService.java
@@ -145,12 +145,6 @@ /** True if canMakePayment() and hasEnrolledInstrument() are forced to return true. */ private boolean mCanMakePaymentEvenWithoutApps; - /** - * Whether there's at least one app that is not an autofill card. Should be read only after all - * payment apps have been queried. - */ - private boolean mHasNonAutofillApp; - private boolean mIsCanMakePaymentResponsePending; private boolean mIsHasEnrolledInstrumentResponsePending; @Nullable @@ -690,9 +684,6 @@ methodTypes.add(PaymentMethodCategory.OTHER); } } - if (BasicCardUtils.merchantSupportsBasicCard(methodDataMap)) { - methodTypes.add(PaymentMethodCategory.BASIC_CARD); - } mJourneyLogger.setRequestedPaymentMethods(methodTypes); } @@ -776,24 +767,19 @@ private void logSelectedMethod(PaymentApp invokedPaymentApp) { @PaymentMethodCategory int category = PaymentMethodCategory.OTHER; - if (invokedPaymentApp.getPaymentAppType() == PaymentAppType.AUTOFILL) { - category = PaymentMethodCategory.BASIC_CARD; - } else { - for (String method : invokedPaymentApp.getInstrumentMethodNames()) { - if (method.equals(MethodStrings.ANDROID_PAY) - || method.equals(MethodStrings.GOOGLE_PAY)) { - category = PaymentMethodCategory.GOOGLE; - break; - } else if (method.equals(MethodStrings.GOOGLE_PLAY_BILLING)) { - assert invokedPaymentApp.getPaymentAppType() - == PaymentAppType.NATIVE_MOBILE_APP; - category = PaymentMethodCategory.PLAY_BILLING; - break; - } else if (method.equals(MethodStrings.SECURE_PAYMENT_CONFIRMATION)) { - assert invokedPaymentApp.getPaymentAppType() == PaymentAppType.INTERNAL; - category = PaymentMethodCategory.SECURE_PAYMENT_CONFIRMATION; - break; - } + for (String method : invokedPaymentApp.getInstrumentMethodNames()) { + if (method.equals(MethodStrings.ANDROID_PAY) + || method.equals(MethodStrings.GOOGLE_PAY)) { + category = PaymentMethodCategory.GOOGLE; + break; + } else if (method.equals(MethodStrings.GOOGLE_PLAY_BILLING)) { + assert invokedPaymentApp.getPaymentAppType() == PaymentAppType.NATIVE_MOBILE_APP; + category = PaymentMethodCategory.PLAY_BILLING; + break; + } else if (method.equals(MethodStrings.SECURE_PAYMENT_CONFIRMATION)) { + assert invokedPaymentApp.getPaymentAppType() == PaymentAppType.INTERNAL; + category = PaymentMethodCategory.SECURE_PAYMENT_CONFIRMATION; + break; } } @@ -1039,13 +1025,8 @@ if (mBrowserPaymentRequest == null) return; if (!mBrowserPaymentRequest.onPaymentAppCreated(paymentApp)) return; mHasEnrolledInstrument |= paymentApp.hasEnrolledInstrument(); - mHasNonAutofillApp |= paymentApp.getPaymentAppType() != PaymentAppType.AUTOFILL; - // Note that only a test can add autofill payment apps when basic-card feature is disabled. - if (PaymentFeatureList.isEnabled(PaymentFeatureList.PAYMENT_REQUEST_BASIC_CARD) - && paymentApp.getPaymentAppType() == PaymentAppType.AUTOFILL) { - mJourneyLogger.setAvailableMethod(PaymentMethodCategory.BASIC_CARD); - } else if (paymentApp.getInstrumentMethodNames().contains(MethodStrings.GOOGLE_PAY) + if (paymentApp.getInstrumentMethodNames().contains(MethodStrings.GOOGLE_PAY) || paymentApp.getInstrumentMethodNames().contains(MethodStrings.ANDROID_PAY)) { mJourneyLogger.setAvailableMethod(PaymentMethodCategory.GOOGLE); } else { @@ -1212,8 +1193,7 @@ private static boolean onlySingleAppCanProvideAllRequiredInformation( PaymentOptions options, List<PaymentApp> allApps) { if (!PaymentOptionsUtils.requestAnyInformation(options)) { - return allApps.size() == 1 - && allApps.get(0).getPaymentAppType() != PaymentAppType.AUTOFILL; + return allApps.size() == 1; } boolean anAppCanProvideAllInfo = false;
diff --git a/components/payments/content/android/junit/src/org/chromium/components/payments/test_support/ShadowPaymentFeatureList.java b/components/payments/content/android/junit/src/org/chromium/components/payments/test_support/ShadowPaymentFeatureList.java index 2a45083..32c4569 100644 --- a/components/payments/content/android/junit/src/org/chromium/components/payments/test_support/ShadowPaymentFeatureList.java +++ b/components/payments/content/android/junit/src/org/chromium/components/payments/test_support/ShadowPaymentFeatureList.java
@@ -36,8 +36,6 @@ ShadowPaymentFeatureList.setFeatureEnabled( PaymentFeatureList.SECURE_PAYMENT_CONFIRMATION, true); ShadowPaymentFeatureList.setFeatureEnabled( - PaymentFeatureList.PAYMENT_REQUEST_BASIC_CARD, true); - ShadowPaymentFeatureList.setFeatureEnabled( PaymentFeatureList.IDENTITY_IN_CAN_MAKE_PAYMENT_EVENT_FEATURE, true); }
diff --git a/components/payments/content/android/payment_feature_list.cc b/components/payments/content/android/payment_feature_list.cc index 66c3d58..af171a00 100644 --- a/components/payments/content/android/payment_feature_list.cc +++ b/components/payments/content/android/payment_feature_list.cc
@@ -21,7 +21,6 @@ // or the .h file (for Android only features). const base::Feature* const kFeaturesExposedToJava[] = { &::features::kIdentityInCanMakePaymentEventFeature, - &::features::kPaymentRequestBasicCard, &::features::kSecurePaymentConfirmation, &::features::kServiceWorkerPaymentApps, &::features::kWebPayments,
diff --git a/components/payments/content/payment_app.cc b/components/payments/content/payment_app.cc index 9820a34..bfd2c2f 100644 --- a/components/payments/content/payment_app.cc +++ b/components/payments/content/payment_app.cc
@@ -23,10 +23,6 @@ case PaymentApp::Type::SERVICE_WORKER_APP: case PaymentApp::Type::NATIVE_MOBILE_APP: return 2; - case PaymentApp::Type::AUTOFILL: - // TODO(https://crbug.com/1209835): Remove PaymentApp::Type::AUTOFILL. - NOTREACHED() << "Autofill payment app is no longer supported"; - return 99; case PaymentApp::Type::UNDEFINED: NOTREACHED(); return 99;
diff --git a/components/payments/content/payment_app.h b/components/payments/content/payment_app.h index 3b8ffd85..e6dc0b6 100644 --- a/components/payments/content/payment_app.h +++ b/components/payments/content/payment_app.h
@@ -33,8 +33,6 @@ // Undefined type of payment app. Can be used for setting the default return // value of an abstract class or an interface. UNDEFINED, - // The payment app built into the browser that uses the autofill data. - AUTOFILL, // A 3rd-party platform-specific mobile app, such as an Android app // integrated via // https://developers.google.com/web/fundamentals/payments/payment-apps-developer-guide/android-payment-apps
diff --git a/components/payments/content/payment_request.cc b/components/payments/content/payment_request.cc index 5e0dbbd..a725774 100644 --- a/components/payments/content/payment_request.cc +++ b/components/payments/content/payment_request.cc
@@ -704,9 +704,7 @@ if (!spec()->request_shipping() && !spec()->request_payer_name() && !spec()->request_payer_phone() && !spec()->request_payer_email()) { - return state()->available_apps().size() == 1 && - state()->available_apps().at(0)->type() != - PaymentApp::Type::AUTOFILL; + return state()->available_apps().size() == 1; } bool an_app_can_provide_all_info = false; @@ -916,8 +914,6 @@ const PaymentApp* selected_app = state_->selected_app(); DCHECK(selected_app); switch (state_->selected_app()->type()) { - case PaymentApp::Type::AUTOFILL: - return JourneyLogger::PaymentMethodCategory::kBasicCard; case PaymentApp::Type::SERVICE_WORKER_APP: // Intentionally fall through. case PaymentApp::Type::NATIVE_MOBILE_APP: {
diff --git a/components/payments/content/payment_request_spec_unittest.cc b/components/payments/content/payment_request_spec_unittest.cc index c0769a5..661e86758 100644 --- a/components/payments/content/payment_request_spec_unittest.cc +++ b/components/payments/content/payment_request_spec_unittest.cc
@@ -22,10 +22,10 @@ using ::testing::ElementsAre; using ::testing::UnorderedElementsAre; -class PaymentRequestSpecTestBase : public testing::Test, - public PaymentRequestSpec::Observer { +class PaymentRequestSpecTest : public testing::Test, + public PaymentRequestSpec::Observer { protected: - ~PaymentRequestSpecTestBase() override = default; + ~PaymentRequestSpecTest() override = default; void OnSpecUpdated() override { on_spec_updated_called_ = true; } @@ -51,29 +51,12 @@ private: std::unique_ptr<PaymentRequestSpec> spec_; bool on_spec_updated_called_ = false; - base::WeakPtrFactory<PaymentRequestSpecTestBase> weak_ptr_factory_{this}; -}; - -class PaymentRequestSpecBasiCardEnabledTest - : public PaymentRequestSpecTestBase { - public: - PaymentRequestSpecBasiCardEnabledTest( - const PaymentRequestSpecBasiCardEnabledTest&) = delete; - PaymentRequestSpecBasiCardEnabledTest& operator=( - const PaymentRequestSpecBasiCardEnabledTest&) = delete; - - protected: - PaymentRequestSpecBasiCardEnabledTest() { - feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); - } - - private: - base::test::ScopedFeatureList feature_list_; + base::WeakPtrFactory<PaymentRequestSpecTest> weak_ptr_factory_{this}; }; // Test that the last shipping option is selected, even in the case of // updateWith. -TEST_F(PaymentRequestSpecBasiCardEnabledTest, ShippingOptionsSelection) { +TEST_F(PaymentRequestSpecTest, ShippingOptionsSelection) { std::vector<mojom::PaymentShippingOptionPtr> shipping_options; mojom::PaymentShippingOptionPtr option = mojom::PaymentShippingOption::New(); option->id = "option:1"; @@ -116,8 +99,7 @@ // Test that the last shipping option is selected, even in the case of // updateWith. -TEST_F(PaymentRequestSpecBasiCardEnabledTest, - ShippingOptionsSelection_NoOptionsAtAll) { +TEST_F(PaymentRequestSpecTest, ShippingOptionsSelection_NoOptionsAtAll) { // No options are provided at first. mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New(); options->request_shipping = true; @@ -156,7 +138,7 @@ // Test that the last shipping option is selected, even in the case of // updateWith. -TEST_F(PaymentRequestSpecBasiCardEnabledTest, UpdateWithNoShippingOptions) { +TEST_F(PaymentRequestSpecTest, UpdateWithNoShippingOptions) { std::vector<mojom::PaymentShippingOptionPtr> shipping_options; mojom::PaymentShippingOptionPtr option = mojom::PaymentShippingOption::New(); option->id = "option:1"; @@ -183,8 +165,7 @@ EXPECT_TRUE(spec()->selected_shipping_option_error().empty()); } -TEST_F(PaymentRequestSpecBasiCardEnabledTest, - SingleCurrencyWithoutDisplayItems) { +TEST_F(PaymentRequestSpecTest, SingleCurrencyWithoutDisplayItems) { mojom::PaymentDetailsPtr details = mojom::PaymentDetails::New(); mojom::PaymentItemPtr total = mojom::PaymentItem::New(); mojom::PaymentCurrencyAmountPtr amount = mojom::PaymentCurrencyAmount::New(); @@ -198,7 +179,7 @@ EXPECT_FALSE(spec()->IsMixedCurrency()); } -TEST_F(PaymentRequestSpecBasiCardEnabledTest, SingleCurrencyWithDisplayItems) { +TEST_F(PaymentRequestSpecTest, SingleCurrencyWithDisplayItems) { mojom::PaymentDetailsPtr details = mojom::PaymentDetails::New(); mojom::PaymentItemPtr total = mojom::PaymentItem::New(); mojom::PaymentCurrencyAmountPtr amount = mojom::PaymentCurrencyAmount::New(); @@ -221,8 +202,7 @@ EXPECT_FALSE(spec()->IsMixedCurrency()); } -TEST_F(PaymentRequestSpecBasiCardEnabledTest, - MultipleCurrenciesWithOneDisplayItem) { +TEST_F(PaymentRequestSpecTest, MultipleCurrenciesWithOneDisplayItem) { mojom::PaymentDetailsPtr details = mojom::PaymentDetails::New(); mojom::PaymentItemPtr total = mojom::PaymentItem::New(); mojom::PaymentCurrencyAmountPtr amount = mojom::PaymentCurrencyAmount::New(); @@ -246,8 +226,7 @@ EXPECT_TRUE(spec()->IsMixedCurrency()); } -TEST_F(PaymentRequestSpecBasiCardEnabledTest, - MultipleCurrenciesWithTwoDisplayItem) { +TEST_F(PaymentRequestSpecTest, MultipleCurrenciesWithTwoDisplayItem) { mojom::PaymentDetailsPtr details = mojom::PaymentDetails::New(); mojom::PaymentItemPtr total = mojom::PaymentItem::New(); mojom::PaymentCurrencyAmountPtr amount = mojom::PaymentCurrencyAmount::New(); @@ -278,7 +257,7 @@ EXPECT_TRUE(spec()->IsMixedCurrency()); } -TEST_F(PaymentRequestSpecBasiCardEnabledTest, RetryWithShippingAddressErrors) { +TEST_F(PaymentRequestSpecTest, RetryWithShippingAddressErrors) { mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New(); options->request_shipping = true; RecreateSpecWithOptionsAndDetails(std::move(options), @@ -305,7 +284,7 @@ EXPECT_TRUE(spec()->has_shipping_address_error()); } -TEST_F(PaymentRequestSpecBasiCardEnabledTest, RetryWithPayerErrors) { +TEST_F(PaymentRequestSpecTest, RetryWithPayerErrors) { mojom::PaymentOptionsPtr options = mojom::PaymentOptions::New(); options->request_payer_email = true; options->request_payer_name = true;
diff --git a/components/payments/content/payment_request_state.cc b/components/payments/content/payment_request_state.cc index 781766af..8bc534e 100644 --- a/components/payments/content/payment_request_state.cc +++ b/components/payments/content/payment_request_state.cc
@@ -169,11 +169,8 @@ void PaymentRequestState::OnPaymentAppCreated(std::unique_ptr<PaymentApp> app) { if (journey_logger_) { - if (app->type() == PaymentApp::Type::AUTOFILL) { - journey_logger_->SetAvailableMethod( - JourneyLogger::PaymentMethodCategory::kBasicCard); - } else if (base::Contains(app->GetAppMethodNames(), methods::kGooglePay) || - base::Contains(app->GetAppMethodNames(), methods::kAndroidPay)) { + if (base::Contains(app->GetAppMethodNames(), methods::kGooglePay) || + base::Contains(app->GetAppMethodNames(), methods::kAndroidPay)) { journey_logger_->SetAvailableMethod( JourneyLogger::PaymentMethodCategory::kGoogle); } else {
diff --git a/components/payments/content/service_worker_payment_app_finder.cc b/components/payments/content/service_worker_payment_app_finder.cc index 8b43425..1aaa14a 100644 --- a/components/payments/content/service_worker_payment_app_finder.cc +++ b/components/payments/content/service_worker_payment_app_finder.cc
@@ -43,34 +43,6 @@ namespace payments { namespace { -// Returns true if |requested| is empty or contains at least one of the items in -// |capabilities|. -template <typename T> -bool CapabilityMatches(const std::vector<T>& requested, - const std::vector<int32_t>& capabilities) { - if (requested.empty()) - return true; - for (const auto& request : requested) { - if (base::Contains(capabilities, static_cast<int32_t>(request))) - return true; - } - return false; -} - -// Returns true if the basic-card |capabilities| of the payment app match the -// |request|. -bool BasicCardCapabilitiesMatch( - const std::vector<content::StoredCapabilities>& capabilities, - const mojom::PaymentMethodDataPtr& request) { - for (const auto& capability : capabilities) { - if (CapabilityMatches(request->supported_networks, - capability.supported_card_networks)) { - return true; - } - } - return capabilities.empty() && request->supported_networks.empty(); -} - // Returns true if |app| supports at least one of the |requests|. bool AppSupportsAtLeastOneRequestedMethodData( const content::StoredPaymentApp& app, @@ -78,12 +50,7 @@ for (const auto& enabled_method : app.enabled_methods) { for (const auto& request : requests) { if (enabled_method == request->supported_method) { - if (!base::FeatureList::IsEnabled(::features::kPaymentRequestBasicCard)) - return true; - if (enabled_method != methods::kBasicCard || - BasicCardCapabilitiesMatch(app.capabilities, request)) { - return true; - } + return true; } } }
diff --git a/components/payments/content/service_worker_payment_app_finder_unittest.cc b/components/payments/content/service_worker_payment_app_finder_unittest.cc index ee2d71a..be7342a 100644 --- a/components/payments/content/service_worker_payment_app_finder_unittest.cc +++ b/components/payments/content/service_worker_payment_app_finder_unittest.cc
@@ -4,8 +4,6 @@ #include "components/payments/content/service_worker_payment_app_finder.h" -#include "base/test/scoped_feature_list.h" -#include "content/public/common/content_features.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/mojom/payments/payment_request.mojom.h" @@ -162,56 +160,4 @@ apps.find(0)->second->enabled_methods); } -class ServiceWorkerPaymentAppFinderBasicCardEnabledTest - : public ServiceWorkerPaymentAppFinderTest { - public: - ServiceWorkerPaymentAppFinderBasicCardEnabledTest( - const ServiceWorkerPaymentAppFinderBasicCardEnabledTest&) = delete; - ServiceWorkerPaymentAppFinderBasicCardEnabledTest& operator=( - const ServiceWorkerPaymentAppFinderBasicCardEnabledTest&) = delete; - - protected: - ServiceWorkerPaymentAppFinderBasicCardEnabledTest() { - feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); - } - - private: - base::test::ScopedFeatureList feature_list_; -}; - -TEST_F(ServiceWorkerPaymentAppFinderBasicCardEnabledTest, - RemoveAppsWithoutMatchingMethodData_NoNetworkCapabilities) { - std::vector<mojom::PaymentMethodDataPtr> requested_methods; - requested_methods.emplace_back(mojom::PaymentMethodData::New()); - requested_methods.back()->supported_method = "basic-card"; - requested_methods.back()->supported_networks = { - mojom::BasicCardNetwork::AMEX}; - content::InstalledPaymentAppsFinder::PaymentApps apps; - apps[0] = std::make_unique<content::StoredPaymentApp>(); - apps[0]->enabled_methods = {"basic-card"}; - - RemoveAppsWithoutMatchingMethodData(requested_methods, &apps); - - EXPECT_TRUE(apps.empty()); -} - -TEST_F(ServiceWorkerPaymentAppFinderBasicCardEnabledTest, - RemoveAppsWithoutMatchingMethodData_NoMatchingNetworkCapabilities) { - std::vector<mojom::PaymentMethodDataPtr> requested_methods; - requested_methods.emplace_back(mojom::PaymentMethodData::New()); - requested_methods.back()->supported_method = "basic-card"; - requested_methods.back()->supported_networks = { - mojom::BasicCardNetwork::AMEX}; - content::InstalledPaymentAppsFinder::PaymentApps apps; - apps[0] = std::make_unique<content::StoredPaymentApp>(); - apps[0]->enabled_methods = {"basic-card"}; - apps[0]->capabilities.emplace_back(); - apps[0]->capabilities.back().supported_card_networks = { - static_cast<int32_t>(mojom::BasicCardNetwork::VISA)}; - - RemoveAppsWithoutMatchingMethodData(requested_methods, &apps); - - EXPECT_TRUE(apps.empty()); -} - } // namespace payments
diff --git a/components/reading_list/core/reading_list_model_unittest.cc b/components/reading_list/core/reading_list_model_unittest.cc index fe8c401..8fd26acf 100644 --- a/components/reading_list/core/reading_list_model_unittest.cc +++ b/components/reading_list/core/reading_list_model_unittest.cc
@@ -12,7 +12,7 @@ #include "components/reading_list/core/reading_list_store_delegate.h" #include "components/sync/model/metadata_change_list.h" #include "components/sync/model/model_error.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include "testing/gtest/include/gtest/gtest.h" namespace {
diff --git a/components/reading_list/core/reading_list_store_unittest.cc b/components/reading_list/core/reading_list_store_unittest.cc index 3c4c7e7..dbe94fd 100644 --- a/components/reading_list/core/reading_list_store_unittest.cc +++ b/components/reading_list/core/reading_list_store_unittest.cc
@@ -13,8 +13,8 @@ #include "base/test/simple_test_clock.h" #include "base/test/task_environment.h" #include "components/reading_list/core/reading_list_model_impl.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/search/ntp_features.cc b/components/search/ntp_features.cc index cea5d0cd..37dd2c7f 100644 --- a/components/search/ntp_features.cc +++ b/components/search/ntp_features.cc
@@ -101,7 +101,7 @@ // If enabled, the first run experience for Modular NTP Desktop v1 will show. const base::Feature kNtpModulesFirstRunExperience{ - "NtpModulesFirstRunExperience", base::FEATURE_DISABLED_BY_DEFAULT}; + "NtpModulesFirstRunExperience", base::FEATURE_ENABLED_BY_DEFAULT}; // If enabled, modules will be loaded but not shown. This is useful to determine // if a user would have seen modules in order to counterfactually log or
diff --git a/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc b/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc index f511e5b6..f038410 100644 --- a/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc +++ b/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc
@@ -22,9 +22,9 @@ #include "components/sync/model/metadata_batch.h" #include "components/sync/protocol/entity_data.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" +#include "components/sync/test/test_matchers.h" #include "components/sync_device_info/device_info.h" #include "components/sync_device_info/device_info_util.h" #include "components/sync_device_info/fake_device_info_tracker.h"
diff --git a/components/session_proto_db/BUILD.gn b/components/session_proto_db/BUILD.gn index ad6e99c..b83d61f 100644 --- a/components/session_proto_db/BUILD.gn +++ b/components/session_proto_db/BUILD.gn
@@ -5,45 +5,47 @@ import("//testing/test.gni") import("//third_party/protobuf/proto_library.gni") -source_set("session_proto_db") { - sources = [ "session_proto_db.h" ] - - deps = [ - ":core", - "//base:base", - "//components/commerce/core:persisted_state_db_content_proto", - "//components/keyed_service/content", - "//components/leveldb_proto", - "//content/public/browser:browser", - "//third_party/leveldatabase", - ] -} - source_set("core") { sources = [ "session_proto_storage.h" ] deps = [ "//components/leveldb_proto" ] } -source_set("unit_tests") { - testonly = true - sources = [ "session_proto_db_unittest.cc" ] +if (!is_ios) { + source_set("session_proto_db") { + sources = [ "session_proto_db.h" ] - deps = [ - ":core", - ":session_proto_db", - ":session_proto_db_test_proto", - "//base:base", - "//base/test:test_support", - "//components/commerce/core:persisted_state_db_content_proto", - "//components/leveldb_proto:test_support", - "//testing/gmock", - "//testing/gtest", - "//third_party/leveldatabase", - "//third_party/protobuf:protobuf_lite", - ] -} + deps = [ + ":core", + "//base:base", + "//components/commerce/core:persisted_state_db_content_proto", + "//components/keyed_service/content", + "//components/leveldb_proto", + "//content/public/browser:browser", + "//third_party/leveldatabase", + ] + } -proto_library("session_proto_db_test_proto") { - sources = [ "session_proto_db_test_proto.proto" ] + source_set("unit_tests") { + testonly = true + sources = [ "session_proto_db_unittest.cc" ] + + deps = [ + ":core", + ":session_proto_db", + ":session_proto_db_test_proto", + "//base:base", + "//base/test:test_support", + "//components/commerce/core:persisted_state_db_content_proto", + "//components/leveldb_proto:test_support", + "//testing/gmock", + "//testing/gtest", + "//third_party/leveldatabase", + "//third_party/protobuf:protobuf_lite", + ] + } + + proto_library("session_proto_db_test_proto") { + sources = [ "session_proto_db_test_proto.proto" ] + } }
diff --git a/components/sync/BUILD.gn b/components/sync/BUILD.gn index 9213f8b..3339009 100644 --- a/components/sync/BUILD.gn +++ b/components/sync/BUILD.gn
@@ -55,79 +55,79 @@ "invalidations/mock_sync_invalidations_service.h", "nigori/nigori_test_utils.cc", "nigori/nigori_test_utils.h", - "test/engine/fake_cryptographer.cc", - "test/engine/fake_cryptographer.h", - "test/engine/fake_model_type_connector.cc", - "test/engine/fake_model_type_connector.h", - "test/engine/fake_model_type_processor.cc", - "test/engine/fake_model_type_processor.h", - "test/engine/fake_sync_engine.cc", - "test/engine/fake_sync_engine.h", - "test/engine/fake_sync_manager.cc", - "test/engine/fake_sync_manager.h", - "test/engine/fake_sync_scheduler.cc", - "test/engine/fake_sync_scheduler.h", - "test/engine/mock_connection_manager.cc", - "test/engine/mock_connection_manager.h", - "test/engine/mock_model_type_processor.cc", - "test/engine/mock_model_type_processor.h", - "test/engine/mock_model_type_worker.cc", - "test/engine/mock_model_type_worker.h", - "test/engine/mock_nudge_handler.cc", - "test/engine/mock_nudge_handler.h", - "test/engine/mock_sync_engine.cc", - "test/engine/mock_sync_engine.h", - "test/engine/mock_update_handler.cc", - "test/engine/mock_update_handler.h", - "test/engine/single_type_mock_server.cc", - "test/engine/single_type_mock_server.h", - "test/engine/sync_engine_host_stub.cc", - "test/engine/sync_engine_host_stub.h", - "test/engine/test_engine_components_factory.cc", - "test/engine/test_engine_components_factory.h", - "test/fake_server/bookmark_entity_builder.cc", - "test/fake_server/bookmark_entity_builder.h", - "test/fake_server/entity_builder_factory.cc", - "test/fake_server/entity_builder_factory.h", - "test/fake_server/fake_server.cc", - "test/fake_server/fake_server.h", - "test/fake_server/fake_server_http_post_provider.cc", - "test/fake_server/fake_server_http_post_provider.h", - "test/fake_server/fake_server_network_resources.cc", - "test/fake_server/fake_server_network_resources.h", - "test/fake_server/fake_server_nigori_helper.cc", - "test/fake_server/fake_server_nigori_helper.h", - "test/fake_server/fake_server_verifier.cc", - "test/fake_server/fake_server_verifier.h", - "test/fake_server/sessions_hierarchy.cc", - "test/fake_server/sessions_hierarchy.h", + "test/bookmark_entity_builder.cc", + "test/bookmark_entity_builder.h", + "test/entity_builder_factory.cc", + "test/entity_builder_factory.h", + "test/fake_cryptographer.cc", + "test/fake_cryptographer.h", + "test/fake_model_type_connector.cc", + "test/fake_model_type_connector.h", + "test/fake_model_type_controller_delegate.cc", + "test/fake_model_type_controller_delegate.h", + "test/fake_model_type_processor.cc", + "test/fake_model_type_processor.h", + "test/fake_model_type_sync_bridge.cc", + "test/fake_model_type_sync_bridge.h", + "test/fake_server.cc", + "test/fake_server.h", + "test/fake_server_http_post_provider.cc", + "test/fake_server_http_post_provider.h", + "test/fake_server_network_resources.cc", + "test/fake_server_network_resources.h", + "test/fake_server_nigori_helper.cc", + "test/fake_server_nigori_helper.h", + "test/fake_server_verifier.cc", + "test/fake_server_verifier.h", + "test/fake_sync_change_processor.cc", + "test/fake_sync_change_processor.h", "test/fake_sync_encryption_handler.cc", "test/fake_sync_encryption_handler.h", + "test/fake_sync_engine.cc", + "test/fake_sync_engine.h", + "test/fake_sync_manager.cc", + "test/fake_sync_manager.h", + "test/fake_sync_scheduler.cc", + "test/fake_sync_scheduler.h", + "test/forwarding_model_type_change_processor.cc", + "test/forwarding_model_type_change_processor.h", + "test/mock_connection_manager.cc", + "test/mock_connection_manager.h", "test/mock_invalidation.cc", "test/mock_invalidation.h", "test/mock_invalidation_tracker.cc", "test/mock_invalidation_tracker.h", - "test/model/fake_model_type_controller_delegate.cc", - "test/model/fake_model_type_controller_delegate.h", - "test/model/fake_model_type_sync_bridge.cc", - "test/model/fake_model_type_sync_bridge.h", - "test/model/fake_sync_change_processor.cc", - "test/model/fake_sync_change_processor.h", - "test/model/forwarding_model_type_change_processor.cc", - "test/model/forwarding_model_type_change_processor.h", - "test/model/mock_model_type_change_processor.cc", - "test/model/mock_model_type_change_processor.h", - "test/model/model_type_store_test_util.cc", - "test/model/model_type_store_test_util.h", - "test/model/stub_model_type_sync_bridge.cc", - "test/model/stub_model_type_sync_bridge.h", - "test/model/sync_change_processor_wrapper_for_test.cc", - "test/model/sync_change_processor_wrapper_for_test.h", - "test/model/sync_error_factory_mock.cc", - "test/model/sync_error_factory_mock.h", - "test/model/test_matchers.h", - "test/model/test_model_type_store_service.cc", - "test/model/test_model_type_store_service.h", + "test/mock_model_type_change_processor.cc", + "test/mock_model_type_change_processor.h", + "test/mock_model_type_processor.cc", + "test/mock_model_type_processor.h", + "test/mock_model_type_worker.cc", + "test/mock_model_type_worker.h", + "test/mock_nudge_handler.cc", + "test/mock_nudge_handler.h", + "test/mock_sync_engine.cc", + "test/mock_sync_engine.h", + "test/mock_update_handler.cc", + "test/mock_update_handler.h", + "test/model_type_store_test_util.cc", + "test/model_type_store_test_util.h", + "test/sessions_hierarchy.cc", + "test/sessions_hierarchy.h", + "test/single_type_mock_server.cc", + "test/single_type_mock_server.h", + "test/stub_model_type_sync_bridge.cc", + "test/stub_model_type_sync_bridge.h", + "test/sync_change_processor_wrapper_for_test.cc", + "test/sync_change_processor_wrapper_for_test.h", + "test/sync_engine_host_stub.cc", + "test/sync_engine_host_stub.h", + "test/sync_error_factory_mock.cc", + "test/sync_error_factory_mock.h", + "test/test_engine_components_factory.cc", + "test/test_engine_components_factory.h", + "test/test_matchers.h", + "test/test_model_type_store_service.cc", + "test/test_model_type_store_service.h", "test/trackable_mock_invalidation.cc", "test/trackable_mock_invalidation.h", ]
diff --git a/components/sync/driver/fake_data_type_controller.h b/components/sync/driver/fake_data_type_controller.h index 54cbed7e..764871b 100644 --- a/components/sync/driver/fake_data_type_controller.h +++ b/components/sync/driver/fake_data_type_controller.h
@@ -9,7 +9,7 @@ #include "components/sync/base/sync_mode.h" #include "components/sync/driver/model_type_controller.h" -#include "components/sync/test/model/fake_model_type_controller_delegate.h" +#include "components/sync/test/fake_model_type_controller_delegate.h" namespace syncer {
diff --git a/components/sync/driver/fake_sync_api_component_factory.cc b/components/sync/driver/fake_sync_api_component_factory.cc index 34bf929..a8187dc 100644 --- a/components/sync/driver/fake_sync_api_component_factory.cc +++ b/components/sync/driver/fake_sync_api_component_factory.cc
@@ -6,7 +6,7 @@ #include "base/test/bind.h" #include "components/sync/driver/data_type_manager_impl.h" -#include "components/sync/test/engine/fake_sync_engine.h" +#include "components/sync/test/fake_sync_engine.h" namespace syncer {
diff --git a/components/sync/driver/glue/sync_engine_impl_unittest.cc b/components/sync/driver/glue/sync_engine_impl_unittest.cc index ee6f23b1..fa40259 100644 --- a/components/sync/driver/glue/sync_engine_impl_unittest.cc +++ b/components/sync/driver/glue/sync_engine_impl_unittest.cc
@@ -39,8 +39,8 @@ #include "components/sync/invalidations/mock_sync_invalidations_service.h" #include "components/sync/invalidations/sync_invalidations_service.h" #include "components/sync/protocol/sync_invalidations_payload.pb.h" -#include "components/sync/test/engine/fake_sync_manager.h" -#include "components/sync/test/engine/sync_engine_host_stub.h" +#include "components/sync/test/fake_sync_manager.h" +#include "components/sync/test/sync_engine_host_stub.h" #include "services/network/test/test_network_connection_tracker.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/driver/model_type_controller_unittest.cc b/components/sync/driver/model_type_controller_unittest.cc index bf02027..4ac4e4f 100644 --- a/components/sync/driver/model_type_controller_unittest.cc +++ b/components/sync/driver/model_type_controller_unittest.cc
@@ -23,7 +23,7 @@ #include "components/sync/model/data_type_activation_request.h" #include "components/sync/model/forwarding_model_type_controller_delegate.h" #include "components/sync/model/type_entities_count.h" -#include "components/sync/test/engine/fake_model_type_processor.h" +#include "components/sync/test/fake_model_type_processor.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/driver/sync_service_crypto_unittest.cc b/components/sync/driver/sync_service_crypto_unittest.cc index 7ae8f15..bea6dba 100644 --- a/components/sync/driver/sync_service_crypto_unittest.cc +++ b/components/sync/driver/sync_service_crypto_unittest.cc
@@ -25,7 +25,7 @@ #include "components/sync/driver/trusted_vault_client.h" #include "components/sync/engine/nigori/key_derivation_params.h" #include "components/sync/engine/nigori/nigori.h" -#include "components/sync/test/engine/mock_sync_engine.h" +#include "components/sync/test/mock_sync_engine.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/components/sync/driver/sync_service_impl_startup_unittest.cc b/components/sync/driver/sync_service_impl_startup_unittest.cc index f10101ff..54240f3 100644 --- a/components/sync/driver/sync_service_impl_startup_unittest.cc +++ b/components/sync/driver/sync_service_impl_startup_unittest.cc
@@ -16,7 +16,7 @@ #include "components/sync/driver/fake_sync_api_component_factory.h" #include "components/sync/driver/sync_client_mock.h" #include "components/sync/driver/sync_service_impl_bundle.h" -#include "components/sync/test/engine/fake_sync_engine.h" +#include "components/sync/test/fake_sync_engine.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/driver/sync_service_impl_unittest.cc b/components/sync/driver/sync_service_impl_unittest.cc index 3083dc1..918c9cf 100644 --- a/components/sync/driver/sync_service_impl_unittest.cc +++ b/components/sync/driver/sync_service_impl_unittest.cc
@@ -45,7 +45,7 @@ #include "components/sync/driver/sync_service_utils.h" #include "components/sync/driver/sync_token_status.h" #include "components/sync/engine/nigori/key_derivation_params.h" -#include "components/sync/test/engine/fake_sync_engine.h" +#include "components/sync/test/fake_sync_engine.h" #include "components/version_info/version_info_values.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/engine/commit_contribution_impl_unittest.cc b/components/sync/engine/commit_contribution_impl_unittest.cc index 365957e..c5b3a50 100644 --- a/components/sync/engine/commit_contribution_impl_unittest.cc +++ b/components/sync/engine/commit_contribution_impl_unittest.cc
@@ -24,7 +24,7 @@ #include "components/sync/protocol/sharing_message_specifics.pb.h" #include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/engine/fake_cryptographer.h" +#include "components/sync/test/fake_cryptographer.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer {
diff --git a/components/sync/engine/get_updates_processor_unittest.cc b/components/sync/engine/get_updates_processor_unittest.cc index 4bfafd2..f385ea1 100644 --- a/components/sync/engine/get_updates_processor_unittest.cc +++ b/components/sync/engine/get_updates_processor_unittest.cc
@@ -21,8 +21,8 @@ #include "components/sync/engine/get_updates_delegate.h" #include "components/sync/engine/update_handler.h" #include "components/sync/protocol/data_type_progress_marker.pb.h" -#include "components/sync/test/engine/mock_update_handler.h" #include "components/sync/test/mock_invalidation.h" +#include "components/sync/test/mock_update_handler.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer {
diff --git a/components/sync/engine/model_type_registry_unittest.cc b/components/sync/engine/model_type_registry_unittest.cc index 8504290..aa3b215 100644 --- a/components/sync/engine/model_type_registry_unittest.cc +++ b/components/sync/engine/model_type_registry_unittest.cc
@@ -13,9 +13,9 @@ #include "components/sync/engine/cancelation_signal.h" #include "components/sync/engine/data_type_activation_response.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/engine/fake_model_type_processor.h" -#include "components/sync/test/engine/mock_nudge_handler.h" +#include "components/sync/test/fake_model_type_processor.h" #include "components/sync/test/fake_sync_encryption_handler.h" +#include "components/sync/test/mock_nudge_handler.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer {
diff --git a/components/sync/engine/model_type_worker_unittest.cc b/components/sync/engine/model_type_worker_unittest.cc index 8f22a081..440af7a 100644 --- a/components/sync/engine/model_type_worker_unittest.cc +++ b/components/sync/engine/model_type_worker_unittest.cc
@@ -33,10 +33,10 @@ #include "components/sync/protocol/password_specifics.pb.h" #include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/engine/fake_cryptographer.h" -#include "components/sync/test/engine/mock_model_type_processor.h" -#include "components/sync/test/engine/mock_nudge_handler.h" -#include "components/sync/test/engine/single_type_mock_server.h" +#include "components/sync/test/fake_cryptographer.h" +#include "components/sync/test/mock_model_type_processor.h" +#include "components/sync/test/mock_nudge_handler.h" +#include "components/sync/test/single_type_mock_server.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/engine/sync_manager_impl_unittest.cc b/components/sync/engine/sync_manager_impl_unittest.cc index f3ca1805..4c9cbb0 100644 --- a/components/sync/engine/sync_manager_impl_unittest.cc +++ b/components/sync/engine/sync_manager_impl_unittest.cc
@@ -37,9 +37,9 @@ #include "components/sync/protocol/encryption.pb.h" #include "components/sync/protocol/proto_value_conversions.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/engine/fake_sync_scheduler.h" -#include "components/sync/test/engine/test_engine_components_factory.h" #include "components/sync/test/fake_sync_encryption_handler.h" +#include "components/sync/test/fake_sync_scheduler.h" +#include "components/sync/test/test_engine_components_factory.h" #include "services/network/test/test_network_connection_tracker.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/engine/sync_scheduler_impl_unittest.cc b/components/sync/engine/sync_scheduler_impl_unittest.cc index 9b80eb2..222ae34 100644 --- a/components/sync/engine/sync_scheduler_impl_unittest.cc +++ b/components/sync/engine/sync_scheduler_impl_unittest.cc
@@ -27,11 +27,11 @@ #include "components/sync/engine/backoff_delay_provider.h" #include "components/sync/engine/cancelation_signal.h" #include "components/sync/engine/data_type_activation_response.h" -#include "components/sync/test/engine/fake_model_type_processor.h" -#include "components/sync/test/engine/mock_connection_manager.h" -#include "components/sync/test/engine/mock_nudge_handler.h" +#include "components/sync/test/fake_model_type_processor.h" #include "components/sync/test/fake_sync_encryption_handler.h" +#include "components/sync/test/mock_connection_manager.h" #include "components/sync/test/mock_invalidation.h" +#include "components/sync/test/mock_nudge_handler.h" #include "net/base/net_errors.h" #include "net/http/http_status_code.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/components/sync/engine/syncer_proto_util_unittest.cc b/components/sync/engine/syncer_proto_util_unittest.cc index 5a45ade..19a34cc9 100644 --- a/components/sync/engine/syncer_proto_util_unittest.cc +++ b/components/sync/engine/syncer_proto_util_unittest.cc
@@ -15,7 +15,7 @@ #include "components/sync/protocol/password_specifics.pb.h" #include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/engine/mock_connection_manager.h" +#include "components/sync/test/mock_connection_manager.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::_;
diff --git a/components/sync/engine/syncer_unittest.cc b/components/sync/engine/syncer_unittest.cc index a4f6cb4..5b88632 100644 --- a/components/sync/engine/syncer_unittest.cc +++ b/components/sync/engine/syncer_unittest.cc
@@ -50,10 +50,10 @@ #include "components/sync/protocol/preference_specifics.pb.h" #include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/engine/mock_connection_manager.h" -#include "components/sync/test/engine/mock_model_type_processor.h" -#include "components/sync/test/engine/mock_nudge_handler.h" #include "components/sync/test/fake_sync_encryption_handler.h" +#include "components/sync/test/mock_connection_manager.h" +#include "components/sync/test/mock_model_type_processor.h" +#include "components/sync/test/mock_nudge_handler.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/model/client_tag_based_model_type_processor_unittest.cc b/components/sync/model/client_tag_based_model_type_processor_unittest.cc index 7ff6c43..17e56e3 100644 --- a/components/sync/model/client_tag_based_model_type_processor_unittest.cc +++ b/components/sync/model/client_tag_based_model_type_processor_unittest.cc
@@ -31,8 +31,8 @@ #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/engine/mock_model_type_worker.h" -#include "components/sync/test/model/fake_model_type_sync_bridge.h" +#include "components/sync/test/fake_model_type_sync_bridge.h" +#include "components/sync/test/mock_model_type_worker.h" #include "testing/gtest/include/gtest/gtest.h" using sync_pb::EntityMetadata;
diff --git a/components/sync/model/client_tag_based_remote_update_handler_unittest.cc b/components/sync/model/client_tag_based_remote_update_handler_unittest.cc index 329602f..c78515b4 100644 --- a/components/sync/model/client_tag_based_remote_update_handler_unittest.cc +++ b/components/sync/model/client_tag_based_remote_update_handler_unittest.cc
@@ -13,10 +13,10 @@ #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/engine/mock_model_type_processor.h" -#include "components/sync/test/engine/mock_model_type_worker.h" -#include "components/sync/test/model/fake_model_type_sync_bridge.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/fake_model_type_sync_bridge.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_processor.h" +#include "components/sync/test/mock_model_type_worker.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer {
diff --git a/components/sync/model/model_type_store_impl_unittest.cc b/components/sync/model/model_type_store_impl_unittest.cc index 549c5bdd..2750661 100644 --- a/components/sync/model/model_type_store_impl_unittest.cc +++ b/components/sync/model/model_type_store_impl_unittest.cc
@@ -16,8 +16,8 @@ #include "components/sync/model/model_error.h" #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/model_type_store_test_util.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/model_type_store_test_util.h" +#include "components/sync/test/test_matchers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/components/sync/model/model_type_sync_bridge_unittest.cc b/components/sync/model/model_type_sync_bridge_unittest.cc index 5a007df8..d119a06 100644 --- a/components/sync/model/model_type_sync_bridge_unittest.cc +++ b/components/sync/model/model_type_sync_bridge_unittest.cc
@@ -11,8 +11,8 @@ #include "components/sync/model/conflict_resolution.h" #include "components/sync/model/metadata_batch.h" #include "components/sync/protocol/model_type_state.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/stub_model_type_sync_bridge.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/stub_model_type_sync_bridge.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/model/syncable_service_based_bridge_unittest.cc b/components/sync/model/syncable_service_based_bridge_unittest.cc index 22347eb..a2592467 100644 --- a/components/sync/model/syncable_service_based_bridge_unittest.cc +++ b/components/sync/model/syncable_service_based_bridge_unittest.cc
@@ -21,9 +21,9 @@ #include "components/sync/model/sync_error_factory.h" #include "components/sync/model/syncable_service.h" #include "components/sync/protocol/entity_specifics.pb.h" -#include "components/sync/test/engine/mock_model_type_worker.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_worker.h" +#include "components/sync/test/model_type_store_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync/test/fake_server/bookmark_entity_builder.cc b/components/sync/test/bookmark_entity_builder.cc similarity index 98% rename from components/sync/test/fake_server/bookmark_entity_builder.cc rename to components/sync/test/bookmark_entity_builder.cc index 813ec2f..e6c0adc 100644 --- a/components/sync/test/fake_server/bookmark_entity_builder.cc +++ b/components/sync/test/bookmark_entity_builder.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/bookmark_entity_builder.h" +#include "components/sync/test/bookmark_entity_builder.h" #include <stdint.h>
diff --git a/components/sync/test/fake_server/bookmark_entity_builder.h b/components/sync/test/bookmark_entity_builder.h similarity index 95% rename from components/sync/test/fake_server/bookmark_entity_builder.h rename to components/sync/test/bookmark_entity_builder.h index 792cd28..6483ff0 100644 --- a/components/sync/test/fake_server/bookmark_entity_builder.h +++ b/components/sync/test/bookmark_entity_builder.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 COMPONENTS_SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ +#ifndef COMPONENTS_SYNC_TEST_BOOKMARK_ENTITY_BUILDER_H_ +#define COMPONENTS_SYNC_TEST_BOOKMARK_ENTITY_BUILDER_H_ #include <memory> #include <string> @@ -136,4 +136,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ +#endif // COMPONENTS_SYNC_TEST_BOOKMARK_ENTITY_BUILDER_H_
diff --git a/components/sync/test/fake_server/entity_builder_factory.cc b/components/sync/test/entity_builder_factory.cc similarity index 92% rename from components/sync/test/fake_server/entity_builder_factory.cc rename to components/sync/test/entity_builder_factory.cc index 6e4a5bc..38ba854e 100644 --- a/components/sync/test/fake_server/entity_builder_factory.cc +++ b/components/sync/test/entity_builder_factory.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/entity_builder_factory.h" +#include "components/sync/test/entity_builder_factory.h" #include "base/guid.h" #include "base/strings/string_number_conversions.h"
diff --git a/components/sync/test/fake_server/entity_builder_factory.h b/components/sync/test/entity_builder_factory.h similarity index 81% rename from components/sync/test/fake_server/entity_builder_factory.h rename to components/sync/test/entity_builder_factory.h index bbb679e..4cda683 100644 --- a/components/sync/test/fake_server/entity_builder_factory.h +++ b/components/sync/test/entity_builder_factory.h
@@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_ENTITY_BUILDER_FACTORY_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_ENTITY_BUILDER_FACTORY_H_ +#ifndef COMPONENTS_SYNC_TEST_ENTITY_BUILDER_FACTORY_H_ +#define COMPONENTS_SYNC_TEST_ENTITY_BUILDER_FACTORY_H_ #include <stdint.h> #include <string> #include "base/strings/string_util.h" -#include "components/sync/test/fake_server/bookmark_entity_builder.h" +#include "components/sync/test/bookmark_entity_builder.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" @@ -42,4 +42,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_ENTITY_BUILDER_FACTORY_H_ +#endif // COMPONENTS_SYNC_TEST_ENTITY_BUILDER_FACTORY_H_
diff --git a/components/sync/test/engine/fake_cryptographer.cc b/components/sync/test/fake_cryptographer.cc similarity index 97% rename from components/sync/test/engine/fake_cryptographer.cc rename to components/sync/test/fake_cryptographer.cc index 012da068..1eb6970 100644 --- a/components/sync/test/engine/fake_cryptographer.cc +++ b/components/sync/test/fake_cryptographer.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/fake_cryptographer.h" +#include "components/sync/test/fake_cryptographer.h" #include "base/containers/contains.h" #include "base/ranges/algorithm.h"
diff --git a/components/sync/test/engine/fake_cryptographer.h b/components/sync/test/fake_cryptographer.h similarity index 91% rename from components/sync/test/engine/fake_cryptographer.h rename to components/sync/test/fake_cryptographer.h index ed14710..0f5a2d80 100644 --- a/components/sync/test/engine/fake_cryptographer.h +++ b/components/sync/test/fake_cryptographer.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 COMPONENTS_SYNC_TEST_ENGINE_FAKE_CRYPTOGRAPHER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_FAKE_CRYPTOGRAPHER_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_CRYPTOGRAPHER_H_ +#define COMPONENTS_SYNC_TEST_FAKE_CRYPTOGRAPHER_H_ #include <memory> #include <set> @@ -54,4 +54,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_FAKE_CRYPTOGRAPHER_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_CRYPTOGRAPHER_H_
diff --git a/components/sync/test/engine/fake_model_type_connector.cc b/components/sync/test/fake_model_type_connector.cc similarity index 90% rename from components/sync/test/engine/fake_model_type_connector.cc rename to components/sync/test/fake_model_type_connector.cc index 0e86998..98e6519 100644 --- a/components/sync/test/engine/fake_model_type_connector.cc +++ b/components/sync/test/fake_model_type_connector.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/fake_model_type_connector.h" +#include "components/sync/test/fake_model_type_connector.h" #include "components/sync/engine/data_type_activation_response.h"
diff --git a/components/sync/test/engine/fake_model_type_connector.h b/components/sync/test/fake_model_type_connector.h similarity index 78% rename from components/sync/test/engine/fake_model_type_connector.h rename to components/sync/test/fake_model_type_connector.h index aba3b84..9c555d0 100644 --- a/components/sync/test/engine/fake_model_type_connector.h +++ b/components/sync/test/fake_model_type_connector.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 COMPONENTS_SYNC_TEST_ENGINE_FAKE_MODEL_TYPE_CONNECTOR_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_FAKE_MODEL_TYPE_CONNECTOR_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_CONNECTOR_H_ +#define COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_CONNECTOR_H_ #include <memory> @@ -26,4 +26,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_FAKE_MODEL_TYPE_CONNECTOR_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_CONNECTOR_H_
diff --git a/components/sync/test/model/fake_model_type_controller_delegate.cc b/components/sync/test/fake_model_type_controller_delegate.cc similarity index 97% rename from components/sync/test/model/fake_model_type_controller_delegate.cc rename to components/sync/test/fake_model_type_controller_delegate.cc index 542bf2c..d5fc3475 100644 --- a/components/sync/test/model/fake_model_type_controller_delegate.cc +++ b/components/sync/test/fake_model_type_controller_delegate.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/fake_model_type_controller_delegate.h" +#include "components/sync/test/fake_model_type_controller_delegate.h" #include <utility>
diff --git a/components/sync/test/model/fake_model_type_controller_delegate.h b/components/sync/test/fake_model_type_controller_delegate.h similarity index 92% rename from components/sync/test/model/fake_model_type_controller_delegate.h rename to components/sync/test/fake_model_type_controller_delegate.h index 4c4afdf..024c592 100644 --- a/components/sync/test/model/fake_model_type_controller_delegate.h +++ b/components/sync/test/fake_model_type_controller_delegate.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_SYNC_TEST_MODEL_FAKE_MODEL_TYPE_CONTROLLER_DELEGATE_H_ -#define COMPONENTS_SYNC_TEST_MODEL_FAKE_MODEL_TYPE_CONTROLLER_DELEGATE_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_CONTROLLER_DELEGATE_H_ +#define COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_CONTROLLER_DELEGATE_H_ #include <memory> @@ -79,4 +79,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_FAKE_MODEL_TYPE_CONTROLLER_DELEGATE_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_CONTROLLER_DELEGATE_H_
diff --git a/components/sync/test/engine/fake_model_type_processor.cc b/components/sync/test/fake_model_type_processor.cc similarity index 94% rename from components/sync/test/engine/fake_model_type_processor.cc rename to components/sync/test/fake_model_type_processor.cc index 7a4029a7..4fcd1b7 100644 --- a/components/sync/test/engine/fake_model_type_processor.cc +++ b/components/sync/test/fake_model_type_processor.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/fake_model_type_processor.h" +#include "components/sync/test/fake_model_type_processor.h" #include <utility>
diff --git a/components/sync/test/engine/fake_model_type_processor.h b/components/sync/test/fake_model_type_processor.h similarity index 83% rename from components/sync/test/engine/fake_model_type_processor.h rename to components/sync/test/fake_model_type_processor.h index e57515a..d993eb3c 100644 --- a/components/sync/test/engine/fake_model_type_processor.h +++ b/components/sync/test/fake_model_type_processor.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 COMPONENTS_SYNC_TEST_ENGINE_FAKE_MODEL_TYPE_PROCESSOR_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_FAKE_MODEL_TYPE_PROCESSOR_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_PROCESSOR_H_ +#define COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_PROCESSOR_H_ #include <memory> @@ -31,4 +31,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_FAKE_MODEL_TYPE_PROCESSOR_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_PROCESSOR_H_
diff --git a/components/sync/test/model/fake_model_type_sync_bridge.cc b/components/sync/test/fake_model_type_sync_bridge.cc similarity index 99% rename from components/sync/test/model/fake_model_type_sync_bridge.cc rename to components/sync/test/fake_model_type_sync_bridge.cc index 849f4fb..c254e0d 100644 --- a/components/sync/test/model/fake_model_type_sync_bridge.cc +++ b/components/sync/test/fake_model_type_sync_bridge.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/fake_model_type_sync_bridge.h" +#include "components/sync/test/fake_model_type_sync_bridge.h" #include <set> #include <utility>
diff --git a/components/sync/test/model/fake_model_type_sync_bridge.h b/components/sync/test/fake_model_type_sync_bridge.h similarity index 97% rename from components/sync/test/model/fake_model_type_sync_bridge.h rename to components/sync/test/fake_model_type_sync_bridge.h index 9327f9f5..2c942e94 100644 --- a/components/sync/test/model/fake_model_type_sync_bridge.h +++ b/components/sync/test/fake_model_type_sync_bridge.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 COMPONENTS_SYNC_TEST_MODEL_FAKE_MODEL_TYPE_SYNC_BRIDGE_H_ -#define COMPONENTS_SYNC_TEST_MODEL_FAKE_MODEL_TYPE_SYNC_BRIDGE_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_SYNC_BRIDGE_H_ +#define COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_SYNC_BRIDGE_H_ #include <map> #include <memory> @@ -19,7 +19,7 @@ namespace sync_pb { class EntityMetadata; class EntitySpecifics; -} +} // namespace sync_pb namespace syncer { @@ -211,4 +211,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_FAKE_MODEL_TYPE_SYNC_BRIDGE_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_MODEL_TYPE_SYNC_BRIDGE_H_
diff --git a/components/sync/test/fake_server/fake_server.cc b/components/sync/test/fake_server.cc similarity index 99% rename from components/sync/test/fake_server/fake_server.cc rename to components/sync/test/fake_server.cc index 5591047..b785ee9 100644 --- a/components/sync/test/fake_server/fake_server.cc +++ b/components/sync/test/fake_server.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include <algorithm> #include <limits>
diff --git a/components/sync/test/fake_server/fake_server.h b/components/sync/test/fake_server.h similarity index 98% rename from components/sync/test/fake_server/fake_server.h rename to components/sync/test/fake_server.h index 2b29e37..c656e89a 100644 --- a/components/sync/test/fake_server/fake_server.h +++ b/components/sync/test/fake_server.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 COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SERVER_H_ #include <stdint.h> @@ -355,4 +355,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_H_
diff --git a/components/sync/test/fake_server/fake_server_http_post_provider.cc b/components/sync/test/fake_server_http_post_provider.cc similarity index 97% rename from components/sync/test/fake_server/fake_server_http_post_provider.cc rename to components/sync/test/fake_server_http_post_provider.cc index 01cc9d9b..df91f9f 100644 --- a/components/sync/test/fake_server/fake_server_http_post_provider.cc +++ b/components/sync/test/fake_server_http_post_provider.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/fake_server_http_post_provider.h" +#include "components/sync/test/fake_server_http_post_provider.h" #include <utility> @@ -10,7 +10,7 @@ #include "base/location.h" #include "base/threading/thread_restrictions.h" #include "base/time/time.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "net/base/net_errors.h" namespace fake_server {
diff --git a/components/sync/test/fake_server/fake_server_http_post_provider.h b/components/sync/test/fake_server_http_post_provider.h similarity index 93% rename from components/sync/test/fake_server/fake_server_http_post_provider.h rename to components/sync/test/fake_server_http_post_provider.h index 98d2910..44cca329 100644 --- a/components/sync/test/fake_server/fake_server_http_post_provider.h +++ b/components/sync/test/fake_server_http_post_provider.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 COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_HTTP_POST_PROVIDER_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SERVER_HTTP_POST_PROVIDER_H_ #include <atomic> #include <string> @@ -105,4 +105,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_HTTP_POST_PROVIDER_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_HTTP_POST_PROVIDER_H_
diff --git a/components/sync/test/fake_server/fake_server_network_resources.cc b/components/sync/test/fake_server_network_resources.cc similarity index 85% rename from components/sync/test/fake_server/fake_server_network_resources.cc rename to components/sync/test/fake_server_network_resources.cc index 6d8871f..f11df1d 100644 --- a/components/sync/test/fake_server/fake_server_network_resources.cc +++ b/components/sync/test/fake_server_network_resources.cc
@@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/fake_server_network_resources.h" +#include "components/sync/test/fake_server_network_resources.h" #include <memory> #include <string> #include "base/threading/thread_task_runner_handle.h" #include "components/sync/engine/net/http_post_provider_factory.h" -#include "components/sync/test/fake_server/fake_server.h" -#include "components/sync/test/fake_server/fake_server_http_post_provider.h" +#include "components/sync/test/fake_server.h" +#include "components/sync/test/fake_server_http_post_provider.h" #include "services/network/public/cpp/shared_url_loader_factory.h" namespace fake_server {
diff --git a/components/sync/test/fake_server/fake_server_network_resources.h b/components/sync/test/fake_server_network_resources.h similarity index 67% rename from components/sync/test/fake_server/fake_server_network_resources.h rename to components/sync/test/fake_server_network_resources.h index d3fff50..21add44 100644 --- a/components/sync/test/fake_server/fake_server_network_resources.h +++ b/components/sync/test/fake_server_network_resources.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 COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_NETWORK_RESOURCES_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_NETWORK_RESOURCES_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_NETWORK_RESOURCES_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SERVER_NETWORK_RESOURCES_H_ #include "base/memory/weak_ptr.h" #include "components/sync/engine/net/http_post_provider_factory.h" @@ -17,4 +17,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_NETWORK_RESOURCES_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_NETWORK_RESOURCES_H_
diff --git a/components/sync/test/fake_server/fake_server_nigori_helper.cc b/components/sync/test/fake_server_nigori_helper.cc similarity index 94% rename from components/sync/test/fake_server/fake_server_nigori_helper.cc rename to components/sync/test/fake_server_nigori_helper.cc index ba0ff2c8..bf0110c0 100644 --- a/components/sync/test/fake_server/fake_server_nigori_helper.cc +++ b/components/sync/test/fake_server_nigori_helper.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" +#include "components/sync/test/fake_server_nigori_helper.h" #include <string> #include <vector> @@ -11,7 +11,7 @@ #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/nigori_specifics.pb.h" #include "components/sync/protocol/sync_entity.pb.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" #include "testing/gtest/include/gtest/gtest.h" namespace fake_server {
diff --git a/components/sync/test/fake_server/fake_server_nigori_helper.h b/components/sync/test/fake_server_nigori_helper.h similarity index 81% rename from components/sync/test/fake_server/fake_server_nigori_helper.h rename to components/sync/test/fake_server_nigori_helper.h index d152662a..5fd37f6 100644 --- a/components/sync/test/fake_server/fake_server_nigori_helper.h +++ b/components/sync/test/fake_server_nigori_helper.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 COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_NIGORI_HELPER_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_NIGORI_HELPER_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_NIGORI_HELPER_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SERVER_NIGORI_HELPER_H_ namespace sync_pb { class NigoriSpecifics; @@ -28,4 +28,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_NIGORI_HELPER_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_NIGORI_HELPER_H_
diff --git a/components/sync/test/fake_server/fake_server_verifier.cc b/components/sync/test/fake_server_verifier.cc similarity index 97% rename from components/sync/test/fake_server/fake_server_verifier.cc rename to components/sync/test/fake_server_verifier.cc index a088d1a..328433b8 100644 --- a/components/sync/test/fake_server/fake_server_verifier.cc +++ b/components/sync/test/fake_server_verifier.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/fake_server_verifier.h" +#include "components/sync/test/fake_server_verifier.h" #include <map> #include <memory> @@ -10,7 +10,7 @@ #include <vector> #include "base/json/json_writer.h" -#include "components/sync/test/fake_server/fake_server.h" +#include "components/sync/test/fake_server.h" using base::JSONWriter; using std::string;
diff --git a/components/sync/test/fake_server/fake_server_verifier.h b/components/sync/test/fake_server_verifier.h similarity index 88% rename from components/sync/test/fake_server/fake_server_verifier.h rename to components/sync/test/fake_server_verifier.h index 46793e3..853379c 100644 --- a/components/sync/test/fake_server/fake_server_verifier.h +++ b/components/sync/test/fake_server_verifier.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 COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_VERIFIER_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_VERIFIER_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SERVER_VERIFIER_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SERVER_VERIFIER_H_ #include <stddef.h> @@ -11,7 +11,7 @@ #include "base/memory/raw_ptr.h" #include "components/sync/base/model_type.h" -#include "components/sync/test/fake_server/sessions_hierarchy.h" +#include "components/sync/test/sessions_hierarchy.h" #include "testing/gtest/include/gtest/gtest.h" namespace fake_server { @@ -59,4 +59,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_VERIFIER_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_VERIFIER_H_
diff --git a/components/sync/test/model/fake_sync_change_processor.cc b/components/sync/test/fake_sync_change_processor.cc similarity index 92% rename from components/sync/test/model/fake_sync_change_processor.cc rename to components/sync/test/fake_sync_change_processor.cc index dc12dcf..e74e2bf 100644 --- a/components/sync/test/model/fake_sync_change_processor.cc +++ b/components/sync/test/fake_sync_change_processor.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/fake_sync_change_processor.h" +#include "components/sync/test/fake_sync_change_processor.h" #include "components/sync/model/sync_change.h" #include "components/sync/model/sync_data.h"
diff --git a/components/sync/test/model/fake_sync_change_processor.h b/components/sync/test/fake_sync_change_processor.h similarity index 82% rename from components/sync/test/model/fake_sync_change_processor.h rename to components/sync/test/fake_sync_change_processor.h index 50fd600..6c87c93 100644 --- a/components/sync/test/model/fake_sync_change_processor.h +++ b/components/sync/test/fake_sync_change_processor.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 COMPONENTS_SYNC_TEST_MODEL_FAKE_SYNC_CHANGE_PROCESSOR_H_ -#define COMPONENTS_SYNC_TEST_MODEL_FAKE_SYNC_CHANGE_PROCESSOR_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SYNC_CHANGE_PROCESSOR_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SYNC_CHANGE_PROCESSOR_H_ #include "components/sync/model/sync_change_processor.h" @@ -35,4 +35,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_FAKE_SYNC_CHANGE_PROCESSOR_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SYNC_CHANGE_PROCESSOR_H_
diff --git a/components/sync/test/fake_sync_encryption_handler.h b/components/sync/test/fake_sync_encryption_handler.h index aa4eb4f..c53c9aac 100644 --- a/components/sync/test/fake_sync_encryption_handler.h +++ b/components/sync/test/fake_sync_encryption_handler.h
@@ -14,7 +14,7 @@ #include "base/time/time.h" #include "components/sync/engine/nigori/keystore_keys_handler.h" #include "components/sync/engine/sync_encryption_handler.h" -#include "components/sync/test/engine/fake_cryptographer.h" +#include "components/sync/test/fake_cryptographer.h" namespace syncer {
diff --git a/components/sync/test/engine/fake_sync_engine.cc b/components/sync/test/fake_sync_engine.cc similarity index 98% rename from components/sync/test/engine/fake_sync_engine.cc rename to components/sync/test/fake_sync_engine.cc index d8bb2de2..d2c97da 100644 --- a/components/sync/test/engine/fake_sync_engine.cc +++ b/components/sync/test/fake_sync_engine.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/fake_sync_engine.h" +#include "components/sync/test/fake_sync_engine.h" #include <utility>
diff --git a/components/sync/test/engine/fake_sync_engine.h b/components/sync/test/fake_sync_engine.h similarity index 95% rename from components/sync/test/engine/fake_sync_engine.h rename to components/sync/test/fake_sync_engine.h index 9617bbd3..9cb53ef 100644 --- a/components/sync/test/engine/fake_sync_engine.h +++ b/components/sync/test/fake_sync_engine.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 COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_ENGINE_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_ENGINE_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SYNC_ENGINE_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SYNC_ENGINE_H_ #include <memory> #include <string> @@ -120,4 +120,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_ENGINE_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SYNC_ENGINE_H_
diff --git a/components/sync/test/engine/fake_sync_manager.cc b/components/sync/test/fake_sync_manager.cc similarity index 97% rename from components/sync/test/engine/fake_sync_manager.cc rename to components/sync/test/fake_sync_manager.cc index 49e25470..eaaae753 100644 --- a/components/sync/test/engine/fake_sync_manager.cc +++ b/components/sync/test/fake_sync_manager.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/fake_sync_manager.h" +#include "components/sync/test/fake_sync_manager.h" #include <cstddef> #include <utility> @@ -16,7 +16,7 @@ #include "base/threading/sequenced_task_runner_handle.h" #include "components/sync/engine/engine_components_factory.h" #include "components/sync/engine/net/http_post_provider_factory.h" -#include "components/sync/test/engine/fake_model_type_connector.h" +#include "components/sync/test/fake_model_type_connector.h" class GURL;
diff --git a/components/sync/test/engine/fake_sync_manager.h b/components/sync/test/fake_sync_manager.h similarity index 95% rename from components/sync/test/engine/fake_sync_manager.h rename to components/sync/test/fake_sync_manager.h index 05e28c5..ddc98b6 100644 --- a/components/sync/test/engine/fake_sync_manager.h +++ b/components/sync/test/fake_sync_manager.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 COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_MANAGER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_MANAGER_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SYNC_MANAGER_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SYNC_MANAGER_H_ #include <map> #include <memory> @@ -15,7 +15,7 @@ #include "base/observer_list.h" #include "components/sync/base/model_type.h" #include "components/sync/engine/sync_manager.h" -#include "components/sync/test/engine/fake_model_type_connector.h" +#include "components/sync/test/fake_model_type_connector.h" #include "components/sync/test/fake_sync_encryption_handler.h" namespace base { @@ -142,4 +142,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_MANAGER_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SYNC_MANAGER_H_
diff --git a/components/sync/test/engine/fake_sync_scheduler.cc b/components/sync/test/fake_sync_scheduler.cc similarity index 97% rename from components/sync/test/engine/fake_sync_scheduler.cc rename to components/sync/test/fake_sync_scheduler.cc index 7b173d79..7b12d03 100644 --- a/components/sync/test/engine/fake_sync_scheduler.cc +++ b/components/sync/test/fake_sync_scheduler.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/fake_sync_scheduler.h" +#include "components/sync/test/fake_sync_scheduler.h" #include <utility>
diff --git a/components/sync/test/engine/fake_sync_scheduler.h b/components/sync/test/fake_sync_scheduler.h similarity index 92% rename from components/sync/test/engine/fake_sync_scheduler.h rename to components/sync/test/fake_sync_scheduler.h index efc780f..9be063be 100644 --- a/components/sync/test/engine/fake_sync_scheduler.h +++ b/components/sync/test/fake_sync_scheduler.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 COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_SCHEDULER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_SCHEDULER_H_ +#ifndef COMPONENTS_SYNC_TEST_FAKE_SYNC_SCHEDULER_H_ +#define COMPONENTS_SYNC_TEST_FAKE_SYNC_SCHEDULER_H_ #include <map> #include <memory> @@ -59,4 +59,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_FAKE_SYNC_SCHEDULER_H_ +#endif // COMPONENTS_SYNC_TEST_FAKE_SYNC_SCHEDULER_H_
diff --git a/components/sync/test/model/forwarding_model_type_change_processor.cc b/components/sync/test/forwarding_model_type_change_processor.cc similarity index 97% rename from components/sync/test/model/forwarding_model_type_change_processor.cc rename to components/sync/test/forwarding_model_type_change_processor.cc index e0d10be8..13da716 100644 --- a/components/sync/test/model/forwarding_model_type_change_processor.cc +++ b/components/sync/test/forwarding_model_type_change_processor.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/forwarding_model_type_change_processor.h" +#include "components/sync/test/forwarding_model_type_change_processor.h" #include <utility>
diff --git a/components/sync/test/model/forwarding_model_type_change_processor.h b/components/sync/test/forwarding_model_type_change_processor.h similarity index 90% rename from components/sync/test/model/forwarding_model_type_change_processor.h rename to components/sync/test/forwarding_model_type_change_processor.h index 62e5576a..761ca3fd 100644 --- a/components/sync/test/model/forwarding_model_type_change_processor.h +++ b/components/sync/test/forwarding_model_type_change_processor.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 COMPONENTS_SYNC_TEST_MODEL_FORWARDING_MODEL_TYPE_CHANGE_PROCESSOR_H_ -#define COMPONENTS_SYNC_TEST_MODEL_FORWARDING_MODEL_TYPE_CHANGE_PROCESSOR_H_ +#ifndef COMPONENTS_SYNC_TEST_FORWARDING_MODEL_TYPE_CHANGE_PROCESSOR_H_ +#define COMPONENTS_SYNC_TEST_FORWARDING_MODEL_TYPE_CHANGE_PROCESSOR_H_ #include <memory> #include <string> @@ -57,4 +57,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_FORWARDING_MODEL_TYPE_CHANGE_PROCESSOR_H_ +#endif // COMPONENTS_SYNC_TEST_FORWARDING_MODEL_TYPE_CHANGE_PROCESSOR_H_
diff --git a/components/sync/test/engine/mock_connection_manager.cc b/components/sync/test/mock_connection_manager.cc similarity index 99% rename from components/sync/test/engine/mock_connection_manager.cc rename to components/sync/test/mock_connection_manager.cc index b00213a..c1dc76a 100644 --- a/components/sync/test/engine/mock_connection_manager.cc +++ b/components/sync/test/mock_connection_manager.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/mock_connection_manager.h" +#include "components/sync/test/mock_connection_manager.h" #include <map> #include <utility>
diff --git a/components/sync/test/engine/mock_connection_manager.h b/components/sync/test/mock_connection_manager.h similarity index 98% rename from components/sync/test/engine/mock_connection_manager.h rename to components/sync/test/mock_connection_manager.h index 3210e5b8..62eafbf 100644 --- a/components/sync/test/engine/mock_connection_manager.h +++ b/components/sync/test/mock_connection_manager.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 COMPONENTS_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ +#ifndef COMPONENTS_SYNC_TEST_MOCK_CONNECTION_MANAGER_H_ +#define COMPONENTS_SYNC_TEST_MOCK_CONNECTION_MANAGER_H_ #include <stdint.h> @@ -358,4 +358,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ +#endif // COMPONENTS_SYNC_TEST_MOCK_CONNECTION_MANAGER_H_
diff --git a/components/sync/test/model/mock_model_type_change_processor.cc b/components/sync/test/mock_model_type_change_processor.cc similarity index 95% rename from components/sync/test/model/mock_model_type_change_processor.cc rename to components/sync/test/mock_model_type_change_processor.cc index 2ae29e6e..bf57b774 100644 --- a/components/sync/test/model/mock_model_type_change_processor.cc +++ b/components/sync/test/mock_model_type_change_processor.cc
@@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "components/sync/test/mock_model_type_change_processor.h" #include <utility> #include "base/memory/ptr_util.h" #include "components/sync/model/metadata_batch.h" -#include "components/sync/test/model/forwarding_model_type_change_processor.h" +#include "components/sync/test/forwarding_model_type_change_processor.h" namespace syncer {
diff --git a/components/sync/test/model/mock_model_type_change_processor.h b/components/sync/test/mock_model_type_change_processor.h similarity index 94% rename from components/sync/test/model/mock_model_type_change_processor.h rename to components/sync/test/mock_model_type_change_processor.h index 26f783b0..f14e208 100644 --- a/components/sync/test/model/mock_model_type_change_processor.h +++ b/components/sync/test/mock_model_type_change_processor.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 COMPONENTS_SYNC_TEST_MODEL_MOCK_MODEL_TYPE_CHANGE_PROCESSOR_H_ -#define COMPONENTS_SYNC_TEST_MODEL_MOCK_MODEL_TYPE_CHANGE_PROCESSOR_H_ +#ifndef COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_CHANGE_PROCESSOR_H_ +#define COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_CHANGE_PROCESSOR_H_ #include <memory> #include <string> @@ -100,4 +100,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_MOCK_MODEL_TYPE_CHANGE_PROCESSOR_H_ +#endif // COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_CHANGE_PROCESSOR_H_
diff --git a/components/sync/test/engine/mock_model_type_processor.cc b/components/sync/test/mock_model_type_processor.cc similarity index 99% rename from components/sync/test/engine/mock_model_type_processor.cc rename to components/sync/test/mock_model_type_processor.cc index 3cf14bd..405ce53 100644 --- a/components/sync/test/engine/mock_model_type_processor.cc +++ b/components/sync/test/mock_model_type_processor.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/mock_model_type_processor.h" +#include "components/sync/test/mock_model_type_processor.h" #include <utility>
diff --git a/components/sync/test/engine/mock_model_type_processor.h b/components/sync/test/mock_model_type_processor.h similarity index 97% rename from components/sync/test/engine/mock_model_type_processor.h rename to components/sync/test/mock_model_type_processor.h index 8ca04b0..8d03c74 100644 --- a/components/sync/test/engine/mock_model_type_processor.h +++ b/components/sync/test/mock_model_type_processor.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 COMPONENTS_SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_PROCESSOR_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_PROCESSOR_H_ +#ifndef COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_PROCESSOR_H_ +#define COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_PROCESSOR_H_ #include <stddef.h> #include <stdint.h> @@ -190,4 +190,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_PROCESSOR_H_ +#endif // COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_PROCESSOR_H_
diff --git a/components/sync/test/engine/mock_model_type_worker.cc b/components/sync/test/mock_model_type_worker.cc similarity index 99% rename from components/sync/test/engine/mock_model_type_worker.cc rename to components/sync/test/mock_model_type_worker.cc index 36eec64..c7cbc6d37 100644 --- a/components/sync/test/engine/mock_model_type_worker.cc +++ b/components/sync/test/mock_model_type_worker.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/mock_model_type_worker.h" +#include "components/sync/test/mock_model_type_worker.h" #include <utility>
diff --git a/components/sync/test/engine/mock_model_type_worker.h b/components/sync/test/mock_model_type_worker.h similarity index 97% rename from components/sync/test/engine/mock_model_type_worker.h rename to components/sync/test/mock_model_type_worker.h index 726b918..a9d8496e 100644 --- a/components/sync/test/engine/mock_model_type_worker.h +++ b/components/sync/test/mock_model_type_worker.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 COMPONENTS_SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_WORKER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_WORKER_H_ +#ifndef COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_WORKER_H_ +#define COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_WORKER_H_ #include <stddef.h> #include <stdint.h> @@ -183,4 +183,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_WORKER_H_ +#endif // COMPONENTS_SYNC_TEST_MOCK_MODEL_TYPE_WORKER_H_
diff --git a/components/sync/test/engine/mock_nudge_handler.cc b/components/sync/test/mock_nudge_handler.cc similarity index 92% rename from components/sync/test/engine/mock_nudge_handler.cc rename to components/sync/test/mock_nudge_handler.cc index f3d4c9b..d272606 100644 --- a/components/sync/test/engine/mock_nudge_handler.cc +++ b/components/sync/test/mock_nudge_handler.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/mock_nudge_handler.h" +#include "components/sync/test/mock_nudge_handler.h" namespace syncer {
diff --git a/components/sync/test/engine/mock_nudge_handler.h b/components/sync/test/mock_nudge_handler.h similarity index 82% rename from components/sync/test/engine/mock_nudge_handler.h rename to components/sync/test/mock_nudge_handler.h index 574b781..79e138c 100644 --- a/components/sync/test/engine/mock_nudge_handler.h +++ b/components/sync/test/mock_nudge_handler.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 COMPONENTS_SYNC_TEST_ENGINE_MOCK_NUDGE_HANDLER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_MOCK_NUDGE_HANDLER_H_ +#ifndef COMPONENTS_SYNC_TEST_MOCK_NUDGE_HANDLER_H_ +#define COMPONENTS_SYNC_TEST_MOCK_NUDGE_HANDLER_H_ #include "base/compiler_specific.h" #include "components/sync/base/model_type.h" @@ -35,4 +35,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_MOCK_NUDGE_HANDLER_H_ +#endif // COMPONENTS_SYNC_TEST_MOCK_NUDGE_HANDLER_H_
diff --git a/components/sync/test/engine/mock_sync_engine.cc b/components/sync/test/mock_sync_engine.cc similarity index 83% rename from components/sync/test/engine/mock_sync_engine.cc rename to components/sync/test/mock_sync_engine.cc index 4c36f3e..faa6d4e 100644 --- a/components/sync/test/engine/mock_sync_engine.cc +++ b/components/sync/test/mock_sync_engine.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/mock_sync_engine.h" +#include "components/sync/test/mock_sync_engine.h" namespace syncer {
diff --git a/components/sync/test/engine/mock_sync_engine.h b/components/sync/test/mock_sync_engine.h similarity index 94% rename from components/sync/test/engine/mock_sync_engine.h rename to components/sync/test/mock_sync_engine.h index 98119d9..612a507 100644 --- a/components/sync/test/engine/mock_sync_engine.h +++ b/components/sync/test/mock_sync_engine.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 COMPONENTS_SYNC_TEST_ENGINE_MOCK_SYNC_ENGINE_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_MOCK_SYNC_ENGINE_H_ +#ifndef COMPONENTS_SYNC_TEST_MOCK_SYNC_ENGINE_H_ +#define COMPONENTS_SYNC_TEST_MOCK_SYNC_ENGINE_H_ #include <memory> #include <string> @@ -82,4 +82,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_MOCK_SYNC_ENGINE_H_ +#endif // COMPONENTS_SYNC_TEST_MOCK_SYNC_ENGINE_H_
diff --git a/components/sync/test/engine/mock_update_handler.cc b/components/sync/test/mock_update_handler.cc similarity index 95% rename from components/sync/test/engine/mock_update_handler.cc rename to components/sync/test/mock_update_handler.cc index c2d29f3..93e6fd0 100644 --- a/components/sync/test/engine/mock_update_handler.cc +++ b/components/sync/test/mock_update_handler.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/mock_update_handler.h" +#include "components/sync/test/mock_update_handler.h" #include <string>
diff --git a/components/sync/test/engine/mock_update_handler.h b/components/sync/test/mock_update_handler.h similarity index 87% rename from components/sync/test/engine/mock_update_handler.h rename to components/sync/test/mock_update_handler.h index 1f84f6c5..b9cccfa7 100644 --- a/components/sync/test/engine/mock_update_handler.h +++ b/components/sync/test/mock_update_handler.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 COMPONENTS_SYNC_TEST_ENGINE_MOCK_UPDATE_HANDLER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_MOCK_UPDATE_HANDLER_H_ +#ifndef COMPONENTS_SYNC_TEST_MOCK_UPDATE_HANDLER_H_ +#define COMPONENTS_SYNC_TEST_MOCK_UPDATE_HANDLER_H_ #include "base/compiler_specific.h" #include "components/sync/base/model_type.h" @@ -40,4 +40,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_MOCK_UPDATE_HANDLER_H_ +#endif // COMPONENTS_SYNC_TEST_MOCK_UPDATE_HANDLER_H_
diff --git a/components/sync/test/model/model_type_store_test_util.cc b/components/sync/test/model_type_store_test_util.cc similarity index 98% rename from components/sync/test/model/model_type_store_test_util.cc rename to components/sync/test/model_type_store_test_util.cc index 79962b4e..3b0b3d4 100644 --- a/components/sync/test/model/model_type_store_test_util.cc +++ b/components/sync/test/model_type_store_test_util.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/model_type_store_test_util.h" #include <utility>
diff --git a/components/sync/test/model/model_type_store_test_util.h b/components/sync/test/model_type_store_test_util.h similarity index 86% rename from components/sync/test/model/model_type_store_test_util.h rename to components/sync/test/model_type_store_test_util.h index 5ab201f..b9981f0c 100644 --- a/components/sync/test/model/model_type_store_test_util.h +++ b/components/sync/test/model_type_store_test_util.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 COMPONENTS_SYNC_TEST_MODEL_MODEL_TYPE_STORE_TEST_UTIL_H_ -#define COMPONENTS_SYNC_TEST_MODEL_MODEL_TYPE_STORE_TEST_UTIL_H_ +#ifndef COMPONENTS_SYNC_TEST_MODEL_TYPE_STORE_TEST_UTIL_H_ +#define COMPONENTS_SYNC_TEST_MODEL_TYPE_STORE_TEST_UTIL_H_ #include <memory> @@ -36,4 +36,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_MODEL_TYPE_STORE_TEST_UTIL_H_ +#endif // COMPONENTS_SYNC_TEST_MODEL_TYPE_STORE_TEST_UTIL_H_
diff --git a/components/sync/test/fake_server/sessions_hierarchy.cc b/components/sync/test/sessions_hierarchy.cc similarity index 95% rename from components/sync/test/fake_server/sessions_hierarchy.cc rename to components/sync/test/sessions_hierarchy.cc index 0dc858bf..032404e 100644 --- a/components/sync/test/fake_server/sessions_hierarchy.cc +++ b/components/sync/test/sessions_hierarchy.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/fake_server/sessions_hierarchy.h" +#include "components/sync/test/sessions_hierarchy.h" #include <sstream>
diff --git a/components/sync/test/fake_server/sessions_hierarchy.h b/components/sync/test/sessions_hierarchy.h similarity index 90% rename from components/sync/test/fake_server/sessions_hierarchy.h rename to components/sync/test/sessions_hierarchy.h index a6278a9..c066c48 100644 --- a/components/sync/test/fake_server/sessions_hierarchy.h +++ b/components/sync/test/sessions_hierarchy.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 COMPONENTS_SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_ -#define COMPONENTS_SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_ +#ifndef COMPONENTS_SYNC_TEST_SESSIONS_HIERARCHY_H_ +#define COMPONENTS_SYNC_TEST_SESSIONS_HIERARCHY_H_ #include <set> #include <string> @@ -63,4 +63,4 @@ } // namespace fake_server -#endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_ +#endif // COMPONENTS_SYNC_TEST_SESSIONS_HIERARCHY_H_
diff --git a/components/sync/test/engine/single_type_mock_server.cc b/components/sync/test/single_type_mock_server.cc similarity index 98% rename from components/sync/test/engine/single_type_mock_server.cc rename to components/sync/test/single_type_mock_server.cc index 5fbd4f4..09abfdc7 100644 --- a/components/sync/test/engine/single_type_mock_server.cc +++ b/components/sync/test/single_type_mock_server.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/single_type_mock_server.h" +#include "components/sync/test/single_type_mock_server.h" #include "components/sync/base/time.h" #include "components/sync/protocol/data_type_progress_marker.pb.h"
diff --git a/components/sync/test/engine/single_type_mock_server.h b/components/sync/test/single_type_mock_server.h similarity index 95% rename from components/sync/test/engine/single_type_mock_server.h rename to components/sync/test/single_type_mock_server.h index 043c36e..91f8c74 100644 --- a/components/sync/test/engine/single_type_mock_server.h +++ b/components/sync/test/single_type_mock_server.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 COMPONENTS_SYNC_TEST_ENGINE_SINGLE_TYPE_MOCK_SERVER_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_SINGLE_TYPE_MOCK_SERVER_H_ +#ifndef COMPONENTS_SYNC_TEST_SINGLE_TYPE_MOCK_SERVER_H_ +#define COMPONENTS_SYNC_TEST_SINGLE_TYPE_MOCK_SERVER_H_ #include <stddef.h> #include <stdint.h> @@ -117,4 +117,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_SINGLE_TYPE_MOCK_SERVER_H_ +#endif // COMPONENTS_SYNC_TEST_SINGLE_TYPE_MOCK_SERVER_H_
diff --git a/components/sync/test/model/stub_model_type_sync_bridge.cc b/components/sync/test/stub_model_type_sync_bridge.cc similarity index 95% rename from components/sync/test/model/stub_model_type_sync_bridge.cc rename to components/sync/test/stub_model_type_sync_bridge.cc index 671d9f38..02dd9e0 100644 --- a/components/sync/test/model/stub_model_type_sync_bridge.cc +++ b/components/sync/test/stub_model_type_sync_bridge.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/stub_model_type_sync_bridge.h" +#include "components/sync/test/stub_model_type_sync_bridge.h" #include <utility>
diff --git a/components/sync/test/model/stub_model_type_sync_bridge.h b/components/sync/test/stub_model_type_sync_bridge.h similarity index 86% rename from components/sync/test/model/stub_model_type_sync_bridge.h rename to components/sync/test/stub_model_type_sync_bridge.h index 84084d6..051ef9c 100644 --- a/components/sync/test/model/stub_model_type_sync_bridge.h +++ b/components/sync/test/stub_model_type_sync_bridge.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 COMPONENTS_SYNC_TEST_MODEL_STUB_MODEL_TYPE_SYNC_BRIDGE_H_ -#define COMPONENTS_SYNC_TEST_MODEL_STUB_MODEL_TYPE_SYNC_BRIDGE_H_ +#ifndef COMPONENTS_SYNC_TEST_STUB_MODEL_TYPE_SYNC_BRIDGE_H_ +#define COMPONENTS_SYNC_TEST_STUB_MODEL_TYPE_SYNC_BRIDGE_H_ #include <memory> #include <string> @@ -36,4 +36,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_STUB_MODEL_TYPE_SYNC_BRIDGE_H_ +#endif // COMPONENTS_SYNC_TEST_STUB_MODEL_TYPE_SYNC_BRIDGE_H_
diff --git a/components/sync/test/model/sync_change_processor_wrapper_for_test.cc b/components/sync/test/sync_change_processor_wrapper_for_test.cc similarity index 93% rename from components/sync/test/model/sync_change_processor_wrapper_for_test.cc rename to components/sync/test/sync_change_processor_wrapper_for_test.cc index f011623..8855bfa3 100644 --- a/components/sync/test/model/sync_change_processor_wrapper_for_test.cc +++ b/components/sync/test/sync_change_processor_wrapper_for_test.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/sync_change_processor_wrapper_for_test.h" +#include "components/sync/test/sync_change_processor_wrapper_for_test.h" #include "base/bind.h" #include "components/sync/model/syncable_service.h"
diff --git a/components/sync/test/model/sync_change_processor_wrapper_for_test.h b/components/sync/test/sync_change_processor_wrapper_for_test.h similarity index 86% rename from components/sync/test/model/sync_change_processor_wrapper_for_test.h rename to components/sync/test/sync_change_processor_wrapper_for_test.h index e2440a8..888780d 100644 --- a/components/sync/test/model/sync_change_processor_wrapper_for_test.h +++ b/components/sync/test/sync_change_processor_wrapper_for_test.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 COMPONENTS_SYNC_TEST_MODEL_SYNC_CHANGE_PROCESSOR_WRAPPER_FOR_TEST_H_ -#define COMPONENTS_SYNC_TEST_MODEL_SYNC_CHANGE_PROCESSOR_WRAPPER_FOR_TEST_H_ +#ifndef COMPONENTS_SYNC_TEST_SYNC_CHANGE_PROCESSOR_WRAPPER_FOR_TEST_H_ +#define COMPONENTS_SYNC_TEST_SYNC_CHANGE_PROCESSOR_WRAPPER_FOR_TEST_H_ #include "base/callback.h" #include "components/sync/model/sync_change_processor.h" @@ -45,4 +45,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_SYNC_CHANGE_PROCESSOR_WRAPPER_FOR_TEST_H_ +#endif // COMPONENTS_SYNC_TEST_SYNC_CHANGE_PROCESSOR_WRAPPER_FOR_TEST_H_
diff --git a/components/sync/test/engine/sync_engine_host_stub.cc b/components/sync/test/sync_engine_host_stub.cc similarity index 93% rename from components/sync/test/engine/sync_engine_host_stub.cc rename to components/sync/test/sync_engine_host_stub.cc index 1899a410..483817ae 100644 --- a/components/sync/test/engine/sync_engine_host_stub.cc +++ b/components/sync/test/sync_engine_host_stub.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/sync_engine_host_stub.h" +#include "components/sync/test/sync_engine_host_stub.h" namespace syncer {
diff --git a/components/sync/test/engine/sync_engine_host_stub.h b/components/sync/test/sync_engine_host_stub.h similarity index 82% rename from components/sync/test/engine/sync_engine_host_stub.h rename to components/sync/test/sync_engine_host_stub.h index 2a29144..7e0dd2a 100644 --- a/components/sync/test/engine/sync_engine_host_stub.h +++ b/components/sync/test/sync_engine_host_stub.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 COMPONENTS_SYNC_TEST_ENGINE_SYNC_ENGINE_HOST_STUB_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_SYNC_ENGINE_HOST_STUB_H_ +#ifndef COMPONENTS_SYNC_TEST_SYNC_ENGINE_HOST_STUB_H_ +#define COMPONENTS_SYNC_TEST_SYNC_ENGINE_HOST_STUB_H_ #include "components/sync/engine/sync_engine_host.h" @@ -27,4 +27,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_SYNC_ENGINE_HOST_STUB_H_ +#endif // COMPONENTS_SYNC_TEST_SYNC_ENGINE_HOST_STUB_H_
diff --git a/components/sync/test/model/sync_error_factory_mock.cc b/components/sync/test/sync_error_factory_mock.cc similarity index 83% rename from components/sync/test/model/sync_error_factory_mock.cc rename to components/sync/test/sync_error_factory_mock.cc index 1506a3e2..4d09c3c 100644 --- a/components/sync/test/model/sync_error_factory_mock.cc +++ b/components/sync/test/sync_error_factory_mock.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/sync_error_factory_mock.h" namespace syncer {
diff --git a/components/sync/test/model/sync_error_factory_mock.h b/components/sync/test/sync_error_factory_mock.h similarity index 76% rename from components/sync/test/model/sync_error_factory_mock.h rename to components/sync/test/sync_error_factory_mock.h index 14768d2..5aef6b3 100644 --- a/components/sync/test/model/sync_error_factory_mock.h +++ b/components/sync/test/sync_error_factory_mock.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 COMPONENTS_SYNC_TEST_MODEL_SYNC_ERROR_FACTORY_MOCK_H_ -#define COMPONENTS_SYNC_TEST_MODEL_SYNC_ERROR_FACTORY_MOCK_H_ +#ifndef COMPONENTS_SYNC_TEST_SYNC_ERROR_FACTORY_MOCK_H_ +#define COMPONENTS_SYNC_TEST_SYNC_ERROR_FACTORY_MOCK_H_ #include <string> @@ -24,4 +24,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_SYNC_ERROR_FACTORY_MOCK_H_ +#endif // COMPONENTS_SYNC_TEST_SYNC_ERROR_FACTORY_MOCK_H_
diff --git a/components/sync/test/engine/test_engine_components_factory.cc b/components/sync/test/test_engine_components_factory.cc similarity index 91% rename from components/sync/test/engine/test_engine_components_factory.cc rename to components/sync/test/test_engine_components_factory.cc index 5c1098d4..770b430 100644 --- a/components/sync/test/engine/test_engine_components_factory.cc +++ b/components/sync/test/test_engine_components_factory.cc
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/engine/test_engine_components_factory.h" +#include "components/sync/test/test_engine_components_factory.h" #include <memory> #include "components/sync/engine/cycle/sync_cycle_context.h" -#include "components/sync/test/engine/fake_sync_scheduler.h" +#include "components/sync/test/fake_sync_scheduler.h" namespace syncer {
diff --git a/components/sync/test/engine/test_engine_components_factory.h b/components/sync/test/test_engine_components_factory.h similarity index 86% rename from components/sync/test/engine/test_engine_components_factory.h rename to components/sync/test/test_engine_components_factory.h index 9423b381..3371d8f 100644 --- a/components/sync/test/engine/test_engine_components_factory.h +++ b/components/sync/test/test_engine_components_factory.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_SYNC_TEST_ENGINE_TEST_ENGINE_COMPONENTS_FACTORY_H_ -#define COMPONENTS_SYNC_TEST_ENGINE_TEST_ENGINE_COMPONENTS_FACTORY_H_ +#ifndef COMPONENTS_SYNC_TEST_TEST_ENGINE_COMPONENTS_FACTORY_H_ +#define COMPONENTS_SYNC_TEST_TEST_ENGINE_COMPONENTS_FACTORY_H_ #include <memory> #include <string> @@ -42,4 +42,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_ENGINE_TEST_ENGINE_COMPONENTS_FACTORY_H_ +#endif // COMPONENTS_SYNC_TEST_TEST_ENGINE_COMPONENTS_FACTORY_H_
diff --git a/components/sync/test/model/test_matchers.h b/components/sync/test/test_matchers.h similarity index 94% rename from components/sync/test/model/test_matchers.h rename to components/sync/test/test_matchers.h index 8abe0c1..2a77afe 100644 --- a/components/sync/test/model/test_matchers.h +++ b/components/sync/test/test_matchers.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 COMPONENTS_SYNC_TEST_MODEL_TEST_MATCHERS_H_ -#define COMPONENTS_SYNC_TEST_MODEL_TEST_MATCHERS_H_ +#ifndef COMPONENTS_SYNC_TEST_TEST_MATCHERS_H_ +#define COMPONENTS_SYNC_TEST_TEST_MATCHERS_H_ #include <map> #include <memory> @@ -79,4 +79,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_TEST_MATCHERS_H_ +#endif // COMPONENTS_SYNC_TEST_TEST_MATCHERS_H_
diff --git a/components/sync/test/model/test_model_type_store_service.cc b/components/sync/test/test_model_type_store_service.cc similarity index 88% rename from components/sync/test/model/test_model_type_store_service.cc rename to components/sync/test/test_model_type_store_service.cc index 014d9c6..429f1dc 100644 --- a/components/sync/test/model/test_model_type_store_service.cc +++ b/components/sync/test/test_model_type_store_service.cc
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/sync/test/model/test_model_type_store_service.h" +#include "components/sync/test/test_model_type_store_service.h" #include "base/threading/sequenced_task_runner_handle.h" #include "components/sync/model/blocking_model_type_store_impl.h" #include "components/sync/model/model_type_store_backend.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/model_type_store_test_util.h" namespace syncer {
diff --git a/components/sync/test/model/test_model_type_store_service.h b/components/sync/test/test_model_type_store_service.h similarity index 85% rename from components/sync/test/model/test_model_type_store_service.h rename to components/sync/test/test_model_type_store_service.h index 2832939b..974dc1c 100644 --- a/components/sync/test/model/test_model_type_store_service.h +++ b/components/sync/test/test_model_type_store_service.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 COMPONENTS_SYNC_TEST_MODEL_TEST_MODEL_TYPE_STORE_SERVICE_H_ -#define COMPONENTS_SYNC_TEST_MODEL_TEST_MODEL_TYPE_STORE_SERVICE_H_ +#ifndef COMPONENTS_SYNC_TEST_TEST_MODEL_TYPE_STORE_SERVICE_H_ +#define COMPONENTS_SYNC_TEST_TEST_MODEL_TYPE_STORE_SERVICE_H_ #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" @@ -39,4 +39,4 @@ } // namespace syncer -#endif // COMPONENTS_SYNC_TEST_MODEL_TEST_MODEL_TYPE_STORE_SERVICE_H_ +#endif // COMPONENTS_SYNC_TEST_TEST_MODEL_TYPE_STORE_SERVICE_H_
diff --git a/components/sync_device_info/device_info_sync_bridge_unittest.cc b/components/sync_device_info/device_info_sync_bridge_unittest.cc index 63425fb9..5468d6c 100644 --- a/components/sync_device_info/device_info_sync_bridge_unittest.cc +++ b/components/sync_device_info/device_info_sync_bridge_unittest.cc
@@ -33,9 +33,9 @@ #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/model_type_state.pb.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" +#include "components/sync/test/test_matchers.h" #include "components/sync_device_info/device_info_prefs.h" #include "components/sync_device_info/device_info_util.h" #include "components/sync_device_info/local_device_info_util.h"
diff --git a/components/sync_device_info/fake_device_info_sync_service.h b/components/sync_device_info/fake_device_info_sync_service.h index 12c40b0..fa1a7690 100644 --- a/components/sync_device_info/fake_device_info_sync_service.h +++ b/components/sync_device_info/fake_device_info_sync_service.h
@@ -5,7 +5,7 @@ #ifndef COMPONENTS_SYNC_DEVICE_INFO_FAKE_DEVICE_INFO_SYNC_SERVICE_H_ #define COMPONENTS_SYNC_DEVICE_INFO_FAKE_DEVICE_INFO_SYNC_SERVICE_H_ -#include "components/sync/test/model/fake_model_type_controller_delegate.h" +#include "components/sync/test/fake_model_type_controller_delegate.h" #include "components/sync_device_info/device_info_sync_service.h" #include "components/sync_device_info/fake_device_info_tracker.h" #include "components/sync_device_info/fake_local_device_info_provider.h"
diff --git a/components/sync_preferences/pref_service_syncable_unittest.cc b/components/sync_preferences/pref_service_syncable_unittest.cc index 2fd7da6..e9a2e4a 100644 --- a/components/sync_preferences/pref_service_syncable_unittest.cc +++ b/components/sync_preferences/pref_service_syncable_unittest.cc
@@ -29,7 +29,7 @@ #include "components/sync/model/syncable_service.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/preference_specifics.pb.h" -#include "components/sync/test/model/sync_error_factory_mock.h" +#include "components/sync/test/sync_error_factory_mock.h" #include "components/sync_preferences/pref_model_associator.h" #include "components/sync_preferences/pref_model_associator_client.h" #include "components/sync_preferences/pref_service_syncable_observer.h"
diff --git a/components/sync_sessions/session_store_unittest.cc b/components/sync_sessions/session_store_unittest.cc index 3a30f32..69e7f2a 100644 --- a/components/sync_sessions/session_store_unittest.cc +++ b/components/sync_sessions/session_store_unittest.cc
@@ -19,8 +19,8 @@ #include "components/sync/protocol/entity_data.h" #include "components/sync/protocol/entity_metadata.pb.h" #include "components/sync/protocol/session_specifics.pb.h" -#include "components/sync/test/model/model_type_store_test_util.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/model_type_store_test_util.h" +#include "components/sync/test/test_matchers.h" #include "components/sync_device_info/local_device_info_util.h" #include "components/sync_sessions/mock_sync_sessions_client.h" #include "components/sync_sessions/session_sync_prefs.h"
diff --git a/components/sync_sessions/session_sync_bridge_unittest.cc b/components/sync_sessions/session_sync_bridge_unittest.cc index 54768096..1f59e0b 100644 --- a/components/sync_sessions/session_sync_bridge_unittest.cc +++ b/components/sync_sessions/session_sync_bridge_unittest.cc
@@ -28,9 +28,9 @@ #include "components/sync/protocol/model_type_state.pb.h" #include "components/sync/protocol/session_specifics.pb.h" #include "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" -#include "components/sync/test/model/test_matchers.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" +#include "components/sync/test/test_matchers.h" #include "components/sync_sessions/mock_sync_sessions_client.h" #include "components/sync_sessions/session_sync_prefs.h" #include "components/sync_sessions/test_matchers.h"
diff --git a/components/sync_user_events/DEPS b/components/sync_user_events/DEPS index 051e8d5a..0c0bd78 100644 --- a/components/sync_user_events/DEPS +++ b/components/sync_user_events/DEPS
@@ -4,5 +4,5 @@ "+components/sync/driver", "+components/sync/model", "+components/sync/protocol", - "+components/sync/test/model", + "+components/sync/test", ]
diff --git a/components/sync_user_events/fake_user_event_service.h b/components/sync_user_events/fake_user_event_service.h index e8225441..931b3675 100644 --- a/components/sync_user_events/fake_user_event_service.h +++ b/components/sync_user_events/fake_user_event_service.h
@@ -9,7 +9,7 @@ #include <vector> #include "components/sync/protocol/user_event_specifics.pb.h" -#include "components/sync/test/model/fake_model_type_controller_delegate.h" +#include "components/sync/test/fake_model_type_controller_delegate.h" #include "components/sync_user_events/user_event_service.h" namespace syncer {
diff --git a/components/sync_user_events/user_event_service_impl_unittest.cc b/components/sync_user_events/user_event_service_impl_unittest.cc index d088e311..0cbfaae 100644 --- a/components/sync_user_events/user_event_service_impl_unittest.cc +++ b/components/sync_user_events/user_event_service_impl_unittest.cc
@@ -11,8 +11,8 @@ #include "components/sync/base/model_type.h" #include "components/sync/driver/test_sync_service.h" #include "components/sync/protocol/user_event_specifics.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "components/sync_user_events/user_event_sync_bridge.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sync_user_events/user_event_sync_bridge_unittest.cc b/components/sync_user_events/user_event_sync_bridge_unittest.cc index d1085ed1..59f76eb 100644 --- a/components/sync_user_events/user_event_sync_bridge_unittest.cc +++ b/components/sync_user_events/user_event_sync_bridge_unittest.cc
@@ -15,8 +15,8 @@ #include "components/sync/model/data_batch.h" #include "components/sync/protocol/entity_specifics.pb.h" #include "components/sync/protocol/user_event_specifics.pb.h" -#include "components/sync/test/model/mock_model_type_change_processor.h" -#include "components/sync/test/model/model_type_store_test_util.h" +#include "components/sync/test/mock_model_type_change_processor.h" +#include "components/sync/test/model_type_store_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/translate/content/renderer/per_frame_translate_agent.h b/components/translate/content/renderer/per_frame_translate_agent.h index 21ed285..6c92b927 100644 --- a/components/translate/content/renderer/per_frame_translate_agent.h +++ b/components/translate/content/renderer/per_frame_translate_agent.h
@@ -138,10 +138,6 @@ // with |error|. void NotifyBrowserTranslationFailed(TranslateErrors::Type error); - // Convenience method to access the main frame. Can return nullptr, typically - // if the page is being closed. - blink::WebLocalFrame* GetMainFrame(); - // The states associated with the current translation. TranslateFrameCallback translate_callback_pending_; std::string source_lang_;
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index 604aab14..2b3547f 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn
@@ -392,6 +392,7 @@ "aggregation_service/aggregation_service_key_fetcher.h", "aggregation_service/aggregation_service_network_fetcher_impl.cc", "aggregation_service/aggregation_service_network_fetcher_impl.h", + "aggregation_service/aggregation_service_observer.h", "aggregation_service/aggregation_service_storage.h", "aggregation_service/aggregation_service_storage_context.h", "aggregation_service/aggregation_service_storage_sql.cc", @@ -1470,8 +1471,6 @@ "private_aggregation/private_aggregation_budget_storage.h", "private_aggregation/private_aggregation_budgeter.cc", "private_aggregation/private_aggregation_budgeter.h", - "private_aggregation/private_aggregation_features.cc", - "private_aggregation/private_aggregation_features.h", "private_aggregation/private_aggregation_host.cc", "private_aggregation/private_aggregation_host.h", "private_aggregation/private_aggregation_manager.cc",
diff --git a/content/browser/aggregation_service/aggregatable_report.cc b/content/browser/aggregation_service/aggregatable_report.cc index 32719cd1..06efa418 100644 --- a/content/browser/aggregation_service/aggregatable_report.cc +++ b/content/browser/aggregation_service/aggregatable_report.cc
@@ -666,7 +666,7 @@ absl::optional<AggregatableReport> AggregatableReport::Provider::CreateFromRequestAndPublicKeys( - AggregatableReportRequest report_request, + const AggregatableReportRequest& report_request, std::vector<PublicKey> public_keys) const { const size_t num_processing_urls = public_keys.size(); DCHECK_EQ(num_processing_urls, report_request.processing_urls().size());
diff --git a/content/browser/aggregation_service/aggregatable_report.h b/content/browser/aggregation_service/aggregatable_report.h index 75bffd2f..4199aad 100644 --- a/content/browser/aggregation_service/aggregatable_report.h +++ b/content/browser/aggregation_service/aggregatable_report.h
@@ -154,7 +154,7 @@ // correspond to `report_request.processing_urls`, which should be // sorted. Returns `absl::nullopt` if an error occurred during construction. virtual absl::optional<AggregatableReport> CreateFromRequestAndPublicKeys( - AggregatableReportRequest report_request, + const AggregatableReportRequest& report_request, std::vector<PublicKey> public_keys) const; // Sets whether to disable encryption of the payload(s). Should only be used
diff --git a/content/browser/aggregation_service/aggregatable_report_assembler.cc b/content/browser/aggregation_service/aggregatable_report_assembler.cc index 77759c8..00d371e 100644 --- a/content/browser/aggregation_service/aggregatable_report_assembler.cc +++ b/content/browser/aggregation_service/aggregatable_report_assembler.cc
@@ -126,7 +126,7 @@ if (pending_requests_.size() >= kMaxSimultaneousRequests) { RecordAssemblyStatus(AssemblyStatus::kTooManySimultaneousRequests); - std::move(callback).Run(absl::nullopt, + std::move(callback).Run(std::move(report_request), absl::nullopt, AssemblyStatus::kTooManySimultaneousRequests); return; } @@ -182,7 +182,8 @@ RecordAssemblyStatus(AssemblyStatus::kPublicKeyFetchFailed); std::move(pending_request.callback) - .Run(absl::nullopt, AssemblyStatus::kPublicKeyFetchFailed); + .Run(std::move(pending_request.report_request), absl::nullopt, + AssemblyStatus::kPublicKeyFetchFailed); pending_requests_.erase(report_id); return; } @@ -192,13 +193,14 @@ absl::optional<AggregatableReport> assembled_report = report_provider_->CreateFromRequestAndPublicKeys( - std::move(pending_request.report_request), std::move(public_keys)); + pending_request.report_request, std::move(public_keys)); AssemblyStatus assembly_status = assembled_report ? AssemblyStatus::kOk : AssemblyStatus::kAssemblyFailed; RecordAssemblyStatus(assembly_status); std::move(pending_request.callback) - .Run(std::move(assembled_report), assembly_status); + .Run(std::move(pending_request.report_request), + std::move(assembled_report), assembly_status); pending_requests_.erase(report_id); }
diff --git a/content/browser/aggregation_service/aggregatable_report_assembler.h b/content/browser/aggregation_service/aggregatable_report_assembler.h index c8072a95..3f33590 100644 --- a/content/browser/aggregation_service/aggregatable_report_assembler.h +++ b/content/browser/aggregation_service/aggregatable_report_assembler.h
@@ -54,7 +54,8 @@ }; using AssemblyCallback = - base::OnceCallback<void(absl::optional<AggregatableReport>, + base::OnceCallback<void(AggregatableReportRequest, + absl::optional<AggregatableReport>, AssemblyStatus)>; // While we shouldn't hit these limits in typical usage, we protect against
diff --git a/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc b/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc index a613627..974fa73 100644 --- a/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc +++ b/content/browser/aggregation_service/aggregatable_report_assembler_unittest.cc
@@ -48,12 +48,12 @@ constexpr char kReportAssemblerStatusHistogramName[] = "PrivacySandbox.AggregationService.ReportAssembler.Status"; -auto MoveRequestAndReturnReport(absl::optional<AggregatableReportRequest>* out, - AggregatableReport report) { +auto CloneRequestAndReturnReport(absl::optional<AggregatableReportRequest>* out, + AggregatableReport report) { return [out, report = std::move(report)]( - AggregatableReportRequest report_request, + const AggregatableReportRequest& report_request, std::vector<PublicKey> public_keys) { - *out = std::move(report_request); + *out = aggregation_service::CloneReportRequest(report_request); return std::move(report); }; } @@ -74,7 +74,7 @@ public: MOCK_METHOD(absl::optional<AggregatableReport>, CreateFromRequestAndPublicKeys, - (AggregatableReportRequest, std::vector<PublicKey>), + (const AggregatableReportRequest&, std::vector<PublicKey>), (const, override)); }; @@ -125,7 +125,7 @@ .WillOnce(base::test::RunOnceCallback<1>( absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed)); EXPECT_CALL(callback(), - Run(Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); + Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _)) .Times(0); @@ -152,7 +152,7 @@ aggregation_service::GenerateKey().public_key, PublicKeyFetchStatus::kOk)); EXPECT_CALL(callback(), - Run(Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); + Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _)) .Times(0); @@ -179,7 +179,7 @@ .WillOnce(base::test::RunOnceCallback<1>( absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed)); EXPECT_CALL(callback(), - Run(Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); + Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _)) .Times(0); @@ -205,7 +205,7 @@ absl::optional<AggregatableReport> report = AggregatableReport::Provider().CreateFromRequestAndPublicKeys( - aggregation_service::CloneReportRequest(request), public_keys); + request, public_keys); ASSERT_TRUE(report.has_value()); EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[0], _)) @@ -214,13 +214,13 @@ EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[1], _)) .WillOnce(base::test::RunOnceCallback<1>(public_keys[1], PublicKeyFetchStatus::kOk)); - EXPECT_CALL(callback(), Run(report, AssemblyStatus::kOk)); + EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk)); absl::optional<AggregatableReportRequest> actual_request; EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, public_keys)) - .WillOnce(MoveRequestAndReturnReport(&actual_request, - std::move(report.value()))); + .WillOnce(CloneRequestAndReturnReport(&actual_request, + std::move(report.value()))); assembler()->AssembleReport(aggregation_service::CloneReportRequest(request), callback().Get()); @@ -244,19 +244,19 @@ absl::optional<AggregatableReport> report = AggregatableReport::Provider().CreateFromRequestAndPublicKeys( - aggregation_service::CloneReportRequest(request), {public_key}); + request, {public_key}); ASSERT_TRUE(report.has_value()); EXPECT_CALL(*fetcher(), GetPublicKey) .WillOnce(base::test::RunOnceCallback<1>(public_key, PublicKeyFetchStatus::kOk)); - EXPECT_CALL(callback(), Run(report, AssemblyStatus::kOk)); + EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk)); absl::optional<AggregatableReportRequest> actual_request; EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys( _, std::vector<PublicKey>{public_key})) - .WillOnce(MoveRequestAndReturnReport(&actual_request, - std::move(report.value()))); + .WillOnce(CloneRequestAndReturnReport(&actual_request, + std::move(report.value()))); assembler()->AssembleReport(aggregation_service::CloneReportRequest(request), callback().Get()); @@ -279,7 +279,7 @@ .WillOnce(base::test::RunOnceCallback<1>( absl::nullopt, PublicKeyFetchStatus::kPublicKeyFetchFailed)); EXPECT_CALL(callback(), - Run(Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); + Run(_, Eq(absl::nullopt), AssemblyStatus::kPublicKeyFetchFailed)); EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, _)) .Times(0); @@ -305,7 +305,7 @@ absl::optional<AggregatableReport> report = AggregatableReport::Provider().CreateFromRequestAndPublicKeys( - aggregation_service::CloneReportRequest(request), public_keys); + request, public_keys); ASSERT_TRUE(report.has_value()); std::vector<FetchCallback> pending_callbacks(2); @@ -313,13 +313,13 @@ .WillOnce(MoveArg<1>(&pending_callbacks.front())); EXPECT_CALL(*fetcher(), GetPublicKey(processing_urls[1], _)) .WillOnce(MoveArg<1>(&pending_callbacks.back())); - EXPECT_CALL(callback(), Run(report, AssemblyStatus::kOk)); + EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk)); absl::optional<AggregatableReportRequest> actual_request; EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys(_, public_keys)) - .WillOnce(MoveRequestAndReturnReport(&actual_request, - std::move(report.value()))); + .WillOnce(CloneRequestAndReturnReport(&actual_request, + std::move(report.value()))); assembler()->AssembleReport(aggregation_service::CloneReportRequest(request), callback().Get()); @@ -364,7 +364,7 @@ absl::optional<AggregatableReport> report = AggregatableReport::Provider().CreateFromRequestAndPublicKeys( - aggregation_service::CloneReportRequest(request), {public_key}); + request, {public_key}); ASSERT_TRUE(report.has_value()); std::vector<FetchCallback> pending_callbacks(2); @@ -372,15 +372,15 @@ .WillOnce(MoveArg<1>(&pending_callbacks.front())) .WillOnce(MoveArg<1>(&pending_callbacks.back())); - EXPECT_CALL(callback(), Run(report, AssemblyStatus::kOk)).Times(2); + EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk)).Times(2); absl::optional<AggregatableReportRequest> first_request; absl::optional<AggregatableReportRequest> second_request; EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys( _, std::vector<PublicKey>{public_key})) - .WillOnce(MoveRequestAndReturnReport(&first_request, report.value())) - .WillOnce(MoveRequestAndReturnReport(&second_request, - std::move(report.value()))); + .WillOnce(CloneRequestAndReturnReport(&first_request, report.value())) + .WillOnce(CloneRequestAndReturnReport(&second_request, + std::move(report.value()))); assembler()->AssembleReport(aggregation_service::CloneReportRequest(request), callback().Get()); @@ -429,11 +429,11 @@ pending_callbacks.push_back(std::move(callback)); })); - EXPECT_CALL(callback(), Run(_, _)).Times(0); + EXPECT_CALL(callback(), Run).Times(0); EXPECT_CALL(checkpoint, Call(current_check++)); - EXPECT_CALL(callback(), Run(Eq(absl::nullopt), + EXPECT_CALL(callback(), Run(_, Eq(absl::nullopt), AssemblyStatus::kTooManySimultaneousRequests)) .Times(1); @@ -444,7 +444,7 @@ EXPECT_CALL(checkpoint, Call(current_check++)); EXPECT_CALL(*report_provider(), CreateFromRequestAndPublicKeys) .WillOnce(Return(report)); - EXPECT_CALL(callback(), Run(report, AssemblyStatus::kOk)); + EXPECT_CALL(callback(), Run(_, report, AssemblyStatus::kOk)); } }
diff --git a/content/browser/aggregation_service/aggregation_service.h b/content/browser/aggregation_service/aggregation_service.h index 8c42ab3..02cde2f5 100644 --- a/content/browser/aggregation_service/aggregation_service.h +++ b/content/browser/aggregation_service/aggregation_service.h
@@ -5,8 +5,12 @@ #ifndef CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_H_ #define CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_H_ +#include <vector> + +#include "base/callback_forward.h" #include "content/browser/aggregation_service/aggregatable_report_assembler.h" #include "content/browser/aggregation_service/aggregatable_report_sender.h" +#include "content/browser/aggregation_service/aggregation_service_storage.h" #include "content/public/browser/storage_partition.h" class GURL; @@ -18,6 +22,7 @@ namespace content { +class AggregationServiceObserver; class AggregatableReport; class AggregatableReportRequest; class BrowserContext; @@ -70,6 +75,24 @@ // time. It is stored on disk (unless in incognito) until then. See the // `AggregatableReportScheduler` for details. virtual void ScheduleReport(AggregatableReportRequest report_request) = 0; + + // Gets all pending report requests that are currently stored. Used for + // populating WebUI. + // TODO(linnan): Consider enforcing a limit on the number of requests + // returned. + virtual void GetPendingReportRequestsForWebUI( + base::OnceCallback<void( + std::vector<AggregationServiceStorage::RequestAndId>)> callback) = 0; + + // Sends the given reports immediately, and runs `reports_sent_callback` once + // they have all been sent. + virtual void SendReportsForWebUI( + const std::vector<AggregationServiceStorage::RequestId>& ids, + base::OnceClosure reports_sent_callback) = 0; + + virtual void AddObserver(AggregationServiceObserver* observer) = 0; + + virtual void RemoveObserver(AggregationServiceObserver* observer) = 0; }; } // namespace content
diff --git a/content/browser/aggregation_service/aggregation_service_impl.cc b/content/browser/aggregation_service/aggregation_service_impl.cc index 355f23e..ae68d2f4 100644 --- a/content/browser/aggregation_service/aggregation_service_impl.cc +++ b/content/browser/aggregation_service/aggregation_service_impl.cc
@@ -10,23 +10,30 @@ #include <utility> #include <vector> +#include "base/barrier_closure.h" #include "base/bind.h" #include "base/callback.h" +#include "base/callback_helpers.h" #include "base/check_op.h" #include "base/files/file_path.h" #include "base/memory/ptr_util.h" +#include "base/memory/weak_ptr.h" #include "base/task/lazy_thread_pool_task_runner.h" #include "base/task/task_traits.h" #include "base/time/default_clock.h" #include "base/time/time.h" #include "base/values.h" +#include "content/browser/aggregation_service/aggregatable_report.h" #include "content/browser/aggregation_service/aggregatable_report_assembler.h" #include "content/browser/aggregation_service/aggregatable_report_scheduler.h" #include "content/browser/aggregation_service/aggregatable_report_sender.h" +#include "content/browser/aggregation_service/aggregation_service_observer.h" +#include "content/browser/aggregation_service/aggregation_service_storage.h" #include "content/browser/aggregation_service/aggregation_service_storage_sql.h" #include "content/browser/aggregation_service/public_key.h" #include "content/browser/storage_partition_impl.h" #include "content/public/browser/storage_partition.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace content { @@ -134,55 +141,90 @@ base::OnceClosure done) { storage_.AsyncCall(&AggregationServiceStorage::ClearDataBetween) .WithArgs(delete_begin, delete_end, std::move(filter)) - .Then(std::move(done)); + .Then(base::BindOnce( + [](base::OnceClosure done, + base::WeakPtr<AggregationServiceImpl> aggregation_service) { + std::move(done).Run(); + + if (aggregation_service) + aggregation_service->NotifyRequestStorageModified(); + }, + std::move(done), weak_factory_.GetWeakPtr())); } void AggregationServiceImpl::ScheduleReport( AggregatableReportRequest report_request) { scheduler_->ScheduleRequest(std::move(report_request)); + NotifyRequestStorageModified(); } void AggregationServiceImpl::OnScheduledReportTimeReached( std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids) { - for (AggregationServiceStorage::RequestAndId& elem : requests_and_ids) { - GURL reporting_url = elem.request.GetReportingUrl(); - AssembleReport( - std::move(elem.request), - base::BindOnce( - &AggregationServiceImpl::OnReportAssemblyComplete, - // `base::Unretained` is safe as the assembler is owned by `this`. - base::Unretained(this), elem.id, std::move(reporting_url))); - } + AssembleAndSendReports(std::move(requests_and_ids), + /*done=*/base::DoNothing()); } void AggregationServiceImpl::OnReportAssemblyComplete( + base::OnceClosure done, AggregationServiceStorage::RequestId request_id, GURL reporting_url, + AggregatableReportRequest report_request, absl::optional<AggregatableReport> report, AggregatableReportAssembler::AssemblyStatus status) { DCHECK_EQ(report.has_value(), status == AggregatableReportAssembler::AssemblyStatus::kOk); if (!report.has_value()) { + std::move(done).Run(); + scheduler_->NotifyInProgressRequestFailed(request_id); + NotifyReportHandled( + AggregationServiceStorage::RequestAndId{ + .request = std::move(report_request), + .id = request_id, + }, + /*report=*/absl::nullopt, + AggregationServiceObserver::ReportStatus::kFailedToAssemble); + NotifyRequestStorageModified(); return; } - SendReport(reporting_url, report.value(), + base::Value value(report->GetAsJson()); + SendReport(reporting_url, value, /*callback=*/ base::BindOnce( &AggregationServiceImpl::OnReportSendingComplete, // `base::Unretained` is safe as the sender is owned by `this`. - base::Unretained(this), request_id)); + base::Unretained(this), std::move(done), + AggregationServiceStorage::RequestAndId{ + .request = std::move(report_request), + .id = request_id, + }, + std::move(*report))); } void AggregationServiceImpl::OnReportSendingComplete( - AggregationServiceStorage::RequestId request_id, + base::OnceClosure done, + AggregationServiceStorage::RequestAndId request_and_id, + AggregatableReport report, AggregatableReportSender::RequestStatus status) { - if (status == AggregatableReportSender::RequestStatus::kOk) { - scheduler_->NotifyInProgressRequestSucceeded(request_id); - } else { - scheduler_->NotifyInProgressRequestFailed(request_id); + std::move(done).Run(); + + AggregationServiceObserver::ReportStatus observer_status; + switch (status) { + case AggregatableReportSender::RequestStatus::kOk: + observer_status = AggregationServiceObserver::ReportStatus::kSent; + scheduler_->NotifyInProgressRequestSucceeded(request_and_id.id); + break; + case AggregatableReportSender::RequestStatus::kNetworkError: + case AggregatableReportSender::RequestStatus::kServerError: + observer_status = AggregationServiceObserver::ReportStatus::kFailedToSend; + scheduler_->NotifyInProgressRequestFailed(request_and_id.id); + break; } + + NotifyReportHandled(std::move(request_and_id), std::move(report), + observer_status); + NotifyRequestStorageModified(); } void AggregationServiceImpl::SetPublicKeysForTesting( @@ -192,4 +234,75 @@ .WithArgs(url, keyset); } +void AggregationServiceImpl::AssembleAndSendReports( + std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids, + base::RepeatingClosure done) { + for (AggregationServiceStorage::RequestAndId& elem : requests_and_ids) { + GURL reporting_url = elem.request.GetReportingUrl(); + AssembleReport( + std::move(elem.request), + base::BindOnce( + &AggregationServiceImpl::OnReportAssemblyComplete, + // `base::Unretained` is safe as the assembler is owned by `this`. + base::Unretained(this), done, elem.id, std::move(reporting_url))); + } +} + +void AggregationServiceImpl::GetPendingReportRequestsForWebUI( + base::OnceCallback< + void(std::vector<AggregationServiceStorage::RequestAndId>)> callback) { + storage_.AsyncCall(&AggregationServiceStorage::GetRequestsReportingOnOrBefore) + .WithArgs(/*not_after_time=*/base::Time::Max()) + .Then(std::move(callback)); +} + +void AggregationServiceImpl::SendReportsForWebUI( + const std::vector<AggregationServiceStorage::RequestId>& ids, + base::OnceClosure reports_sent_callback) { + storage_.AsyncCall(&AggregationServiceStorage::GetRequests) + .WithArgs(ids) + .Then(base::BindOnce( + &AggregationServiceImpl::OnGetRequestsToSendFromWebUI, + weak_factory_.GetWeakPtr(), std::move(reports_sent_callback))); +} + +void AggregationServiceImpl::OnGetRequestsToSendFromWebUI( + base::OnceClosure reports_sent_callback, + std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids) { + if (requests_and_ids.empty()) { + std::move(reports_sent_callback).Run(); + return; + } + + auto barrier = base::BarrierClosure(requests_and_ids.size(), + std::move(reports_sent_callback)); + AssembleAndSendReports(std::move(requests_and_ids), std::move(barrier)); +} + +void AggregationServiceImpl::AddObserver(AggregationServiceObserver* observer) { + observers_.AddObserver(observer); +} + +void AggregationServiceImpl::RemoveObserver( + AggregationServiceObserver* observer) { + observers_.RemoveObserver(observer); +} + +void AggregationServiceImpl::NotifyReportHandled( + AggregationServiceStorage::RequestAndId request_and_id, + absl::optional<AggregatableReport> report, + AggregationServiceObserver::ReportStatus status) { + base::Time now = base::Time::Now(); + for (auto& observer : observers_) { + observer.OnReportHandled(request_and_id, report, + /*report_handled_time=*/now, status); + } +} + +void AggregationServiceImpl::NotifyRequestStorageModified() { + for (auto& observer : observers_) { + observer.OnRequestStorageModified(); + } +} + } // namespace content \ No newline at end of file
diff --git a/content/browser/aggregation_service/aggregation_service_impl.h b/content/browser/aggregation_service/aggregation_service_impl.h index 9a56d45..d53e2755 100644 --- a/content/browser/aggregation_service/aggregation_service_impl.h +++ b/content/browser/aggregation_service/aggregation_service_impl.h
@@ -10,12 +10,17 @@ #include <memory> #include <vector> +#include "base/callback_forward.h" #include "base/containers/flat_map.h" +#include "base/memory/weak_ptr.h" +#include "base/observer_list.h" #include "base/threading/sequence_bound.h" #include "content/browser/aggregation_service/aggregatable_report_assembler.h" #include "content/browser/aggregation_service/aggregatable_report_scheduler.h" #include "content/browser/aggregation_service/aggregatable_report_sender.h" #include "content/browser/aggregation_service/aggregation_service.h" +#include "content/browser/aggregation_service/aggregation_service_observer.h" +#include "content/browser/aggregation_service/aggregation_service_storage.h" #include "content/browser/aggregation_service/aggregation_service_storage_context.h" #include "content/common/content_export.h" #include "content/public/browser/storage_partition.h" @@ -32,6 +37,7 @@ struct PublicKeyset; class AggregatableReport; +class AggregatableReportRequest; class AggregationServiceStorage; class AggregatableReportScheduler; class StoragePartitionImpl; @@ -75,6 +81,15 @@ StoragePartition::StorageKeyMatcherFunction filter, base::OnceClosure done) override; void ScheduleReport(AggregatableReportRequest report_request) override; + void GetPendingReportRequestsForWebUI( + base::OnceCallback< + void(std::vector<AggregationServiceStorage::RequestAndId>)> callback) + override; + void SendReportsForWebUI( + const std::vector<AggregationServiceStorage::RequestId>& ids, + base::OnceClosure reports_sent_callback) override; + void AddObserver(AggregationServiceObserver* observer) override; + void RemoveObserver(AggregationServiceObserver* observer) override; // AggregationServiceStorageContext: const base::SequenceBound<AggregationServiceStorage>& GetStorage() override; @@ -97,18 +112,42 @@ std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids); void OnReportAssemblyComplete( + base::OnceClosure done, AggregationServiceStorage::RequestId request_id, GURL reporting_url, + AggregatableReportRequest report_request, absl::optional<AggregatableReport> report, AggregatableReportAssembler::AssemblyStatus status); - void OnReportSendingComplete(AggregationServiceStorage::RequestId request_id, - AggregatableReportSender::RequestStatus status); + void OnReportSendingComplete( + base::OnceClosure done, + AggregationServiceStorage::RequestAndId request_and_id, + AggregatableReport report, + AggregatableReportSender::RequestStatus status); + + void AssembleAndSendReports( + std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids, + base::RepeatingClosure done); + + void OnGetRequestsToSendFromWebUI( + base::OnceClosure reports_sent_callback, + std::vector<AggregationServiceStorage::RequestAndId> requests_and_ids); + + void NotifyReportHandled( + AggregationServiceStorage::RequestAndId request_and_id, + absl::optional<AggregatableReport> report, + AggregationServiceObserver::ReportStatus status); + + void NotifyRequestStorageModified(); base::SequenceBound<AggregationServiceStorage> storage_; std::unique_ptr<AggregatableReportScheduler> scheduler_; std::unique_ptr<AggregatableReportAssembler> assembler_; std::unique_ptr<AggregatableReportSender> sender_; + + base::ObserverList<AggregationServiceObserver> observers_; + + base::WeakPtrFactory<AggregationServiceImpl> weak_factory_{this}; }; } // namespace content
diff --git a/content/browser/aggregation_service/aggregation_service_impl_unittest.cc b/content/browser/aggregation_service/aggregation_service_impl_unittest.cc index 4db2819..ff5386ad 100644 --- a/content/browser/aggregation_service/aggregation_service_impl_unittest.cc +++ b/content/browser/aggregation_service/aggregation_service_impl_unittest.cc
@@ -4,6 +4,7 @@ #include "content/browser/aggregation_service/aggregation_service_impl.h" +#include <stddef.h> #include <stdint.h> #include <map> @@ -18,23 +19,33 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/raw_ptr.h" #include "base/memory/scoped_refptr.h" +#include "base/run_loop.h" +#include "base/scoped_observation.h" #include "base/test/bind.h" #include "base/time/time.h" #include "content/browser/aggregation_service/aggregatable_report.h" #include "content/browser/aggregation_service/aggregatable_report_assembler.h" #include "content/browser/aggregation_service/aggregatable_report_scheduler.h" #include "content/browser/aggregation_service/aggregatable_report_sender.h" +#include "content/browser/aggregation_service/aggregation_service_observer.h" #include "content/browser/aggregation_service/aggregation_service_storage.h" #include "content/browser/aggregation_service/aggregation_service_test_utils.h" #include "content/public/test/browser_task_environment.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace content { +namespace { +using aggregation_service::RequestIdIs; +using testing::_; +using testing::ElementsAre; +} // namespace + // TODO(alexmt): Consider rewriting these tests using gmock. class TestAggregatableReportAssembler : public AggregatableReportAssembler { @@ -48,22 +59,46 @@ void AssembleReport(AggregatableReportRequest request, AssemblyCallback callback) override { - callbacks_.emplace(unique_id_counter_++, std::move(callback)); + pending_requests_.emplace(unique_id_counter_++, + PendingRequest{.request = std::move(request), + .callback = std::move(callback)}); + if (pending_requests_.size() < min_requests_count_) + return; + + wait_loop_.Quit(); } void TriggerResponse(int64_t report_id, absl::optional<AggregatableReport> report, AssemblyStatus status) { - ASSERT_TRUE(base::Contains(callbacks_, report_id)); ASSERT_EQ(report.has_value(), status == AssemblyStatus::kOk); - std::move(callbacks_[report_id]).Run(std::move(report), status); - callbacks_.erase(report_id); + auto iter = pending_requests_.find(report_id); + ASSERT_TRUE(iter != pending_requests_.end()); + + std::move(iter->second.callback) + .Run(std::move(iter->second.request), std::move(report), status); + pending_requests_.erase(iter); + } + + void WaitForRequests(size_t num_requests) { + min_requests_count_ = num_requests; + if (pending_requests_.size() >= num_requests) + return; + wait_loop_.Run(); } private: + struct PendingRequest { + AggregatableReportRequest request; + AssemblyCallback callback; + }; + int64_t unique_id_counter_ = 0; - std::map<int64_t, AssemblyCallback> callbacks_; + std::map<int64_t, PendingRequest> pending_requests_; + + size_t min_requests_count_ = 0; + base::RunLoop wait_loop_; }; class TestAggregatableReportSender : public AggregatableReportSender { @@ -154,6 +189,22 @@ completed_requests_status_; }; +class MockAggregationServiceObserver : public AggregationServiceObserver { + public: + MockAggregationServiceObserver() = default; + ~MockAggregationServiceObserver() override = default; + + MOCK_METHOD(void, OnRequestStorageModified, (), (override)); + + MOCK_METHOD(void, + OnReportHandled, + (const AggregationServiceStorage::RequestAndId& request_and_id, + const absl::optional<AggregatableReport>& report, + base::Time report_handle_time, + ReportStatus status), + (override)); +}; + class AggregationServiceImplTest : public testing::Test { public: AggregationServiceImplTest() @@ -192,7 +243,8 @@ void AssembleReport(AggregatableReportRequest request) { service()->AssembleReport( std::move(request), base::BindLambdaForTesting( - [&](absl::optional<AggregatableReport> report, + [&](AggregatableReportRequest, + absl::optional<AggregatableReport> report, AggregationService::AssemblyStatus status) { last_assembled_report_ = std::move(report); last_assembly_status_ = status; @@ -211,6 +263,12 @@ service()->ScheduleReport(std::move(request)); } + void StoreReport(AggregatableReportRequest request) { + service() + ->storage_.AsyncCall(&AggregationServiceStorage::StoreRequest) + .WithArgs(std::move(request)); + } + AggregationServiceImpl* service() { return service_impl_.get(); } TestAggregatableReportAssembler* assembler() { return test_assembler_; } TestAggregatableReportSender* sender() { return test_sender_; } @@ -344,9 +402,21 @@ ScheduleReport(std::move(request)); + MockAggregationServiceObserver observer; + base::ScopedObservation<AggregationService, AggregationServiceObserver> + observation(&observer); + observation.Observe(service()); + // Request IDs begin at 1. - scheduler()->TriggerReportingTime( - /*request_ids=*/{AggregationServiceStorage::RequestId(1)}); + AggregationServiceStorage::RequestId request_id(1); + + EXPECT_CALL(observer, OnRequestStorageModified); + EXPECT_CALL(observer, + OnReportHandled( + RequestIdIs(request_id), _, _, + AggregationServiceObserver::ReportStatus::kFailedToAssemble)); + + scheduler()->TriggerReportingTime(/*request_ids=*/{request_id}); std::vector<AggregatableReport::AggregationServicePayload> payloads; payloads.emplace_back(/*payload=*/kABCD1234AsBytes, @@ -358,14 +428,8 @@ /*report_id=*/0, absl::nullopt, AggregatableReportAssembler::AssemblyStatus::kAssemblyFailed); - ASSERT_TRUE( - scheduler() - ->WasRequestSuccessful(AggregationServiceStorage::RequestId(1)) - .has_value()); - EXPECT_FALSE( - scheduler() - ->WasRequestSuccessful(AggregationServiceStorage::RequestId(1)) - .value()); + ASSERT_TRUE(scheduler()->WasRequestSuccessful(request_id).has_value()); + EXPECT_FALSE(scheduler()->WasRequestSuccessful(request_id).value()); } TEST_F(AggregationServiceImplTest, ScheduleReport_FailedSending) { @@ -374,8 +438,21 @@ ScheduleReport(std::move(request)); - scheduler()->TriggerReportingTime( - /*request_ids=*/{AggregationServiceStorage::RequestId(1)}); + MockAggregationServiceObserver observer; + base::ScopedObservation<AggregationService, AggregationServiceObserver> + observation(&observer); + observation.Observe(service()); + + // Request IDs begin at 1. + AggregationServiceStorage::RequestId request_id(1); + + EXPECT_CALL(observer, OnRequestStorageModified); + EXPECT_CALL( + observer, + OnReportHandled(RequestIdIs(request_id), _, _, + AggregationServiceObserver::ReportStatus::kFailedToSend)); + + scheduler()->TriggerReportingTime(/*request_ids=*/{request_id}); std::vector<AggregatableReport::AggregationServicePayload> payloads; payloads.emplace_back(/*payload=*/kABCD1234AsBytes, @@ -390,14 +467,8 @@ sender()->TriggerResponse( /*report_id=*/0, AggregatableReportSender::RequestStatus::kNetworkError); - ASSERT_TRUE( - scheduler() - ->WasRequestSuccessful(AggregationServiceStorage::RequestId(1)) - .has_value()); - EXPECT_FALSE( - scheduler() - ->WasRequestSuccessful(AggregationServiceStorage::RequestId(1)) - .value()); + ASSERT_TRUE(scheduler()->WasRequestSuccessful(request_id).has_value()); + EXPECT_FALSE(scheduler()->WasRequestSuccessful(request_id).value()); } TEST_F(AggregationServiceImplTest, @@ -453,4 +524,70 @@ .value()); } +TEST_F(AggregationServiceImplTest, GetPendingReportRequestsForWebUI) { + StoreReport(aggregation_service::CreateExampleRequest()); + StoreReport(aggregation_service::CreateExampleRequest()); + + base::RunLoop run_loop; + service()->GetPendingReportRequestsForWebUI(base::BindLambdaForTesting( + [&](std::vector<AggregationServiceStorage::RequestAndId> + requests_and_ids) { + // IDs autoincrement from 1. + EXPECT_THAT( + requests_and_ids, + ElementsAre(RequestIdIs(AggregationServiceStorage::RequestId(1)), + RequestIdIs(AggregationServiceStorage::RequestId(2)))); + run_loop.Quit(); + })); + run_loop.Run(); +} + +TEST_F(AggregationServiceImplTest, SendReportsForWebUI) { + StoreReport(aggregation_service::CreateExampleRequest()); + + // IDs autoincrement from 1. + AggregationServiceStorage::RequestId request_id(1); + + MockAggregationServiceObserver observer; + base::ScopedObservation<AggregationService, AggregationServiceObserver> + observation(&observer); + observation.Observe(service()); + + EXPECT_CALL(observer, OnRequestStorageModified); + EXPECT_CALL(observer, OnReportHandled(RequestIdIs(request_id), _, _, + AggregationServiceObserver::kSent)); + + service()->SendReportsForWebUI({request_id}, base::DoNothing()); + + assembler()->WaitForRequests(/*num_requests=*/1); + + std::vector<AggregatableReport::AggregationServicePayload> payloads; + payloads.emplace_back(/*payload=*/kABCD1234AsBytes, + /*key_id=*/"key_1", + /*debug_cleartext_payload=*/absl::nullopt); + AggregatableReport report(std::move(payloads), "example_shared_info"); + + assembler()->TriggerResponse( + /*report_id=*/0, std::move(report), + AggregatableReportAssembler::AssemblyStatus::kOk); + + sender()->TriggerResponse(/*report_id=*/0, + AggregatableReportSender::RequestStatus::kOk); +} + +TEST_F(AggregationServiceImplTest, ClearData_NotifyObservers) { + MockAggregationServiceObserver observer; + base::ScopedObservation<AggregationService, AggregationServiceObserver> + observation(&observer); + observation.Observe(service()); + + EXPECT_CALL(observer, OnRequestStorageModified); + + base::RunLoop run_loop; + service()->ClearData(/*delete_begin=*/base::Time::Min(), + /*delete_end=*/base::Time::Max(), + /*filter=*/base::NullCallback(), run_loop.QuitClosure()); + run_loop.Run(); +} + } // namespace content
diff --git a/content/browser/aggregation_service/aggregation_service_observer.h b/content/browser/aggregation_service/aggregation_service_observer.h new file mode 100644 index 0000000..29335c44 --- /dev/null +++ b/content/browser/aggregation_service/aggregation_service_observer.h
@@ -0,0 +1,48 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_OBSERVER_H_ +#define CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_OBSERVER_H_ + +#include "base/observer_list_types.h" +#include "content/browser/aggregation_service/aggregation_service_storage.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace base { +class Time; +} // namespace base + +namespace content { + +class AggregatableReport; + +// Observes events in the Aggregation Service. Observers are registered on +// `AggregationService`. +class AggregationServiceObserver : public base::CheckedObserver { + public: + enum ReportStatus { + kPending, + kSent, + kFailedToAssemble, + kFailedToSend, + }; + + ~AggregationServiceObserver() override = default; + + // Called when requests in storage change. + virtual void OnRequestStorageModified() {} + + // Called when a report has been handled, i.e. attempted to be assembled and + // sent, regardless of success. `report_handled_time` indicates when the + // report has been handled. + virtual void OnReportHandled( + const AggregationServiceStorage::RequestAndId& request_and_id, + const absl::optional<AggregatableReport>& report, + base::Time report_handled_time, + ReportStatus status) {} +}; + +} // namespace content + +#endif // CONTENT_BROWSER_AGGREGATION_SERVICE_AGGREGATION_SERVICE_OBSERVER_H_
diff --git a/content/browser/aggregation_service/aggregation_service_storage.h b/content/browser/aggregation_service/aggregation_service_storage.h index 1bd1066..f91c569c 100644 --- a/content/browser/aggregation_service/aggregation_service_storage.h +++ b/content/browser/aggregation_service/aggregation_service_storage.h
@@ -71,12 +71,17 @@ base::Time strictly_after_time) = 0; // Returns requests with report times on or before `not_after_time`. The - // returned reports are ordered by report time. + // returned requests are ordered by report time. // TODO(crbug.com/1340046): Limit the number of in-progress reports kept in // memory at the same time. virtual std::vector<RequestAndId> GetRequestsReportingOnOrBefore( base::Time not_after_time) = 0; + // Returns the requests with the given IDs. Empty vector is returned if `ids` + // is empty. + virtual std::vector<RequestAndId> GetRequests( + const std::vector<RequestId>& ids) = 0; + // Adjusts the report time of all reports with report times strictly before // `now`. Each new report time is `now` + a random delay. The random delay for // each report is picked independently from a uniform distribution between
diff --git a/content/browser/aggregation_service/aggregation_service_storage_sql.cc b/content/browser/aggregation_service/aggregation_service_storage_sql.cc index 27ae1b6..7b2953c 100644 --- a/content/browser/aggregation_service/aggregation_service_storage_sql.cc +++ b/content/browser/aggregation_service/aggregation_service_storage_sql.cc
@@ -527,6 +527,38 @@ return result; } +std::vector<AggregationServiceStorage::RequestAndId> +AggregationServiceStorageSql::GetRequests( + const std::vector<AggregationServiceStorage::RequestId>& ids) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + if (!EnsureDatabaseOpen(DbCreationPolicy::kFailIfAbsent)) + return {}; + + static constexpr char kGetRequestSql[] = + "SELECT request_id,request_proto FROM report_requests " + "WHERE request_id=?"; + sql::Statement statement( + db_.GetCachedStatement(SQL_FROM_HERE, kGetRequestSql)); + + std::vector<AggregationServiceStorage::RequestAndId> result; + for (AggregationServiceStorage::RequestId id : ids) { + statement.Reset(/*clear_bound_vars=*/true); + statement.BindInt64(0, *id); + if (!statement.Step()) + continue; + absl::optional<AggregatableReportRequest> parsed_request = + AggregatableReportRequest::Deserialize(statement.ColumnBlob(1)); + if (!parsed_request) + continue; + result.push_back(AggregationServiceStorage::RequestAndId{ + .request = std::move(*parsed_request), + .id = id, + }); + } + return result; +} + absl::optional<base::Time> AggregationServiceStorageSql::AdjustOfflineReportTimes( base::Time now,
diff --git a/content/browser/aggregation_service/aggregation_service_storage_sql.h b/content/browser/aggregation_service/aggregation_service_storage_sql.h index 9d2b8e4..0ff7e0e 100644 --- a/content/browser/aggregation_service/aggregation_service_storage_sql.h +++ b/content/browser/aggregation_service/aggregation_service_storage_sql.h
@@ -65,6 +65,8 @@ base::Time strictly_after_time) override; std::vector<AggregationServiceStorage::RequestAndId> GetRequestsReportingOnOrBefore(base::Time not_after_time) override; + std::vector<AggregationServiceStorage::RequestAndId> GetRequests( + const std::vector<AggregationServiceStorage::RequestId>& ids) override; absl::optional<base::Time> AdjustOfflineReportTimes( base::Time now, base::TimeDelta min_delay,
diff --git a/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc b/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc index 0b6559bfb..69eb43b 100644 --- a/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc +++ b/content/browser/aggregation_service/aggregation_service_storage_sql_unittest.cc
@@ -24,6 +24,7 @@ #include "sql/database.h" #include "sql/meta_table.h" #include "sql/test/test_helpers.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/storage_key/storage_key.h" @@ -33,6 +34,11 @@ namespace { +using aggregation_service::RequestIdIs; +using testing::ElementsAre; + +using RequestId = AggregationServiceStorage::RequestId; + const char kExampleUrl[] = "https://helper.test/.well-known/aggregation-service/keys.json"; @@ -457,8 +463,7 @@ ASSERT_EQ(stored_requests_and_ids.size(), 1u); // IDs autoincrement from 1. - EXPECT_EQ(stored_requests_and_ids[0].id, - AggregationServiceStorage::RequestId(1)); + EXPECT_EQ(stored_requests_and_ids[0].id, RequestId(1)); EXPECT_TRUE(aggregation_service::ReportRequestsEqual( stored_requests_and_ids[0].request, request)); } @@ -474,7 +479,7 @@ 1u); // IDs autoincrement from 1. - storage_->DeleteRequest(AggregationServiceStorage::RequestId(1)); + storage_->DeleteRequest(RequestId(1)); EXPECT_TRUE( storage_->GetRequestsReportingOnOrBefore(base::Time::Max()).empty()); } @@ -555,6 +560,22 @@ } } +TEST_F(AggregationServiceStorageSqlTest, GetRequests_ReturnValuesAlignWithIds) { + OpenDatabase(); + + AggregatableReportRequest request = + aggregation_service::CreateExampleRequest(); + + storage_->StoreRequest(aggregation_service::CloneReportRequest(request)); + storage_->StoreRequest(aggregation_service::CloneReportRequest(request)); + storage_->StoreRequest(std::move(request)); + + // IDs autoincrement from 1. + EXPECT_THAT( + storage_->GetRequests({RequestId(1), RequestId(3), RequestId(4)}), + ElementsAre(RequestIdIs(RequestId(1)), RequestIdIs(RequestId(3)))); +} + TEST_F(AggregationServiceStorageSqlTest, NextReportTimeAfter_ReturnValuesAlignWithReportTime) { OpenDatabase(); @@ -627,12 +648,10 @@ storage_->GetRequestsReportingOnOrBefore(kExampleTime); ASSERT_EQ(example_time_reports.size(), 2u); - EXPECT_EQ(base::flat_set<AggregationServiceStorage::RequestId>( + EXPECT_EQ(base::flat_set<RequestId>( {example_time_reports[0].id, example_time_reports[1].id}), // Request IDs autoincrement from 1. - base::flat_set<AggregationServiceStorage::RequestId>( - {AggregationServiceStorage::RequestId(1), - AggregationServiceStorage::RequestId(2)})); + base::flat_set<RequestId>({RequestId(1), RequestId(2)})); ASSERT_TRUE(storage_->NextReportTimeAfter(kExampleTime).has_value()); EXPECT_EQ(storage_->NextReportTimeAfter(kExampleTime).value(), @@ -647,7 +666,7 @@ std::vector<AggregationServiceStorage::RequestAndId> all_reports = storage_->GetRequestsReportingOnOrBefore(kExampleTime + base::Hours(1)); ASSERT_EQ(all_reports.size(), 3u); - EXPECT_EQ(all_reports[2].id, AggregationServiceStorage::RequestId(3)); + EXPECT_EQ(all_reports[2].id, RequestId(3)); EXPECT_FALSE( storage_->NextReportTimeAfter(kExampleTime + base::Hours(1)).has_value()); @@ -698,7 +717,7 @@ ASSERT_EQ(stored_reports.size(), 1u); // Only the last request should be left. Request IDs start from 1. - EXPECT_EQ(stored_reports[0].id, AggregationServiceStorage::RequestId(3)); + EXPECT_EQ(stored_reports[0].id, RequestId(3)); } TEST_F(AggregationServiceStorageSqlTest, @@ -737,7 +756,7 @@ ASSERT_EQ(stored_reports.size(), 1u); // Only the last request should be left. Request IDs start from 1. - EXPECT_EQ(stored_reports[0].id, AggregationServiceStorage::RequestId(3)); + EXPECT_EQ(stored_reports[0].id, RequestId(3)); } TEST_F(AggregationServiceStorageSqlTest,
diff --git a/content/browser/aggregation_service/aggregation_service_test_utils.cc b/content/browser/aggregation_service/aggregation_service_test_utils.cc index bf66dab..5c84566 100644 --- a/content/browser/aggregation_service/aggregation_service_test_utils.cc +++ b/content/browser/aggregation_service/aggregation_service_test_utils.cc
@@ -378,6 +378,30 @@ MockAggregationService::~MockAggregationService() = default; +void MockAggregationService::AddObserver(AggregationServiceObserver* observer) { + observers_.AddObserver(observer); +} + +void MockAggregationService::RemoveObserver( + AggregationServiceObserver* observer) { + observers_.RemoveObserver(observer); +} + +void MockAggregationService::NotifyRequestStorageModified() { + for (auto& observer : observers_) { + observer.OnRequestStorageModified(); + } +} + +void MockAggregationService::NotifyReportHandled( + AggregationServiceStorage::RequestAndId request, + absl::optional<AggregatableReport> report, + base::Time report_handled_time, + AggregationServiceObserver::ReportStatus status) { + for (auto& observer : observers_) + observer.OnReportHandled(request, report, report_handled_time, status); +} + std::ostream& operator<<( std::ostream& out, AggregationServicePayloadContents::Operation operation) {
diff --git a/content/browser/aggregation_service/aggregation_service_test_utils.h b/content/browser/aggregation_service/aggregation_service_test_utils.h index 2639795..a1af63b 100644 --- a/content/browser/aggregation_service/aggregation_service_test_utils.h +++ b/content/browser/aggregation_service/aggregation_service_test_utils.h
@@ -12,9 +12,12 @@ #include <vector> #include "base/containers/span.h" +#include "base/observer_list.h" #include "base/threading/sequence_bound.h" #include "content/browser/aggregation_service/aggregatable_report.h" #include "content/browser/aggregation_service/aggregation_service.h" +#include "content/browser/aggregation_service/aggregation_service_observer.h" +#include "content/browser/aggregation_service/aggregation_service_storage.h" #include "content/browser/aggregation_service/aggregation_service_storage_context.h" #include "content/browser/aggregation_service/public_key.h" #include "content/common/aggregatable_report.mojom.h" @@ -85,6 +88,10 @@ const EVP_HPKE_KEY& key, const std::string& expected_serialized_shared_info); +MATCHER_P(RequestIdIs, matcher, "") { + return ExplainMatchResult(matcher, arg.id, result_listener); +} + } // namespace aggregation_service // The strings "ABCD1234" and "EFGH5678", Base64-decoded to bytes. Note that @@ -148,6 +155,35 @@ ScheduleReport, (AggregatableReportRequest report_request), (override)); + + MOCK_METHOD( + void, + GetPendingReportRequestsForWebUI, + (base::OnceCallback< + void(std::vector<AggregationServiceStorage::RequestAndId>)> callback), + (override)); + + MOCK_METHOD(void, + SendReportsForWebUI, + (const std::vector<AggregationServiceStorage::RequestId>& ids, + base::OnceClosure reports_sent_callback), + (override)); + + void AddObserver(AggregationServiceObserver* observer) override; + + void RemoveObserver(AggregationServiceObserver* observer) override; + + void NotifyRequestStorageModified(); + + // `report_handled_time` indicates when the report has been handled. + void NotifyReportHandled(AggregationServiceStorage::RequestAndId request, + absl::optional<AggregatableReport> report, + base::Time report_handled_time, + AggregationServiceObserver::ReportStatus status); + + private: + base::ObserverList<AggregationServiceObserver, /*check_empty=*/true> + observers_; }; // Only used for logging in tests.
diff --git a/content/browser/android/content_feature_list.cc b/content/browser/android/content_feature_list.cc index 9a53afd..6ca78b65 100644 --- a/content/browser/android/content_feature_list.cc +++ b/content/browser/android/content_feature_list.cc
@@ -26,6 +26,7 @@ &features::kAutoDisableAccessibility, &features::kAccessibilityPageZoom, &features::kBackgroundMediaRendererHasModerateBinding, + &features::kBindingManagerUseNotPerceptibleBinding, &features::kComputeAXMode, &features::kFedCm, &features::kOnDemandAccessibilityEvents,
diff --git a/content/browser/android/gesture_listener_manager.cc b/content/browser/android/gesture_listener_manager.cc index 9631cd2..345b771 100644 --- a/content/browser/android/gesture_listener_manager.cc +++ b/content/browser/android/gesture_listener_manager.cc
@@ -12,6 +12,7 @@ #include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents_observer.h" #include "third_party/blink/public/common/input/web_input_event.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "ui/events/android/gesture_event_type.h" #include "ui/events/blink/did_overscroll_params.h" #include "ui/gfx/geometry/size_f.h" @@ -154,7 +155,8 @@ void GestureListenerManager::GestureEventAck( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { // This is called to fix crash happening while WebContents is being // destroyed. See https://crbug.com/803244#c20 if (web_contents_->IsBeingDestroyed()) @@ -175,8 +177,14 @@ env, j_obj, /*isDirectionUp*/ event.data.scroll_begin.delta_y_hint > 0); return; } + float x = -1.f, y = -1.f; + if (scroll_result_data && scroll_result_data->root_scroll_offset) { + x = scroll_result_data->root_scroll_offset->x(); + y = scroll_result_data->root_scroll_offset->y(); + } + Java_GestureListenerManagerImpl_onEventAck( - env, j_obj, static_cast<int>(event.GetType()), consumed); + env, j_obj, static_cast<int>(event.GetType()), consumed, x, y); } void GestureListenerManager::DidStopFlinging() {
diff --git a/content/browser/android/gesture_listener_manager.h b/content/browser/android/gesture_listener_manager.h index 2b4d45b..8a93a1b 100644 --- a/content/browser/android/gesture_listener_manager.h +++ b/content/browser/android/gesture_listener_manager.h
@@ -11,6 +11,7 @@ #include "content/browser/android/render_widget_host_connector.h" #include "content/common/content_export.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" namespace blink { class WebGestureEvent; @@ -55,7 +56,8 @@ bool has_listeners_attached() const { return has_listeners_attached_; } void SetHasListenersAttached(JNIEnv* env, jboolean enabled); void GestureEventAck(const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result); + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data); void DidStopFlinging(); bool FilterInputEvent(const blink::WebInputEvent& event); void DidOverscroll(const ui::DidOverscrollParams& params);
diff --git a/content/browser/attribution_reporting/attribution_aggregatable_report_golden_unittest.cc b/content/browser/attribution_reporting/attribution_aggregatable_report_golden_unittest.cc index 67870a3d..681aee5 100644 --- a/content/browser/attribution_reporting/attribution_aggregatable_report_golden_unittest.cc +++ b/content/browser/attribution_reporting/attribution_aggregatable_report_golden_unittest.cc
@@ -116,7 +116,8 @@ aggregation_service().AssembleReport( std::move(*request), base::BindLambdaForTesting( - [&](absl::optional<AggregatableReport> assembled_report, + [&](AggregatableReportRequest, + absl::optional<AggregatableReport> assembled_report, AggregationService::AssemblyStatus status) { EXPECT_EQ(status, AggregationService::AssemblyStatus::kOk); ASSERT_TRUE(assembled_report);
diff --git a/content/browser/attribution_reporting/attribution_manager_impl.cc b/content/browser/attribution_reporting/attribution_manager_impl.cc index b832a8d..c185be7a 100644 --- a/content/browser/attribution_reporting/attribution_manager_impl.cc +++ b/content/browser/attribution_reporting/attribution_manager_impl.cc
@@ -872,6 +872,7 @@ AttributionReport report, bool is_debug_report, ReportSentCallback callback, + AggregatableReportRequest, absl::optional<AggregatableReport> assembled_report, AggregationService::AssemblyStatus) { if (!assembled_report.has_value()) {
diff --git a/content/browser/attribution_reporting/attribution_manager_impl.h b/content/browser/attribution_reporting/attribution_manager_impl.h index d2f94a9..f06203f 100644 --- a/content/browser/attribution_reporting/attribution_manager_impl.h +++ b/content/browser/attribution_reporting/attribution_manager_impl.h
@@ -40,6 +40,7 @@ namespace content { class AggregatableReport; +class AggregatableReportRequest; class AttributionCookieChecker; class AttributionDataHostManager; class AttributionStorage; @@ -148,6 +149,7 @@ AttributionReport report, bool is_debug_report, ReportSentCallback callback, + AggregatableReportRequest, absl::optional<AggregatableReport> assembled_report, AggregationService::AssemblyStatus); void MarkReportCompleted(AttributionReport::Id report_id);
diff --git a/content/browser/attribution_reporting/attribution_manager_impl_unittest.cc b/content/browser/attribution_reporting/attribution_manager_impl_unittest.cc index 56cfc77c..36f10d4 100644 --- a/content/browser/attribution_reporting/attribution_manager_impl_unittest.cc +++ b/content/browser/attribution_reporting/attribution_manager_impl_unittest.cc
@@ -1163,7 +1163,8 @@ .Times(3) .WillRepeatedly([](AggregatableReportRequest request, AggregationService::AssemblyCallback callback) { - std::move(callback).Run(CreateExampleAggregatableReport(), + std::move(callback).Run(std::move(request), + CreateExampleAggregatableReport(), AggregationService::AssemblyStatus::kOk); }); @@ -1696,7 +1697,8 @@ EXPECT_CALL(*aggregation_service_, AssembleReport) .WillOnce([](AggregatableReportRequest request, AggregationService::AssemblyCallback callback) { - std::move(callback).Run(CreateExampleAggregatableReport(), + std::move(callback).Run(std::move(request), + CreateExampleAggregatableReport(), AggregationService::AssemblyStatus::kOk); }); } else { @@ -1790,7 +1792,8 @@ EXPECT_CALL(*aggregation_service_, AssembleReport) .WillOnce([](AggregatableReportRequest request, AggregationService::AssemblyCallback callback) { - std::move(callback).Run(CreateExampleAggregatableReport(), + std::move(callback).Run(std::move(request), + CreateExampleAggregatableReport(), AggregationService::AssemblyStatus::kOk); }); } @@ -1849,7 +1852,7 @@ .WillOnce([](AggregatableReportRequest request, AggregationService::AssemblyCallback callback) { std::move(callback).Run( - absl::nullopt, + std::move(request), absl::nullopt, AggregationService::AssemblyStatus::kAssemblyFailed); }); }
diff --git a/content/browser/child_process_launcher_helper_android.cc b/content/browser/child_process_launcher_helper_android.cc index 168723e4..ba1957b 100644 --- a/content/browser/child_process_launcher_helper_android.cc +++ b/content/browser/child_process_launcher_helper_android.cc
@@ -158,8 +158,7 @@ void ChildProcessLauncherHelper::AfterLaunchOnLauncherThread( const ChildProcessLauncherHelper::Process& process, - const base::LaunchOptions& options) { -} + const base::LaunchOptions& options) {} ChildProcessTerminationInfo ChildProcessLauncherHelper::GetTerminationInfo( const ChildProcessLauncherHelper::Process& process, @@ -178,7 +177,7 @@ app_state == base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES; if (app_foreground && - (info.binding_state == base::android::ChildBindingState::MODERATE || + (info.binding_state == base::android::ChildBindingState::VISIBLE || info.binding_state == base::android::ChildBindingState::STRONG)) { info.status = base::TERMINATION_STATUS_OOM_PROTECTED; } else { @@ -262,9 +261,7 @@ // Called from ChildProcessLauncher.java when the ChildProcess was started. // |handle| is the processID of the child process as originated in Java, 0 if // the ChildProcess could not be created. -void ChildProcessLauncherHelper::OnChildProcessStarted( - JNIEnv*, - jint handle) { +void ChildProcessLauncherHelper::OnChildProcessStarted(JNIEnv*, jint handle) { DCHECK(CurrentlyOnProcessLauncherTaskRunner()); scoped_refptr<ChildProcessLauncherHelper> ref(this); Release(); // Balances with LaunchProcessOnLauncherThread.
diff --git a/content/browser/gpu/gpu_data_manager_impl.cc b/content/browser/gpu/gpu_data_manager_impl.cc index b48b1c0d..54cc8dc 100644 --- a/content/browser/gpu/gpu_data_manager_impl.cc +++ b/content/browser/gpu/gpu_data_manager_impl.cc
@@ -331,7 +331,7 @@ private_->ProcessCrashed(); } -std::unique_ptr<base::ListValue> GpuDataManagerImpl::GetLogMessages() const { +base::Value::List GpuDataManagerImpl::GetLogMessages() const { base::AutoLock auto_lock(lock_); return private_->GetLogMessages(); }
diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h index 07942db..1fc56c0 100644 --- a/content/browser/gpu/gpu_data_manager_impl.h +++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -170,8 +170,8 @@ void ProcessCrashed(); - // Returns a new copy of the ListValue. - std::unique_ptr<base::ListValue> GetLogMessages() const; + // Returns a base::Value::List with the log messages. + base::Value::List GetLogMessages() const; // Called when switching GPUs. void HandleGpuSwitch();
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc index d9e9ec5..36bdf11 100644 --- a/content/browser/gpu/gpu_data_manager_impl_private.cc +++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -1440,15 +1440,14 @@ &GpuDataManagerObserver::OnGpuProcessCrashed); } -std::unique_ptr<base::ListValue> GpuDataManagerImplPrivate::GetLogMessages() - const { - auto value = std::make_unique<base::ListValue>(); +base::Value::List GpuDataManagerImplPrivate::GetLogMessages() const { + base::Value::List value; for (const auto& log_message : log_messages_) { base::Value::Dict dict; dict.Set("level", log_message.level); dict.Set("header", log_message.header); dict.Set("message", log_message.message); - value->GetList().Append(std::move(dict)); + value.Append(std::move(dict)); } return value; }
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.h b/content/browser/gpu/gpu_data_manager_impl_private.h index ce23add2..af6dd8d8 100644 --- a/content/browser/gpu/gpu_data_manager_impl_private.h +++ b/content/browser/gpu/gpu_data_manager_impl_private.h
@@ -121,7 +121,7 @@ void ProcessCrashed(); - std::unique_ptr<base::ListValue> GetLogMessages() const; + base::Value::List GetLogMessages() const; void HandleGpuSwitch();
diff --git a/content/browser/gpu/gpu_internals_ui.cc b/content/browser/gpu/gpu_internals_ui.cc index d1f76a50..1db580a 100644 --- a/content/browser/gpu/gpu_internals_ui.cc +++ b/content/browser/gpu/gpu_internals_ui.cc
@@ -720,10 +720,8 @@ void OnCallAsync(const base::Value::List& list); // Submessages dispatched from OnCallAsync - std::unique_ptr<base::Value> OnRequestClientInfo( - std::vector<base::Value> list); - std::unique_ptr<base::ListValue> OnRequestLogMessages( - std::vector<base::Value> list); + base::Value::Dict OnRequestClientInfo(); + base::Value::List OnRequestLogMessages(); private: // True if observing the GpuDataManager (re-attaching as observer would @@ -760,38 +758,27 @@ } void GpuMessageHandler::OnCallAsync(const base::Value::List& args_list) { - DCHECK_GE(args_list.size(), static_cast<size_t>(2)); + DCHECK_GE(args_list.size(), 2u); + DCHECK(args_list[1].is_string()) << "submessage isn't string"; + // unpack args into requestId, submessage and submessageArgs const base::Value& requestId = args_list[0]; std::string submessage; - if (args_list[1].is_string()) - submessage = args_list[1].GetString(); - else - DCHECK(false) << "submessage isn't string"; - - std::vector<base::Value> submessageArgs; - for (size_t i = 2; i < args_list.size(); ++i) { - submessageArgs.push_back(args_list[i].Clone()); - } + submessage = args_list[1].GetString(); // call the submessage handler - std::unique_ptr<base::Value> ret; if (submessage == "requestClientInfo") { - ret = OnRequestClientInfo(std::move(submessageArgs)); + web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onCallAsyncReply", + requestId, OnRequestClientInfo()); } else if (submessage == "requestLogMessages") { - ret = OnRequestLogMessages(std::move(submessageArgs)); + web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onCallAsyncReply", + requestId, OnRequestLogMessages()); } else { // unrecognized submessage NOTREACHED(); - return; - } - // call BrowserBridge.onCallAsyncReply with result - if (ret) { - web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onCallAsyncReply", - requestId, *ret); - } else { web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onCallAsyncReply", requestId); + return; } } @@ -818,8 +805,7 @@ OnGpuInfoUpdate(); } -std::unique_ptr<base::Value> GpuMessageHandler::OnRequestClientInfo( - std::vector<base::Value> args) { +base::Value::Dict GpuMessageHandler::OnRequestClientInfo() { DCHECK_CURRENTLY_ON(BrowserThread::UI); base::Value::Dict dict; @@ -839,11 +825,10 @@ std::string("Skia/" STRINGIZE(SK_MILESTONE) " " SKIA_COMMIT_HASH)); dict.Set("revision_identifier", GPU_LISTS_VERSION); - return std::make_unique<base::Value>(std::move(dict)); + return dict; } -std::unique_ptr<base::ListValue> GpuMessageHandler::OnRequestLogMessages( - std::vector<base::Value> args) { +base::Value::List GpuMessageHandler::OnRequestLogMessages() { DCHECK_CURRENTLY_ON(BrowserThread::UI); return GpuDataManagerImpl::GetInstance()->GetLogMessages();
diff --git a/content/browser/interest_group/ad_auction_service_impl_unittest.cc b/content/browser/interest_group/ad_auction_service_impl_unittest.cc index 347a6eb..036e78dc 100644 --- a/content/browser/interest_group/ad_auction_service_impl_unittest.cc +++ b/content/browser/interest_group/ad_auction_service_impl_unittest.cc
@@ -34,6 +34,7 @@ #include "content/browser/private_aggregation/private_aggregation_test_utils.h" #include "content/browser/renderer_host/render_frame_host_impl.h" #include "content/browser/storage_partition_impl.h" +#include "content/common/private_aggregation_features.h" #include "content/public/browser/browser_context.h" #include "content/public/common/content_client.h" #include "content/public/common/content_features.h" @@ -4971,82 +4972,6 @@ EXPECT_EQ(99, GetPriority(kOriginA, kInterestGroupName)); } -TEST_F(AdAuctionServiceImplTest, PrivateAggregationReportForwarded) { - constexpr char kBiddingScript[] = R"( -function generateBid( - interestGroup, auctionSignals, perBuyerSignals, trustedBiddingSignals, - browserSignals) { - privateAggregation.sendHistogramReport({bucket: 1, value: 2}); - return {'ad': 'example', 'bid': 1, 'render': 'https://example.com/render'}; -} -)"; - - constexpr char kDecisionScript[] = R"( -function scoreAd( - adMetadata, bid, auctionConfig, trustedScoringSignals, browserSignals) { - return bid; -} -)"; - - class TestPrivateAggregationManagerImpl - : public PrivateAggregationManagerImpl { - public: - TestPrivateAggregationManagerImpl( - std::unique_ptr<PrivateAggregationBudgeter> budgeter, - std::unique_ptr<PrivateAggregationHost> host) - : PrivateAggregationManagerImpl(std::move(budgeter), - std::move(host), - /*storage_partition=*/nullptr) {} - }; - - base::MockRepeatingCallback<void(AggregatableReportRequest, - PrivateAggregationBudgetKey)> - mock_callback; - - static_cast<StoragePartitionImpl*>( - browser_context()->GetDefaultStoragePartition()) - ->OverridePrivateAggregationManagerForTesting( - std::make_unique<TestPrivateAggregationManagerImpl>( - std::make_unique<MockPrivateAggregationBudgeter>(), - std::make_unique<PrivateAggregationHost>( - /*on_report_request_received=*/mock_callback.Get()))); - - network_responder_->RegisterScriptResponse(kBiddingUrlPath, kBiddingScript); - network_responder_->RegisterScriptResponse(kDecisionUrlPath, kDecisionScript); - - blink::InterestGroup interest_group = CreateInterestGroup(); - interest_group.bidding_url = kUrlA.Resolve(kBiddingUrlPath); - interest_group.priority = 2; - interest_group.ads.emplace(); - blink::InterestGroup::Ad ad( - /*render_url=*/GURL("https://example.com/render"), - /*metadata=*/absl::nullopt); - interest_group.ads->emplace_back(std::move(ad)); - JoinInterestGroupAndFlush(interest_group); - - blink::AuctionConfig auction_config; - auction_config.seller = kOriginA; - auction_config.decision_logic_url = kUrlA.Resolve(kDecisionUrlPath); - auction_config.non_shared_params.interest_group_buyers = {kOriginA}; - - EXPECT_CALL(mock_callback, Run) - .WillRepeatedly( - testing::Invoke([this](AggregatableReportRequest request, - PrivateAggregationBudgetKey budget_key) { - ASSERT_EQ(request.payload_contents().contributions.size(), 1u); - EXPECT_EQ(request.payload_contents().contributions[0].bucket, 1); - EXPECT_EQ(request.payload_contents().contributions[0].value, 2); - EXPECT_EQ(request.shared_info().reporting_origin, kOriginA); - EXPECT_EQ(budget_key.api(), - PrivateAggregationBudgetKey::Api::kFledge); - EXPECT_EQ(budget_key.origin(), kOriginA); - })); - - absl::optional<GURL> auction_result = - RunAdAuctionAndFlush(std::move(auction_config)); - ASSERT_NE(auction_result, absl::nullopt); -} - class AdAuctionServiceImplNumAuctionLimitTest : public AdAuctionServiceImplTest { public: @@ -5520,4 +5445,146 @@ EXPECT_TRUE(network_responder_->ReportSent("/seller_debug_win_2")); } +class AdAuctionServiceImplPrivateAggregationEnabledTest + : public AdAuctionServiceImplTest { + public: + AdAuctionServiceImplPrivateAggregationEnabledTest() { + feature_list_.InitAndEnableFeature(content::kPrivateAggregationApi); + } + + protected: + base::test::ScopedFeatureList feature_list_; +}; + +TEST_F(AdAuctionServiceImplPrivateAggregationEnabledTest, + PrivateAggregationReportForwarded) { + constexpr char kBiddingScript[] = R"( +function generateBid( + interestGroup, auctionSignals, perBuyerSignals, trustedBiddingSignals, + browserSignals) { + privateAggregation.sendHistogramReport({bucket: 1, value: 2}); + return {'ad': 'example', 'bid': 1, 'render': 'https://example.com/render'}; +} +)"; + + constexpr char kDecisionScript[] = R"( +function scoreAd( + adMetadata, bid, auctionConfig, trustedScoringSignals, browserSignals) { + return bid; +} +)"; + + class TestPrivateAggregationManagerImpl + : public PrivateAggregationManagerImpl { + public: + TestPrivateAggregationManagerImpl( + std::unique_ptr<PrivateAggregationBudgeter> budgeter, + std::unique_ptr<PrivateAggregationHost> host) + : PrivateAggregationManagerImpl(std::move(budgeter), + std::move(host), + /*storage_partition=*/nullptr) {} + }; + + base::MockRepeatingCallback<void(AggregatableReportRequest, + PrivateAggregationBudgetKey)> + mock_callback; + + static_cast<StoragePartitionImpl*>( + browser_context()->GetDefaultStoragePartition()) + ->OverridePrivateAggregationManagerForTesting( + std::make_unique<TestPrivateAggregationManagerImpl>( + std::make_unique<MockPrivateAggregationBudgeter>(), + std::make_unique<PrivateAggregationHost>( + /*on_report_request_received=*/mock_callback.Get()))); + + network_responder_->RegisterScriptResponse(kBiddingUrlPath, kBiddingScript); + network_responder_->RegisterScriptResponse(kDecisionUrlPath, kDecisionScript); + + blink::InterestGroup interest_group = CreateInterestGroup(); + interest_group.bidding_url = kUrlA.Resolve(kBiddingUrlPath); + interest_group.priority = 2; + interest_group.ads.emplace(); + blink::InterestGroup::Ad ad( + /*render_url=*/GURL("https://example.com/render"), + /*metadata=*/absl::nullopt); + interest_group.ads->emplace_back(std::move(ad)); + JoinInterestGroupAndFlush(interest_group); + + blink::AuctionConfig auction_config; + auction_config.seller = kOriginA; + auction_config.decision_logic_url = kUrlA.Resolve(kDecisionUrlPath); + auction_config.non_shared_params.interest_group_buyers = {kOriginA}; + + EXPECT_CALL(mock_callback, Run) + .WillRepeatedly( + testing::Invoke([this](AggregatableReportRequest request, + PrivateAggregationBudgetKey budget_key) { + ASSERT_EQ(request.payload_contents().contributions.size(), 1u); + EXPECT_EQ(request.payload_contents().contributions[0].bucket, 1); + EXPECT_EQ(request.payload_contents().contributions[0].value, 2); + EXPECT_EQ(request.shared_info().reporting_origin, kOriginA); + EXPECT_EQ(budget_key.api(), + PrivateAggregationBudgetKey::Api::kFledge); + EXPECT_EQ(budget_key.origin(), kOriginA); + })); + + absl::optional<GURL> auction_result = + RunAdAuctionAndFlush(std::move(auction_config)); + EXPECT_NE(auction_result, absl::nullopt); +} + +class AdAuctionServiceImplPrivateAggregationDisabledTest + : public AdAuctionServiceImplTest { + public: + AdAuctionServiceImplPrivateAggregationDisabledTest() { + feature_list_.InitAndDisableFeature(content::kPrivateAggregationApi); + } + + protected: + base::test::ScopedFeatureList feature_list_; +}; + +TEST_F(AdAuctionServiceImplPrivateAggregationDisabledTest, + PrivateAggregationNotExposed) { + constexpr char kBiddingScript[] = R"( +function generateBid( + interestGroup, auctionSignals, perBuyerSignals, trustedBiddingSignals, + browserSignals) { + privateAggregation.sendHistogramReport({bucket: 1, value: 2}); + return {'ad': 'example', 'bid': 1, 'render': 'https://example.com/render'}; +} +)"; + + constexpr char kDecisionScript[] = R"( +function scoreAd( + adMetadata, bid, auctionConfig, trustedScoringSignals, browserSignals) { + return bid; +} +)"; + + network_responder_->RegisterScriptResponse(kBiddingUrlPath, kBiddingScript); + network_responder_->RegisterScriptResponse(kDecisionUrlPath, kDecisionScript); + + blink::InterestGroup interest_group = CreateInterestGroup(); + interest_group.bidding_url = kUrlA.Resolve(kBiddingUrlPath); + interest_group.priority = 2; + interest_group.ads.emplace(); + blink::InterestGroup::Ad ad( + /*render_url=*/GURL("https://example.com/render"), + /*metadata=*/absl::nullopt); + interest_group.ads->emplace_back(std::move(ad)); + JoinInterestGroupAndFlush(interest_group); + + blink::AuctionConfig auction_config; + auction_config.seller = kOriginA; + auction_config.decision_logic_url = kUrlA.Resolve(kDecisionUrlPath); + auction_config.non_shared_params.interest_group_buyers = {kOriginA}; + + absl::optional<GURL> auction_result = + RunAdAuctionAndFlush(std::move(auction_config)); + + // privateAggregation should cause a ReferenceError. + EXPECT_EQ(auction_result, absl::nullopt); +} + } // namespace content
diff --git a/content/browser/interest_group/auction_runner_unittest.cc b/content/browser/interest_group/auction_runner_unittest.cc index 30427084..d40e72be 100644 --- a/content/browser/interest_group/auction_runner_unittest.cc +++ b/content/browser/interest_group/auction_runner_unittest.cc
@@ -35,6 +35,7 @@ #include "content/browser/interest_group/interest_group_manager_impl.h" #include "content/browser/interest_group/interest_group_storage.h" #include "content/common/aggregatable_report.mojom-shared.h" +#include "content/common/private_aggregation_features.h" #include "content/public/browser/site_instance.h" #include "content/public/test/test_renderer_host.h" #include "content/services/auction_worklet/auction_v8_helper.h" @@ -1495,11 +1496,13 @@ std::vector<auction_worklet::mojom::PreviousWinPtr> bidder2_prev_wins; }; - AuctionRunnerTest() + explicit AuctionRunnerTest(bool should_enable_private_aggregation = true) : task_environment_(base::test::TaskEnvironment::TimeSource::MOCK_TIME) { mojo::SetDefaultProcessErrorHandler(base::BindRepeating( &AuctionRunnerTest::OnBadMessage, base::Unretained(this))); DebuggableAuctionWorkletTracker::GetInstance()->AddObserver(this); + scoped_feature_list_.InitWithFeatureState( + content::kPrivateAggregationApi, should_enable_private_aggregation); } ~AuctionRunnerTest() override { @@ -2060,6 +2063,8 @@ std::set<url::Origin> disallowed_sellers_; std::set<url::Origin> disallowed_buyers_; + base::test::ScopedFeatureList scoped_feature_list_; + base::test::TaskEnvironment task_environment_; // RunLoop that's quit on auction completion. @@ -9100,5 +9105,45 @@ GURL("https://seller0.test/win/11"))); } +// Enable and test forDebuggingOnly.reportAdAuctionLoss() and +// forDebuggingOnly.reportAdAuctionWin() APIs. +class AuctionRunnerPrivateAggregationAPIDisabledTest + : public AuctionRunnerTest { + public: + AuctionRunnerPrivateAggregationAPIDisabledTest() + : AuctionRunnerTest(/*should_enable_private_aggregation=*/false) {} +}; + +TEST_F(AuctionRunnerPrivateAggregationAPIDisabledTest, ReportsNotSent) { + auction_worklet::AddJavascriptResponse( + &url_loader_factory_, kBidder1Url, + MakeBidScript(kSeller, "1", "https://ad1.com/", /*num_ad_components=*/2, + kBidder1, kBidder1Name, + /*has_signals=*/true, "k1", "a", + /*report_post_auction_signals=*/true)); + auction_worklet::AddJavascriptResponse( + &url_loader_factory_, kBidder2Url, + MakeBidScript(kSeller, "2", "https://ad2.com/", /*num_ad_components=*/2, + kBidder2, kBidder2Name, + /*has_signals=*/true, "l2", "b", + /*report_post_auction_signals=*/true)); + auction_worklet::AddJavascriptResponse( + &url_loader_factory_, kSellerUrl, + MakeAuctionScript(/*report_post_auction_signals=*/true)); + auction_worklet::AddBidderJsonResponse( + &url_loader_factory_, + GURL(kBidder1TrustedSignalsUrl.spec() + + "?hostname=publisher1.com&keys=k1,k2"), + kBidder1SignalsJson); + auction_worklet::AddBidderJsonResponse( + &url_loader_factory_, + GURL(kBidder2TrustedSignalsUrl.spec() + + "?hostname=publisher1.com&keys=l1,l2"), + kBidder2SignalsJson); + + const Result& res = RunStandardAuction(); + EXPECT_TRUE(res.private_aggregation_requests.empty()); +} + } // namespace } // namespace content
diff --git a/content/browser/payments/payment_app_database.cc b/content/browser/payments/payment_app_database.cc index 4886f70..5b42a09 100644 --- a/content/browser/payments/payment_app_database.cc +++ b/content/browser/payments/payment_app_database.cc
@@ -17,7 +17,6 @@ #include "content/browser/service_worker/service_worker_context_wrapper.h" #include "content/browser/service_worker/service_worker_registration.h" #include "content/public/browser/browser_thread.h" -#include "content/public/common/content_features.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/manifest/manifest.h" #include "third_party/blink/public/common/storage_key/storage_key.h" @@ -84,10 +83,6 @@ instrument->icons.emplace_back(icon); } instrument->method = instrument_proto.method(); - if (base::FeatureList::IsEnabled(::features::kPaymentRequestBasicCard)) { - instrument->stringified_capabilities = - instrument_proto.stringified_capabilities(); - } return instrument; } @@ -745,13 +740,6 @@ continue; apps[id]->enabled_methods.emplace_back(instrument_proto.method()); - if (base::FeatureList::IsEnabled(::features::kPaymentRequestBasicCard)) { - apps[id]->capabilities.emplace_back(StoredCapabilities()); - for (const auto& network : instrument_proto.supported_card_networks()) { - apps[id]->capabilities.back().supported_card_networks.emplace_back( - network); - } - } } std::move(callback).Run(std::move(apps)); @@ -939,14 +927,6 @@ size_proto->set_height(size.height()); } } - if (base::FeatureList::IsEnabled(::features::kPaymentRequestBasicCard)) { - instrument_proto.set_stringified_capabilities( - instrument->stringified_capabilities); - for (const auto& network : instrument->supported_networks) { - instrument_proto.add_supported_card_networks( - static_cast<int32_t>(network)); - } - } std::string serialized_instrument; bool success = instrument_proto.SerializeToString(&serialized_instrument);
diff --git a/content/browser/payments/payment_manager_unittest.cc b/content/browser/payments/payment_manager_unittest.cc index a539758..529180e 100644 --- a/content/browser/payments/payment_manager_unittest.cc +++ b/content/browser/payments/payment_manager_unittest.cc
@@ -7,9 +7,7 @@ #include "base/bind.h" #include "base/memory/raw_ptr.h" #include "base/run_loop.h" -#include "base/test/scoped_feature_list.h" #include "content/browser/payments/payment_app_content_unittest_base.h" -#include "content/public/common/content_features.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/mojom/payments/payment_app.mojom.h" #include "url/gurl.h" @@ -262,64 +260,7 @@ ASSERT_EQ(0U, keys.size()); } -class PaymentManagerBasicCardEnabledTest : public PaymentManagerTest { - public: - PaymentManagerBasicCardEnabledTest( - const PaymentManagerBasicCardEnabledTest&) = delete; - PaymentManagerBasicCardEnabledTest& operator=( - const PaymentManagerBasicCardEnabledTest&) = delete; - - protected: - PaymentManagerBasicCardEnabledTest() { - feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); - } - - private: - base::test::ScopedFeatureList feature_list_; -}; - -TEST_F(PaymentManagerBasicCardEnabledTest, SetAndGetPaymentInstrument) { - PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND; - PaymentInstrumentPtr write_details = PaymentInstrument::New(); - write_details->name = "Visa ending ****4756"; - write_details->method = "visa"; - write_details->stringified_capabilities = "{}"; - SetPaymentInstrument("test_key", std::move(write_details), &write_status); - // Write the first instrument of a web payment app will return - // FETCH_PAYMENT_APP_INFO_FAILED since the web app's manifest is not - // available, but the write of the instrument is succeed, otherwise will - // return the other errors. - ASSERT_EQ(PaymentHandlerStatus::FETCH_PAYMENT_APP_INFO_FAILED, write_status); - - PaymentHandlerStatus read_status = PaymentHandlerStatus::NOT_FOUND; - PaymentInstrumentPtr read_details; - GetPaymentInstrument("test_key", &read_details, &read_status); - ASSERT_EQ(PaymentHandlerStatus::SUCCESS, read_status); - EXPECT_EQ("Visa ending ****4756", read_details->name); - EXPECT_EQ("visa", read_details->method); - EXPECT_EQ("{}", read_details->stringified_capabilities); -} - -class PaymentManagerBasicCardDisabledTest : public PaymentManagerTest { - public: - PaymentManagerBasicCardDisabledTest( - const PaymentManagerBasicCardDisabledTest&) = delete; - PaymentManagerBasicCardDisabledTest& operator=( - const PaymentManagerBasicCardDisabledTest&) = delete; - - protected: - PaymentManagerBasicCardDisabledTest() { - feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); - } - - private: - base::test::ScopedFeatureList feature_list_; -}; - -// This test corresponds to the test of the same name in -// PaymentManagerBasicCardEnabledTest. The only difference between them is -// the expected value of read_details->stringified_capabilities. -TEST_F(PaymentManagerBasicCardDisabledTest, SetAndGetPaymentInstrument) { +TEST_F(PaymentManagerTest, SetAndGetPaymentInstrument) { PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND; PaymentInstrumentPtr write_details = PaymentInstrument::New(); write_details->name = "ChromePay: chrome@chromepay.com";
diff --git a/content/browser/private_aggregation/private_aggregation_features.h b/content/browser/private_aggregation/private_aggregation_features.h deleted file mode 100644 index 5c0b2d4..0000000 --- a/content/browser/private_aggregation/private_aggregation_features.h +++ /dev/null
@@ -1,19 +0,0 @@ -// Copyright 2022 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_PRIVATE_AGGREGATION_PRIVATE_AGGREGATION_FEATURES_H_ -#define CONTENT_BROWSER_PRIVATE_AGGREGATION_PRIVATE_AGGREGATION_FEATURES_H_ - -#include "base/feature_list.h" - -namespace content { - -// Enables the Private Aggregation API. Note that this API also requires the -// `kPrivacySandboxAggregationService` to be enabled to successfully send -// reports. -extern const base::Feature kPrivateAggregationApi; - -} // namespace content - -#endif // CONTENT_BROWSER_PRIVATE_AGGREGATION_PRIVATE_AGGREGATION_FEATURES_H_
diff --git a/content/browser/renderer_host/cookie_utils.cc b/content/browser/renderer_host/cookie_utils.cc index 2ce1736..ab0c50d 100644 --- a/content/browser/renderer_host/cookie_utils.cc +++ b/content/browser/renderer_host/cookie_utils.cc
@@ -24,14 +24,16 @@ DCHECK(rfh); ukm::SourceId source_id = rfh->GetPageUkmSourceId(); + auto downgrade_metric = + static_cast<int64_t>(status.GetBreakingDowngradeMetricsEnumValue(url)); if (access_type == CookieAccessDetails::Type::kRead) { ukm::builders::SchemefulSameSiteContextDowngrade(source_id) - .SetRequestPerCookie(status.GetBreakingDowngradeMetricsEnumValue(url)) + .SetRequestPerCookie(downgrade_metric) .Record(ukm::UkmRecorder::Get()); } else { DCHECK(access_type == CookieAccessDetails::Type::kChange); ukm::builders::SchemefulSameSiteContextDowngrade(source_id) - .SetResponsePerCookie(status.GetBreakingDowngradeMetricsEnumValue(url)) + .SetResponsePerCookie(downgrade_metric) .Record(ukm::UkmRecorder::Get()); } }
diff --git a/content/browser/renderer_host/cross_process_frame_connector.cc b/content/browser/renderer_host/cross_process_frame_connector.cc index 898f5cb4..b47f4ea 100644 --- a/content/browser/renderer_host/cross_process_frame_connector.cc +++ b/content/browser/renderer_host/cross_process_frame_connector.cc
@@ -23,6 +23,7 @@ #include "third_party/blink/public/common/frame/frame_visual_properties.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "ui/gfx/geometry/dip_util.h" namespace content { @@ -260,7 +261,8 @@ void CrossProcessFrameConnector::ForwardAckedTouchpadZoomEvent( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { auto* root_view = GetRootRenderWidgetHostView(); if (!root_view) return; @@ -269,7 +271,8 @@ const gfx::PointF root_point = view_->TransformPointToRootCoordSpaceF(event.PositionInWidget()); root_event.SetPositionInWidget(root_point); - root_view->GestureEventAck(root_event, ack_result); + root_view->GestureEventAck(root_event, ack_result, + std::move(scroll_result_data)); } bool CrossProcessFrameConnector::BubbleScrollEvent( @@ -507,12 +510,14 @@ void CrossProcessFrameConnector::DidAckGestureEvent( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { auto* root_view = GetRootRenderWidgetHostView(); if (!root_view) return; - root_view->ChildDidAckGestureEvent(event, ack_result); + root_view->ChildDidAckGestureEvent(event, ack_result, + std::move(scroll_result_data)); } void CrossProcessFrameConnector::SetVisibilityForChildViews(
diff --git a/content/browser/renderer_host/cross_process_frame_connector.h b/content/browser/renderer_host/cross_process_frame_connector.h index 646d0ad..db41a3d 100644 --- a/content/browser/renderer_host/cross_process_frame_connector.h +++ b/content/browser/renderer_host/cross_process_frame_connector.h
@@ -19,6 +19,7 @@ #include "third_party/blink/public/mojom/frame/lifecycle.mojom.h" #include "third_party/blink/public/mojom/frame/viewport_intersection_state.mojom.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "third_party/blink/public/mojom/input/pointer_lock_result.mojom-shared.h" #include "ui/display/screen_infos.h" #include "ui/gfx/geometry/rect.h" @@ -165,7 +166,8 @@ // for processing. void ForwardAckedTouchpadZoomEvent( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result); + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data); // A gesture scroll sequence that is not consumed by a child must be bubbled // to ancestors who may consume it. @@ -251,7 +253,8 @@ bool has_size() const { return has_size_; } void DidAckGestureEvent(const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result); + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data); // Called by RenderWidgetHostViewChildFrame to update the visibility of any // nested child RWHVCFs inside it.
diff --git a/content/browser/renderer_host/input/gesture_event_queue.cc b/content/browser/renderer_host/input/gesture_event_queue.cc index 1a8fdf4..de92d92 100644 --- a/content/browser/renderer_host/input/gesture_event_queue.cc +++ b/content/browser/renderer_host/input/gesture_event_queue.cc
@@ -8,6 +8,7 @@ #include "base/trace_event/trace_event.h" #include "content/browser/renderer_host/input/touchpad_tap_suppression_controller.h" #include "content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom.h" #include "ui/events/blink/blink_features.h" #include "ui/events/blink/web_input_event_traits.h" @@ -16,8 +17,8 @@ namespace content { -GestureEventQueue::GestureEventWithLatencyInfoAndAckState:: - GestureEventWithLatencyInfoAndAckState( +GestureEventQueue::GestureEventWithLatencyInfoAckStateAndScrollResultData:: + GestureEventWithLatencyInfoAckStateAndScrollResultData( const GestureEventWithLatencyInfo& event) : GestureEventWithLatencyInfo(event) {} @@ -157,7 +158,8 @@ blink::mojom::InputEventResultSource ack_source, blink::mojom::InputEventResultState ack_result, WebInputEvent::Type type, - const ui::LatencyInfo& latency) { + const ui::LatencyInfo& latency, + blink::mojom::ScrollResultDataPtr scroll_result_data) { TRACE_EVENT0("input", "GestureEventQueue::ProcessGestureAck"); if (sent_events_awaiting_ack_.empty()) { @@ -174,6 +176,7 @@ if (outstanding_event.event.GetType() == type) { outstanding_event.latency.AddNewLatencyFrom(latency); outstanding_event.set_ack_info(ack_source, ack_result); + outstanding_event.set_scroll_result_data(std::move(scroll_result_data)); break; } } @@ -191,17 +194,24 @@ auto iter = sent_events_awaiting_ack_.begin(); if (iter->ack_state() == blink::mojom::InputEventResultState::kUnknown) break; - GestureEventWithLatencyInfoAndAckState event = *iter; + GestureEventWithLatencyInfoAckStateAndScrollResultData event = *iter; sent_events_awaiting_ack_.erase(iter); - AckGestureEventToClient(event, event.ack_source(), event.ack_state()); + + auto scroll_result_data = blink::mojom::ScrollResultData::New( + event.scroll_result_data().root_scroll_offset); + + AckGestureEventToClient(event, event.ack_source(), event.ack_state(), + std::move(scroll_result_data)); } } void GestureEventQueue::AckGestureEventToClient( const GestureEventWithLatencyInfo& event_with_latency, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) { - client_->OnGestureEventAck(event_with_latency, ack_source, ack_result); + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { + client_->OnGestureEventAck(event_with_latency, ack_source, ack_result, + std::move(scroll_result_data)); } TouchpadTapSuppressionController*
diff --git a/content/browser/renderer_host/input/gesture_event_queue.h b/content/browser/renderer_host/input/gesture_event_queue.h index 4285b8c..3f7959d9 100644 --- a/content/browser/renderer_host/input/gesture_event_queue.h +++ b/content/browser/renderer_host/input/gesture_event_queue.h
@@ -14,8 +14,10 @@ #include "content/browser/renderer_host/event_with_latency_info.h" #include "content/browser/renderer_host/input/fling_controller.h" #include "content/common/content_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom.h" namespace content { class GestureEventQueueTest; @@ -33,7 +35,8 @@ virtual void OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) = 0; + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) = 0; }; // Despite its name, this class isn't so much one queue as it is a collection @@ -104,7 +107,8 @@ void ProcessGestureAck(blink::mojom::InputEventResultSource ack_source, blink::mojom::InputEventResultState ack_result, blink::WebInputEvent::Type type, - const ui::LatencyInfo& latency); + const ui::LatencyInfo& latency, + blink::mojom::ScrollResultDataPtr scroll_result_data); // Returns the |TouchpadTapSuppressionController| instance. TouchpadTapSuppressionController* GetTouchpadTapSuppressionController(); @@ -141,10 +145,12 @@ friend class GestureEventQueueTest; friend class MockRenderWidgetHost; - class GestureEventWithLatencyInfoAndAckState + class GestureEventWithLatencyInfoAckStateAndScrollResultData : public GestureEventWithLatencyInfo { public: - GestureEventWithLatencyInfoAndAckState(const GestureEventWithLatencyInfo&); + GestureEventWithLatencyInfoAckStateAndScrollResultData( + const GestureEventWithLatencyInfo&); + ~GestureEventWithLatencyInfoAckStateAndScrollResultData() = default; blink::mojom::InputEventResultState ack_state() const { return ack_state_; } void set_ack_info(blink::mojom::InputEventResultSource source, blink::mojom::InputEventResultState state) { @@ -154,12 +160,28 @@ blink::mojom::InputEventResultSource ack_source() const { return ack_source_; } + void set_scroll_result_data( + blink::mojom::ScrollResultDataPtr scroll_result_data) { + // Creating a new instance and setting the field(s) explicitly because + // having blink::mojom::ScrollResultDataPtr as a field makes this class + // move-only and causes issues pushing into and removing from + // sent_events_awaiting_ack_. + // TODO(sinansahin): This class can probably be refactored to work with + // being move-only. + scroll_result_data_ = blink::mojom::ScrollResultData( + scroll_result_data ? scroll_result_data->root_scroll_offset + : absl::nullopt); + } + const blink::mojom::ScrollResultData& scroll_result_data() { + return scroll_result_data_; + } private: blink::mojom::InputEventResultSource ack_source_ = blink::mojom::InputEventResultSource::kUnknown; blink::mojom::InputEventResultState ack_state_ = blink::mojom::InputEventResultState::kUnknown; + blink::mojom::ScrollResultData scroll_result_data_; }; // Inovked on the expiration of the debounce interval to release @@ -173,9 +195,11 @@ // ACK completed events in order until we have reached an incomplete event. // Will preserve the FIFO order as events originally arrived. void AckCompletedEvents(); - void AckGestureEventToClient(const GestureEventWithLatencyInfo&, - blink::mojom::InputEventResultSource, - blink::mojom::InputEventResultState); + void AckGestureEventToClient( + const GestureEventWithLatencyInfo&, + blink::mojom::InputEventResultSource, + blink::mojom::InputEventResultState, + blink::mojom::ScrollResultDataPtr scroll_result_data); bool FlingInProgressForTest() const; @@ -187,8 +211,8 @@ bool processing_acks_ = false; - using GestureQueueWithAckState = - base::circular_deque<GestureEventWithLatencyInfoAndAckState>; + using GestureQueueWithAckState = base::circular_deque< + GestureEventWithLatencyInfoAckStateAndScrollResultData>; // Stores outstanding events that have been sent to the renderer but not yet // been ACK'd. These are kept in the order they were sent in so that they can
diff --git a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc index 8ba2b0f7..c98a2a4 100644 --- a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc
@@ -23,7 +23,9 @@ #include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom.h" #include "ui/events/blink/blink_features.h" +#include "ui/gfx/geometry/point_f.h" using blink::WebGestureDevice; using blink::WebGestureEvent; @@ -75,16 +77,18 @@ if (sync_ack_result_) { std::unique_ptr<blink::mojom::InputEventResultState> ack_result = std::move(sync_ack_result_); - SendInputEventACK(event.event.GetType(), *ack_result); + SendInputEventACK(event.event.GetType(), *ack_result, nullptr); } } void OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) override { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override { ++acked_gesture_event_count_; last_acked_event_ = event.event; + last_acked_event_scroll_result_data_ = std::move(scroll_result_data); if (sync_followup_event_) { auto sync_followup_event = std::move(sync_followup_event_); SimulateGestureEvent(*sync_followup_event); @@ -161,10 +165,11 @@ } void SendInputEventACK(WebInputEvent::Type type, - blink::mojom::InputEventResultState ack) { + blink::mojom::InputEventResultState ack, + blink::mojom::ScrollResultDataPtr scroll_result_data) { queue()->ProcessGestureAck( blink::mojom::InputEventResultSource::kCompositorThread, ack, type, - ui::LatencyInfo()); + ui::LatencyInfo(), std::move(scroll_result_data)); } void RunUntilIdle() { task_environment_.RunUntilIdle(); } @@ -231,6 +236,10 @@ return queue_.get(); } + blink::mojom::ScrollResultDataPtr last_acked_event_scroll_result_data() { + return std::move(last_acked_event_scroll_result_data_); + } + private: base::test::SingleThreadTaskEnvironment task_environment_; std::unique_ptr<GestureEventQueue> queue_; @@ -240,6 +249,7 @@ std::unique_ptr<blink::mojom::InputEventResultState> sync_ack_result_; std::unique_ptr<WebGestureEvent> sync_followup_event_; base::test::ScopedFeatureList feature_list_; + blink::mojom::ScrollResultDataPtr last_acked_event_scroll_result_data_; }; class GestureEventQueueWithCompositorEventQueueTest @@ -269,7 +279,7 @@ EXPECT_EQ(1U, GetAndResetAckedGestureEventCount()); SendInputEventACK(WebInputEvent::Type::kGestureShowPress, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); EXPECT_EQ(0U, GestureEventQueueSize()); EXPECT_EQ(1U, GetAndResetAckedGestureEventCount()); @@ -518,14 +528,14 @@ // Simulate GSB ACK. SendInputEventACK(WebInputEvent::Type::kGestureScrollBegin, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); EXPECT_EQ(WebInputEvent::Type::kGestureScrollBegin, last_acked_event().GetType()); EXPECT_EQ(2U, GestureEventQueueSize()); // Simulate GSE ACK first since it's usually dispatched non-blocking. SendInputEventACK(WebInputEvent::Type::kGestureScrollEnd, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); // GSE ACK will be cached in GestureEventQueue since we haven't ACKed GSU yet. EXPECT_EQ(WebInputEvent::Type::kGestureScrollBegin, last_acked_event().GetType()); @@ -533,7 +543,7 @@ // Simulate GSU ACK. SendInputEventACK(WebInputEvent::Type::kGestureScrollUpdate, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); // Both ACKs should be released in order. EXPECT_EQ(WebInputEvent::Type::kGestureScrollEnd, last_acked_event().GetType()); @@ -567,25 +577,31 @@ GestureEventLastQueueEvent().GetType()); SendInputEventACK(WebInputEvent::Type::kGestureScrollBegin, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); EXPECT_EQ(4U, GestureEventQueueSize()); + auto scroll_result_data = + blink::mojom::ScrollResultData::New(gfx::PointF(0.f, 4.f)); SendInputEventACK(WebInputEvent::Type::kGesturePinchBegin, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); SendInputEventACK(WebInputEvent::Type::kGestureScrollUpdate, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, + std::move(scroll_result_data)); // Both GestureScrollUpdate and GesturePinchUpdate should have been sent. EXPECT_EQ(WebInputEvent::Type::kGestureScrollUpdate, last_acked_event().GetType()); + // scroll_result_data should be preserved. + EXPECT_EQ(4.f, + last_acked_event_scroll_result_data()->root_scroll_offset->y()); EXPECT_EQ(2U, GestureEventQueueSize()); EXPECT_EQ(0U, GetAndResetSentGestureEventCount()); // Ack the last 2 GesturePinchUpdate events. SendInputEventACK(WebInputEvent::Type::kGesturePinchUpdate, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); SendInputEventACK(WebInputEvent::Type::kGesturePinchUpdate, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, nullptr); EXPECT_EQ(WebInputEvent::Type::kGesturePinchUpdate, last_acked_event().GetType()); EXPECT_EQ(0U, GestureEventQueueSize());
diff --git a/content/browser/renderer_host/input/input_disposition_handler.h b/content/browser/renderer_host/input/input_disposition_handler.h index 002a37b..33336d5 100644 --- a/content/browser/renderer_host/input/input_disposition_handler.h +++ b/content/browser/renderer_host/input/input_disposition_handler.h
@@ -9,6 +9,7 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" namespace content { @@ -29,7 +30,8 @@ virtual void OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) = 0; + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) = 0; }; } // namespace content
diff --git a/content/browser/renderer_host/input/input_router_impl.cc b/content/browser/renderer_host/input/input_router_impl.cc index 8846216..863e3e4 100644 --- a/content/browser/renderer_host/input/input_router_impl.cc +++ b/content/browser/renderer_host/input/input_router_impl.cc
@@ -26,6 +26,7 @@ #include "services/tracing/public/cpp/perfetto/flow_event_utils.h" #include "third_party/blink/public/common/input/web_coalesced_input_event.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "third_party/blink/public/mojom/input/input_handler.mojom-shared.h" #include "third_party/blink/public/mojom/input/touch_event.mojom.h" #include "ui/events/blink/blink_event_util.h" @@ -145,7 +146,8 @@ TRACE_EVENT_INSTANT0("input", "FilteredForFling", TRACE_EVENT_SCOPE_THREAD); disposition_handler_->OnGestureEventAck( gesture_event, blink::mojom::InputEventResultSource::kBrowser, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, + /*scroll_result_data=*/nullptr); return; } @@ -172,7 +174,8 @@ TRACE_EVENT_SCOPE_THREAD); disposition_handler_->OnGestureEventAck( gesture_event, blink::mojom::InputEventResultSource::kBrowser, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, + /*scroll_result_data=*/nullptr); return; } @@ -181,7 +184,8 @@ if (HandleGestureScrollForStylusWriting(gesture_event.event)) { disposition_handler_->OnGestureEventAck( gesture_event, blink::mojom::InputEventResultSource::kBrowser, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, + /*scroll_result_data=*/nullptr); return; } @@ -215,7 +219,8 @@ TRACE_EVENT_SCOPE_THREAD); disposition_handler_->OnGestureEventAck( gesture_event, blink::mojom::InputEventResultSource::kBrowser, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, + /*scroll_result_data=*/nullptr); } } @@ -502,9 +507,11 @@ void InputRouterImpl::OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { touch_event_queue_.OnGestureEventAck(event, ack_result); - disposition_handler_->OnGestureEventAck(event, ack_source, ack_result); + disposition_handler_->OnGestureEventAck(event, ack_source, ack_result, + std::move(scroll_result_data)); } void InputRouterImpl::SendGeneratedWheelEvent( @@ -558,7 +565,8 @@ const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, blink::mojom::InputEventResultState ack_result) { - OnGestureEventAck(event, ack_source, ack_result); + OnGestureEventAck(event, ack_source, ack_result, + /*scroll_result_data=*/nullptr); } bool InputRouterImpl::IsWheelScrollInProgress() { @@ -596,7 +604,8 @@ TRACE_EVENT_SCOPE_THREAD); if (filtered_state != blink::mojom::InputEventResultState::kUnknown) { std::move(callback).Run(blink::mojom::InputEventResultSource::kBrowser, - latency_info, filtered_state, nullptr, nullptr); + latency_info, filtered_state, nullptr, nullptr, + /*scroll_result_data=*/nullptr); } return; } @@ -615,7 +624,8 @@ const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action) { + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data) { // Filter source to ensure only valid values are sent from the // renderer. if (source == blink::mojom::InputEventResultSource::kBrowser) { @@ -624,9 +634,9 @@ return; } - std::move(callback).Run(source, latency, state, - std::move(overscroll), - std::move(touch_action)); + std::move(callback).Run( + source, latency, state, std::move(overscroll), + std::move(touch_action), std::move(scroll_result_data)); }, std::move(callback), weak_this_); client_->GetWidgetInputHandler()->DispatchEvent( @@ -636,9 +646,10 @@ TRACE_EVENT_SCOPE_THREAD); client_->GetWidgetInputHandler()->DispatchNonBlockingEvent( std::move(event)); - std::move(callback).Run( - blink::mojom::InputEventResultSource::kBrowser, latency_info, - blink::mojom::InputEventResultState::kIgnored, nullptr, nullptr); + std::move(callback).Run(blink::mojom::InputEventResultSource::kBrowser, + latency_info, + blink::mojom::InputEventResultState::kIgnored, + nullptr, nullptr, /*scroll_result_data=*/nullptr); } } @@ -649,7 +660,8 @@ const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action) { + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data) { TRACE_EVENT2("input", "InputRouterImpl::KeyboardEventHandled", "type", WebInputEvent::GetName(event.event.GetType()), "ack", InputEventResultStateToString(state)); @@ -672,7 +684,8 @@ const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action) { + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data) { TRACE_EVENT2("input", "InputRouterImpl::MouseEventHandled", "type", WebInputEvent::GetName(event.event.GetType()), "ack", InputEventResultStateToString(state)); @@ -689,7 +702,8 @@ const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action) { + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data) { TRACE_EVENT2("input", "InputRouterImpl::TouchEventHandled", "type", WebInputEvent::GetName(touch_event.event.GetType()), "ack", InputEventResultStateToString(state)); @@ -720,7 +734,8 @@ const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action) { + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data) { TRACE_EVENT2("input", "InputRouterImpl::GestureEventHandled", "type", WebInputEvent::GetName(gesture_event.event.GetType()), "ack", InputEventResultStateToString(state)); @@ -734,8 +749,9 @@ } // |gesture_event_queue_| will forward to OnGestureEventAck when appropriate. - gesture_event_queue_.ProcessGestureAck( - source, state, gesture_event.event.GetType(), latency); + gesture_event_queue_.ProcessGestureAck(source, state, + gesture_event.event.GetType(), latency, + std::move(scroll_result_data)); } void InputRouterImpl::MouseWheelEventHandled( @@ -745,7 +761,8 @@ const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action) { + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data) { TRACE_EVENT2("input", "InputRouterImpl::MouseWheelEventHandled", "type", WebInputEvent::GetName(event.event.GetType()), "ack", InputEventResultStateToString(state));
diff --git a/content/browser/renderer_host/input/input_router_impl.h b/content/browser/renderer_host/input/input_router_impl.h index ce6298c..74eb5f9 100644 --- a/content/browser/renderer_host/input/input_router_impl.h +++ b/content/browser/renderer_host/input/input_router_impl.h
@@ -152,7 +152,8 @@ void OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) override; + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; // FlingControllerEventSenderClient void SendGeneratedWheelEvent( @@ -193,32 +194,38 @@ const ui::LatencyInfo& latency_info, blink::mojom::WidgetInputHandler::DispatchEventCallback callback); - void KeyboardEventHandled(const NativeWebKeyboardEventWithLatencyInfo& event, - KeyboardEventCallback event_result_callback, - blink::mojom::InputEventResultSource source, - const ui::LatencyInfo& latency, - blink::mojom::InputEventResultState state, - blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action); + void KeyboardEventHandled( + const NativeWebKeyboardEventWithLatencyInfo& event, + KeyboardEventCallback event_result_callback, + blink::mojom::InputEventResultSource source, + const ui::LatencyInfo& latency, + blink::mojom::InputEventResultState state, + blink::mojom::DidOverscrollParamsPtr overscroll, + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data); void MouseEventHandled(const MouseEventWithLatencyInfo& event, MouseEventCallback event_result_callback, blink::mojom::InputEventResultSource source, const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action); + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data); void TouchEventHandled(const TouchEventWithLatencyInfo& touch_event, blink::mojom::InputEventResultSource source, const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action); - void GestureEventHandled(const GestureEventWithLatencyInfo& gesture_event, - blink::mojom::InputEventResultSource source, - const ui::LatencyInfo& latency, - blink::mojom::InputEventResultState state, - blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action); + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data); + void GestureEventHandled( + const GestureEventWithLatencyInfo& gesture_event, + blink::mojom::InputEventResultSource source, + const ui::LatencyInfo& latency, + blink::mojom::InputEventResultState state, + blink::mojom::DidOverscrollParamsPtr overscroll, + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data); void MouseWheelEventHandled( const MouseWheelEventWithLatencyInfo& event, MouseWheelEventQueueClient::MouseWheelEventHandledCallback callback, @@ -226,7 +233,8 @@ const ui::LatencyInfo& latency, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action); + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data); // Called when a touch timeout-affecting bit has changed, in turn toggling the // touch ack timeout feature of the |touch_event_queue_| as appropriate. Input
diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc index ad91a1db..5eb9a033 100644 --- a/content/browser/renderer_host/input/input_router_impl_unittest.cc +++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -529,7 +529,8 @@ TouchEventWithLatencyInfo(touch_event_), blink::mojom::InputEventResultSource::kMainThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kNoConsumerExists, nullptr, - blink::mojom::TouchActionOptional::New(cc::TouchAction::kPanY)); + blink::mojom::TouchActionOptional::New(cc::TouchAction::kPanY), + nullptr); EXPECT_EQ(input_router_->AllowedTouchAction().value(), cc::TouchAction::kAuto); } @@ -542,7 +543,7 @@ input_router_->TouchEventHandled( TouchEventWithLatencyInfo(touch_event_), blink::mojom::InputEventResultSource::kMainThread, ui::LatencyInfo(), - state, nullptr, std::move(touch_action)); + state, nullptr, std::move(touch_action), nullptr); EXPECT_EQ(input_router_->touch_action_filter_.num_of_active_touches_, 1); ReleaseTouchPoint(0); input_router_->OnTouchEventAck( @@ -560,7 +561,8 @@ TouchEventWithLatencyInfo(touch_event_), blink::mojom::InputEventResultSource::kCompositorThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kNotConsumed, - nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kPan)); + nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kPan), + nullptr); EXPECT_TRUE(input_router_->touch_event_queue_.IsTimeoutRunningForTesting()); input_router_->SetTouchActionFromMain(cc::TouchAction::kPan); EXPECT_FALSE( @@ -1464,7 +1466,7 @@ dispatched_messages[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kMainThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kConsumed, nullptr, - blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone)); + blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone), nullptr); EXPECT_EQ(1U, disposition_handler_->GetAndResetAckCount()); EXPECT_FALSE(TouchEventTimeoutEnabled()); @@ -1551,7 +1553,7 @@ touch_press_event1[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kMainThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kConsumed, nullptr, - blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone)); + blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone), nullptr); touch_move_event1[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultState::kConsumed); @@ -1576,7 +1578,8 @@ touch_press_event2[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kCompositorThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kConsumed, - nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kAuto)); + nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kAuto), + nullptr); touch_press_event2[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultState::kConsumed); touch_move_event2[0]->ToEvent()->CallCallback( @@ -1617,7 +1620,7 @@ touch_press_event1[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kMainThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kConsumed, nullptr, - blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone)); + blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone), nullptr); touch_move_event1[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultState::kConsumed); @@ -1695,7 +1698,7 @@ dispatched_messages[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kMainThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kConsumed, nullptr, - blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone)); + blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone), nullptr); EXPECT_EQ(0U, GetAndResetDispatchedMessages().size()); dispatched_messages[1]->ToEvent()->CallCallback( blink::mojom::InputEventResultState::kNotConsumed); @@ -1833,7 +1836,7 @@ dispatched_messages[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kMainThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kConsumed, nullptr, - blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone)); + blink::mojom::TouchActionOptional::New(cc::TouchAction::kNone), nullptr); ReleaseTouchPoint(0); SendTouchEvent(); @@ -2209,7 +2212,7 @@ dispatched_messages[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kCompositorThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kNotConsumed, - wheel_overscroll.Clone(), nullptr); + wheel_overscroll.Clone(), nullptr, nullptr); client_overscroll = client_->GetAndResetOverscroll(); EXPECT_EQ(wheel_overscroll.accumulated_overscroll, @@ -2278,7 +2281,8 @@ dispatched_messages[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kCompositorThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kConsumed, - nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kPan)); + nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kPan), + nullptr); ASSERT_EQ(1U, disposition_handler_->GetAndResetAckCount()); absl::optional<cc::TouchAction> allowed_touch_action = AllowedTouchAction(); cc::TouchAction compositor_allowed_touch_action = @@ -2470,7 +2474,8 @@ dispatched_messages[0]->ToEvent()->CallCallback( blink::mojom::InputEventResultSource::kCompositorThread, ui::LatencyInfo(), blink::mojom::InputEventResultState::kNotConsumed, - nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kPan)); + nullptr, blink::mojom::TouchActionOptional::New(cc::TouchAction::kPan), + nullptr); ASSERT_EQ(1U, disposition_handler_->GetAndResetAckCount()); absl::optional<cc::TouchAction> allowed_touch_action = AllowedTouchAction(); cc::TouchAction compositor_allowed_touch_action =
diff --git a/content/browser/renderer_host/input/mock_input_disposition_handler.cc b/content/browser/renderer_host/input/mock_input_disposition_handler.cc index f13decf7..d48b069 100644 --- a/content/browser/renderer_host/input/mock_input_disposition_handler.cc +++ b/content/browser/renderer_host/input/mock_input_disposition_handler.cc
@@ -58,7 +58,8 @@ void MockInputDispositionHandler::OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { VLOG(1) << __FUNCTION__ << " called!"; acked_gesture_event_ = event.event; RecordAckCalled(event.event.GetType(), ack_result);
diff --git a/content/browser/renderer_host/input/mock_input_disposition_handler.h b/content/browser/renderer_host/input/mock_input_disposition_handler.h index be8f7ce1..3e18cb0c 100644 --- a/content/browser/renderer_host/input/mock_input_disposition_handler.h +++ b/content/browser/renderer_host/input/mock_input_disposition_handler.h
@@ -13,6 +13,7 @@ #include "base/memory/raw_ptr.h" #include "content/browser/renderer_host/input/input_disposition_handler.h" #include "content/browser/renderer_host/input/input_router.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" namespace content { @@ -36,7 +37,8 @@ void OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) override; + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; size_t GetAndResetAckCount();
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index d03ad26..6cb172a 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -122,6 +122,7 @@ #include "third_party/blink/public/common/widget/visual_properties.h" #include "third_party/blink/public/mojom/drag/drag.mojom.h" #include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "third_party/blink/public/mojom/input/touch_event.mojom.h" #include "ui/base/clipboard/clipboard_constants.h" #include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h" @@ -3266,7 +3267,8 @@ void RenderWidgetHostImpl::OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); for (auto& input_event_observer : input_event_observers_) input_event_observer.OnInputEventAck(ack_source, ack_result, event.event); @@ -3277,7 +3279,8 @@ touch_emulator->OnGestureEventAck(event.event, GetView()); if (view_) - view_->GestureEventAck(event.event, ack_result); + view_->GestureEventAck(event.event, ack_result, + std::move(scroll_result_data)); } void RenderWidgetHostImpl::OnTouchEventAck(
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 52a67f705..5274639 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -55,6 +55,7 @@ #include "services/viz/public/mojom/hit_test/input_target_client.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "third_party/blink/public/mojom/input/input_handler.mojom.h" #include "third_party/blink/public/mojom/input/pointer_lock_context.mojom.h" #include "third_party/blink/public/mojom/manifest/display_mode.mojom.h" @@ -915,7 +916,8 @@ void OnGestureEventAck( const GestureEventWithLatencyInfo& event, blink::mojom::InputEventResultSource ack_source, - blink::mojom::InputEventResultState ack_result) override; + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; // virtual for testing. virtual void OnMouseEventAck(const MouseEventWithLatencyInfo& event,
diff --git a/content/browser/renderer_host/render_widget_host_input_event_router.cc b/content/browser/renderer_host/render_widget_host_input_event_router.cc index 43dbbac..0ef81ec 100644 --- a/content/browser/renderer_host/render_widget_host_input_event_router.cc +++ b/content/browser/renderer_host/render_widget_host_input_event_router.cc
@@ -1609,7 +1609,8 @@ if (!touchscreen_gesture_target_) { root_view->GestureEventAck( - gesture_event, blink::mojom::InputEventResultState::kNoConsumerExists); + gesture_event, blink::mojom::InputEventResultState::kNoConsumerExists, + nullptr); return; } @@ -1711,7 +1712,7 @@ } else { root_view->GestureEventAck( touchpad_gesture_event, - blink::mojom::InputEventResultState::kNoConsumerExists); + blink::mojom::InputEventResultState::kNoConsumerExists, nullptr); } return; } @@ -1726,7 +1727,7 @@ } else { root_view->GestureEventAck( touchpad_gesture_event, - blink::mojom::InputEventResultState::kNoConsumerExists); + blink::mojom::InputEventResultState::kNoConsumerExists, nullptr); } return; } @@ -1741,7 +1742,7 @@ if (!touchpad_gesture_target_) { root_view->GestureEventAck( touchpad_gesture_event, - blink::mojom::InputEventResultState::kNoConsumerExists); + blink::mojom::InputEventResultState::kNoConsumerExists, nullptr); return; }
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index d107ef6..83657180 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -228,7 +228,8 @@ } void GestureEventAck( const WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) override { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override { gesture_event_type_ = event.GetType(); ack_result_ = ack_result; }
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index bca58e9..3539884 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -1770,7 +1770,8 @@ void RenderWidgetHostViewAndroid::GestureEventAck( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { if (overscroll_controller_) overscroll_controller_->OnGestureEventAck(event, ack_result); mouse_wheel_phase_handler_.GestureEventAck(event, ack_result); @@ -1782,16 +1783,19 @@ StopFlingingIfNecessary(event, ack_result); if (gesture_listener_manager_) - gesture_listener_manager_->GestureEventAck(event, ack_result); + gesture_listener_manager_->GestureEventAck(event, ack_result, + std::move(scroll_result_data)); HandleSwipeToMoveCursorGestureAck(event); } void RenderWidgetHostViewAndroid::ChildDidAckGestureEvent( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { if (gesture_listener_manager_) - gesture_listener_manager_->GestureEventAck(event, ack_result); + gesture_listener_manager_->GestureEventAck(event, ack_result, + std::move(scroll_result_data)); } blink::mojom::InputEventResultState
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index 8cbaa47f..9a63457 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -161,11 +161,14 @@ blink::mojom::InputEventResultState ack_result) override; blink::mojom::InputEventResultState FilterInputEvent( const blink::WebInputEvent& input_event) override; - void GestureEventAck(const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) override; + void GestureEventAck( + const blink::WebGestureEvent& event, + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; void ChildDidAckGestureEvent( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) override; + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; blink::mojom::PointerLockResult LockMouse( bool request_unadjusted_movement) override; blink::mojom::PointerLockResult ChangeMouseLock(
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 5e45adfa..9d1301a5 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -55,6 +55,7 @@ #include "content/public/common/page_visibility_state.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/blink/public/common/input/web_input_event.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "third_party/blink/public/mojom/widget/record_content_to_visible_time_request.mojom.h" #include "ui/accessibility/accessibility_switches.h" #include "ui/accessibility/aura/aura_window_properties.h" @@ -1014,7 +1015,8 @@ void RenderWidgetHostViewAura::GestureEventAck( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { const blink::WebInputEvent::Type event_type = event.GetType(); if (event_type == blink::WebGestureEvent::Type::kGestureScrollBegin || event_type == blink::WebGestureEvent::Type::kGestureScrollEnd) {
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index f406646..23a925f 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -157,8 +157,10 @@ gfx::Rect GetBoundsInRootWindow() override; void WheelEventAck(const blink::WebMouseWheelEvent& event, blink::mojom::InputEventResultState ack_result) override; - void GestureEventAck(const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) override; + void GestureEventAck( + const blink::WebGestureEvent& event, + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; void DidOverscroll(const ui::DidOverscrollParams& params) override; void ProcessAckedTouchEvent( const TouchEventWithLatencyInfo& touch,
diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index a92abef..999eeb6 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc
@@ -414,11 +414,13 @@ void RenderWidgetHostViewBase::GestureEventAck( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) {} + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) {} void RenderWidgetHostViewBase::ChildDidAckGestureEvent( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) {} + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) {} void RenderWidgetHostViewBase::ForwardTouchpadZoomEventIfNecessary( const blink::WebGestureEvent& event,
diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index 763c624e..f3a4f396 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h
@@ -35,6 +35,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom-forward.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "third_party/skia/include/core/SkImageInfo.h" #include "ui/accessibility/ax_action_handler_registry.h" #include "ui/base/ime/mojom/text_input_state.mojom-forward.h" @@ -225,12 +226,15 @@ virtual void WheelEventAck(const blink::WebMouseWheelEvent& event, blink::mojom::InputEventResultState ack_result); - virtual void GestureEventAck(const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result); + virtual void GestureEventAck( + const blink::WebGestureEvent& event, + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data); virtual void ChildDidAckGestureEvent( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result); + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data); // Create a platform specific SyntheticGestureTarget implementation that will // be used to inject synthetic input events.
diff --git a/content/browser/renderer_host/render_widget_host_view_child_frame.cc b/content/browser/renderer_host/render_widget_host_view_child_frame.cc index fe70c30..4e6d62b 100644 --- a/content/browser/renderer_host/render_widget_host_view_child_frame.cc +++ b/content/browser/renderer_host/render_widget_host_view_child_frame.cc
@@ -35,6 +35,7 @@ #include "third_party/blink/public/common/input/web_touch_event.h" #include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom.h" #include "third_party/blink/public/mojom/frame/viewport_intersection_state.mojom.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "ui/base/ime/mojom/text_input_state.mojom.h" #include "ui/display/display_util.h" #include "ui/gfx/geometry/dip_util.h" @@ -549,7 +550,8 @@ void RenderWidgetHostViewChildFrame::GestureEventAck( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { // Stop flinging if a GSU event with momentum phase is sent to the renderer // but not consumed. StopFlingingIfNecessary(event, ack_result); @@ -558,7 +560,9 @@ return; if (event.IsTouchpadZoomEvent()) - ProcessTouchpadZoomEventAckInRoot(event, ack_result); + ProcessTouchpadZoomEventAckInRoot( + event, ack_result, + scroll_result_data ? scroll_result_data.Clone() : nullptr); // GestureScrollBegin is a blocking event; It is forwarded for bubbling if // its ack is not consumed. For the rest of the scroll events @@ -582,15 +586,18 @@ } } - frame_connector_->DidAckGestureEvent(event, ack_result); + frame_connector_->DidAckGestureEvent(event, ack_result, + std::move(scroll_result_data)); } void RenderWidgetHostViewChildFrame::ProcessTouchpadZoomEventAckInRoot( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { DCHECK(event.IsTouchpadZoomEvent()); - frame_connector_->ForwardAckedTouchpadZoomEvent(event, ack_result); + frame_connector_->ForwardAckedTouchpadZoomEvent( + event, ack_result, std::move(scroll_result_data)); } void RenderWidgetHostViewChildFrame::ForwardTouchpadZoomEventIfNecessary(
diff --git a/content/browser/renderer_host/render_widget_host_view_child_frame.h b/content/browser/renderer_host/render_widget_host_view_child_frame.h index 457dabe4..70b151bc 100644 --- a/content/browser/renderer_host/render_widget_host_view_child_frame.h +++ b/content/browser/renderer_host/render_widget_host_view_child_frame.h
@@ -32,6 +32,7 @@ #include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom-forward.h" #include "third_party/blink/public/mojom/frame/viewport_intersection_state.mojom-forward.h" #include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include "third_party/blink/public/mojom/widget/record_content_to_visible_time_request.mojom-forward.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/native_widget_types.h" @@ -118,8 +119,10 @@ void UpdateTooltipFromKeyboard(const std::u16string& tooltip_text, const gfx::Rect& bounds) override; void ClearKeyboardTriggeredTooltip() override; - void GestureEventAck(const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) override; + void GestureEventAck( + const blink::WebGestureEvent& event, + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; // Since the URL of content rendered by this class is not displayed in // the URL bar, this method does not need an implementation. void ResetFallbackToFirstNavigationSurface() override {} @@ -297,7 +300,8 @@ void ProcessTouchpadZoomEventAckInRoot( const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result); + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data); void ForwardTouchpadZoomEventIfNecessary( const blink::WebGestureEvent& event, blink::mojom::InputEventResultState ack_result) override;
diff --git a/content/browser/renderer_host/render_widget_host_view_child_frame_unittest.cc b/content/browser/renderer_host/render_widget_host_view_child_frame_unittest.cc index 4d1d5f2..dcb6c40b 100644 --- a/content/browser/renderer_host/render_widget_host_view_child_frame_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_view_child_frame_unittest.cc
@@ -55,6 +55,11 @@ 1, base::UnguessableToken::Deserialize(2, 3)); +blink::mojom::ScrollResultDataPtr MakeDefaultScrollResultData() { + return blink::mojom::ScrollResultData::New( + absl::optional<::gfx::PointF>(::gfx::PointF(0, 100))); +} + } // namespace class MockFrameConnector : public CrossProcessFrameConnector { @@ -343,16 +348,19 @@ blink::WebInputEvent::Type::kGestureScrollEnd, blink::WebGestureDevice::kTouchscreen); - view_->GestureEventAck( - scroll_begin, blink::mojom::InputEventResultState::kNoConsumerExists); + view_->GestureEventAck(scroll_begin, + blink::mojom::InputEventResultState::kNoConsumerExists, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kGestureScrollBegin, test_frame_connector_->GetAndResetLastBubbledEventType()); - view_->GestureEventAck( - scroll_update, blink::mojom::InputEventResultState::kNoConsumerExists); + view_->GestureEventAck(scroll_update, + blink::mojom::InputEventResultState::kNoConsumerExists, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kGestureScrollUpdate, test_frame_connector_->GetAndResetLastBubbledEventType()); view_->GestureEventAck(scroll_end, - blink::mojom::InputEventResultState::kIgnored); + blink::mojom::InputEventResultState::kIgnored, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kGestureScrollEnd, test_frame_connector_->GetAndResetLastBubbledEventType()); } @@ -372,23 +380,27 @@ blink::WebGestureDevice::kTouchscreen); view_->GestureEventAck(scroll_begin, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kUndefined, test_frame_connector_->GetAndResetLastBubbledEventType()); view_->GestureEventAck(scroll_update, - blink::mojom::InputEventResultState::kConsumed); + blink::mojom::InputEventResultState::kConsumed, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kUndefined, test_frame_connector_->GetAndResetLastBubbledEventType()); // Scrolling in a child my reach its extent and no longer be consumed, however // scrolling is latched to the child so we do not bubble the update. - view_->GestureEventAck( - scroll_update, blink::mojom::InputEventResultState::kNoConsumerExists); + view_->GestureEventAck(scroll_update, + blink::mojom::InputEventResultState::kNoConsumerExists, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kUndefined, test_frame_connector_->GetAndResetLastBubbledEventType()); view_->GestureEventAck(scroll_end, - blink::mojom::InputEventResultState::kIgnored); + blink::mojom::InputEventResultState::kIgnored, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kUndefined, test_frame_connector_->GetAndResetLastBubbledEventType()); } @@ -410,35 +422,41 @@ test_frame_connector_->SetCanBubble(false); - view_->GestureEventAck( - scroll_begin, blink::mojom::InputEventResultState::kNoConsumerExists); + view_->GestureEventAck(scroll_begin, + blink::mojom::InputEventResultState::kNoConsumerExists, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kGestureScrollBegin, test_frame_connector_->GetAndResetLastBubbledEventType()); // The GSB was rejected, so the child view must not attempt to bubble the // remaining events of the scroll sequence. - view_->GestureEventAck( - scroll_update, blink::mojom::InputEventResultState::kNoConsumerExists); + view_->GestureEventAck(scroll_update, + blink::mojom::InputEventResultState::kNoConsumerExists, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kUndefined, test_frame_connector_->GetAndResetLastBubbledEventType()); view_->GestureEventAck(scroll_end, - blink::mojom::InputEventResultState::kIgnored); + blink::mojom::InputEventResultState::kIgnored, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kUndefined, test_frame_connector_->GetAndResetLastBubbledEventType()); test_frame_connector_->SetCanBubble(true); // When we have a new scroll gesture, the view may try bubbling again. - view_->GestureEventAck( - scroll_begin, blink::mojom::InputEventResultState::kNoConsumerExists); + view_->GestureEventAck(scroll_begin, + blink::mojom::InputEventResultState::kNoConsumerExists, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kGestureScrollBegin, test_frame_connector_->GetAndResetLastBubbledEventType()); - view_->GestureEventAck( - scroll_update, blink::mojom::InputEventResultState::kNoConsumerExists); + view_->GestureEventAck(scroll_update, + blink::mojom::InputEventResultState::kNoConsumerExists, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kGestureScrollUpdate, test_frame_connector_->GetAndResetLastBubbledEventType()); view_->GestureEventAck(scroll_end, - blink::mojom::InputEventResultState::kIgnored); + blink::mojom::InputEventResultState::kIgnored, + MakeDefaultScrollResultData()); EXPECT_EQ(blink::WebInputEvent::Type::kGestureScrollEnd, test_frame_connector_->GetAndResetLastBubbledEventType()); }
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index a27ce05..0549e3b 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h
@@ -6,6 +6,7 @@ #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ #include "base/memory/raw_ptr.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #import <Cocoa/Cocoa.h> @@ -178,8 +179,10 @@ void UnlockKeyboard() override; bool IsKeyboardLocked() override; base::flat_map<std::string, std::string> GetKeyboardLayoutMap() override; - void GestureEventAck(const blink::WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) override; + void GestureEventAck( + const blink::WebGestureEvent& event, + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) override; void ProcessAckedTouchEvent( const TouchEventWithLatencyInfo& touch, blink::mojom::InputEventResultState ack_result) override;
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 9c42f305..d460e05 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -5,6 +5,7 @@ #include "content/browser/renderer_host/render_widget_host_view_mac.h" #import <Carbon/Carbon.h> +#include "third_party/blink/public/mojom/input/input_handler.mojom-forward.h" #include <limits> #include <memory> @@ -1358,7 +1359,8 @@ void RenderWidgetHostViewMac::GestureEventAck( const WebGestureEvent& event, - blink::mojom::InputEventResultState ack_result) { + blink::mojom::InputEventResultState ack_result, + blink::mojom::ScrollResultDataPtr scroll_result_data) { ForwardTouchpadZoomEventIfNecessary(event, ack_result); // Stop flinging if a GSU event with momentum phase is sent to the renderer
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc index 24bd386..1c12459c 100644 --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc
@@ -79,7 +79,6 @@ #include "content/browser/notifications/platform_notification_context_impl.h" #include "content/browser/payments/payment_app_context_impl.h" #include "content/browser/preloading/prerender/prerender_host_registry.h" -#include "content/browser/private_aggregation/private_aggregation_features.h" #include "content/browser/private_aggregation/private_aggregation_manager_impl.h" #include "content/browser/push_messaging/push_messaging_context.h" #include "content/browser/quota/quota_context.h" @@ -93,6 +92,7 @@ #include "content/browser/ssl_private_key_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/worker_host/shared_worker_service_impl.h" +#include "content/common/private_aggregation_features.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h"
diff --git a/content/browser/utility_sandbox_delegate_win.cc b/content/browser/utility_sandbox_delegate_win.cc index 2ae5fc8..e7f5b06 100644 --- a/content/browser/utility_sandbox_delegate_win.cc +++ b/content/browser/utility_sandbox_delegate_win.cc
@@ -105,6 +105,64 @@ policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); return true; } + +std::string UtilityAppContainerId(base::CommandLine& cmd_line) { + return base::WideToUTF8(cmd_line.GetProgram().value()); +} + +bool IconReaderPreSpawnTarget(sandbox::TargetPolicy* policy) { + policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, + sandbox::USER_LOCKDOWN); + policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED); + policy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); + policy->SetLockdownDefaultDacl(); + policy->SetAlternateDesktop(true); + + sandbox::MitigationFlags flags = policy->GetDelayedProcessMitigations(); + flags |= sandbox::MITIGATION_DYNAMIC_CODE_DISABLE; + if (sandbox::SBOX_ALL_OK != policy->SetDelayedProcessMitigations(flags)) + return false; + + auto* config = policy->GetConfig(); + if (config->IsConfigured()) + return true; + + // Allow file read. These should match IconLoader::GroupForFilepath(). + config->AddRule(sandbox::SubSystem::kFiles, + sandbox::Semantics::kFilesAllowReadonly, L"\\??\\*.exe"); + config->AddRule(sandbox::SubSystem::kFiles, + sandbox::Semantics::kFilesAllowReadonly, L"\\??\\*.dll"); + config->AddRule(sandbox::SubSystem::kFiles, + sandbox::Semantics::kFilesAllowReadonly, L"\\??\\*.ico"); + return true; +} + +bool XrCompositingPreSpawnTarget(sandbox::TargetPolicy* policy, + base::CommandLine& cmd_line, + sandbox::mojom::Sandbox sandbox_type) { + if (!base::FeatureList::IsEnabled(sandbox::policy::features::kXRSandbox)) + return true; + // TODO(https://crbug.com/881919): Try to harden the XR Compositor + // sandbox to use mitigations and restrict the token. + + // Unprotected token/job. + policy->SetTokenLevel(sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED); + sandbox::policy::SandboxWin::SetJobLevel( + sandbox_type, sandbox::JobLevel::kUnprotected, 0, policy); + + // There were issues with some mitigations, causing an inability + // to load OpenVR and Oculus APIs. + policy->SetProcessMitigations(0); + policy->SetDelayedProcessMitigations(0); + + std::string appcontainer_id = UtilityAppContainerId(cmd_line); + auto result = sandbox::policy::SandboxWin::AddAppContainerProfileToPolicy( + cmd_line, sandbox_type, appcontainer_id, policy); + if (result != sandbox::SBOX_ALL_OK) + return false; + + return true; +} } // namespace std::string UtilitySandboxedProcessLauncherDelegate::GetSandboxTag() { @@ -114,19 +172,21 @@ bool UtilitySandboxedProcessLauncherDelegate::GetAppContainerId( std::string* appcontainer_id) { - if (sandbox_type_ == sandbox::mojom::Sandbox::kNetwork) { - *appcontainer_id = base::WideToUTF8(cmd_line_.GetProgram().value()); - return true; + switch (sandbox_type_) { + case sandbox::mojom::Sandbox::kMediaFoundationCdm: + case sandbox::mojom::Sandbox::kNetwork: + case sandbox::mojom::Sandbox::kWindowsSystemProxyResolver: + *appcontainer_id = UtilityAppContainerId(cmd_line_); + return true; + case sandbox::mojom::Sandbox::kXrCompositing: + if (base::FeatureList::IsEnabled(sandbox::policy::features::kXRSandbox)) { + *appcontainer_id = UtilityAppContainerId(cmd_line_); + return true; + } + return false; + default: + return false; } - - if ((sandbox_type_ == sandbox::mojom::Sandbox::kXrCompositing && - base::FeatureList::IsEnabled(sandbox::policy::features::kXRSandbox)) || - sandbox_type_ == sandbox::mojom::Sandbox::kMediaFoundationCdm || - sandbox_type_ == sandbox::mojom::Sandbox::kWindowsSystemProxyResolver) { - *appcontainer_id = base::WideToUTF8(cmd_line_.GetProgram().value()); - return true; - } - return false; } bool UtilitySandboxedProcessLauncherDelegate::DisableDefaultPolicy() { @@ -179,54 +239,13 @@ } if (sandbox_type_ == sandbox::mojom::Sandbox::kIconReader) { - policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, - sandbox::USER_LOCKDOWN); - policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED); - policy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); - policy->SetLockdownDefaultDacl(); - policy->SetAlternateDesktop(true); - - sandbox::MitigationFlags flags = policy->GetDelayedProcessMitigations(); - flags |= sandbox::MITIGATION_DYNAMIC_CODE_DISABLE; - if (sandbox::SBOX_ALL_OK != policy->SetDelayedProcessMitigations(flags)) + if (!IconReaderPreSpawnTarget(policy)) return false; - - if (!policy->GetConfig()->IsConfigured()) { - auto* config = policy->GetConfig(); - // Allow file read. These should match IconLoader::GroupForFilepath(). - config->AddRule(sandbox::SubSystem::kFiles, - sandbox::Semantics::kFilesAllowReadonly, L"\\??\\*.exe"); - config->AddRule(sandbox::SubSystem::kFiles, - sandbox::Semantics::kFilesAllowReadonly, L"\\??\\*.dll"); - config->AddRule(sandbox::SubSystem::kFiles, - sandbox::Semantics::kFilesAllowReadonly, L"\\??\\*.ico"); - } } - if (sandbox_type_ == sandbox::mojom::Sandbox::kXrCompositing && - base::FeatureList::IsEnabled(sandbox::policy::features::kXRSandbox)) { - // There were issues with some mitigations, causing an inability - // to load OpenVR and Oculus APIs. - // TODO(https://crbug.com/881919): Try to harden the XR Compositor - // sandbox to use mitigations and restrict the token. - policy->SetProcessMitigations(0); - policy->SetDelayedProcessMitigations(0); - - std::string appcontainer_id; - if (!GetAppContainerId(&appcontainer_id)) { + if (sandbox_type_ == sandbox::mojom::Sandbox::kXrCompositing) { + if (!XrCompositingPreSpawnTarget(policy, cmd_line_, sandbox_type_)) return false; - } - sandbox::ResultCode result = - sandbox::policy::SandboxWin::AddAppContainerProfileToPolicy( - cmd_line_, sandbox_type_, appcontainer_id, policy); - if (result != sandbox::SBOX_ALL_OK) { - return false; - } - - // Unprotected token/job. - policy->SetTokenLevel(sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED); - sandbox::policy::SandboxWin::SetJobLevel( - sandbox_type_, sandbox::JobLevel::kUnprotected, 0, policy); } if (sandbox_type_ == sandbox::mojom::Sandbox::kMediaFoundationCdm ||
diff --git a/content/browser/webid/fedcm_metrics.h b/content/browser/webid/fedcm_metrics.h index 1390216d..e40daa9b 100644 --- a/content/browser/webid/fedcm_metrics.h +++ b/content/browser/webid/fedcm_metrics.h
@@ -24,7 +24,7 @@ kTooManyRequests, kAborted, kUnhandledRequest, - kNoNetworkManager, + kRpNotPotentiallyTrustworthy, kNotSelectAccount, kManifestHttpNotFound, kManifestNoResponse,
diff --git a/content/browser/webid/federated_auth_request_impl.cc b/content/browser/webid/federated_auth_request_impl.cc index f083a85..7f7eeb9 100644 --- a/content/browser/webid/federated_auth_request_impl.cc +++ b/content/browser/webid/federated_auth_request_impl.cc
@@ -29,6 +29,7 @@ #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" #include "content/public/common/page_visibility_state.h" +#include "services/network/public/cpp/is_potentially_trustworthy.h" #include "third_party/blink/public/mojom/devtools/console_message.mojom.h" #include "third_party/blink/public/mojom/devtools/inspector_issue.mojom.h" #include "ui/accessibility/ax_mode.h" @@ -313,17 +314,18 @@ prefer_auto_sign_in_ = prefer_auto_sign_in && IsFedCmAutoSigninEnabled(); start_time_ = base::TimeTicks::Now(); - // TODO(crbug.com/1307709): Handle network managers for multiple IDPs. - network_manager_ = CreateNetworkManager(identity_provider_ptr->config_url); - if (!network_manager_) { - fedcm_metrics_->RecordRequestTokenStatus(TokenStatus::kNoNetworkManager); - // TODO(yigu): this is due to provider url being non-secure. We should - // reject early in the renderer process. + if (!network::IsOriginPotentiallyTrustworthy( + url::Origin::Create(identity_provider_ptr->config_url))) { + fedcm_metrics_->RecordRequestTokenStatus( + TokenStatus::kRpNotPotentiallyTrustworthy); CompleteRequest(FederatedAuthRequestResult::kError, "", /*should_delay_callback=*/false); return; } + // TODO(crbug.com/1307709): Handle network managers for multiple IDPs. + network_manager_ = CreateNetworkManager(identity_provider_ptr->config_url); + FederatedApiPermissionStatus permission_status = api_permission_delegate_->GetApiPermissionStatus(origin()); @@ -413,12 +415,13 @@ logout_requests_.push(std::move(request)); } - network_manager_ = CreateNetworkManager(origin().GetURL()); - if (!network_manager_) { + if (!network::IsOriginPotentiallyTrustworthy(origin())) { CompleteLogoutRequest(LogoutRpsStatus::kError); return; } + network_manager_ = CreateNetworkManager(origin().GetURL()); + if (!IsFedCmIdpSignoutEnabled()) { CompleteLogoutRequest(LogoutRpsStatus::kError); return; @@ -477,14 +480,8 @@ } else { manifest_list_checked_ = true; } - // network_manager_ can be null here during tests when FetchManifestList - // synchronously calls the callback with an error, in which case CleanUp() - // will set the network_manager_ to null. If that happens we can safely - // skip calling FetchManifest. - if (network_manager_) { - network_manager_->FetchManifest(icon_ideal_size, icon_minimum_size, - std::move(manifest_callback)); - } + network_manager_->FetchManifest(icon_ideal_size, icon_minimum_size, + std::move(manifest_callback)); } void FederatedAuthRequestImpl::OnManifestListFetched(
diff --git a/content/browser/webid/federated_auth_request_impl_unittest.cc b/content/browser/webid/federated_auth_request_impl_unittest.cc index f1d892d..df511471 100644 --- a/content/browser/webid/federated_auth_request_impl_unittest.cc +++ b/content/browser/webid/federated_auth_request_impl_unittest.cc
@@ -386,7 +386,9 @@ fetched_endpoints_ |= FetchedEndpoint::MANIFEST_LIST; std::set<GURL> url_set(config_.manifest_list.provider_urls.begin(), config_.manifest_list.provider_urls.end()); - std::move(callback).Run(FetchStatus::kSuccess, url_set); + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce(std::move(callback), FetchStatus::kSuccess, url_set)); } void FetchManifest(absl::optional<int> idp_brand_icon_ideal_size, @@ -399,25 +401,33 @@ endpoints.accounts = config_.manifest.accounts_endpoint; endpoints.client_metadata = config_.manifest.client_metadata_endpoint; endpoints.revocation = config_.manifest.revocation_endpoint; - std::move(callback).Run(config_.manifest.fetch_status, endpoints, - IdentityProviderMetadata()); + + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce(std::move(callback), config_.manifest.fetch_status, + endpoints, IdentityProviderMetadata())); } void FetchClientMetadata(const GURL& endpoint, const std::string& client_id, FetchClientMetadataCallback callback) override { fetched_endpoints_ |= FetchedEndpoint::CLIENT_METADATA; - std::move(callback).Run(config_.client_metadata.fetch_status, - IdpNetworkRequestManager::ClientMetadata{ - config_.client_metadata.privacy_policy_url, - config_.client_metadata.terms_of_service_url}); + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce(std::move(callback), + config_.client_metadata.fetch_status, + IdpNetworkRequestManager::ClientMetadata{ + config_.client_metadata.privacy_policy_url, + config_.client_metadata.terms_of_service_url})); } void SendAccountsRequest(const GURL& accounts_url, const std::string& client_id, AccountsRequestCallback callback) override { fetched_endpoints_ |= FetchedEndpoint::ACCOUNTS; - std::move(callback).Run(config_.accounts_response, config_.accounts); + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), + config_.accounts_response, config_.accounts)); } void SendTokenRequest(const GURL& token_url, @@ -430,10 +440,12 @@ : std::string(); base::OnceCallback bound_callback = base::BindOnce( std::move(callback), config_.token_response, delivered_token); - if (config_.delay_token_response) + if (config_.delay_token_response) { delayed_callbacks_.push_back(std::move(bound_callback)); - else - std::move(bound_callback).Run(); + } else { + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, std::move(bound_callback)); + } } int get_fetched_endpoints() { return fetched_endpoints_; } @@ -697,6 +709,7 @@ // Ensure that the request makes its way to FederatedAuthRequestImpl. request_remote_.FlushForTesting(); + base::RunLoop().RunUntilIdle(); if (wait_for_callback) { // Fast forward clock so that the pending // FederatedAuthRequestImpl::OnRejectRequest() task, if any, gets a @@ -743,9 +756,11 @@ dismiss_callback) { displayed_accounts_ = AccountList(accounts.begin(), accounts.end()); - std::move(on_selected) - .Run(accounts[0].id, - accounts[0].login_state == LoginState::kSignIn); + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce( + std::move(on_selected), accounts[0].id, + accounts[0].login_state == LoginState::kSignIn)); })); } } else { @@ -941,7 +956,7 @@ RequestExpectations request_not_in_list = { RequestTokenStatus::kError, FederatedAuthRequestResult::kErrorManifestNotInManifestList, - FetchedEndpoint::MANIFEST_LIST}; + FetchedEndpoint::MANIFEST_LIST | FetchedEndpoint::MANIFEST}; RequestParameters parameters{"https://not-in-list.example", kClientId, kNonce, /*prefer_auto_sign_in=*/false}; @@ -962,7 +977,7 @@ RequestExpectations expectations = { RequestTokenStatus::kError, FederatedAuthRequestResult::kErrorManifestNotInManifestList, - FetchedEndpoint::MANIFEST_LIST}; + FetchedEndpoint::MANIFEST_LIST | FetchedEndpoint::MANIFEST}; RunAuthTest(parameters, expectations, config); } @@ -1030,6 +1045,23 @@ RunAuthTest(kDefaultRequestParameters, expectations, configuration); } +// Test that request fails if the idp is not https. +TEST_F(FederatedAuthRequestImplTest, ProviderNotTrustworthy) { + RequestParameters request = kDefaultRequestParameters; + request.provider = "http://idp.example/fedcm.json"; + MockConfiguration configuration = kConfigurationValid; + configuration.manifest_list.provider_urls = + std::set<std::string>{kProviderUrl}; + RequestExpectations expectations = {RequestTokenStatus::kError, + FederatedAuthRequestResult::kError, + /*fetched_endpoints=*/0}; + RunAuthTest(request, expectations, configuration); + + histogram_tester_.ExpectUniqueSample( + "Blink.FedCm.Status.RequestIdToken", + TokenStatus::kRpNotPotentiallyTrustworthy, 1); +} + // Test that request fails if accounts endpoint cannot be reached. TEST_F(FederatedAuthRequestImplTest, AccountEndpointCannotBeReached) { MockConfiguration configuration = kConfigurationValid;
diff --git a/content/browser/webid/idp_network_request_manager.cc b/content/browser/webid/idp_network_request_manager.cc index 0841ba4..a92d903 100644 --- a/content/browser/webid/idp_network_request_manager.cc +++ b/content/browser/webid/idp_network_request_manager.cc
@@ -20,7 +20,6 @@ #include "net/cookies/site_for_cookies.h" #include "net/http/http_request_headers.h" #include "net/http/http_status_code.h" -#include "services/network/public/cpp/is_potentially_trustworthy.h" #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/simple_url_loader.h" @@ -519,10 +518,6 @@ std::unique_ptr<IdpNetworkRequestManager> IdpNetworkRequestManager::Create( const GURL& provider, RenderFrameHostImpl* host) { - // FedCM is restricted to secure contexts. - if (!network::IsOriginPotentiallyTrustworthy(url::Origin::Create(provider))) - return nullptr; - // Use the browser process URL loader factory because it has cross-origin // read blocking disabled. This is safe because even though these are // renderer-initiated fetches, the browser parses the responses and does not @@ -583,8 +578,10 @@ IdpNetworkRequestManager::ComputeManifestListUrl(provider_); if (!manifest_list_url) { - OnManifestListParsed(std::move(callback), FetchStatus::kHttpNotFoundError, - data_decoder::DataDecoder::ValueOrError()); + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(&OnManifestListParsed, std::move(callback), + FetchStatus::kHttpNotFoundError, + data_decoder::DataDecoder::ValueOrError())); return; }
diff --git a/content/browser/webrtc/webrtc_getusermedia_browsertest.cc b/content/browser/webrtc/webrtc_getusermedia_browsertest.cc index 69f3933..a29c438 100644 --- a/content/browser/webrtc/webrtc_getusermedia_browsertest.cc +++ b/content/browser/webrtc/webrtc_getusermedia_browsertest.cc
@@ -144,23 +144,21 @@ devices_as_json, base::JSON_ALLOW_TRAILING_COMMAS); ASSERT_TRUE(parsed_json.has_value()) << parsed_json.error().message; - EXPECT_EQ(parsed_json->type(), base::Value::Type::LIST); - ASSERT_TRUE(parsed_json->is_list()); - for (const auto& entry : parsed_json->GetListDeprecated()) { - const base::DictionaryValue* dict; - std::string kind; - std::string device_id; - ASSERT_TRUE(entry.GetAsDictionary(&dict)); - ASSERT_TRUE(dict->GetString("kind", &kind)); - ASSERT_TRUE(dict->GetString("id", &device_id)); - ASSERT_FALSE(device_id.empty()); - EXPECT_TRUE(kind == "audio" || kind == "video"); - if (kind == "audio") { - audio_ids->push_back(device_id); - } else if (kind == "video") { - video_ids->push_back(device_id); + for (const auto& entry : parsed_json->GetList()) { + const base::Value::Dict* dict = entry.GetIfDict(); + ASSERT_TRUE(dict); + const std::string* kind = dict->FindString("kind"); + const std::string* device_id = dict->FindString("id"); + ASSERT_TRUE(kind); + ASSERT_TRUE(device_id); + ASSERT_FALSE(device_id->empty()); + EXPECT_TRUE(*kind == "audio" || *kind == "video"); + if (*kind == "audio") { + audio_ids->push_back(*device_id); + } else if (*kind == "video") { + video_ids->push_back(*device_id); } } ASSERT_FALSE(audio_ids->empty());
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index aca90ff..fe887ad 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn
@@ -148,6 +148,8 @@ "origin_util.cc", "partition_alloc_support.cc", "partition_alloc_support.h", + "private_aggregation_features.cc", + "private_aggregation_features.h", "process_type.cc", "process_visibility_tracker.cc", "process_visibility_tracker.h", @@ -431,7 +433,10 @@ # See comment at the top of //content/BUILD.gn for how this works. group("for_content_tests") { - visibility = [ "//content/test/*" ] + visibility = [ + "//content/services/auction_worklet:tests", + "//content/test/*", + ] if (!is_component_build) { public_deps = [ ":common" ] }
diff --git a/content/browser/private_aggregation/private_aggregation_features.cc b/content/common/private_aggregation_features.cc similarity index 78% rename from content/browser/private_aggregation/private_aggregation_features.cc rename to content/common/private_aggregation_features.cc index 9913b09..dd5b14c1 100644 --- a/content/browser/private_aggregation/private_aggregation_features.cc +++ b/content/common/private_aggregation_features.cc
@@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/private_aggregation/private_aggregation_features.h" +#include "content/common/private_aggregation_features.h" + +#include "base/feature_list.h" namespace content {
diff --git a/content/common/private_aggregation_features.h b/content/common/private_aggregation_features.h new file mode 100644 index 0000000..78e005f --- /dev/null +++ b/content/common/private_aggregation_features.h
@@ -0,0 +1,20 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_COMMON_PRIVATE_AGGREGATION_FEATURES_H_ +#define CONTENT_COMMON_PRIVATE_AGGREGATION_FEATURES_H_ + +#include "base/feature_list.h" +#include "content/common/content_export.h" + +namespace content { + +// Enables the Private Aggregation API. Note that this API also requires the +// `kPrivacySandboxAggregationService` to be enabled to successfully send +// reports. +CONTENT_EXPORT extern const base::Feature kPrivateAggregationApi; + +} // namespace content + +#endif // CONTENT_COMMON_PRIVATE_AGGREGATION_FEATURES_H_
diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn index b2f7ce1..4bcaf77 100644 --- a/content/public/android/BUILD.gn +++ b/content/public/android/BUILD.gn
@@ -650,6 +650,7 @@ "//base:base_java_process_launcher_test_support", "//base:base_java_test_support", "//base:base_junit_test_support", + "//content/public/common:common_java", "//content/public/test/android:content_java_test_support", "//media/mojo/mojom:mojom_java", "//mojo/public/java:base_java",
diff --git a/content/public/android/java/src/org/chromium/content/browser/BindingManager.java b/content/public/android/java/src/org/chromium/content/browser/BindingManager.java index a326200..9d334458 100644 --- a/content/public/android/java/src/org/chromium/content/browser/BindingManager.java +++ b/content/public/android/java/src/org/chromium/content/browser/BindingManager.java
@@ -8,12 +8,13 @@ import android.content.Context; import android.content.res.Configuration; +import androidx.annotation.VisibleForTesting; import androidx.collection.ArraySet; import org.chromium.base.Log; -import org.chromium.base.library_loader.LibraryLoader; -import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.process_launcher.ChildProcessConnection; +import org.chromium.content_public.browser.ContentFeatureList; +import org.chromium.content_public.common.ContentFeatures; import java.util.Iterator; import java.util.Set; @@ -25,13 +26,15 @@ class BindingManager implements ComponentCallbacks2 { private static final String TAG = "BindingManager"; - // Low reduce ratio of moderate binding. - private static final float MODERATE_BINDING_LOW_REDUCE_RATIO = 0.25f; - // High reduce ratio of moderate binding. - private static final float MODERATE_BINDING_HIGH_REDUCE_RATIO = 0.5f; + // Low reduce ratio of bindings. + private static final float BINDING_LOW_REDUCE_RATIO = 0.25f; + // High reduce ratio of binding. + private static final float BINDING_HIGH_REDUCE_RATIO = 0.5f; // Delays used when clearing moderate binding pool when onSentToBackground happens. - private static final long MODERATE_BINDING_POOL_CLEARER_DELAY_MILLIS = 10 * 1000; + private static final long BINDING_POOL_CLEARER_DELAY_MILLIS = 10 * 1000; + + private static Boolean sUseNotPerceptibleBinding; private final Set<ChildProcessConnection> mConnections = new ArraySet<ChildProcessConnection>(); // Can be -1 to mean no max size. @@ -39,8 +42,8 @@ private final Iterable<ChildProcessConnection> mRanking; private final Runnable mDelayedClearer; - // If not null, this is the connection in |mConnections| that does not have a moderate binding - // added by BindingManager. + // If not null, this is the connection in |mConnections| that does not have a binding added + // by BindingManager. private ChildProcessConnection mWaivedConnection; @Override @@ -53,9 +56,9 @@ return; } if (level <= TRIM_MEMORY_RUNNING_MODERATE) { - reduce(MODERATE_BINDING_LOW_REDUCE_RATIO); + reduce(BINDING_LOW_REDUCE_RATIO); } else if (level <= TRIM_MEMORY_RUNNING_LOW) { - reduce(MODERATE_BINDING_HIGH_REDUCE_RATIO); + reduce(BINDING_HIGH_REDUCE_RATIO); } else if (level == TRIM_MEMORY_UI_HIDDEN) { // This will be handled by |mDelayedClearer|. return; @@ -98,18 +101,18 @@ int numRemoved = 0; for (ChildProcessConnection connection : mRanking) { if (mConnections.contains(connection)) { - removeModerateBindingIfNeeded(connection); + removeBindingIfNeeded(connection); mConnections.remove(connection); if (++numRemoved == numberOfConnections) break; } } } - private void removeModerateBindingIfNeeded(ChildProcessConnection connection) { + private void removeBindingIfNeeded(ChildProcessConnection connection) { if (connection == mWaivedConnection) { mWaivedConnection = null; } else { - removeModerateBinding(connection); + removeBinding(connection); } } @@ -121,11 +124,11 @@ if (lowestRanked == mWaivedConnection) return; if (mWaivedConnection != null) { assert mConnections.contains(mWaivedConnection); - addModerateBinding(mWaivedConnection); + addBinding(mWaivedConnection); mWaivedConnection = null; } if (!mConnections.contains(lowestRanked)) return; - removeModerateBinding(lowestRanked); + removeBinding(lowestRanked); mWaivedConnection = lowestRanked; } @@ -138,7 +141,7 @@ void onSentToBackground() { assert LauncherThread.runningOnLauncherThread(); if (mConnections.isEmpty()) return; - LauncherThread.postDelayed(mDelayedClearer, MODERATE_BINDING_POOL_CLEARER_DELAY_MILLIS); + LauncherThread.postDelayed(mDelayedClearer, BINDING_POOL_CLEARER_DELAY_MILLIS); } /** Called when the embedding application is brought to foreground. */ @@ -148,29 +151,53 @@ } /** - * @return the number of moderate bindings that are the result of just BindingManager. + * @return the number of exclusive bindings that are the result of just BindingManager. */ - int getExclusiveModerateBindingCount() { - int exclusiveModerateBindingCount = 0; + int getExclusiveBindingCount() { + int exclusiveBindingCount = 0; for (ChildProcessConnection connection : mConnections) { - if (!isExclusiveModerateBinding(connection)) continue; - - exclusiveModerateBindingCount++; + if ((useNotPerceptibleBinding()) ? isExclusiveNotPerceptibleBinding(connection) + : isExclusiveVisibleBinding(connection)) { + exclusiveBindingCount++; + } } - return exclusiveModerateBindingCount; + return exclusiveBindingCount; } /** - * @param connection The connection to check if BindingManager has a moderate binding for. + * @param connection The connection to check if BindingManager has a binding for. * @return whether this BindingManager has an exclusive moderate connection. */ - boolean hasExclusiveModerateBinding(ChildProcessConnection connection) { - return mConnections.contains(connection) && isExclusiveModerateBinding(connection); + boolean hasExclusiveVisibleBinding(ChildProcessConnection connection) { + return !useNotPerceptibleBinding() && mConnections.contains(connection) + && isExclusiveVisibleBinding(connection); } - private boolean isExclusiveModerateBinding(ChildProcessConnection connection) { + @VisibleForTesting + static void resetUseNotPerceptibleBindingForTesting() { + sUseNotPerceptibleBinding = null; + } + + @VisibleForTesting + static boolean useNotPerceptibleBinding() { + if (sUseNotPerceptibleBinding == null) { + sUseNotPerceptibleBinding = ChildProcessConnection.supportNotPerceptibleBinding() + && ContentFeatureList.isEnabled( + ContentFeatures.BINDING_MANAGER_USE_NOT_PERCEPTIBLE_BINDING); + } + return sUseNotPerceptibleBinding; + } + + private boolean isExclusiveNotPerceptibleBinding(ChildProcessConnection connection) { return connection != mWaivedConnection && !connection.isStrongBindingBound() - && connection.getModerateBindingCount() == 1; + && !connection.isVisibleBindingBound() + && connection.getNotPerceptibleBindingCount() == 1; + } + + private boolean isExclusiveVisibleBinding(ChildProcessConnection connection) { + return connection != mWaivedConnection && !connection.isStrongBindingBound() + && !connection.isNotPerceptibleBindingBound() + && connection.getVisibleBindingCount() == 1; } /** @@ -200,12 +227,6 @@ @Override public void run() { Log.i(TAG, "Release moderate connections: %d", mConnections.size()); - // Tests may not load the native library which is required for - // recording histograms. - if (LibraryLoader.getInstance().isInitialized()) { - RecordHistogram.recordCount1MHistogram( - "Android.ModerateBindingCount", mConnections.size()); - } removeAllConnections(); } }; @@ -221,14 +242,14 @@ // Note that the size of connections is currently fairly small (40). // If it became bigger we should consider using an alternate data structure. boolean alreadyInQueue = !mConnections.add(connection); - if (!alreadyInQueue) addModerateBinding(connection); + if (!alreadyInQueue) addBinding(connection); assert mMaxSize == -1 || mConnections.size() <= mMaxSize; } public void removeConnection(ChildProcessConnection connection) { assert LauncherThread.runningOnLauncherThread(); boolean alreadyInQueue = mConnections.remove(connection); - if (alreadyInQueue) removeModerateBindingIfNeeded(connection); + if (alreadyInQueue) removeBindingIfNeeded(connection); assert !mConnections.contains(connection); } @@ -238,11 +259,19 @@ ensureLowestRankIsWaived(); } - private void addModerateBinding(ChildProcessConnection connection) { - connection.addModerateBinding(); + private void addBinding(ChildProcessConnection connection) { + if (useNotPerceptibleBinding()) { + connection.addNotPerceptibleBinding(); + return; + } + connection.addVisibleBinding(); } - private void removeModerateBinding(ChildProcessConnection connection) { - connection.removeModerateBinding(); + private void removeBinding(ChildProcessConnection connection) { + if (useNotPerceptibleBinding()) { + connection.removeNotPerceptibleBinding(); + return; + } + connection.removeVisibleBinding(); } }
diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionMetrics.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionMetrics.java index ba0e9e4..175b335 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionMetrics.java +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionMetrics.java
@@ -136,9 +136,9 @@ cancelEmitting(); } - private boolean bindingManagerHasExclusiveModerateBinding(ChildProcessConnection connection) { + private boolean bindingManagerHasExclusiveVisibleBinding(ChildProcessConnection connection) { if (mBindingManager != null) { - return mBindingManager.hasExclusiveModerateBinding(connection); + return mBindingManager.hasExclusiveVisibleBinding(connection); } return false; } @@ -150,37 +150,42 @@ // Binding counts from all connections. int strongBindingCount = 0; - int moderateBindingCount = 0; + int visibleBindingCount = 0; + int notPerceptibleBindingCount = 0; int waivedBindingCount = 0; - // Moderate binding from BindingManager which could be waived. + // Bindings from BindingManager which could be waived. int waivableBindingCount = 0; - // Moderate and waived connections if BindingManager didn't exist. - int contentModerateBindingCount = 0; + // Visible and waived connections if BindingManager didn't exist. + int contentVisibleBindingCount = 0; int contentWaivedBindingCount = 0; if (mBindingManager != null) { - waivableBindingCount = mBindingManager.getExclusiveModerateBindingCount(); + waivableBindingCount = mBindingManager.getExclusiveBindingCount(); } for (ChildProcessConnection connection : mConnections) { if (connection.isStrongBindingBound()) { strongBindingCount++; - } else if (connection.isModerateBindingBound()) { - moderateBindingCount++; - if (bindingManagerHasExclusiveModerateBinding(connection)) { + } else if (connection.isVisibleBindingBound()) { + visibleBindingCount++; + if (bindingManagerHasExclusiveVisibleBinding(connection)) { contentWaivedBindingCount++; } else { - contentModerateBindingCount++; + contentVisibleBindingCount++; } + } else if (connection.isNotPerceptibleBindingBound()) { + notPerceptibleBindingCount++; + contentWaivedBindingCount++; } else { waivedBindingCount++; contentWaivedBindingCount++; } } - assert strongBindingCount + moderateBindingCount + waivedBindingCount + assert strongBindingCount + visibleBindingCount + notPerceptibleBindingCount + + waivedBindingCount == mConnections.size(); final int totalConnections = mConnections.size(); @@ -193,14 +198,17 @@ RecordHistogram.recordCount100Histogram( "Android.ChildProcessBinding.StrongConnections", strongBindingCount); RecordHistogram.recordCount100Histogram( - "Android.ChildProcessBinding.ModerateConnections", moderateBindingCount); + "Android.ChildProcessBinding.VisibleConnections", visibleBindingCount); + RecordHistogram.recordCount100Histogram( + "Android.ChildProcessBinding.NotPerceptibleConnections", + notPerceptibleBindingCount); RecordHistogram.recordCount100Histogram( "Android.ChildProcessBinding.WaivedConnections", waivedBindingCount); // Metrics if BindingManager wasn't running. RecordHistogram.recordCount100Histogram( - "Android.ChildProcessBinding.ContentModerateConnections", - contentModerateBindingCount); + "Android.ChildProcessBinding.ContentVisibleConnections", + contentVisibleBindingCount); RecordHistogram.recordCount100Histogram( "Android.ChildProcessBinding.ContentWaivedConnections", contentWaivedBindingCount); RecordHistogram.recordCount100Histogram( @@ -213,15 +221,18 @@ "Android.ChildProcessBinding.PercentageStrongConnections_" + bucket, Math.round((float) strongBindingCount / totalConnections * 100)); RecordHistogram.recordPercentageHistogram( - "Android.ChildProcessBinding.PercentageModerateConnections_" + bucket, - Math.round((float) moderateBindingCount / totalConnections * 100)); + "Android.ChildProcessBinding.PercentageVisibleConnections_" + bucket, + Math.round((float) visibleBindingCount / totalConnections * 100)); + RecordHistogram.recordPercentageHistogram( + "Android.ChildProcessBinding.PercentageNotPerceptibleConnections_" + bucket, + Math.round((float) notPerceptibleBindingCount / totalConnections * 100)); RecordHistogram.recordPercentageHistogram( "Android.ChildProcessBinding.PercentageWaivedConnections_" + bucket, Math.round((float) waivedBindingCount / totalConnections * 100)); RecordHistogram.recordPercentageHistogram( - "Android.ChildProcessBinding.PercentageContentModerateConnections_" + bucket, - Math.round((float) contentModerateBindingCount / totalConnections * 100)); + "Android.ChildProcessBinding.PercentageContentVisibleConnections_" + bucket, + Math.round((float) contentVisibleBindingCount / totalConnections * 100)); RecordHistogram.recordPercentageHistogram( "Android.ChildProcessBinding.PercentageContentWaivedConnections_" + bucket, Math.round((float) contentWaivedBindingCount / totalConnections * 100));
diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncherHelperImpl.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncherHelperImpl.java index 1748f358..568c714 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncherHelperImpl.java +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncherHelperImpl.java
@@ -356,7 +356,7 @@ private long mStartTimeMs; // This is the current computed importance from all the inputs from setPriority. - // The initial value is MODERATE since a newly created connection has moderate bindings. + // The initial value is MODERATE since a newly created connection has visible bindings. private @ChildProcessImportance int mEffectiveImportance = ChildProcessImportance.MODERATE; private boolean mVisible; @@ -768,7 +768,7 @@ // Nothing to add. break; case ChildProcessImportance.MODERATE: - connection.addModerateBinding(); + connection.addVisibleBinding(); break; case ChildProcessImportance.IMPORTANT: connection.addStrongBinding(); @@ -793,7 +793,7 @@ // Nothing to remove. break; case ChildProcessImportance.MODERATE: - connection.removeModerateBinding(); + connection.removeVisibleBinding(); break; case ChildProcessImportance.IMPORTANT: connection.removeStrongBinding();
diff --git a/content/public/android/java/src/org/chromium/content/browser/GestureListenerManagerImpl.java b/content/public/android/java/src/org/chromium/content/browser/GestureListenerManagerImpl.java index 9be06fa..7d1b5af2 100644 --- a/content/public/android/java/src/org/chromium/content/browser/GestureListenerManagerImpl.java +++ b/content/public/android/java/src/org/chromium/content/browser/GestureListenerManagerImpl.java
@@ -241,7 +241,7 @@ } @CalledByNative - private void onEventAck(int event, boolean consumed) { + private void onEventAck(int event, boolean consumed, float scrollOffsetX, float scrollOffsetY) { switch (event) { case EventType.GESTURE_FLING_START: // If we're here, then |consumed| is false as otherwise #onFlingStart() would have @@ -445,7 +445,9 @@ final boolean gestureScrollInProgress = mIsGestureScrollInProgress; setGestureScrollInProgress(false); - if (gestureScrollInProgress) updateOnScrollEnd(); + if (gestureScrollInProgress) { + updateOnScrollEnd(); + } resetFlingGesture(); }
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherIntegrationTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherIntegrationTest.java index 05a38ad4..4ed72ac 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherIntegrationTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/ChildProcessLauncherIntegrationTest.java
@@ -64,7 +64,7 @@ } private static class TestChildProcessConnection extends ChildProcessConnection { - private RuntimeException mRemovedBothModerateAndStrongBinding; + private RuntimeException mRemovedBothVisibleAndStrongBinding; public TestChildProcessConnection(Context context, ComponentName serviceName, boolean bindToCaller, boolean bindAsExternalService, @@ -76,31 +76,30 @@ @Override protected void unbind() { super.unbind(); - if (mRemovedBothModerateAndStrongBinding == null) { - mRemovedBothModerateAndStrongBinding = new RuntimeException("unbind"); + if (mRemovedBothVisibleAndStrongBinding == null) { + mRemovedBothVisibleAndStrongBinding = new RuntimeException("unbind"); } } @Override - public void removeModerateBinding() { - super.removeModerateBinding(); - if (mRemovedBothModerateAndStrongBinding == null && !isStrongBindingBound()) { - mRemovedBothModerateAndStrongBinding = - new RuntimeException("removeModerateBinding"); + public void removeVisibleBinding() { + super.removeVisibleBinding(); + if (mRemovedBothVisibleAndStrongBinding == null && !isStrongBindingBound()) { + mRemovedBothVisibleAndStrongBinding = new RuntimeException("removeVisibleBinding"); } } @Override public void removeStrongBinding() { super.removeStrongBinding(); - if (mRemovedBothModerateAndStrongBinding == null && !isModerateBindingBound()) { - mRemovedBothModerateAndStrongBinding = new RuntimeException("removeStrongBinding"); + if (mRemovedBothVisibleAndStrongBinding == null && !isVisibleBindingBound()) { + mRemovedBothVisibleAndStrongBinding = new RuntimeException("removeStrongBinding"); } } - public void throwIfDroppedBothModerateAndStrongBinding() { - if (mRemovedBothModerateAndStrongBinding != null) { - throw new RuntimeException(mRemovedBothModerateAndStrongBinding); + public void throwIfDroppedBothVisibleAndStrongBinding() { + if (mRemovedBothVisibleAndStrongBinding != null) { + throw new RuntimeException(mRemovedBothVisibleAndStrongBinding); } } } @@ -133,7 +132,7 @@ @Override public void run() { Assert.assertEquals(1, connections.size()); - connections.get(0).throwIfDroppedBothModerateAndStrongBinding(); + connections.get(0).throwIfDroppedBothVisibleAndStrongBinding(); } }); @@ -148,10 +147,10 @@ // Verify that the process has not lost its importance now that the // data: URL is also in the same process as the file: URLs. Assert.assertEquals(1, connections.size()); - connections.get(0).throwIfDroppedBothModerateAndStrongBinding(); + connections.get(0).throwIfDroppedBothVisibleAndStrongBinding(); } else { Assert.assertEquals(2, connections.size()); - connections.get(1).throwIfDroppedBothModerateAndStrongBinding(); + connections.get(1).throwIfDroppedBothVisibleAndStrongBinding(); } } });
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java b/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java index c856c910..c3afb4b 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java
@@ -412,16 +412,15 @@ final ChildProcessConnection connection = getSandboxedChildProcessConnection(); // Need to poll here because there is an intentional delay for removing binding. - CriteriaHelper.pollInstrumentationThread( - () - -> ChildProcessLauncherTestUtils.runOnLauncherAndGetResult( - () -> !connection.isModerateBindingBound()), - "Failed to remove moderate binding"); + CriteriaHelper.pollInstrumentationThread(() -> { + return ChildProcessLauncherTestUtils.runOnLauncherAndGetResult( + () -> !connection.isVisibleBindingBound()); + }, "Failed to remove moderate binding"); TestThreadUtils.runOnUiThreadBlocking( () -> webContents.setImportance(ChildProcessImportance.MODERATE)); ChildProcessLauncherTestUtils.runOnLauncherThreadBlocking( - () -> Assert.assertTrue(connection.isModerateBindingBound())); + () -> Assert.assertTrue(connection.isVisibleBindingBound())); } @Test
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 0fb02fe8..8ff1c9b 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
@@ -11,6 +11,7 @@ import android.app.Activity; import android.app.Application; import android.content.ComponentName; +import android.os.Build; import android.util.Pair; import org.junit.After; @@ -23,13 +24,18 @@ 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; import org.chromium.base.test.util.Feature; +import org.chromium.content_public.common.ContentFeatures; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Unit tests for BindingManager and ChildProcessConnection. @@ -38,9 +44,16 @@ * are tested. */ @RunWith(BaseRobolectricTestRunner.class) -@Config(manifest = Config.NONE) +@Config(manifest = Config.NONE, sdk = Build.VERSION_CODES.Q) @LooperMode(LooperMode.Mode.LEGACY) public class BindingManagerTest { + private static final Map<String, Boolean> DISABLE_NOT_PERCEPTIBLE_BINDING = new HashMap<>() { + { put(ContentFeatures.BINDING_MANAGER_USE_NOT_PERCEPTIBLE_BINDING, false); } + }; + private static final Map<String, Boolean> ENABLE_NOT_PERCEPTIBLE_BINDING = new HashMap<>() { + { put(ContentFeatures.BINDING_MANAGER_USE_NOT_PERCEPTIBLE_BINDING, true); } + }; + // Creates a mocked ChildProcessConnection that is optionally added to a BindingManager. private static ChildProcessConnection createTestChildProcessConnection( int pid, BindingManager manager, List<ChildProcessConnection> iterable) { @@ -52,7 +65,7 @@ connection.start(false /* useStrongBinding */, null /* serviceCallback */); manager.addConnection(connection); iterable.add(connection); - connection.removeModerateBinding(); // Remove initial binding. + connection.removeVisibleBinding(); // Remove initial binding. return connection; } @@ -78,6 +91,37 @@ @After public void tearDown() { LauncherThread.setLauncherThreadAsLauncherThread(); + FeatureList.setTestValues(null); + } + + private void setupBindingType(boolean useNotPerceptibleBinding) { + BindingManager.resetUseNotPerceptibleBindingForTesting(); + if (useNotPerceptibleBinding) { + FeatureList.setTestFeatures(ENABLE_NOT_PERCEPTIBLE_BINDING); + boolean isQOrHigher = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; + Assert.assertEquals(isQOrHigher, BindingManager.useNotPerceptibleBinding()); + return; + } + FeatureList.setTestFeatures(DISABLE_NOT_PERCEPTIBLE_BINDING); + Assert.assertFalse(BindingManager.useNotPerceptibleBinding()); + } + + private void checkConnections(ChildProcessConnection[] connections, + boolean useNotPerceptibleBinding, boolean isConnected) { + boolean[] connected = new boolean[connections.length]; + Arrays.fill(connected, isConnected); + checkConnections(connections, useNotPerceptibleBinding, connected); + } + + private void checkConnections(ChildProcessConnection[] connections, + boolean useNotPerceptibleBinding, boolean[] connected) { + assert connections.length == connected.length; + for (int i = 0; i < connections.length; i++) { + Assert.assertEquals(!useNotPerceptibleBinding && connected[i], + connections[i].isVisibleBindingBound()); + Assert.assertEquals(useNotPerceptibleBinding && connected[i], + connections[i].isNotPerceptibleBindingBound()); + } } /** @@ -86,17 +130,33 @@ */ @Test @Feature({"ProcessManagement"}) - public void testModerateBindingDropOnBackground() { - doTestModerateBindingDropOnBackground(mManager); + public void testVisibleBindingDropOnBackground() { + setupBindingType(false); + doTestBindingDropOnBackground(mManager); } @Test @Feature({"ProcessManagement"}) - public void testModerateBindingDropOnBackgroundWithVariableSize() { - doTestModerateBindingDropOnBackground(mVariableManager); + public void testVisibleBindingDropOnBackgroundWithVariableSize() { + setupBindingType(false); + doTestBindingDropOnBackground(mVariableManager); } - private void doTestModerateBindingDropOnBackground(BindingManager manager) { + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingDropOnBackground() { + setupBindingType(true); + doTestBindingDropOnBackground(mManager); + } + + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingDropOnBackgroundWithVariableSize() { + setupBindingType(true); + doTestBindingDropOnBackground(mVariableManager); + } + + private void doTestBindingDropOnBackground(BindingManager manager) { ChildProcessConnection[] connections = new ChildProcessConnection[3]; for (int i = 0; i < connections.length; i++) { connections[i] = createTestChildProcessConnection(i + 1 /* pid */, manager, mIterable); @@ -104,40 +164,36 @@ // Verify that each connection has a moderate binding after binding and releasing a strong // binding. - for (ChildProcessConnection connection : connections) { - Assert.assertTrue(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); // Verify that leaving the application for a short time doesn't clear the moderate bindings. manager.onSentToBackground(); - for (ChildProcessConnection connection : connections) { - Assert.assertTrue(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); + manager.onBroughtToForeground(); ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); - for (ChildProcessConnection connection : connections) { - Assert.assertTrue(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); // Call onSentToBackground() and verify that all the moderate bindings drop after some // delay. manager.onSentToBackground(); - for (ChildProcessConnection connection : connections) { - Assert.assertTrue(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); + ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); - for (ChildProcessConnection connection : connections) { - Assert.assertFalse(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/false); // Call onBroughtToForeground() and verify that the previous moderate bindings aren't // recovered. manager.onBroughtToForeground(); - for (ChildProcessConnection connection : connections) { - Assert.assertFalse(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/false); } /** @@ -145,17 +201,33 @@ */ @Test @Feature({"ProcessManagement"}) - public void testModerateBindingDropOnLowMemory() { - doTestModerateBindingDropOnLowMemory(mManager); + public void testVisibleBindingDropOnLowMemory() { + setupBindingType(false); + doTestBindingDropOnLowMemory(mManager); } @Test @Feature({"ProcessManagement"}) - public void testModerateBindingDropOnLowMemoryVariableSize() { - doTestModerateBindingDropOnLowMemory(mVariableManager); + public void testVisibleBindingDropOnLowMemoryVariableSize() { + setupBindingType(false); + doTestBindingDropOnLowMemory(mVariableManager); } - private void doTestModerateBindingDropOnLowMemory(BindingManager manager) { + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingDropOnLowMemory() { + setupBindingType(true); + doTestBindingDropOnLowMemory(mManager); + } + + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingDropOnLowMemoryVariableSize() { + setupBindingType(true); + doTestBindingDropOnLowMemory(mVariableManager); + } + + private void doTestBindingDropOnLowMemory(BindingManager manager) { final Application app = mActivity.getApplication(); ChildProcessConnection[] connections = new ChildProcessConnection[4]; @@ -163,15 +235,13 @@ connections[i] = createTestChildProcessConnection(i + 1 /* pid */, manager, mIterable); } - for (ChildProcessConnection connection : connections) { - Assert.assertTrue(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); // Call onLowMemory() and verify that all the moderate bindings drop. app.onLowMemory(); - for (ChildProcessConnection connection : connections) { - Assert.assertFalse(connection.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/false); } /** @@ -179,17 +249,33 @@ */ @Test @Feature({"ProcessManagement"}) - public void testModerateBindingDropOnTrimMemory() { - doTestModerateBindingDropOnTrimMemory(mManager); + public void testVisibleBindingDropOnTrimMemory() { + setupBindingType(false); + doTestBindingDropOnTrimMemory(mManager); } @Test @Feature({"ProcessManagement"}) - public void testModerateBindingDropOnTrimMemoryWithVariableSize() { - doTestModerateBindingDropOnTrimMemory(mVariableManager); + public void testVisibleBindingDropOnTrimMemoryWithVariableSize() { + setupBindingType(false); + doTestBindingDropOnTrimMemory(mVariableManager); } - private void doTestModerateBindingDropOnTrimMemory(BindingManager manager) { + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingDropOnTrimMemory() { + setupBindingType(true); + doTestBindingDropOnTrimMemory(mManager); + } + + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingDropOnTrimMemoryWithVariableSize() { + setupBindingType(true); + doTestBindingDropOnTrimMemory(mVariableManager); + } + + private void doTestBindingDropOnTrimMemory(BindingManager manager) { final Application app = mActivity.getApplication(); // This test applies only to the moderate-binding manager. @@ -213,14 +299,18 @@ for (ChildProcessConnection connection : connections) { manager.addConnection(connection); mIterable.add(connection); - Assert.assertTrue(message, connection.isModerateBindingBound()); } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); + app.onTrimMemory(pair.first); // Verify that some of the moderate bindings have been dropped. for (int i = 0; i < connections.length; i++) { - Assert.assertEquals( - message, i >= pair.second, connections[i].isModerateBindingBound()); + Assert.assertEquals(message, i >= pair.second, + BindingManager.useNotPerceptibleBinding() + ? connections[i].isNotPerceptibleBindingBound() + : connections[i].isVisibleBindingBound()); } } } @@ -231,38 +321,74 @@ */ @Test @Feature({"ProcessManagement"}) - public void testModerateBindingTillBackgroundedSentToBackground() { - doTestModerateBindingTillBackgroundedSentToBackground(mManager); + public void testVisibleBindingTillBackgroundedSentToBackground() { + setupBindingType(false); + doTestBindingTillBackgroundedSentToBackground(mManager); } @Test @Feature({"ProcessManagement"}) - public void testModerateBindingTillBackgroundedSentToBackgroundWithVariableSize() { - doTestModerateBindingTillBackgroundedSentToBackground(mVariableManager); + public void testVisibleBindingTillBackgroundedSentToBackgroundWithVariableSize() { + setupBindingType(false); + doTestBindingTillBackgroundedSentToBackground(mVariableManager); } - private void doTestModerateBindingTillBackgroundedSentToBackground(BindingManager manager) { - ChildProcessConnection connection = createTestChildProcessConnection(0, manager, mIterable); - Assert.assertTrue(connection.isModerateBindingBound()); + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingTillBackgroundedSentToBackground() { + setupBindingType(true); + doTestBindingTillBackgroundedSentToBackground(mManager); + } + + @Test + @Feature({"ProcessManagement"}) + public void testNotPerceptibleBindingTillBackgroundedSentToBackgroundWithVariableSize() { + setupBindingType(true); + doTestBindingTillBackgroundedSentToBackground(mVariableManager); + } + + private void doTestBindingTillBackgroundedSentToBackground(BindingManager manager) { + ChildProcessConnection[] connection = new ChildProcessConnection[1]; + connection[0] = createTestChildProcessConnection(0, manager, mIterable); + checkConnections( + connection, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); manager.onSentToBackground(); ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); - Assert.assertFalse(connection.isModerateBindingBound()); + checkConnections( + connection, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/false); // Bringing Chrome to the foreground should not re-add the moderate bindings. manager.onBroughtToForeground(); - Assert.assertFalse(connection.isModerateBindingBound()); + checkConnections( + connection, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/false); } @Test @Feature({"ProcessManagement"}) - public void testOneWaivedConnection() { + public void testOneWaivedConnection_VisibleBinding() { + setupBindingType(false); testOneWaivedConnection(mManager); } @Test @Feature({"ProcessManagement"}) - public void testOneWaivedConnectionWithVariableSize() { + public void testOneWaivedConnectionWithVariableSize_VisibleBinding() { + setupBindingType(false); + testOneWaivedConnection(mVariableManager); + } + + @Test + @Feature({"ProcessManagement"}) + public void testOneWaivedConnection_NotPerceptibleBinding() { + setupBindingType(true); + testOneWaivedConnection(mManager); + } + + @Test + @Feature({"ProcessManagement"}) + public void testOneWaivedConnectionWithVariableSize_NotPerceptibleBinding() { + setupBindingType(true); testOneWaivedConnection(mVariableManager); } @@ -273,34 +399,29 @@ } // Make sure binding is added for all connections. - for (ChildProcessConnection c : connections) { - Assert.assertTrue(c.isModerateBindingBound()); - } + checkConnections( + connections, BindingManager.useNotPerceptibleBinding(), /*isConnected=*/true); // Move middle connection to be the first (ie lowest ranked). mIterable.set(0, connections[1]); mIterable.set(1, connections[0]); manager.rankingChanged(); - Assert.assertTrue(connections[0].isModerateBindingBound()); - Assert.assertFalse(connections[1].isModerateBindingBound()); - Assert.assertTrue(connections[2].isModerateBindingBound()); + checkConnections(connections, BindingManager.useNotPerceptibleBinding(), + new boolean[] {true, false, true}); // Swap back. mIterable.set(0, connections[0]); mIterable.set(1, connections[1]); manager.rankingChanged(); - Assert.assertFalse(connections[0].isModerateBindingBound()); - Assert.assertTrue(connections[1].isModerateBindingBound()); - Assert.assertTrue(connections[2].isModerateBindingBound()); + checkConnections(connections, BindingManager.useNotPerceptibleBinding(), + new boolean[] {false, true, true}); manager.removeConnection(connections[1]); - Assert.assertFalse(connections[0].isModerateBindingBound()); - Assert.assertFalse(connections[1].isModerateBindingBound()); - Assert.assertTrue(connections[2].isModerateBindingBound()); + checkConnections(connections, BindingManager.useNotPerceptibleBinding(), + new boolean[] {false, false, true}); manager.removeConnection(connections[0]); - Assert.assertFalse(connections[0].isModerateBindingBound()); - Assert.assertFalse(connections[1].isModerateBindingBound()); - Assert.assertTrue(connections[2].isModerateBindingBound()); + checkConnections(connections, BindingManager.useNotPerceptibleBinding(), + new boolean[] {false, false, true}); } }
diff --git a/content/public/android/junit/src/org/chromium/content/browser/ChildProcessConnectionMetricsUnitTest.java b/content/public/android/junit/src/org/chromium/content/browser/ChildProcessConnectionMetricsUnitTest.java index d768a2dd..0341ffc01 100644 --- a/content/public/android/junit/src/org/chromium/content/browser/ChildProcessConnectionMetricsUnitTest.java +++ b/content/public/android/junit/src/org/chromium/content/browser/ChildProcessConnectionMetricsUnitTest.java
@@ -5,29 +5,44 @@ package org.chromium.content.browser; import android.content.ComponentName; +import android.os.Build; import androidx.test.filters.SmallTest; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; import org.chromium.base.ChildBindingState; +import org.chromium.base.FeatureList; import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.UmaRecorderHolder; import org.chromium.base.process_launcher.ChildProcessConnection; import org.chromium.base.process_launcher.TestChildProcessConnection; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.content_public.common.ContentFeatures; +import java.util.HashMap; import java.util.LinkedList; +import java.util.Map; /** * Unit test for {@link ChildProcessConnectionMetrics}. */ @RunWith(BaseRobolectricTestRunner.class) +@Config(manifest = Config.NONE, sdk = Build.VERSION_CODES.Q) public class ChildProcessConnectionMetricsUnitTest { + private static final Map<String, Boolean> DISABLE_NOT_PERCEPTIBLE_BINDING = new HashMap<>() { + { put(ContentFeatures.BINDING_MANAGER_USE_NOT_PERCEPTIBLE_BINDING, false); } + }; + private static final Map<String, Boolean> ENABLE_NOT_PERCEPTIBLE_BINDING = new HashMap<>() { + { put(ContentFeatures.BINDING_MANAGER_USE_NOT_PERCEPTIBLE_BINDING, true); } + }; + private LinkedList<ChildProcessConnection> mRanking; private BindingManager mBindingManager; private ChildProcessConnectionMetrics mConnectionMetrics; @@ -42,9 +57,15 @@ mConnectionMetrics.setBindingManager(mBindingManager); } + @After + public void tearDown() { + FeatureList.setTestValues(null); + } + @Test @SmallTest public void testEmitMetricsNoConnections() { + setupBindingType(false); ChildProcessConnection connection = createMockConnection(ChildBindingState.STRONG); mConnectionMetrics.addConnection(connection); removeConnection(connection); @@ -61,10 +82,16 @@ "Android.ChildProcessBinding.PercentageStrongConnections_LessThan3Connections")); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ModerateConnections", 0)); + "Android.ChildProcessBinding.VisibleConnections", 0)); Assert.assertEquals(0, RecordHistogram.getHistogramTotalCountForTesting( - "Android.ChildProcessBinding.PercentageModerateConnections_LessThan3Connections")); + "Android.ChildProcessBinding.PercentageVisibleConnections_LessThan3Connections")); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.NotPerceptibleConnections", 0)); + Assert.assertEquals(0, + RecordHistogram.getHistogramTotalCountForTesting( + "Android.ChildProcessBinding.PercentageNotPerceptibleConnections_LessThan3Connections")); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( "Android.ChildProcessBinding.WaivedConnections", 0)); @@ -74,10 +101,10 @@ Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ContentModerateConnections", 0)); + "Android.ChildProcessBinding.ContentVisibleConnections", 0)); Assert.assertEquals(0, RecordHistogram.getHistogramTotalCountForTesting( - "Android.ChildProcessBinding.PercentageContentModerateConnections_LessThan3Connections")); + "Android.ChildProcessBinding.PercentageContentVisibleConnections_LessThan3Connections")); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( "Android.ChildProcessBinding.ContentWaivedConnections", 0)); @@ -95,16 +122,88 @@ @Test @SmallTest - public void testEmitMetrics() { + public void testEmitMetrics_BindingManagerUsesNotPerceptible() { + setupBindingType(true); mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.STRONG)); - mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.MODERATE)); + mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.VISIBLE)); + mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.WAIVED)); + mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.WAIVED)); + mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.WAIVED)); + ChildProcessConnection lowestRankingConnection = + createMockConnection(ChildBindingState.WAIVED); + mConnectionMetrics.addConnection(lowestRankingConnection); + setLowestRanking(lowestRankingConnection); + + mConnectionMetrics.emitMetrics(); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.TotalConnections", 6)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.StrongConnections", 1)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageStrongConnections_6To10Connections", + 17)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.VisibleConnections", 1)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageVisibleConnections_6To10Connections", + 17)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.NotPerceptibleConnections", 3)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageNotPerceptibleConnections_6To10Connections", + 50)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.WaivedConnections", 1)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageWaivedConnections_6To10Connections", + 17)); + + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.ContentVisibleConnections", 1)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageContentVisibleConnections_6To10Connections", + 17)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.ContentWaivedConnections", 4)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageContentWaivedConnections_6To10Connections", + 67)); + + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.WaivableConnections", 3)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageWaivableConnections_6To10Connections", + 50)); + } + + @Test + @SmallTest + public void testEmitMetrics_BindingManagerUsesVisible() { + setupBindingType(false); + mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.STRONG)); + mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.VISIBLE)); ChildProcessConnection lowestRankingConnection = createMockConnection(ChildBindingState.WAIVED); mConnectionMetrics.addConnection(lowestRankingConnection); mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.WAIVED)); mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.WAIVED)); mConnectionMetrics.addConnection(createMockConnection(ChildBindingState.WAIVED)); - setLowestRanking(lowestRankingConnection); // Now 0 moderate bindings. + setLowestRanking(lowestRankingConnection); mConnectionMetrics.emitMetrics(); @@ -120,13 +219,20 @@ 17)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ModerateConnections", 4)); + "Android.ChildProcessBinding.VisibleConnections", 4)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.PercentageModerateConnections_6To10Connections", + "Android.ChildProcessBinding.PercentageVisibleConnections_6To10Connections", 67)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.NotPerceptibleConnections", 0)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageNotPerceptibleConnections_6To10Connections", + 0)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( "Android.ChildProcessBinding.WaivedConnections", 1)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( @@ -135,10 +241,10 @@ Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ContentModerateConnections", 1)); + "Android.ChildProcessBinding.ContentVisibleConnections", 1)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.PercentageContentModerateConnections_6To10Connections", + "Android.ChildProcessBinding.PercentageContentVisibleConnections_6To10Connections", 17)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( @@ -160,11 +266,12 @@ @Test @SmallTest public void testEmitMetricsWithUpdate() { + setupBindingType(false); ChildProcessConnection lowestRankingConnection = - createMockConnection(ChildBindingState.MODERATE); + createMockConnection(ChildBindingState.VISIBLE); mConnectionMetrics.addConnection(lowestRankingConnection); ChildProcessConnection highestRankingConnection = - createMockConnection(ChildBindingState.MODERATE); + createMockConnection(ChildBindingState.VISIBLE); mConnectionMetrics.addConnection(highestRankingConnection); setLowestRanking(lowestRankingConnection); mConnectionMetrics.emitMetrics(); @@ -181,13 +288,20 @@ 0)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ModerateConnections", 2)); + "Android.ChildProcessBinding.VisibleConnections", 2)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.PercentageModerateConnections_LessThan3Connections", + "Android.ChildProcessBinding.PercentageVisibleConnections_LessThan3Connections", 100)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.NotPerceptibleConnections", 0)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageNotPerceptibleConnections_LessThan3Connections", + 0)); + Assert.assertEquals(1, + RecordHistogram.getHistogramValueCountForTesting( "Android.ChildProcessBinding.WaivedConnections", 0)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( @@ -196,10 +310,10 @@ Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ContentModerateConnections", 2)); + "Android.ChildProcessBinding.ContentVisibleConnections", 2)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.PercentageContentModerateConnections_LessThan3Connections", + "Android.ChildProcessBinding.PercentageContentVisibleConnections_LessThan3Connections", 100)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( @@ -233,11 +347,18 @@ 0)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ModerateConnections", 1)); + "Android.ChildProcessBinding.VisibleConnections", 1)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.PercentageModerateConnections_LessThan3Connections", + "Android.ChildProcessBinding.PercentageVisibleConnections_LessThan3Connections", 50)); + Assert.assertEquals(2, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.NotPerceptibleConnections", 0)); + Assert.assertEquals(2, + RecordHistogram.getHistogramValueCountForTesting( + "Android.ChildProcessBinding.PercentageNotPerceptibleConnections_LessThan3Connections", + 0)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( "Android.ChildProcessBinding.WaivedConnections", 1)); @@ -248,10 +369,10 @@ Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.ContentModerateConnections", 0)); + "Android.ChildProcessBinding.ContentVisibleConnections", 0)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( - "Android.ChildProcessBinding.PercentageContentModerateConnections_LessThan3Connections", + "Android.ChildProcessBinding.PercentageContentVisibleConnections_LessThan3Connections", 0)); Assert.assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( @@ -282,9 +403,9 @@ connection.start(/*useStrongBinding=*/false, /*serviceCallback*/ null); if (contentBindingState == ChildBindingState.STRONG) { connection.addStrongBinding(); - connection.removeModerateBinding(); + connection.removeVisibleBinding(); } else if (contentBindingState == ChildBindingState.WAIVED) { - connection.removeModerateBinding(); + connection.removeVisibleBinding(); } mBindingManager.addConnection(connection); return connection; @@ -299,10 +420,11 @@ final boolean hasContentStrongBinding = connection.isStrongBindingBound(); final boolean lowestRank = mRanking.size() == 1 && mRanking.get(0) == connection; - final boolean needsModerateBinding = contentBindingState == ChildBindingState.MODERATE; - final boolean hasContentModerateBinding = - (lowestRank && connection.isModerateBindingBound()) - || connection.getModerateBindingCount() == 2; + final boolean needsVisibleBinding = contentBindingState == ChildBindingState.VISIBLE; + final boolean hasContentVisibleBinding = + ((lowestRank || BindingManager.useNotPerceptibleBinding()) + && connection.isVisibleBindingBound()) + || connection.getVisibleBindingCount() == 2; if (needsStrongBinding && !hasContentStrongBinding) { connection.addStrongBinding(); @@ -310,10 +432,10 @@ connection.removeStrongBinding(); } - if (needsModerateBinding && !hasContentModerateBinding) { - connection.addModerateBinding(); - } else if (!needsModerateBinding && hasContentModerateBinding) { - connection.removeModerateBinding(); + if (needsVisibleBinding && !hasContentVisibleBinding) { + connection.addVisibleBinding(); + } else if (!needsVisibleBinding && hasContentVisibleBinding) { + connection.removeVisibleBinding(); } } @@ -336,4 +458,15 @@ mConnectionMetrics.removeConnection(connection); mBindingManager.removeConnection(connection); } + + private void setupBindingType(boolean useNotPerceptibleBinding) { + BindingManager.resetUseNotPerceptibleBindingForTesting(); + if (useNotPerceptibleBinding) { + FeatureList.setTestFeatures(ENABLE_NOT_PERCEPTIBLE_BINDING); + Assert.assertTrue(BindingManager.useNotPerceptibleBinding()); + return; + } + FeatureList.setTestFeatures(DISABLE_NOT_PERCEPTIBLE_BINDING); + Assert.assertFalse(BindingManager.useNotPerceptibleBinding()); + } }
diff --git a/content/public/browser/child_process_termination_info.h b/content/public/browser/child_process_termination_info.h index b857132..e74de37 100644 --- a/content/public/browser/child_process_termination_info.h +++ b/content/public/browser/child_process_termination_info.h
@@ -43,7 +43,7 @@ // the same as not having main frames. bool renderer_was_subframe = false; - // True if child service has strong or moderate binding at time of death. + // Child service binding state at time of death. base::android::ChildBindingState binding_state = base::android::ChildBindingState::UNBOUND;
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc index fd51e0c6..701aee4 100644 --- a/content/public/common/content_features.cc +++ b/content/public/common/content_features.cc
@@ -849,11 +849,6 @@ const base::Feature kWebPaymentAPICSP{"WebPaymentAPICSP", base::FEATURE_DISABLED_BY_DEFAULT}; -// Enable the basic-card payment method from the PaymentRequest API. This has -// been disabled since M100 and is soon to be removed: crbug.com/1209835. -const base::Feature kPaymentRequestBasicCard{"PaymentRequestBasicCard", - base::FEATURE_DISABLED_BY_DEFAULT}; - // Use this feature to experiment terminating a service worker when it doesn't // control any clients: https://crbug.com/1043845. const base::Feature kServiceWorkerTerminationOnNoControllee{ @@ -1204,6 +1199,12 @@ "BackgroundMediaRendererHasModerateBinding", base::FEATURE_DISABLED_BY_DEFAULT}; +// When this feature is enabled the BindingManager for non-low-end devices will +// use a not perceptible binding for background renderers on Android Q+. +const base::Feature kBindingManagerUseNotPerceptibleBinding{ + "BindingManagerUseNotPerceptibleBinding", + base::FEATURE_DISABLED_BY_DEFAULT}; + // Reduce the priority of GPU process when in background so it is more likely // to be killed first if the OS needs more memory. const base::Feature kReduceGpuPriorityOnBackground{
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h index a436c7c..f256351 100644 --- a/content/public/common/content_features.h +++ b/content/public/common/content_features.h
@@ -182,7 +182,6 @@ CONTENT_EXPORT extern const base::Feature kOriginIsolationHeader; CONTENT_EXPORT extern const base::Feature kOverscrollHistoryNavigation; CONTENT_EXPORT extern const base::Feature kWebPaymentAPICSP; -CONTENT_EXPORT extern const base::Feature kPaymentRequestBasicCard; CONTENT_EXPORT extern const base::Feature kPeriodicBackgroundSync; CONTENT_EXPORT extern const base::Feature kFeaturePolicyHeader; CONTENT_EXPORT extern const base::Feature kPepper3DImageChromium; @@ -313,6 +312,8 @@ CONTENT_EXPORT extern const base::Feature kAccessibilityPageZoom; CONTENT_EXPORT extern const base::Feature kBackgroundMediaRendererHasModerateBinding; +CONTENT_EXPORT extern const base::Feature + kBindingManagerUseNotPerceptibleBinding; CONTENT_EXPORT extern const base::Feature kReduceGpuPriorityOnBackground; CONTENT_EXPORT extern const base::Feature kOnDemandAccessibilityEvents; CONTENT_EXPORT extern const base::Feature kRequestDesktopSiteAdditions;
diff --git a/content/services/auction_worklet/BUILD.gn b/content/services/auction_worklet/BUILD.gn index 8b61840..4ff02b60 100644 --- a/content/services/auction_worklet/BUILD.gn +++ b/content/services/auction_worklet/BUILD.gn
@@ -84,6 +84,7 @@ ":protocol_sources", "//base", "//content:export", + "//content/common", "//gin", "//mojo/public/cpp/bindings", "//net", @@ -136,6 +137,7 @@ deps = [ "//base", "//base/test:test_support", + "//content/common:for_content_tests", "//gin", "//net", "//services/network:test_support",
diff --git a/content/services/auction_worklet/bidder_worklet_unittest.cc b/content/services/auction_worklet/bidder_worklet_unittest.cc index b0c6c3f..539aa1e 100644 --- a/content/services/auction_worklet/bidder_worklet_unittest.cc +++ b/content/services/auction_worklet/bidder_worklet_unittest.cc
@@ -21,6 +21,7 @@ #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "base/time/time.h" +#include "content/common/private_aggregation_features.h" #include "content/services/auction_worklet/auction_v8_helper.h" #include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom.h" #include "content/services/auction_worklet/public/mojom/private_aggregation_request.mojom.h" @@ -2870,138 +2871,6 @@ /*expected_set_priority=*/9.0); } -TEST_F(BidderWorkletTest, GenerateBidPrivateAggregationRequests) { - auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest1 = - auction_worklet::mojom::PrivateAggregationRequest::New( - content::mojom::AggregatableReportHistogramContribution::New( - /*bucket=*/123, - /*value=*/45), - content::mojom::AggregationServiceMode::kDefault); - auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest2 = - auction_worklet::mojom::PrivateAggregationRequest::New( - content::mojom::AggregatableReportHistogramContribution::New( - /*bucket=*/absl::MakeInt128(/*high=*/1, /*low=*/0), - /*value=*/1), - content::mojom::AggregationServiceMode::kDefault); - - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunGenerateBidWithJavascriptExpectingResult( - CreateGenerateBidScript( - R"({ad: "ad", bid:1, render:"https://response.test/" })", - /*extra_code=*/R"( - privateAggregation.sendHistogramReport({bucket: 123, value: 45}); - )"), - /*expected_bid=*/ - mojom::BidderWorkletBid::New( - "\"ad\"", 1, GURL("https://response.test/"), - /*ad_components=*/absl::nullopt, base::TimeDelta()), - /*expected_data_version=*/absl::nullopt, - /*expected_errors=*/{}, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - /*expected_set_priority=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // BigInt bucket - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunGenerateBidWithJavascriptExpectingResult( - CreateGenerateBidScript( - R"({ad: "ad", bid:1, render:"https://response.test/" })", - /*extra_code=*/R"( - privateAggregation.sendHistogramReport({bucket: 123n, value: 45}); - )"), - /*expected_bid=*/ - mojom::BidderWorkletBid::New( - "\"ad\"", 1, GURL("https://response.test/"), - /*ad_components=*/absl::nullopt, base::TimeDelta()), - /*expected_data_version=*/absl::nullopt, - /*expected_errors=*/{}, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - /*expected_set_priority=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // Large bucket - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest2.Clone()); - - RunGenerateBidWithJavascriptExpectingResult( - CreateGenerateBidScript( - R"({ad: "ad", bid:1, render:"https://response.test/" })", - /*extra_code=*/R"( - privateAggregation.sendHistogramReport( - {bucket: 18446744073709551616n, value: 1}); - )"), - /*expected_bid=*/ - mojom::BidderWorkletBid::New( - "\"ad\"", 1, GURL("https://response.test/"), - /*ad_components=*/absl::nullopt, base::TimeDelta()), - /*expected_data_version=*/absl::nullopt, - /*expected_errors=*/{}, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - /*expected_set_priority=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // Multiple requests - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - expected_pa_requests.push_back(kExpectedRequest2.Clone()); - - RunGenerateBidWithJavascriptExpectingResult( - CreateGenerateBidScript( - R"({ad: "ad", bid:1, render:"https://response.test/" })", - /*extra_code=*/R"( - privateAggregation.sendHistogramReport({bucket: 123, value: 45}); - privateAggregation.sendHistogramReport( - {bucket: 18446744073709551616n, value: 1}); - )"), - /*expected_bid=*/ - mojom::BidderWorkletBid::New( - "\"ad\"", 1, GURL("https://response.test/"), - /*ad_components=*/absl::nullopt, base::TimeDelta()), - /*expected_data_version=*/absl::nullopt, - /*expected_errors=*/{}, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - /*expected_set_priority=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // An unrelated exception after sendHistogramReport shouldn't block the report - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunGenerateBidWithJavascriptExpectingResult( - CreateGenerateBidScript( - R"({ad: "ad", bid:1, render:"https://response.test/" })", - /*extra_code=*/R"( - privateAggregation.sendHistogramReport({bucket: 123, value: 45}); - error; - )"), - /*expected_bid=*/mojom::BidderWorkletBidPtr(), - /*expected_data_version=*/absl::nullopt, - /*expected_errors=*/ - {"https://url.test/:6 Uncaught ReferenceError: error is not defined."}, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - /*expected_set_priority=*/absl::nullopt, - std::move(expected_pa_requests)); - } -} - TEST_F(BidderWorkletTest, ReportWin) { RunReportWinWithFunctionBodyExpectingResult( "", /*expected_report_url =*/absl::nullopt); @@ -4229,7 +4098,149 @@ "reporting url for key 'view': 'http://view.example.com/'."}); } -TEST_F(BidderWorkletTest, ReportWinPrivateAggregationRequests) { +class BidderWorkletPrivateAggregationEnabledTest : public BidderWorkletTest { + public: + BidderWorkletPrivateAggregationEnabledTest() { + scoped_feature_list_.InitAndEnableFeature(content::kPrivateAggregationApi); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +TEST_F(BidderWorkletPrivateAggregationEnabledTest, GenerateBid) { + auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest1 = + auction_worklet::mojom::PrivateAggregationRequest::New( + content::mojom::AggregatableReportHistogramContribution::New( + /*bucket=*/123, + /*value=*/45), + content::mojom::AggregationServiceMode::kDefault); + auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest2 = + auction_worklet::mojom::PrivateAggregationRequest::New( + content::mojom::AggregatableReportHistogramContribution::New( + /*bucket=*/absl::MakeInt128(/*high=*/1, /*low=*/0), + /*value=*/1), + content::mojom::AggregationServiceMode::kDefault); + + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunGenerateBidWithJavascriptExpectingResult( + CreateGenerateBidScript( + R"({ad: "ad", bid:1, render:"https://response.test/" })", + /*extra_code=*/R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + )"), + /*expected_bid=*/ + mojom::BidderWorkletBid::New( + "\"ad\"", 1, GURL("https://response.test/"), + /*ad_components=*/absl::nullopt, base::TimeDelta()), + /*expected_data_version=*/absl::nullopt, + /*expected_errors=*/{}, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + /*expected_set_priority=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // BigInt bucket + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunGenerateBidWithJavascriptExpectingResult( + CreateGenerateBidScript( + R"({ad: "ad", bid:1, render:"https://response.test/" })", + /*extra_code=*/R"( + privateAggregation.sendHistogramReport({bucket: 123n, value: 45}); + )"), + /*expected_bid=*/ + mojom::BidderWorkletBid::New( + "\"ad\"", 1, GURL("https://response.test/"), + /*ad_components=*/absl::nullopt, base::TimeDelta()), + /*expected_data_version=*/absl::nullopt, + /*expected_errors=*/{}, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + /*expected_set_priority=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // Large bucket + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest2.Clone()); + + RunGenerateBidWithJavascriptExpectingResult( + CreateGenerateBidScript( + R"({ad: "ad", bid:1, render:"https://response.test/" })", + /*extra_code=*/R"( + privateAggregation.sendHistogramReport( + {bucket: 18446744073709551616n, value: 1}); + )"), + /*expected_bid=*/ + mojom::BidderWorkletBid::New( + "\"ad\"", 1, GURL("https://response.test/"), + /*ad_components=*/absl::nullopt, base::TimeDelta()), + /*expected_data_version=*/absl::nullopt, + /*expected_errors=*/{}, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + /*expected_set_priority=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // Multiple requests + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + expected_pa_requests.push_back(kExpectedRequest2.Clone()); + + RunGenerateBidWithJavascriptExpectingResult( + CreateGenerateBidScript( + R"({ad: "ad", bid:1, render:"https://response.test/" })", + /*extra_code=*/R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + privateAggregation.sendHistogramReport( + {bucket: 18446744073709551616n, value: 1}); + )"), + /*expected_bid=*/ + mojom::BidderWorkletBid::New( + "\"ad\"", 1, GURL("https://response.test/"), + /*ad_components=*/absl::nullopt, base::TimeDelta()), + /*expected_data_version=*/absl::nullopt, + /*expected_errors=*/{}, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + /*expected_set_priority=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // An unrelated exception after sendHistogramReport shouldn't block the report + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunGenerateBidWithJavascriptExpectingResult( + CreateGenerateBidScript( + R"({ad: "ad", bid:1, render:"https://response.test/" })", + /*extra_code=*/R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + error; + )"), + /*expected_bid=*/mojom::BidderWorkletBidPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_errors=*/ + {"https://url.test/:6 Uncaught ReferenceError: error is not defined."}, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + /*expected_set_priority=*/absl::nullopt, + std::move(expected_pa_requests)); + } +} + +TEST_F(BidderWorkletPrivateAggregationEnabledTest, ReportWin) { auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest1 = auction_worklet::mojom::PrivateAggregationRequest::New( content::mojom::AggregatableReportHistogramContribution::New( @@ -4320,5 +4331,45 @@ } } +class BidderWorkletPrivateAggregationDisabledTest : public BidderWorkletTest { + public: + BidderWorkletPrivateAggregationDisabledTest() { + scoped_feature_list_.InitAndDisableFeature(content::kPrivateAggregationApi); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +TEST_F(BidderWorkletPrivateAggregationDisabledTest, GenerateBid) { + RunGenerateBidWithJavascriptExpectingResult( + CreateGenerateBidScript( + R"({ad: "ad", bid:1, render:"https://response.test/" })", + /*extra_code=*/R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + )"), + /*expected_bid=*/mojom::BidderWorkletBidPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_errors=*/ + {"https://url.test/:5 Uncaught ReferenceError: privateAggregation is not " + "defined."}, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + /*expected_set_priority=*/absl::nullopt, + /*expected_pa_requests=*/{}); +} + +TEST_F(BidderWorkletPrivateAggregationDisabledTest, ReportWin) { + RunReportWinWithFunctionBodyExpectingResult( + R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + )", + /*expected_report_url =*/absl::nullopt, + /*expected_ad_beacon_map=*/{}, /*expected_pa_requests=*/{}, + /*expected_errors=*/ + {"https://url.test/:11 Uncaught ReferenceError: privateAggregation is " + "not defined."}); +} + } // namespace } // namespace auction_worklet
diff --git a/content/services/auction_worklet/context_recycler_unittest.cc b/content/services/auction_worklet/context_recycler_unittest.cc index 660bec5..3503108 100644 --- a/content/services/auction_worklet/context_recycler_unittest.cc +++ b/content/services/auction_worklet/context_recycler_unittest.cc
@@ -15,6 +15,7 @@ #include "base/threading/thread_task_runner_handle.h" #include "content/common/aggregatable_report.mojom-shared.h" #include "content/common/aggregatable_report.mojom.h" +#include "content/common/private_aggregation_features.h" #include "content/services/auction_worklet/auction_v8_helper.h" #include "content/services/auction_worklet/for_debugging_only_bindings.h" #include "content/services/auction_worklet/private_aggregation_bindings.h" @@ -511,8 +512,20 @@ } } +class ContextRecyclerPrivateAggregationEnabledTest + : public ContextRecyclerTest { + public: + ContextRecyclerPrivateAggregationEnabledTest() { + scoped_feature_list_.InitAndEnableFeature(content::kPrivateAggregationApi); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + // Exercise PrivateAggregationBindings, and make sure they reset properly. -TEST_F(ContextRecyclerTest, PrivateAggregationBindings) { +TEST_F(ContextRecyclerPrivateAggregationEnabledTest, + PrivateAggregationBindings) { using PrivateAggregationRequests = std::vector<auction_worklet::mojom::PrivateAggregationRequestPtr>; @@ -861,4 +874,55 @@ } } +class ContextRecyclerPrivateAggregationDisabledTest + : public ContextRecyclerTest { + public: + ContextRecyclerPrivateAggregationDisabledTest() { + scoped_feature_list_.InitAndDisableFeature(content::kPrivateAggregationApi); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +// Exercise PrivateAggregationBindings, and make sure they reset properly. +TEST_F(ContextRecyclerPrivateAggregationDisabledTest, + PrivateAggregationBindings) { + using PrivateAggregationRequests = + std::vector<auction_worklet::mojom::PrivateAggregationRequestPtr>; + + const char kScript[] = R"( + function test(args) { + privateAggregation.sendHistogramReport(args); + } + )"; + + v8::Local<v8::UnboundScript> script = Compile(kScript); + ASSERT_FALSE(script.IsEmpty()); + + ContextRecycler context_recycler(helper_.get()); + context_recycler.AddPrivateAggregationBindings(); + + { + ContextRecyclerScope scope(context_recycler); + std::vector<std::string> error_msgs; + + gin::Dictionary dict = gin::Dictionary::CreateEmpty(helper_->isolate()); + dict.Set("bucket", 123); + dict.Set("value", 45); + + Run(scope, script, "test", error_msgs, + gin::ConvertToV8(helper_->isolate(), dict)); + EXPECT_THAT( + error_msgs, + ElementsAre("https://example.org/script.js:3 Uncaught ReferenceError: " + "privateAggregation is not defined.")); + + PrivateAggregationRequests pa_requests = + context_recycler.private_aggregation_bindings() + ->TakePrivateAggregationRequests(); + ASSERT_TRUE(pa_requests.empty()); + } +} + } // namespace auction_worklet
diff --git a/content/services/auction_worklet/private_aggregation_bindings.cc b/content/services/auction_worklet/private_aggregation_bindings.cc index 3b1694d..e1e50e1 100644 --- a/content/services/auction_worklet/private_aggregation_bindings.cc +++ b/content/services/auction_worklet/private_aggregation_bindings.cc
@@ -10,8 +10,10 @@ #include <string> #include <utility> +#include "base/feature_list.h" #include "base/strings/string_util.h" #include "content/common/aggregatable_report.mojom.h" +#include "content/common/private_aggregation_features.h" #include "content/services/auction_worklet/auction_v8_helper.h" #include "content/services/auction_worklet/public/mojom/private_aggregation_request.mojom.h" #include "gin/converter.h" @@ -78,6 +80,10 @@ void PrivateAggregationBindings::FillInGlobalTemplate( v8::Local<v8::ObjectTemplate> global_template) { + if (!base::FeatureList::IsEnabled(content::kPrivateAggregationApi)) { + return; + } + v8::Local<v8::External> v8_this = v8::External::New(v8_helper_->isolate(), this);
diff --git a/content/services/auction_worklet/seller_worklet_unittest.cc b/content/services/auction_worklet/seller_worklet_unittest.cc index 5c743df8..88801f2 100644 --- a/content/services/auction_worklet/seller_worklet_unittest.cc +++ b/content/services/auction_worklet/seller_worklet_unittest.cc
@@ -18,6 +18,7 @@ #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "base/time/time.h" +#include "content/common/private_aggregation_features.h" #include "content/services/auction_worklet/auction_v8_helper.h" #include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom.h" #include "content/services/auction_worklet/worklet_devtools_debug_test_util.h" @@ -1570,110 +1571,6 @@ run_loop.Run(); } -TEST_F(SellerWorkletTest, ScoreAdPrivateAggregationRequests) { - auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest1 = - auction_worklet::mojom::PrivateAggregationRequest::New( - content::mojom::AggregatableReportHistogramContribution::New( - /*bucket=*/123, - /*value=*/45), - content::mojom::AggregationServiceMode::kDefault); - auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest2 = - auction_worklet::mojom::PrivateAggregationRequest::New( - content::mojom::AggregatableReportHistogramContribution::New( - /*bucket=*/absl::MakeInt128(/*high=*/1, /*low=*/0), - /*value=*/1), - content::mojom::AggregationServiceMode::kDefault); - - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunScoreAdWithJavascriptExpectingResult( - CreateScoreAdScript( - "5", - "privateAggregation.sendHistogramReport({bucket: 123, value: 45})"), - 5, /*expected_errors=*/{}, - mojom::ComponentAuctionModifiedBidParamsPtr(), - /*expected_data_version=*/absl::nullopt, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // BigInt bucket - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunScoreAdWithJavascriptExpectingResult( - CreateScoreAdScript("5", - "privateAggregation.sendHistogramReport(" - "{bucket: 123n, value: 45})"), - 5, /*expected_errors=*/{}, - mojom::ComponentAuctionModifiedBidParamsPtr(), - /*expected_data_version=*/absl::nullopt, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // Large bucket - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest2.Clone()); - - RunScoreAdWithJavascriptExpectingResult( - CreateScoreAdScript("5", - "privateAggregation.sendHistogramReport(" - "{bucket: 18446744073709551616n, value: 1})"), - 5, /*expected_errors=*/{}, - mojom::ComponentAuctionModifiedBidParamsPtr(), - /*expected_data_version=*/absl::nullopt, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // Multiple requests - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - expected_pa_requests.push_back(kExpectedRequest2.Clone()); - - RunScoreAdWithJavascriptExpectingResult( - CreateScoreAdScript("5", R"( - privateAggregation.sendHistogramReport({bucket: 123, value: 45}); - privateAggregation.sendHistogramReport({bucket: 18446744073709551616n, - value: 1}); - )"), - 5, /*expected_errors=*/{}, - mojom::ComponentAuctionModifiedBidParamsPtr(), - /*expected_data_version=*/absl::nullopt, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - std::move(expected_pa_requests)); - } - - // An unrelated exception after sendHistogramReport shouldn't block the report - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunScoreAdWithJavascriptExpectingResult( - CreateScoreAdScript("5", R"( - privateAggregation.sendHistogramReport({bucket: 123, value: 45}); - error; - )"), - 0, /*expected_errors=*/ - {"https://url.test/:6 Uncaught ReferenceError: error is not defined."}, - mojom::ComponentAuctionModifiedBidParamsPtr(), - /*expected_data_version=*/absl::nullopt, - /*expected_debug_loss_report_url=*/absl::nullopt, - /*expected_debug_win_report_url=*/absl::nullopt, - std::move(expected_pa_requests)); - } -} - // Test multiple ReportWin() calls on a single worklet, in parallel. Do this // twice, once before the worklet has loaded its Javascript, and once after, to // make sure both cases work. @@ -2187,101 +2084,6 @@ "reporting url for key 'view': 'http://view.example.com/'."}); } -TEST_F(SellerWorkletTest, ReportResultPrivateAggregationRequests) { - auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest1 = - auction_worklet::mojom::PrivateAggregationRequest::New( - content::mojom::AggregatableReportHistogramContribution::New( - /*bucket=*/123, - /*value=*/45), - content::mojom::AggregationServiceMode::kDefault); - auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest2 = - auction_worklet::mojom::PrivateAggregationRequest::New( - content::mojom::AggregatableReportHistogramContribution::New( - /*bucket=*/absl::MakeInt128(/*high=*/1, /*low=*/0), - /*value=*/1), - content::mojom::AggregationServiceMode::kDefault); - - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunReportResultCreatedScriptExpectingResult( - R"(5)", - R"(privateAggregation.sendHistogramReport({bucket: 123, value: 45});)", - /*expected_signals_for_winner=*/"5", - /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, - std::move(expected_pa_requests), - /*expected_errors=*/{}); - } - - // BigInt bucket - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunReportResultCreatedScriptExpectingResult( - R"(5)", - R"(privateAggregation.sendHistogramReport({bucket: 123n, value: 45});)", - /*expected_signals_for_winner=*/"5", - /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, - std::move(expected_pa_requests), - /*expected_errors=*/{}); - } - - // Large bucket - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest2.Clone()); - - RunReportResultCreatedScriptExpectingResult( - R"(5)", - R"(privateAggregation.sendHistogramReport( - {bucket: 18446744073709551616n, value: 1});)", - /*expected_signals_for_winner=*/"5", - /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, - std::move(expected_pa_requests), - /*expected_errors=*/{}); - } - - // Multiple requests - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - expected_pa_requests.push_back(kExpectedRequest2.Clone()); - - RunReportResultCreatedScriptExpectingResult( - R"(5)", - R"( - privateAggregation.sendHistogramReport({bucket: 123, value: 45}); - privateAggregation.sendHistogramReport({bucket: 18446744073709551616n, - value: 1}); - )", - /*expected_signals_for_winner=*/"5", - /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, - std::move(expected_pa_requests), - /*expected_errors=*/{}); - } - - // An unrelated exception after sendHistogramReport shouldn't block the report - { - PrivateAggregationRequests expected_pa_requests; - expected_pa_requests.push_back(kExpectedRequest1.Clone()); - - RunReportResultCreatedScriptExpectingResult( - R"(5)", - R"( - privateAggregation.sendHistogramReport({bucket: 123, value: 45}); - error; - )", - /*expected_signals_for_winner=*/absl::nullopt, - /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, - std::move(expected_pa_requests), - /*expected_errors=*/ - {"https://url.test/:11 Uncaught ReferenceError: error is not " - "defined."}); - } -} - TEST_F(SellerWorkletTest, ReportResultBid) { bid_ = 5; RunReportResultCreatedScriptExpectingResult( @@ -3458,5 +3260,251 @@ } } +class SellerWorkletPrivateAggregationEnabledTest : public SellerWorkletTest { + public: + SellerWorkletPrivateAggregationEnabledTest() { + scoped_feature_list_.InitAndEnableFeature(content::kPrivateAggregationApi); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +TEST_F(SellerWorkletPrivateAggregationEnabledTest, ScoreAd) { + auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest1 = + auction_worklet::mojom::PrivateAggregationRequest::New( + content::mojom::AggregatableReportHistogramContribution::New( + /*bucket=*/123, + /*value=*/45), + content::mojom::AggregationServiceMode::kDefault); + auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest2 = + auction_worklet::mojom::PrivateAggregationRequest::New( + content::mojom::AggregatableReportHistogramContribution::New( + /*bucket=*/absl::MakeInt128(/*high=*/1, /*low=*/0), + /*value=*/1), + content::mojom::AggregationServiceMode::kDefault); + + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunScoreAdWithJavascriptExpectingResult( + CreateScoreAdScript( + "5", + "privateAggregation.sendHistogramReport({bucket: 123, value: 45})"), + 5, /*expected_errors=*/{}, + mojom::ComponentAuctionModifiedBidParamsPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // BigInt bucket + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunScoreAdWithJavascriptExpectingResult( + CreateScoreAdScript("5", + "privateAggregation.sendHistogramReport(" + "{bucket: 123n, value: 45})"), + 5, /*expected_errors=*/{}, + mojom::ComponentAuctionModifiedBidParamsPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // Large bucket + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest2.Clone()); + + RunScoreAdWithJavascriptExpectingResult( + CreateScoreAdScript("5", + "privateAggregation.sendHistogramReport(" + "{bucket: 18446744073709551616n, value: 1})"), + 5, /*expected_errors=*/{}, + mojom::ComponentAuctionModifiedBidParamsPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // Multiple requests + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + expected_pa_requests.push_back(kExpectedRequest2.Clone()); + + RunScoreAdWithJavascriptExpectingResult( + CreateScoreAdScript("5", R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + privateAggregation.sendHistogramReport({bucket: 18446744073709551616n, + value: 1}); + )"), + 5, /*expected_errors=*/{}, + mojom::ComponentAuctionModifiedBidParamsPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + std::move(expected_pa_requests)); + } + + // An unrelated exception after sendHistogramReport shouldn't block the report + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunScoreAdWithJavascriptExpectingResult( + CreateScoreAdScript("5", R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + error; + )"), + 0, /*expected_errors=*/ + {"https://url.test/:6 Uncaught ReferenceError: error is not defined."}, + mojom::ComponentAuctionModifiedBidParamsPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + std::move(expected_pa_requests)); + } +} + +TEST_F(SellerWorkletPrivateAggregationEnabledTest, ReportResult) { + auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest1 = + auction_worklet::mojom::PrivateAggregationRequest::New( + content::mojom::AggregatableReportHistogramContribution::New( + /*bucket=*/123, + /*value=*/45), + content::mojom::AggregationServiceMode::kDefault); + auction_worklet::mojom::PrivateAggregationRequestPtr kExpectedRequest2 = + auction_worklet::mojom::PrivateAggregationRequest::New( + content::mojom::AggregatableReportHistogramContribution::New( + /*bucket=*/absl::MakeInt128(/*high=*/1, /*low=*/0), + /*value=*/1), + content::mojom::AggregationServiceMode::kDefault); + + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunReportResultCreatedScriptExpectingResult( + R"(5)", + R"(privateAggregation.sendHistogramReport({bucket: 123, value: 45});)", + /*expected_signals_for_winner=*/"5", + /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, + std::move(expected_pa_requests), + /*expected_errors=*/{}); + } + + // BigInt bucket + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunReportResultCreatedScriptExpectingResult( + R"(5)", + R"(privateAggregation.sendHistogramReport({bucket: 123n, value: 45});)", + /*expected_signals_for_winner=*/"5", + /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, + std::move(expected_pa_requests), + /*expected_errors=*/{}); + } + + // Large bucket + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest2.Clone()); + + RunReportResultCreatedScriptExpectingResult( + R"(5)", + R"(privateAggregation.sendHistogramReport( + {bucket: 18446744073709551616n, value: 1});)", + /*expected_signals_for_winner=*/"5", + /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, + std::move(expected_pa_requests), + /*expected_errors=*/{}); + } + + // Multiple requests + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + expected_pa_requests.push_back(kExpectedRequest2.Clone()); + + RunReportResultCreatedScriptExpectingResult( + R"(5)", + R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + privateAggregation.sendHistogramReport({bucket: 18446744073709551616n, + value: 1}); + )", + /*expected_signals_for_winner=*/"5", + /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, + std::move(expected_pa_requests), + /*expected_errors=*/{}); + } + + // An unrelated exception after sendHistogramReport shouldn't block the report + { + PrivateAggregationRequests expected_pa_requests; + expected_pa_requests.push_back(kExpectedRequest1.Clone()); + + RunReportResultCreatedScriptExpectingResult( + R"(5)", + R"( + privateAggregation.sendHistogramReport({bucket: 123, value: 45}); + error; + )", + /*expected_signals_for_winner=*/absl::nullopt, + /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, + std::move(expected_pa_requests), + /*expected_errors=*/ + {"https://url.test/:11 Uncaught ReferenceError: error is not " + "defined."}); + } +} + +class SellerWorkletPrivateAggregationDisabledTest : public SellerWorkletTest { + public: + SellerWorkletPrivateAggregationDisabledTest() { + scoped_feature_list_.InitAndDisableFeature(content::kPrivateAggregationApi); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +TEST_F(SellerWorkletPrivateAggregationDisabledTest, ScoreAd) { + RunScoreAdWithJavascriptExpectingResult( + CreateScoreAdScript( + "5", + "privateAggregation.sendHistogramReport({bucket: 123, value: 45})"), + 0, /*expected_errors=*/ + {"https://url.test/:4 Uncaught ReferenceError: privateAggregation is not " + "defined."}, + mojom::ComponentAuctionModifiedBidParamsPtr(), + /*expected_data_version=*/absl::nullopt, + /*expected_debug_loss_report_url=*/absl::nullopt, + /*expected_debug_win_report_url=*/absl::nullopt, + /*expected_pa_requests=*/{}); +} + +TEST_F(SellerWorkletPrivateAggregationDisabledTest, ReportResult) { + RunReportResultCreatedScriptExpectingResult( + R"(5)", + R"(privateAggregation.sendHistogramReport({bucket: 123, value: 45});)", + /*expected_signals_for_winner=*/absl::nullopt, + /*expected_report_url=*/absl::nullopt, /*expected_ad_beacon_map=*/{}, + /*expected_pa_requests=*/{}, + /*expected_errors=*/ + {"https://url.test/:9 Uncaught ReferenceError: privateAggregation is " + "not defined."}); +} + } // namespace } // namespace auction_worklet
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 2d69b03..1fee445 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -862,9 +862,6 @@ data_deps = [ ":telemetry_gpu_integration_test_data", - # For WebGPU CTS tests. - "//third_party/dawn/webgpu-cts", - # For anything using Skia Gold (pixel, maps). "//ui/base:goldctl", ] @@ -894,6 +891,10 @@ "//content/test/gpu/gpu_project_config.py", "//content/test/gpu/run_gpu_integration_test.py", ] + data_deps = [ + # For WebGPU CTS tests. + "//third_party/dawn/webgpu-cts", + ] } group("telemetry_gpu_unittest_data") {
diff --git a/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py b/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py index 27c92cc..1ea0315 100644 --- a/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py +++ b/content/test/gpu/gpu_tests/webgpu_cts_integration_test.py
@@ -7,9 +7,7 @@ import json import logging import os -import subprocess import sys -import tempfile import threading from typing import Any, Dict, List import unittest @@ -24,8 +22,9 @@ EXPECTATIONS_FILE = os.path.join(gpu_path_util.CHROMIUM_SRC_DIR, 'third_party', 'dawn', 'webgpu-cts', 'expectations.txt') -LIST_SCRIPT = os.path.join(gpu_path_util.CHROMIUM_SRC_DIR, 'third_party', - 'dawn', 'webgpu-cts', 'scripts', 'list.py') +TEST_LIST_FILE = os.path.join(gpu_path_util.CHROMIUM_SRC_DIR, 'third_party', + 'dawn', 'third_party', 'gn', 'webgpu-cts', + 'test_list.txt') WORKER_TEST_GLOB_FILE = os.path.join(gpu_path_util.CHROMIUM_SRC_DIR, 'third_party', 'dawn', 'webgpu-cts', 'worker_test_globs.txt') @@ -104,7 +103,6 @@ _build_dir = None - _typescript_tempdir = tempfile.TemporaryDirectory() _test_list = None _worker_test_globs = None @@ -254,20 +252,13 @@ def GenerateGpuTests(cls, options: ct.ParsedCmdArgs) -> ct.TestGenerator: cls.SetClassVariablesFromOptions(options) if cls._test_list is None: - p = subprocess.run([ - sys.executable, LIST_SCRIPT, '--js-out-dir', - cls._typescript_tempdir.name - ], - stdout=subprocess.PIPE, - check=True) - cls._test_list = p.stdout.decode('utf-8').splitlines() + with open(TEST_LIST_FILE) as f: + cls._test_list = [l for l in f.read().splitlines() if l] if cls._worker_test_globs is None: with open(WORKER_TEST_GLOB_FILE) as f: contents = f.read() cls._worker_test_globs = [l for l in contents.splitlines() if l] for line in cls._test_list: # pylint:disable=not-an-iterable - if not line: - continue test_inputs = [line, False] for wg in cls._worker_test_globs: # pylint:disable=not-an-iterable if fnmatch.fnmatch(line, wg): @@ -373,31 +364,6 @@ elif response_type == MESSAGE_TYPE_TEST_FINISHED: VerifyMessageOrderTestFinished(message_state) - # TODO(crbug.com/1340602): Remove log, etc. once the Dawn code has - # been updated to send multiple message types. - if 's' in response: - result.status = response['s'] - if 'l' in response: - result.log_pieces.append(response['l']) - if 'js_duration_ms' in response: - js_duration = response['js_duration_ms'] / 1000 - # Specify the precision to avoid scientific notation. Nanoseconds - # should be more precision than we need anyways. - self.additionalTags[JAVASCRIPT_DURATION] = '%.9fs' % js_duration - - if 'final' in response: - is_final_payload = response['final'] - # Get multiple log pieces if necessary, e.g. if a monolithic log - # would have gone over the max payload size. - while not is_final_payload: - future = asyncio.run_coroutine_threadsafe( - asyncio.wait_for(WebGpuCtsIntegrationTest.websocket.recv(), - MULTI_PAYLOAD_TIMEOUT), - WebGpuCtsIntegrationTest.event_loop) - response = future.result() - response = json.loads(response) - result.log_pieces.append(response['l']) - is_final_payload = response['final'] break else: @@ -567,9 +533,9 @@ message_state: A map from message type to a boolean denoting whether a message of that type has been received before. """ - # TODO(crbug.com/1340602): Add message state verification once the Dawn code - # has been updated to send multiple message types. - del message_state # currently unused + if not message_state[MESSAGE_TYPE_TEST_LOG]: + raise WebGpuMessageProtocolError( + 'Received finish message before log message') def TestNameFromInputs(query: str, worker: bool) -> str:
diff --git a/content/test/mock_widget_input_handler.cc b/content/test/mock_widget_input_handler.cc index 5f625b00..99868b2c 100644 --- a/content/test/mock_widget_input_handler.cc +++ b/content/test/mock_widget_input_handler.cc
@@ -228,9 +228,10 @@ MockWidgetInputHandler::DispatchedEventMessage::~DispatchedEventMessage() { if (callback_) { - std::move(callback_).Run( - blink::mojom::InputEventResultSource::kUnknown, ui::LatencyInfo(), - blink::mojom::InputEventResultState::kNotConsumed, nullptr, nullptr); + std::move(callback_).Run(blink::mojom::InputEventResultSource::kUnknown, + ui::LatencyInfo(), + blink::mojom::InputEventResultState::kNotConsumed, + nullptr, nullptr, nullptr); base::RunLoop().RunUntilIdle(); } } @@ -244,7 +245,8 @@ blink::mojom::InputEventResultState state) { if (callback_) { std::move(callback_).Run(blink::mojom::InputEventResultSource::kMainThread, - ui::LatencyInfo(), state, nullptr, nullptr); + ui::LatencyInfo(), state, nullptr, nullptr, + nullptr); base::RunLoop().RunUntilIdle(); } } @@ -254,10 +256,12 @@ const ui::LatencyInfo& latency_info, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action) { + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data) { if (callback_) { std::move(callback_).Run(source, latency_info, state, std::move(overscroll), - std::move(touch_action)); + std::move(touch_action), + std::move(scroll_result_data)); base::RunLoop().RunUntilIdle(); } }
diff --git a/content/test/mock_widget_input_handler.h b/content/test/mock_widget_input_handler.h index 62cf928..1d66346 100644 --- a/content/test/mock_widget_input_handler.h +++ b/content/test/mock_widget_input_handler.h
@@ -178,7 +178,8 @@ const ui::LatencyInfo& latency_info, blink::mojom::InputEventResultState state, blink::mojom::DidOverscrollParamsPtr overscroll, - blink::mojom::TouchActionOptionalPtr touch_action); + blink::mojom::TouchActionOptionalPtr touch_action, + blink::mojom::ScrollResultDataPtr scroll_result_data); // Return if the callback is set. bool HasCallback() const;
diff --git a/content/test/test_aggregation_service_impl.cc b/content/test/test_aggregation_service_impl.cc index f9189d0..6a7bee1 100644 --- a/content/test/test_aggregation_service_impl.cc +++ b/content/test/test_aggregation_service_impl.cc
@@ -55,6 +55,7 @@ void HandleAggregatableReportCallback( base::OnceCallback<void(base::Value::Dict)> callback, + AggregatableReportRequest, absl::optional<AggregatableReport> report, AggregatableReportAssembler::AssemblyStatus status) { if (!report.has_value()) {
diff --git a/docs/speed/metrics_changelog/2021_11_cls.md b/docs/speed/metrics_changelog/2021_11_cls.md index ccb2c7a9..4ae8be3 100644 --- a/docs/speed/metrics_changelog/2021_11_cls.md +++ b/docs/speed/metrics_changelog/2021_11_cls.md
@@ -3,19 +3,22 @@ ### Record CLS value at the first OnHidden in addition to tab close in UKM -The cumulative layout shift score will be recorded the first time a page moves +The Cumulative Layout Shift score will be recorded the first time a page moves from the foreground to the background, which can fill in for the layout shift values that are not able to be recorded at tab close, the current CLS reporting -point. [Source code for this change] -(https://chromium-review.googlesource.com/c/chromium/src/+/3251379). +point. +[Source code for this change](https://chromium-review.googlesource.com/c/chromium/src/+/3251379). ## How does this affect a site's metrics? -There should be an increase of reporting the cumulative layout shift value on +There should be an increase of reporting the Cumulative Layout Shift value on desktop sites which have FCP values. +Note this only affects UKM (and so CrUX) reporting of CLS and does not affect +PerformanceObserver observations as measured in JavaScript. + ## When were users affected? The updated metric was added in Chrome 98 which we released in the week of -February 1, 2022. The CrUX report will include this update starting with CrUX +February 1, 2022. The CrUX report included this update starting with CrUX BigQuery 202207 (August 9, 2022). \ No newline at end of file
diff --git a/docs/webapps/integration-testing-framework.md b/docs/webapps/integration-testing-framework.md index 54080b57..56034d1 100644 --- a/docs/webapps/integration-testing-framework.md +++ b/docs/webapps/integration-testing-framework.md
@@ -59,6 +59,8 @@ To accept arguments, list the argument [types][cuj-enums-sheet] you wish to accept in the "Argument Types" column in the actions [file][cuj-actions-sheet]. If an required argument type does not exist, please add it to that [file][cuj-enums-sheet]. +When a test specified as action with arguments, it can also specify `ArgType::All`, which will create a separate test for every possible value of that argument. + To allow for future de-parsing of modes (when generating C++ tests), modes will always be PascalCase. ##### Default argument values @@ -246,6 +248,8 @@ The templates also support [parameterizing](#parameterized-action) an action, which causes any test that uses the action to be expanded into multiple tests, one per specified output action. Arguments carry over into the output action by using bash-style string replacement of argument values. If an output action doesn't support a given argument value then that parameterization is simply excluded during test generation. +Similarly, the templates support specifying `ArgType::All` as an argument, signifying that the test can be expanded into multiple tests, one for each argument value. This is also supported in the parameterized actions field. + To see any "skipped" parameterized output functions, please run the script with the `-v` option to see the log. #### Default Values
diff --git a/gpu/command_buffer/service/shared_image/compound_image_backing.cc b/gpu/command_buffer/service/shared_image/compound_image_backing.cc index f5f135f..470930c 100644 --- a/gpu/command_buffer/service/shared_image/compound_image_backing.cc +++ b/gpu/command_buffer/service/shared_image/compound_image_backing.cc
@@ -306,17 +306,19 @@ } auto shm_backing = std::make_unique<SharedMemoryImageBacking>( - gpu::Mailbox(), format, size, color_space, surface_origin, alpha_type, + mailbox, format, size, color_space, surface_origin, alpha_type, SHARED_IMAGE_USAGE_CPU_WRITE, std::move(shm_wrapper)); + shm_backing->SetNotReferencedCounted(); auto gpu_backing = gpu_backing_factory->CreateSharedImage( - gpu::Mailbox(), format, surface_handle, size, color_space, surface_origin, + mailbox, format, surface_handle, size, color_space, surface_origin, alpha_type, usage | SHARED_IMAGE_USAGE_CPU_UPLOAD, /*is_thread_safe=*/false); if (!gpu_backing) { DLOG(ERROR) << "Failed to create GPU backing"; return nullptr; } + gpu_backing->SetNotReferencedCounted(); return std::make_unique<CompoundImageBacking>( mailbox, format, size, color_space, surface_origin, alpha_type, usage,
diff --git a/gpu/command_buffer/service/shared_image/gl_image_backing_factory.cc b/gpu/command_buffer/service/shared_image/gl_image_backing_factory.cc index ce485b2..46e193f 100644 --- a/gpu/command_buffer/service/shared_image/gl_image_backing_factory.cc +++ b/gpu/command_buffer/service/shared_image/gl_image_backing_factory.cc
@@ -21,7 +21,6 @@ #include "ui/gfx/color_space.h" #include "ui/gfx/geometry/size.h" #include "ui/gl/buffer_format_utils.h" -#include "ui/gl/gl_image_shared_memory.h" #include "ui/gl/progress_reporter.h" namespace gpu { @@ -41,14 +40,12 @@ const GpuDriverBugWorkarounds& workarounds, const gles2::FeatureInfo* feature_info, ImageFactory* image_factory, - gl::ProgressReporter* progress_reporter, - const bool for_shared_memory_gmbs) + gl::ProgressReporter* progress_reporter) : GLCommonImageBackingFactory(gpu_preferences, workarounds, feature_info, progress_reporter), - image_factory_(image_factory), - for_shared_memory_gmbs_(for_shared_memory_gmbs) { + image_factory_(image_factory) { gpu_memory_buffer_formats_ = feature_info->feature_flags().gpu_memory_buffer_formats; // Return if scanout images are not supported @@ -153,10 +150,8 @@ return nullptr; } - const gfx::GpuMemoryBufferType handle_type = handle.type; GLenum target = - (handle_type == gfx::SHARED_MEMORY_BUFFER || - !NativeBufferNeedsPlatformSpecificTextureTarget(buffer_format, plane)) + !NativeBufferNeedsPlatformSpecificTextureTarget(buffer_format, plane) ? GL_TEXTURE_2D : gpu::GetPlatformSpecificTextureTarget(); scoped_refptr<gl::GLImage> image = @@ -181,8 +176,8 @@ texture_2d_support = (gpu::GetPlatformSpecificTextureTarget() == GL_TEXTURE_2D); #endif // BUILDFLAG(IS_MAC) - DCHECK(handle_type == gfx::SHARED_MEMORY_BUFFER || target != GL_TEXTURE_2D || - texture_2d_support || image->ShouldBindOrCopy() == gl::GLImage::BIND); + DCHECK(target != GL_TEXTURE_2D || texture_2d_support || + image->ShouldBindOrCopy() == gl::GLImage::BIND); #endif // DCHECK_IS_ON() if (usage & SHARED_IMAGE_USAGE_MACOS_VIDEO_TOOLBOX) image->DisableInUseByWindowServer(); @@ -221,20 +216,6 @@ gfx::BufferPlane plane, SurfaceHandle surface_handle, const gfx::Size& size) { - if (handle.type == gfx::SHARED_MEMORY_BUFFER) { - if (plane != gfx::BufferPlane::DEFAULT) - return nullptr; - auto image = base::MakeRefCounted<gl::GLImageSharedMemory>(size); - if (color_space.IsValid()) - image->SetColorSpace(color_space); - if (!image->Initialize(handle.region, handle.id, format, handle.offset, - handle.stride)) { - return nullptr; - } - - return image; - } - if (!image_factory_) return nullptr; @@ -256,10 +237,8 @@ if (thread_safe) { return false; } - // If the GLImage factory is created specifically for SHARED_MEMORY Gmbs, - // make sure that it used for that purpose based on flag - if ((for_shared_memory_gmbs_ && gmb_type != gfx::SHARED_MEMORY_BUFFER) || - (!for_shared_memory_gmbs_ && gmb_type == gfx::SHARED_MEMORY_BUFFER)) { + // Never used with shared memory GMBs. + if (gmb_type == gfx::SHARED_MEMORY_BUFFER) { return false; } if (usage & SHARED_IMAGE_USAGE_CPU_UPLOAD) {
diff --git a/gpu/command_buffer/service/shared_image/gl_image_backing_factory.h b/gpu/command_buffer/service/shared_image/gl_image_backing_factory.h index a7b6a8083..da6b09c 100644 --- a/gpu/command_buffer/service/shared_image/gl_image_backing_factory.h +++ b/gpu/command_buffer/service/shared_image/gl_image_backing_factory.h
@@ -34,8 +34,6 @@ class GPU_GLES2_EXPORT GLImageBackingFactory : public GLCommonImageBackingFactory { public: - // for_shared_memory_gmbs is a temporary parameter which is used for checking - // if gfx::SHARED_MEMORY_BUFFER is supported by the factory. // It is used for migrating GLImage backing, for part that works with // SharedMemory GMB with SharedMemoryImageBacking and Composite backings, and // all other parts with OzoneImageBacking and other backings. @@ -43,8 +41,7 @@ const GpuDriverBugWorkarounds& workarounds, const gles2::FeatureInfo* feature_info, ImageFactory* image_factory, - gl::ProgressReporter* progress_reporter, - const bool for_shared_memory_gmbs); + gl::ProgressReporter* progress_reporter); ~GLImageBackingFactory() override; // SharedImageBackingFactory implementation. @@ -121,9 +118,6 @@ // Factory used to generate GLImages for SCANOUT backings. const raw_ptr<ImageFactory> image_factory_ = nullptr; - // Whether factory is specifically for SHARED_MEMORY Gmbs - const bool for_shared_memory_gmbs_ = false; - BufferFormatInfo buffer_format_info_[viz::RESOURCE_FORMAT_MAX + 1]; GpuMemoryBufferFormatSet gpu_memory_buffer_formats_; };
diff --git a/gpu/command_buffer/service/shared_image/gl_image_backing_factory_unittest.cc b/gpu/command_buffer/service/shared_image/gl_image_backing_factory_unittest.cc index cce492b..df96665e 100644 --- a/gpu/command_buffer/service/shared_image/gl_image_backing_factory_unittest.cc +++ b/gpu/command_buffer/service/shared_image/gl_image_backing_factory_unittest.cc
@@ -109,10 +109,7 @@ preferences.use_passthrough_cmd_decoder = use_passthrough(); backing_factory_ = std::make_unique<GLImageBackingFactory>( preferences, workarounds, context_state_->feature_info(), factory, - &progress_reporter_, /*for_shared_memory_gmbs=*/false); - backing_factory_shmem_ = std::make_unique<GLImageBackingFactory>( - preferences, workarounds, context_state_->feature_info(), factory, - &progress_reporter_, /*for_shared_memory_gmbs=*/true); + &progress_reporter_); memory_type_tracker_ = std::make_unique<MemoryTypeTracker>(nullptr); shared_image_representation_factory_ = @@ -142,7 +139,6 @@ scoped_refptr<gl::GLContext> context_; scoped_refptr<SharedContextState> context_state_; std::unique_ptr<GLImageBackingFactory> backing_factory_; - std::unique_ptr<GLImageBackingFactory> backing_factory_shmem_; gles2::MailboxManagerImpl mailbox_manager_; std::unique_ptr<SharedImageManager> shared_image_manager_; std::unique_ptr<MemoryTypeTracker> memory_type_tracker_; @@ -751,44 +747,6 @@ EXPECT_GT(stub_image->update_counter(), update_counter); } -TEST_P(GLImageBackingFactoryWithGMBTest, GpuMemoryBufferImportSharedMemory) { - auto mailbox = Mailbox::GenerateForSharedImage(); - gfx::Size size(256, 256); - gfx::BufferFormat format = viz::BufferFormat(get_format()); - auto color_space = gfx::ColorSpace::CreateSRGB(); - GrSurfaceOrigin surface_origin = kTopLeft_GrSurfaceOrigin; - SkAlphaType alpha_type = kPremul_SkAlphaType; - uint32_t usage = SHARED_IMAGE_USAGE_GLES2; - - size_t shm_size = 0u; - ASSERT_TRUE(gfx::BufferSizeForBufferFormatChecked(size, format, &shm_size)); - gfx::GpuMemoryBufferHandle handle; - handle.type = gfx::SHARED_MEMORY_BUFFER; - handle.region = base::UnsafeSharedMemoryRegion::Create(shm_size); - ASSERT_TRUE(handle.region.IsValid()); - handle.offset = 0; - handle.stride = static_cast<uint32_t>( - gfx::RowSizeForBufferFormat(size.width(), format, 0)); - - auto backing = backing_factory_shmem_->CreateSharedImage( - mailbox, kClientId, std::move(handle), format, gfx::BufferPlane::DEFAULT, - kNullSurfaceHandle, size, color_space, surface_origin, alpha_type, usage); - if (!can_create_scanout_or_gmb_shared_image(get_format())) { - EXPECT_FALSE(backing); - return; - } - ASSERT_TRUE(backing); - - std::unique_ptr<SharedImageRepresentationFactoryRef> ref = - shared_image_manager_->Register(std::move(backing), - memory_type_tracker_.get()); - scoped_refptr<gl::GLImage> image = GetImageFromMailbox(mailbox); - ASSERT_EQ(image->GetType(), gl::GLImage::Type::MEMORY); - auto* shm_image = static_cast<gl::GLImageSharedMemory*>(image.get()); - EXPECT_EQ(size, shm_image->GetSize()); - EXPECT_EQ(format, shm_image->format()); -} - TEST_P(GLImageBackingFactoryWithGMBTest, GpuMemoryBufferImportNative_WithRGBEmulation) { if (use_passthrough())
diff --git a/gpu/command_buffer/service/shared_image/gl_texture_image_backing.cc b/gpu/command_buffer/service/shared_image/gl_texture_image_backing.cc index b7927e8..6566c142 100644 --- a/gpu/command_buffer/service/shared_image/gl_texture_image_backing.cc +++ b/gpu/command_buffer/service/shared_image/gl_texture_image_backing.cc
@@ -42,6 +42,7 @@ #include "ui/gl/gl_image_native_pixmap.h" #include "ui/gl/gl_image_shared_memory.h" #include "ui/gl/gl_implementation.h" +#include "ui/gl/gl_utils.h" #include "ui/gl/gl_version_info.h" #include "ui/gl/scoped_binders.h" #include "ui/gl/scoped_make_current.h" @@ -159,6 +160,30 @@ ClearTrackingSharedImageBacking::SetClearedRect(cleared_rect); } +void GLTextureImageBacking::Update(std::unique_ptr<gfx::GpuFence> in_fence) {} + +bool GLTextureImageBacking::UploadFromMemory(const SkPixmap& pixmap) { + DCHECK(gl::GLContext::GetCurrent()); + + const GLuint texture_id = GetGLServiceId(); + const GLenum gl_format = texture_params_.format; + const GLenum gl_type = texture_params_.type; + const GLenum gl_target = texture_params_.target; + + gl::GLApi* api = gl::g_current_gl_context; + gl::ScopedTextureBinder scoped_texture_binder(gl_target, texture_id); + gl::ScopedPixelStore unpack_row_length(GL_UNPACK_ROW_LENGTH, 0); + gl::ScopedPixelStore unpack_skip_pixels(GL_UNPACK_SKIP_PIXELS, 0); + gl::ScopedPixelStore unpack_skip_rows(GL_UNPACK_SKIP_ROWS, 0); + gl::ScopedPixelStore unpack_alignment(GL_UNPACK_ALIGNMENT, 4); + + api->glTexSubImage2DFn(gl_target, 0, 0, 0, size().width(), size().height(), + gl_format, gl_type, pixmap.addr()); + DCHECK_EQ(api->glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); + + return true; +} + bool GLTextureImageBacking::ProduceLegacyMailbox( MailboxManager* mailbox_manager) { if (IsPassthrough()) @@ -231,8 +256,6 @@ tracker); } -void GLTextureImageBacking::Update(std::unique_ptr<gfx::GpuFence> in_fence) {} - void GLTextureImageBacking::InitializeGLTexture( GLuint service_id, const InitializeGLTextureParams& params) { @@ -240,7 +263,7 @@ params.target, service_id, params.framebuffer_attachment_angle, IsPassthrough() ? &passthrough_texture_ : nullptr, IsPassthrough() ? nullptr : &texture_); - + texture_params_ = params; if (IsPassthrough()) { passthrough_texture_->SetEstimatedSize(EstimatedSize(format(), size())); SetClearedRect(params.is_cleared ? gfx::Rect(size()) : gfx::Rect());
diff --git a/gpu/command_buffer/service/shared_image/gl_texture_image_backing.h b/gpu/command_buffer/service/shared_image/gl_texture_image_backing.h index a1938fd..cc814b7 100644 --- a/gpu/command_buffer/service/shared_image/gl_texture_image_backing.h +++ b/gpu/command_buffer/service/shared_image/gl_texture_image_backing.h
@@ -65,6 +65,7 @@ MemoryTypeTracker* tracker, scoped_refptr<SharedContextState> context_state) override; void Update(std::unique_ptr<gfx::GpuFence> in_fence) override; + bool UploadFromMemory(const SkPixmap& pixmap) override; bool IsPassthrough() const { return is_passthrough_; } @@ -72,6 +73,8 @@ gles2::Texture* texture_ = nullptr; scoped_refptr<gles2::TexturePassthrough> passthrough_texture_; + GLTextureImageBackingHelper::InitializeGLTextureParams texture_params_; + sk_sp<SkPromiseImageTexture> cached_promise_texture_; scoped_refptr<gl::GLImageEGL> image_egl_; };
diff --git a/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.cc b/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.cc index a809737..e2cb9eb 100644 --- a/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.cc +++ b/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.cc
@@ -37,11 +37,13 @@ const GpuPreferences& gpu_preferences, const GpuDriverBugWorkarounds& workarounds, const gles2::FeatureInfo* feature_info, - gl::ProgressReporter* progress_reporter) + gl::ProgressReporter* progress_reporter, + bool for_cpu_upload_usage) : GLCommonImageBackingFactory(gpu_preferences, workarounds, feature_info, - progress_reporter) {} + progress_reporter), + for_cpu_upload_usage_(for_cpu_upload_usage) {} GLTextureImageBackingFactory::~GLTextureImageBackingFactory() = default; @@ -134,10 +136,19 @@ return false; } - constexpr uint32_t kInvalidUsages = SHARED_IMAGE_USAGE_VIDEO_DECODE | - SHARED_IMAGE_USAGE_SCANOUT | - SHARED_IMAGE_USAGE_CPU_UPLOAD; + bool has_cpu_upload_usage = usage & SHARED_IMAGE_USAGE_CPU_UPLOAD; + if (for_cpu_upload_usage_ != has_cpu_upload_usage) + return false; + + if (has_cpu_upload_usage) { + // Drop scanout usage for shared memory GMBs to match legacy behaviour + // from GLImageBackingFactory. + usage = usage & ~SHARED_IMAGE_USAGE_SCANOUT; + } + + constexpr uint32_t kInvalidUsages = + SHARED_IMAGE_USAGE_VIDEO_DECODE | SHARED_IMAGE_USAGE_SCANOUT; if (usage & kInvalidUsages) { return false; }
diff --git a/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.h b/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.h index 7feeebd..d75d5917 100644 --- a/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.h +++ b/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory.h
@@ -31,10 +31,14 @@ class GPU_GLES2_EXPORT GLTextureImageBackingFactory : public GLCommonImageBackingFactory { public: + // The `for_cpu_upload_usage` parameter controls if this factory accepts + // `SHARED_IMAGE_USAGE_CPU_UPLOAD`. It is strict, if true the usage must + // include CPU upload and if false it must not. GLTextureImageBackingFactory(const GpuPreferences& gpu_preferences, const GpuDriverBugWorkarounds& workarounds, const gles2::FeatureInfo* feature_info, - gl::ProgressReporter* progress_reporter); + gl::ProgressReporter* progress_reporter, + bool for_cpu_upload_usage); ~GLTextureImageBackingFactory() override; // SharedImageBackingFactory implementation. @@ -97,6 +101,8 @@ SkAlphaType alpha_type, uint32_t usage, base::span<const uint8_t> pixel_data); + + const bool for_cpu_upload_usage_; }; } // namespace gpu
diff --git a/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory_unittest.cc b/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory_unittest.cc index a8a3a70e..e1278c4 100644 --- a/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory_unittest.cc +++ b/gpu/command_buffer/service/shared_image/gl_texture_image_backing_factory_unittest.cc
@@ -105,7 +105,7 @@ preferences.use_passthrough_cmd_decoder = use_passthrough(); backing_factory_ = std::make_unique<GLTextureImageBackingFactory>( preferences, workarounds, context_state_->feature_info(), - &progress_reporter_); + &progress_reporter_, /*for_cpu_upload_usage=*/false); memory_type_tracker_ = std::make_unique<MemoryTypeTracker>(nullptr); shared_image_representation_factory_ =
diff --git a/gpu/command_buffer/service/shared_image/iosurface_image_backing_factory_unittest.cc b/gpu/command_buffer/service/shared_image/iosurface_image_backing_factory_unittest.cc index 0e2a6d23..37d4245 100644 --- a/gpu/command_buffer/service/shared_image/iosurface_image_backing_factory_unittest.cc +++ b/gpu/command_buffer/service/shared_image/iosurface_image_backing_factory_unittest.cc
@@ -71,7 +71,7 @@ backing_factory_ = std::make_unique<GLImageBackingFactory>( preferences, workarounds, context_state_->feature_info(), &image_factory_, - /*progress_reporter=*/nullptr, /*for_shared_memory_gmbs=*/false); + /*progress_reporter=*/nullptr); memory_type_tracker_ = std::make_unique<MemoryTypeTracker>(nullptr); shared_image_representation_factory_ =
diff --git a/gpu/command_buffer/service/shared_image/shared_image_backing.cc b/gpu/command_buffer/service/shared_image/shared_image_backing.cc index db0f6d51..e5c9063 100644 --- a/gpu/command_buffer/service/shared_image/shared_image_backing.cc +++ b/gpu/command_buffer/service/shared_image/shared_image_backing.cc
@@ -177,8 +177,14 @@ } #endif +void SharedImageBacking::SetNotReferencedCounted() { + DCHECK(!HasAnyRefs()); + is_reference_counted_ = false; +} + void SharedImageBacking::AddRef(SharedImageRepresentation* representation) { AutoLock auto_lock(this); + DCHECK(is_reference_counted_); bool first_ref = refs_.empty(); refs_.push_back(representation); @@ -190,6 +196,7 @@ void SharedImageBacking::ReleaseRef(SharedImageRepresentation* representation) { AutoLock auto_lock(this); + DCHECK(is_reference_counted_); auto found = std::find(refs_.begin(), refs_.end(), representation); DCHECK(found != refs_.end());
diff --git a/gpu/command_buffer/service/shared_image/shared_image_backing.h b/gpu/command_buffer/service/shared_image/shared_image_backing.h index ce81623..61964c31 100644 --- a/gpu/command_buffer/service/shared_image/shared_image_backing.h +++ b/gpu/command_buffer/service/shared_image/shared_image_backing.h
@@ -99,11 +99,17 @@ const Mailbox& mailbox() const { return mailbox_; } size_t estimated_size() const { return estimated_size_; } bool is_thread_safe() const { return !!lock_; } + bool is_reference_counted() const { return is_reference_counted_; } + void OnContextLost(); // Creates SkImageInfo matching backing size, format, alpha and color space. SkImageInfo AsSkImageInfo() const; + // Disables reference counting for backing. No references should be added, + // either before or after this is called. + void SetNotReferencedCounted(); + // Concrete functions to manage a ref count. void AddRef(SharedImageRepresentation* representation); void ReleaseRef(SharedImageRepresentation* representation); @@ -277,6 +283,8 @@ const uint32_t usage_; const size_t estimated_size_; + bool is_reference_counted_ = true; + raw_ptr<SharedImageFactory> factory_ = nullptr; // Bound to the thread on which the backing is created. The |factory_|
diff --git a/gpu/command_buffer/service/shared_image/shared_image_factory.cc b/gpu/command_buffer/service/shared_image/shared_image_factory.cc index 01473b3..1dfc3ac 100644 --- a/gpu/command_buffer/service/shared_image/shared_image_factory.cc +++ b/gpu/command_buffer/service/shared_image/shared_image_factory.cc
@@ -325,7 +325,8 @@ std::make_unique<GLTextureImageBackingFactory>( gpu_preferences, workarounds, feature_info.get(), shared_context_state_ ? shared_context_state_->progress_reporter() - : nullptr); + : nullptr, + /*for_cpu_upload_usage=*/false); factories_.push_back(std::move(gl_texture_backing_factory)); } @@ -342,12 +343,13 @@ #if !BUILDFLAG(IS_ANDROID) if (use_gl) { - auto gl_image_backing_factory = std::make_unique<GLImageBackingFactory>( - gpu_preferences, workarounds, feature_info.get(), image_factory, - shared_context_state_ ? shared_context_state_->progress_reporter() - : nullptr, - /*for_shared_memory_gmbs=*/true); - factories_.push_back(std::move(gl_image_backing_factory)); + auto gl_texture_backing_factory = + std::make_unique<GLTextureImageBackingFactory>( + gpu_preferences, workarounds, feature_info.get(), + shared_context_state_ ? shared_context_state_->progress_reporter() + : nullptr, + /*for_cpu_upload_usage=*/true); + factories_.push_back(std::move(gl_texture_backing_factory)); } #endif @@ -436,8 +438,7 @@ auto gl_image_backing_factory = std::make_unique<GLImageBackingFactory>( gpu_preferences, workarounds, feature_info.get(), image_factory, shared_context_state_ ? shared_context_state_->progress_reporter() - : nullptr, - /*for_shared_memory_gmbs=*/false); + : nullptr); factories_.push_back(std::move(gl_image_backing_factory)); } #endif
diff --git a/gpu/command_buffer/service/shared_image/shared_image_representation.cc b/gpu/command_buffer/service/shared_image/shared_image_representation.cc index 55ba754..711c969 100644 --- a/gpu/command_buffer/service/shared_image/shared_image_representation.cc +++ b/gpu/command_buffer/service/shared_image/shared_image_representation.cc
@@ -27,9 +27,7 @@ // TODO(hitawala): Rewrite the reference counting so that // SharedImageRepresentation does not need manager and manager attaches to // backing in Register(). - // If mailbox is zero this is owned by a compound backing and not reference - // counted. - if (manager_ && !backing_->mailbox().IsZero()) { + if (manager_ && backing_->is_reference_counted()) { backing_->AddRef(this); } } @@ -39,9 +37,7 @@ // error is. CHECK(!has_scoped_access_) << "Destroying a SharedImageRepresentation with " "outstanding Scoped*Access objects."; - // If mailbox is zero this is owned by a compound backing and not reference - // counted. - if (manager_ && !backing_->mailbox().IsZero()) { + if (manager_ && backing_->is_reference_counted()) { manager_->OnRepresentationDestroyed(backing_->mailbox(), this); } }
diff --git "a/infra/config/generated/builders/ci/Mac Builder \050dbg\051/properties.json" "b/infra/config/generated/builders/ci/Mac Builder \050dbg\051/properties.json" index 2a7f1843..bdef630 100644 --- "a/infra/config/generated/builders/ci/Mac Builder \050dbg\051/properties.json" +++ "b/infra/config/generated/builders/ci/Mac Builder \050dbg\051/properties.json"
@@ -55,6 +55,39 @@ "project": "chromium" } } + }, + { + "builder_id": { + "bucket": "ci", + "builder": "mac-osxbeta-rel", + "project": "chromium" + }, + "builder_spec": { + "build_gs_bucket": "chromium-fyi-archive", + "builder_group": "chromium.fyi", + "execution_mode": "TEST", + "legacy_chromium_config": { + "apply_configs": [ + "mb", + "goma_use_local" + ], + "build_config": "Release", + "config": "chromium", + "target_bits": 64, + "target_platform": "mac" + }, + "legacy_gclient_config": { + "config": "chromium" + }, + "legacy_test_results_config": { + "config": "staging_server" + }, + "parent": { + "bucket": "ci", + "builder": "Mac Builder (dbg)", + "project": "chromium" + } + } } ] }, @@ -70,10 +103,19 @@ "bucket": "ci", "builder": "Mac12 Tests (dbg)", "project": "chromium" + }, + { + "bucket": "ci", + "builder": "mac-osxbeta-rel", + "project": "chromium" } ], "mirroring_builder_group_and_names": [ { + "builder": "mac-osxbeta-rel", + "group": "tryserver.chromium.mac" + }, + { "builder": "mac_chromium_compile_dbg_ng", "group": "tryserver.chromium.mac" },
diff --git a/infra/config/generated/builders/ci/Mac Builder/properties.json b/infra/config/generated/builders/ci/Mac Builder/properties.json index 67ddb31..c9b1b812b 100644 --- a/infra/config/generated/builders/ci/Mac Builder/properties.json +++ b/infra/config/generated/builders/ci/Mac Builder/properties.json
@@ -211,39 +211,6 @@ "project": "chromium" } } - }, - { - "builder_id": { - "bucket": "ci", - "builder": "mac-osxbeta-rel", - "project": "chromium" - }, - "builder_spec": { - "build_gs_bucket": "chromium-fyi-archive", - "builder_group": "chromium.fyi", - "execution_mode": "TEST", - "legacy_chromium_config": { - "apply_configs": [ - "mb", - "goma_use_local" - ], - "build_config": "Release", - "config": "chromium", - "target_bits": 64, - "target_platform": "mac" - }, - "legacy_gclient_config": { - "config": "chromium" - }, - "legacy_test_results_config": { - "config": "staging_server" - }, - "parent": { - "bucket": "ci", - "builder": "Mac Builder", - "project": "chromium" - } - } } ] }, @@ -284,11 +251,6 @@ "bucket": "ci", "builder": "Mac12 Tests (py2 less)", "project": "chromium" - }, - { - "bucket": "ci", - "builder": "mac-osxbeta-rel", - "project": "chromium" } ], "mirroring_builder_group_and_names": [ @@ -297,10 +259,6 @@ "group": "tryserver.chromium.mac" }, { - "builder": "mac-osxbeta-rel", - "group": "tryserver.chromium.mac" - }, - { "builder": "mac-rel", "group": "tryserver.chromium.mac" },
diff --git a/infra/config/generated/builders/ci/mac-osxbeta-rel/properties.json b/infra/config/generated/builders/ci/mac-osxbeta-rel/properties.json index 48b8012..426784a1 100644 --- a/infra/config/generated/builders/ci/mac-osxbeta-rel/properties.json +++ b/infra/config/generated/builders/ci/mac-osxbeta-rel/properties.json
@@ -6,7 +6,7 @@ { "builder_id": { "bucket": "ci", - "builder": "Mac Builder", + "builder": "Mac Builder (dbg)", "project": "chromium" }, "builder_spec": { @@ -15,18 +15,14 @@ "execution_mode": "COMPILE_AND_TEST", "legacy_chromium_config": { "apply_configs": [ - "mb", - "goma_use_local" + "mb" ], - "build_config": "Release", + "build_config": "Debug", "config": "chromium", "target_bits": 64, "target_platform": "mac" }, "legacy_gclient_config": { - "apply_configs": [ - "use_clang_coverage" - ], "config": "chromium" } } @@ -59,7 +55,7 @@ }, "parent": { "bucket": "ci", - "builder": "Mac Builder", + "builder": "Mac Builder (dbg)", "project": "chromium" } } @@ -79,7 +75,7 @@ "group": "tryserver.chromium.mac" }, { - "builder": "mac_chromium_compile_rel_ng", + "builder": "mac_chromium_compile_dbg_ng", "group": "tryserver.chromium.mac" } ]
diff --git a/infra/config/generated/builders/try/mac-osxbeta-rel/properties.json b/infra/config/generated/builders/try/mac-osxbeta-rel/properties.json index 415d42a..395105a 100644 --- a/infra/config/generated/builders/try/mac-osxbeta-rel/properties.json +++ b/infra/config/generated/builders/try/mac-osxbeta-rel/properties.json
@@ -6,7 +6,7 @@ { "builder_id": { "bucket": "ci", - "builder": "Mac Builder", + "builder": "Mac Builder (dbg)", "project": "chromium" }, "builder_spec": { @@ -15,18 +15,14 @@ "execution_mode": "COMPILE_AND_TEST", "legacy_chromium_config": { "apply_configs": [ - "mb", - "goma_use_local" + "mb" ], - "build_config": "Release", + "build_config": "Debug", "config": "chromium", "target_bits": 64, "target_platform": "mac" }, "legacy_gclient_config": { - "apply_configs": [ - "use_clang_coverage" - ], "config": "chromium" } } @@ -59,7 +55,7 @@ }, "parent": { "bucket": "ci", - "builder": "Mac Builder", + "builder": "Mac Builder (dbg)", "project": "chromium" } } @@ -69,7 +65,7 @@ "builder_ids": [ { "bucket": "ci", - "builder": "Mac Builder", + "builder": "Mac Builder (dbg)", "project": "chromium" } ],
diff --git a/infra/config/generated/builders/try/mac_chromium_compile_dbg_ng/properties.json b/infra/config/generated/builders/try/mac_chromium_compile_dbg_ng/properties.json index b6ddd5f..aecf7e6b 100644 --- a/infra/config/generated/builders/try/mac_chromium_compile_dbg_ng/properties.json +++ b/infra/config/generated/builders/try/mac_chromium_compile_dbg_ng/properties.json
@@ -55,6 +55,39 @@ "project": "chromium" } } + }, + { + "builder_id": { + "bucket": "ci", + "builder": "mac-osxbeta-rel", + "project": "chromium" + }, + "builder_spec": { + "build_gs_bucket": "chromium-fyi-archive", + "builder_group": "chromium.fyi", + "execution_mode": "TEST", + "legacy_chromium_config": { + "apply_configs": [ + "mb", + "goma_use_local" + ], + "build_config": "Release", + "config": "chromium", + "target_bits": 64, + "target_platform": "mac" + }, + "legacy_gclient_config": { + "config": "chromium" + }, + "legacy_test_results_config": { + "config": "staging_server" + }, + "parent": { + "bucket": "ci", + "builder": "Mac Builder (dbg)", + "project": "chromium" + } + } } ] }, @@ -70,6 +103,11 @@ "bucket": "ci", "builder": "Mac12 Tests (dbg)", "project": "chromium" + }, + { + "bucket": "ci", + "builder": "mac-osxbeta-rel", + "project": "chromium" } ], "is_compile_only": true
diff --git a/infra/config/generated/builders/try/mac_chromium_compile_rel_ng/properties.json b/infra/config/generated/builders/try/mac_chromium_compile_rel_ng/properties.json index 8ffe31f5..b2697ec 100644 --- a/infra/config/generated/builders/try/mac_chromium_compile_rel_ng/properties.json +++ b/infra/config/generated/builders/try/mac_chromium_compile_rel_ng/properties.json
@@ -211,39 +211,6 @@ "project": "chromium" } } - }, - { - "builder_id": { - "bucket": "ci", - "builder": "mac-osxbeta-rel", - "project": "chromium" - }, - "builder_spec": { - "build_gs_bucket": "chromium-fyi-archive", - "builder_group": "chromium.fyi", - "execution_mode": "TEST", - "legacy_chromium_config": { - "apply_configs": [ - "mb", - "goma_use_local" - ], - "build_config": "Release", - "config": "chromium", - "target_bits": 64, - "target_platform": "mac" - }, - "legacy_gclient_config": { - "config": "chromium" - }, - "legacy_test_results_config": { - "config": "staging_server" - }, - "parent": { - "bucket": "ci", - "builder": "Mac Builder", - "project": "chromium" - } - } } ] }, @@ -284,11 +251,6 @@ "bucket": "ci", "builder": "Mac12 Tests (py2 less)", "project": "chromium" - }, - { - "bucket": "ci", - "builder": "mac-osxbeta-rel", - "project": "chromium" } ], "is_compile_only": true
diff --git a/infra/config/generated/luci/luci-scheduler.cfg b/infra/config/generated/luci/luci-scheduler.cfg index 0b949bc3..826e229 100644 --- a/infra/config/generated/luci/luci-scheduler.cfg +++ b/infra/config/generated/luci/luci-scheduler.cfg
@@ -1372,6 +1372,17 @@ } } job { + id: "GPU Flake Finder" + realm: "ci" + schedule: "triggered" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "GPU Flake Finder" + } +} +job { id: "GPU Linux Builder" realm: "ci" acl_sets: "ci"
diff --git a/infra/config/subprojects/chromium/ci/chromium.fyi.star b/infra/config/subprojects/chromium/ci/chromium.fyi.star index 93cade76..9f2227a 100644 --- a/infra/config/subprojects/chromium/ci/chromium.fyi.star +++ b/infra/config/subprojects/chromium/ci/chromium.fyi.star
@@ -756,7 +756,7 @@ builderless = False, os = os.MAC_DEFAULT, cores = 12, - triggered_by = ["ci/Mac Builder"], + triggered_by = ["ci/Mac Builder (dbg)"], ) ci.builder(
diff --git a/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star b/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star index a282f32..16d42e2 100644 --- a/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star +++ b/infra/config/subprojects/chromium/ci/chromium.gpu.fyi.star
@@ -205,6 +205,7 @@ executable = "recipe:chromium_expectation_files/expectation_file_scripts", # This will eventually be set up to run on a schedule, but only support # manual triggering for now until we get a successful build. + schedule = "triggered", triggered_by = [], service_account = "chromium-automated-expectation@chops-service-accounts.iam.gserviceaccount.com", properties = {
diff --git a/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star b/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star index b508b052..91a8dd2 100644 --- a/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star +++ b/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star
@@ -48,7 +48,7 @@ try_.builder( name = "mac-osxbeta-rel", mirrors = [ - "ci/Mac Builder", + "ci/Mac Builder (dbg)", "ci/mac-osxbeta-rel", ], builderless = False,
diff --git a/ios/chrome/browser/BUILD.gn b/ios/chrome/browser/BUILD.gn index d19898e6..e175726 100644 --- a/ios/chrome/browser/BUILD.gn +++ b/ios/chrome/browser/BUILD.gn
@@ -62,7 +62,6 @@ ] deps = [ - ":settings_resources", "//base", "//components/autofill/core/browser", "//components/autofill/ios/browser", @@ -103,6 +102,7 @@ "//ios/chrome/browser/complex_tasks", "//ios/chrome/browser/download/background_service", "//ios/chrome/browser/itunes_urls", + "//ios/chrome/browser/resources:settings_resources", "//ios/chrome/browser/sync/glue", "//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui/coordinators:chrome_coordinators", @@ -286,38 +286,6 @@ } } -tweak_info_plist("experimental_info_plist") { - info_plists = [ "resources/Settings.bundle/Experimental.plist" ] - if (ios_enable_metrickit) { - info_plists += [ "resources/Settings.bundle/ExperimentalMetricKit.plist" ] - } - if (ios_enable_sandbox_dump) { - info_plists += [ "resources/Settings.bundle/ExperimentalSandboxDump.plist" ] - } - info_plists += [ "resources/Settings.bundle/ExperimentalFlags.plist" ] -} - -bundle_data("settings_experimental_synctypeslist_plist") { - sources = - [ "resources/Settings.bundle/ExperimentalSyncTypesListDisabled.plist" ] - outputs = [ "{{bundle_resources_dir}}/Settings.bundle/{{source_file_part}}" ] -} - -bundle_data("settings_resources_experimental_plist") { - public_deps = [ - ":experimental_info_plist", - ":settings_experimental_synctypeslist_plist", - ] - sources = get_target_outputs(":experimental_info_plist") - outputs = [ "{{bundle_resources_dir}}/Settings.bundle/Experimental.plist" ] -} - -bundle_data("settings_resources") { - public_deps = [ ":settings_resources_experimental_plist" ] - sources = [ "resources/Settings.bundle/Root.plist" ] - outputs = [ "{{bundle_resources_dir}}/Settings.bundle/{{source_file_part}}" ] -} - source_set("unit_tests") { configs += [ "//build/config/compiler:enable_arc" ] testonly = true
diff --git a/ios/chrome/browser/OWNERS b/ios/chrome/browser/OWNERS index d98bf90..eccf229a 100644 --- a/ios/chrome/browser/OWNERS +++ b/ios/chrome/browser/OWNERS
@@ -1,3 +1,2 @@ per-file ios_chrome_io_thread*=rch@chromium.org per-file system_flags*=* -per-file resources/*=*
diff --git a/ios/chrome/browser/commerce/shopping_service_factory.mm b/ios/chrome/browser/commerce/shopping_service_factory.mm index 423bd77..168f1bd2 100644 --- a/ios/chrome/browser/commerce/shopping_service_factory.mm +++ b/ios/chrome/browser/commerce/shopping_service_factory.mm
@@ -59,7 +59,7 @@ chrome_state), OptimizationGuideServiceFactory::GetForBrowserState(chrome_state), pref_service, IdentityManagerFactory::GetForBrowserState(chrome_state), - chrome_state->GetSharedURLLoaderFactory()); + chrome_state->GetSharedURLLoaderFactory(), nullptr); } web::BrowserState* ShoppingServiceFactory::GetBrowserStateToUse(
diff --git a/ios/chrome/browser/resources/BUILD.gn b/ios/chrome/browser/resources/BUILD.gn new file mode 100644 index 0000000..dc2b2d6 --- /dev/null +++ b/ios/chrome/browser/resources/BUILD.gn
@@ -0,0 +1,37 @@ +# Copyright 2022 The Chromium Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/apple/tweak_info_plist.gni") +import("//ios/chrome/features.gni") + +tweak_info_plist("experimental_info_plist") { + info_plists = [ "Settings.bundle/Experimental.plist" ] + if (ios_enable_metrickit) { + info_plists += [ "Settings.bundle/ExperimentalMetricKit.plist" ] + } + if (ios_enable_sandbox_dump) { + info_plists += [ "Settings.bundle/ExperimentalSandboxDump.plist" ] + } + info_plists += [ "Settings.bundle/ExperimentalFlags.plist" ] +} + +bundle_data("settings_experimental_synctypeslist_plist") { + sources = [ "Settings.bundle/ExperimentalSyncTypesListDisabled.plist" ] + outputs = [ "{{bundle_resources_dir}}/Settings.bundle/{{source_file_part}}" ] +} + +bundle_data("settings_resources_experimental_plist") { + public_deps = [ + ":experimental_info_plist", + ":settings_experimental_synctypeslist_plist", + ] + sources = get_target_outputs(":experimental_info_plist") + outputs = [ "{{bundle_resources_dir}}/Settings.bundle/Experimental.plist" ] +} + +bundle_data("settings_resources") { + public_deps = [ ":settings_resources_experimental_plist" ] + sources = [ "Settings.bundle/Root.plist" ] + outputs = [ "{{bundle_resources_dir}}/Settings.bundle/{{source_file_part}}" ] +}
diff --git a/ios/chrome/browser/resources/OWNERS b/ios/chrome/browser/resources/OWNERS new file mode 100644 index 0000000..fc659e5 --- /dev/null +++ b/ios/chrome/browser/resources/OWNERS
@@ -0,0 +1,2 @@ +# All committers can modify non-stable Experimental Settings. +per-file *=* \ No newline at end of file
diff --git a/ios/chrome/browser/ui/browser_view/BUILD.gn b/ios/chrome/browser/ui/browser_view/BUILD.gn index ab20a12..19a43fd 100644 --- a/ios/chrome/browser/ui/browser_view/BUILD.gn +++ b/ios/chrome/browser/ui/browser_view/BUILD.gn
@@ -328,6 +328,7 @@ "//ios/chrome/browser:pref_names", "//ios/chrome/browser/ntp:features", "//ios/chrome/browser/ui:feature_flags", + "//ios/chrome/browser/ui/content_suggestions:constants", "//ios/chrome/browser/ui/content_suggestions:feature_flags", "//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/start_surface:feature_flags",
diff --git a/ios/chrome/browser/ui/browser_view/browser_view_controller_egtest.mm b/ios/chrome/browser/ui/browser_view/browser_view_controller_egtest.mm index ce4308a..d40a3c2 100644 --- a/ios/chrome/browser/ui/browser_view/browser_view_controller_egtest.mm +++ b/ios/chrome/browser/ui/browser_view/browser_view_controller_egtest.mm
@@ -10,6 +10,7 @@ #include "base/strings/sys_string_conversions.h" #include "components/strings/grit/components_strings.h" #import "ios/chrome/browser/pref_names.h" +#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_constants.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_feature.h" #import "ios/chrome/browser/ui/start_surface/start_surface_features.h" #import "ios/chrome/browser/ui/ui_feature_flags.h" @@ -39,6 +40,14 @@ // Tests that the NTP is interactable even when multiple NTP are opened during // the animation of the first NTP opening. See crbug.com/1032544. - (void)testPageInteractable { + // Ensures that the first favicon in Most Visited row is the test URL. + [ChromeEarlGrey clearBrowsingHistory]; + std::map<GURL, std::string> responses; + const GURL firstURL = web::test::HttpServer::MakeUrl("http://first"); + responses[firstURL] = "First window"; + web::test::SetUpSimpleHttpServer(responses); + [ChromeEarlGrey loadURL:firstURL]; + // Scope for the synchronization disabled. { ScopedSynchronizationDisabler syncDisabler; @@ -57,31 +66,26 @@ [ChromeEarlGrey waitForMainTabCount:3]; + NSInteger faviconIndex = 0; [[EarlGrey - selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( - IDS_IOS_CONTENT_SUGGESTIONS_BOOKMARKS)] - performAction:grey_tap()]; - [[EarlGrey selectElementWithMatcher: - chrome_test_util::NavigationBarTitleWithAccessibilityLabelId( - IDS_IOS_CONTENT_SUGGESTIONS_BOOKMARKS)] - assertWithMatcher:grey_sufficientlyVisible()]; - [[EarlGrey - selectElementWithMatcher:chrome_test_util::NavigationBarDoneButton()] - performAction:grey_tap()]; + selectElementWithMatcher: + grey_accessibilityID([NSString + stringWithFormat: + @"%@%li", + kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix, + faviconIndex])] performAction:grey_tap()]; + [ChromeEarlGrey waitForWebStateContainingText:responses[firstURL]]; [ChromeEarlGrey selectTabAtIndex:1]; [[EarlGrey - selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( - IDS_IOS_CONTENT_SUGGESTIONS_BOOKMARKS)] - performAction:grey_tap()]; - [[EarlGrey selectElementWithMatcher: - chrome_test_util::NavigationBarTitleWithAccessibilityLabelId( - IDS_IOS_CONTENT_SUGGESTIONS_BOOKMARKS)] - assertWithMatcher:grey_sufficientlyVisible()]; - [[EarlGrey - selectElementWithMatcher:chrome_test_util::NavigationBarDoneButton()] - performAction:grey_tap()]; + selectElementWithMatcher: + grey_accessibilityID([NSString + stringWithFormat: + @"%@%li", + kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix, + faviconIndex])] performAction:grey_tap()]; + [ChromeEarlGrey waitForWebStateContainingText:responses[firstURL]]; } // Tests that evaluating JavaScript in the omnibox (e.g, a bookmarklet) works.
diff --git a/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator_unittest.mm b/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator_unittest.mm index df80bb8..47790b5 100644 --- a/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/recent_tabs/recent_tabs_coordinator_unittest.mm
@@ -13,7 +13,7 @@ #include "components/signin/public/identity_manager/identity_test_environment.h" #include "components/signin/public/identity_manager/primary_account_mutator.h" #include "components/sync/driver/sync_service.h" -#include "components/sync/test/model/fake_model_type_controller_delegate.h" +#import "components/sync/test/fake_model_type_controller_delegate.h" #include "components/sync_sessions/open_tabs_ui_delegate.h" #include "components/sync_sessions/session_sync_service.h" #include "components/sync_user_events/global_id_mapper.h"
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm index 7d4f9f3..0c8383e 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm
@@ -385,7 +385,13 @@ // Tests that tapping Close All shows no tabs, shows Undo button, and displays // the empty state. Then tests tapping Undo shows Close All button again. // Validates this case when Tab Grid Bulk Actions feature is enabled. -- (void)testCloseAllAndUndoCloseAll { +// TODO(crbug.com/1353093): failing on small devices on simulator +#if TARGET_IPHONE_SIMULATOR +#define MAYBE_testCloseAllAndUndoCloseAll DISABLED_testCloseAllAndUndoCloseAll +#else +#define MAYBE_testCloseAllAndUndoCloseAll testCloseAllAndUndoCloseAll +#endif +- (void)MAYBE_testCloseAllAndUndoCloseAll { [ChromeEarlGreyUI openTabGrid]; // Close all tabs
diff --git a/ios/chrome/browser/web/navigation_egtest.mm b/ios/chrome/browser/web/navigation_egtest.mm index 355dba5..8815199d 100644 --- a/ios/chrome/browser/web/navigation_egtest.mm +++ b/ios/chrome/browser/web/navigation_egtest.mm
@@ -583,7 +583,15 @@ // Tests that navigating forward from NTP works when resuming from session // restore. This is a regression test for https://crbug.com/814790. -- (void)testRestoreHistoryToNTPAndNavigateForward { +// TODO(crbug.com/1353093): failing on small devices on simulator +#if TARGET_IPHONE_SIMULATOR +#define MAYBE_testRestoreHistoryToNTPAndNavigateForward \ + DISABLED_testRestoreHistoryToNTPAndNavigateForward +#else +#define MAYBE_testRestoreHistoryToNTPAndNavigateForward \ + testRestoreHistoryToNTPAndNavigateForward +#endif +- (void)MAYBE_testRestoreHistoryToNTPAndNavigateForward { GREYAssertTrue(self.testServer->Start(), @"Test server failed to start."); const GURL destinationURL = self.testServer->GetURL(kSimpleFileBasedTestURL); [ChromeEarlGrey loadURL:destinationURL];
diff --git a/ios/chrome/test/app/sync_test_util.mm b/ios/chrome/test/app/sync_test_util.mm index dc5df82..2a3edbc 100644 --- a/ios/chrome/test/app/sync_test_util.mm +++ b/ios/chrome/test/app/sync_test_util.mm
@@ -27,12 +27,12 @@ #include "components/sync/nigori/nigori_test_utils.h" #import "components/sync/protocol/device_info_specifics.pb.h" #import "components/sync/protocol/sync_enums.pb.h" -#include "components/sync/test/fake_server/entity_builder_factory.h" -#include "components/sync/test/fake_server/fake_server.h" -#include "components/sync/test/fake_server/fake_server_network_resources.h" -#include "components/sync/test/fake_server/fake_server_nigori_helper.h" -#include "components/sync/test/fake_server/fake_server_verifier.h" -#include "components/sync/test/fake_server/sessions_hierarchy.h" +#import "components/sync/test/entity_builder_factory.h" +#import "components/sync/test/fake_server.h" +#import "components/sync/test/fake_server_network_resources.h" +#import "components/sync/test/fake_server_nigori_helper.h" +#import "components/sync/test/fake_server_verifier.h" +#import "components/sync/test/sessions_hierarchy.h" #include "components/sync_device_info/device_info.h" #include "components/sync_device_info/device_info_sync_service.h" #import "components/sync_device_info/device_info_util.h"
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 b08f92ef..afbf7ff 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 @@ -c868456fff52c395a571feeac68fb0589bfaa786 \ No newline at end of file +bf83314709cbcd8b425996de7c5ac75cbf4dae73 \ 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 1ca79c7..b4925c1 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 @@ -c40bcbd8069f0e9874476b572872ecc8e012ee91 \ No newline at end of file +cb424b44f05743826cea48104dd86e95a4dc06a5 \ 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 c4b2dedb1..7b82b67b 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 @@ -045ab7447672875b613d217804e63d2a90594034 \ No newline at end of file +5d8fd40458185e846f0ef2a1bc833a3b2fe7aebb \ 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 e8ade13..2dac6c5 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 @@ -3a5d9f134c5975d3c46ec23104e97adebf4e7f3b \ No newline at end of file +8d8e8813fca2f62e5ce4a5b92d1f1753511cc9c1 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 index 7b3287c..e7663f0 100644 --- a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -f854da58b72fec69b6dd70ea242aeb81219fa872 \ No newline at end of file +3fed867e537a8eb0965f9dbaef0bd2f7e4a05dc7 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 index 968e9bc..de6c3c0 100644 --- a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -4a1a12ead0461db5de3f0ecf30259093fa2e805a \ No newline at end of file +97917ba5feca2622a02987ff860eecc0236266ec \ 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 3c1be8c..27d062f2 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 @@ -2030f49e827362a2a64fb94e817ac7c8705d13ab \ No newline at end of file +5fd89a76196347f433fe647605b671558ace73af \ 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 c0d9ceb..d636404 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 @@ -fc19f8e34e493b718aad7d8278e17342c411037e \ No newline at end of file +9b6b6d93825fac944d48d11c371dec3d79e2534f \ 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 f610051..a5bdfe7 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 @@ -654db9f77b4b4184346a9559fd3a466fc62a9e3a \ No newline at end of file +7a4b34eb7bebf4d442b8200e3c95bb33c39a54f6 \ 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 b899467..1592f87 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 @@ -308960f3e7d177e01b31fbb95e5076ff3c39c4ea \ No newline at end of file +ff22673ff91691afac4a3645b2f99233cd538709 \ No newline at end of file
diff --git a/ios/web_view/internal/sync/web_view_sync_client_unittest.mm b/ios/web_view/internal/sync/web_view_sync_client_unittest.mm index ef2c6aa..d9ebb61d 100644 --- a/ios/web_view/internal/sync/web_view_sync_client_unittest.mm +++ b/ios/web_view/internal/sync/web_view_sync_client_unittest.mm
@@ -21,7 +21,7 @@ #include "components/sync/base/model_type.h" #include "components/sync/driver/data_type_controller.h" #include "components/sync/driver/test_sync_service.h" -#include "components/sync/test/model/test_model_type_store_service.h" +#import "components/sync/test/test_model_type_store_service.h" #include "components/sync_device_info/fake_device_info_sync_service.h" #include "ios/web/public/test/web_task_environment.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/media/renderers/win/media_foundation_renderer_unittest.cc b/media/renderers/win/media_foundation_renderer_unittest.cc index f80b5f1..38c733c1 100644 --- a/media/renderers/win/media_foundation_renderer_unittest.cc +++ b/media/renderers/win/media_foundation_renderer_unittest.cc
@@ -154,7 +154,11 @@ } protected: - base::win::ScopedCOMInitializer com_initializer_; + // IMF* interfaces (e.g. IMediaProtectionPMPServer or + // IMFContentDecryptionModule) may require an MTA to run successfully. + base::win::ScopedCOMInitializer com_initializer_{ + base::win::ScopedCOMInitializer::kMTA}; + base::test::TaskEnvironment task_environment_; base::MockOnceCallback<void(bool)> set_cdm_cb_; base::MockOnceCallback<void(PipelineStatus)> renderer_init_cb_;
diff --git a/mojo/core/BUILD.gn b/mojo/core/BUILD.gn index 176e435f..bca5857c 100644 --- a/mojo/core/BUILD.gn +++ b/mojo/core/BUILD.gn
@@ -92,6 +92,10 @@ "ipcz_api.cc", "ipcz_driver/driver.cc", "ipcz_driver/driver.h", + "ipcz_driver/mojo_trap.cc", + "ipcz_driver/mojo_trap.h", + "ipcz_driver/object.cc", + "ipcz_driver/object.h", "message_pipe_dispatcher.cc", "node_channel.cc", "node_controller.cc",
diff --git a/mojo/core/core_ipcz.cc b/mojo/core/core_ipcz.cc index df52158..fa5456d 100644 --- a/mojo/core/core_ipcz.cc +++ b/mojo/core/core_ipcz.cc
@@ -15,6 +15,7 @@ #include "base/numerics/safe_conversions.h" #include "base/time/time.h" #include "mojo/core/ipcz_api.h" +#include "mojo/core/ipcz_driver/mojo_trap.h" #include "third_party/ipcz/include/ipcz/ipcz.h" namespace mojo::core { @@ -434,7 +435,12 @@ MojoResult MojoCreateTrapIpcz(MojoTrapEventHandler handler, const MojoCreateTrapOptions* options, MojoHandle* trap_handle) { - return MOJO_RESULT_UNIMPLEMENTED; + if (!handler || !trap_handle) { + return MOJO_RESULT_INVALID_ARGUMENT; + } + + *trap_handle = ipcz_driver::MojoTrap::MakeBoxed(handler); + return MOJO_RESULT_OK; } MojoResult MojoAddTriggerIpcz(MojoHandle trap_handle, @@ -443,20 +449,32 @@ MojoTriggerCondition condition, uintptr_t context, const MojoAddTriggerOptions* options) { - return MOJO_RESULT_UNIMPLEMENTED; + auto* trap = ipcz_driver::MojoTrap::FromBox(trap_handle); + if (!trap) { + return MOJO_RESULT_INVALID_ARGUMENT; + } + return trap->AddTrigger(handle, signals, condition, context); } MojoResult MojoRemoveTriggerIpcz(MojoHandle trap_handle, uintptr_t context, const MojoRemoveTriggerOptions* options) { - return MOJO_RESULT_UNIMPLEMENTED; + auto* trap = ipcz_driver::MojoTrap::FromBox(trap_handle); + if (!trap) { + return MOJO_RESULT_INVALID_ARGUMENT; + } + return trap->RemoveTrigger(context); } MojoResult MojoArmTrapIpcz(MojoHandle trap_handle, const MojoArmTrapOptions* options, uint32_t* num_blocking_events, MojoTrapEvent* blocking_events) { - return MOJO_RESULT_UNIMPLEMENTED; + auto* trap = ipcz_driver::MojoTrap::FromBox(trap_handle); + if (!trap) { + return MOJO_RESULT_INVALID_ARGUMENT; + } + return trap->Arm(blocking_events, num_blocking_events); } MojoResult MojoWrapPlatformHandleIpcz(
diff --git a/mojo/core/core_ipcz_test.cc b/mojo/core/core_ipcz_test.cc index 66dd575..2ca30ec3 100644 --- a/mojo/core/core_ipcz_test.cc +++ b/mojo/core/core_ipcz_test.cc
@@ -180,5 +180,85 @@ EXPECT_EQ(MOJO_RESULT_OK, mojo().Close(d)); } +TEST_F(CoreIpczTest, Traps) { + MojoHandle a, b; + EXPECT_EQ(MOJO_RESULT_OK, mojo().CreateMessagePipe(nullptr, &a, &b)); + + // A simple trap event handler which treats its event context as a + // MojoTrapEvent pointer, where the fired event will be copied. + auto handler = [](const MojoTrapEvent* event) { + *reinterpret_cast<MojoTrapEvent*>(event->trigger_context) = *event; + }; + MojoHandle trap; + EXPECT_EQ(MOJO_RESULT_OK, mojo().CreateTrap(handler, nullptr, &trap)); + + // Initialize these events with an impossible result code. + MojoTrapEvent readable_event = {.result = MOJO_RESULT_UNKNOWN}; + MojoTrapEvent writable_event = {.result = MOJO_RESULT_UNKNOWN}; + uintptr_t kReadableContext = reinterpret_cast<uintptr_t>(&readable_event); + uintptr_t kWritableContext = reinterpret_cast<uintptr_t>(&writable_event); + EXPECT_EQ(MOJO_RESULT_OK, + mojo().AddTrigger(trap, b, MOJO_HANDLE_SIGNAL_READABLE, + MOJO_TRIGGER_CONDITION_SIGNALS_SATISFIED, + kReadableContext, nullptr)); + EXPECT_EQ(MOJO_RESULT_OK, + mojo().AddTrigger(trap, b, MOJO_HANDLE_SIGNAL_WRITABLE, + MOJO_TRIGGER_CONDITION_SIGNALS_SATISFIED, + kWritableContext, nullptr)); + + // Arming should fail because the pipe is always writable. + uint32_t num_events = 1; + MojoTrapEvent event = {.struct_size = sizeof(event)}; + EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, + mojo().ArmTrap(trap, nullptr, &num_events, &event)); + EXPECT_EQ(kWritableContext, event.trigger_context); + EXPECT_EQ(MOJO_RESULT_OK, event.result); + + // But we should be able to arm after removing that trigger. Trigger removal + // should also notify the writable trigger of cancellation. + EXPECT_EQ(MOJO_RESULT_OK, + mojo().RemoveTrigger(trap, kWritableContext, nullptr)); + EXPECT_EQ(MOJO_RESULT_CANCELLED, writable_event.result); + EXPECT_EQ(MOJO_RESULT_OK, mojo().ArmTrap(trap, nullptr, nullptr, nullptr)); + + // Making `b` readable by writing to `a` should immediately activate the + // remaining trigger. + EXPECT_EQ(MOJO_RESULT_UNKNOWN, readable_event.result); + EXPECT_EQ(MOJO_RESULT_OK, + mojo().WriteMessage(a, CreateMessage("lol"), nullptr)); + EXPECT_EQ(MOJO_RESULT_CANCELLED, writable_event.result); + EXPECT_EQ(MOJO_RESULT_OK, readable_event.result); + + // Clear the pipe and re-arm the trap. + MojoMessageHandle message; + EXPECT_EQ(MOJO_RESULT_OK, mojo().ReadMessage(b, nullptr, &message)); + EXPECT_EQ(MOJO_RESULT_OK, mojo().DestroyMessage(message)); + EXPECT_EQ(MOJO_RESULT_OK, mojo().ArmTrap(trap, nullptr, nullptr, nullptr)); + + // Closing `a` should activate the readable trigger again, this time to signal + // its permanent unsatisfiability. + EXPECT_EQ(MOJO_RESULT_OK, readable_event.result); + EXPECT_EQ(MOJO_RESULT_OK, mojo().Close(a)); + EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, readable_event.result); + + // Closing `b` itself should elicit one final cancellation event. + EXPECT_EQ(MOJO_RESULT_OK, mojo().Close(b)); + EXPECT_EQ(MOJO_RESULT_CANCELLED, readable_event.result); + + // Finally, closing the trap with an active trigger should also elicit a + // cancellation event. + EXPECT_EQ(MOJO_RESULT_OK, mojo().CreateMessagePipe(nullptr, &a, &b)); + readable_event.result = MOJO_RESULT_UNKNOWN; + EXPECT_EQ(MOJO_RESULT_OK, + mojo().AddTrigger(trap, b, MOJO_HANDLE_SIGNAL_READABLE, + MOJO_TRIGGER_CONDITION_SIGNALS_SATISFIED, + kReadableContext, nullptr)); + EXPECT_EQ(MOJO_RESULT_OK, mojo().Close(trap)); + EXPECT_EQ(MOJO_RESULT_CANCELLED, readable_event.result); + + EXPECT_EQ(MOJO_RESULT_OK, mojo().Close(a)); + EXPECT_EQ(MOJO_RESULT_OK, mojo().Close(b)); +} + } // namespace } // namespace mojo::core
diff --git a/mojo/core/ipcz_driver/driver.cc b/mojo/core/ipcz_driver/driver.cc index 25229d9..26263fa 100644 --- a/mojo/core/ipcz_driver/driver.cc +++ b/mojo/core/ipcz_driver/driver.cc
@@ -5,6 +5,7 @@ #include "mojo/core/ipcz_driver/driver.h" #include "base/rand_util.h" +#include "mojo/core/ipcz_driver/object.h" #include "third_party/ipcz/include/ipcz/ipcz.h" namespace mojo::core::ipcz_driver { @@ -14,7 +15,12 @@ IpczResult IPCZ_API Close(IpczDriverHandle handle, uint32_t flags, const void* options) { - return IPCZ_RESULT_UNIMPLEMENTED; + scoped_refptr<ObjectBase> object = ObjectBase::TakeFromHandle(handle); + if (!object) { + return IPCZ_RESULT_INVALID_ARGUMENT; + } + object->Close(); + return IPCZ_RESULT_OK; } IpczResult IPCZ_API Serialize(IpczDriverHandle handle,
diff --git a/mojo/core/ipcz_driver/mojo_trap.cc b/mojo/core/ipcz_driver/mojo_trap.cc new file mode 100644 index 0000000..f8e1e39 --- /dev/null +++ b/mojo/core/ipcz_driver/mojo_trap.cc
@@ -0,0 +1,425 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/core/ipcz_driver/mojo_trap.h" + +#include <cstdint> +#include <tuple> +#include <utility> + +#include "base/check_op.h" +#include "base/memory/ref_counted.h" +#include "base/notreached.h" +#include "mojo/core/ipcz_api.h" + +namespace mojo::core::ipcz_driver { + +namespace { + +// Translates Mojo signal conditions to equivalent IpczTrapConditions. +void GetConditionsForSignals(MojoHandleSignals signals, + IpczTrapConditions* conditions) { + conditions->flags |= IPCZ_TRAP_DEAD; + + if (signals & MOJO_HANDLE_SIGNAL_WRITABLE) { + // TODO: Portals should be able to set default put limits that apply to all + // of their put operations unless overridden. For now this hack effectively + // gives all data pipes 2 MB of capacity. + conditions->flags |= IPCZ_TRAP_BELOW_MAX_REMOTE_BYTES; + conditions->max_remote_bytes = 2 * 1024 * 1024; + } + + if (signals & MOJO_HANDLE_SIGNAL_READABLE) { + // Mojo's readable signal is equivalent to the condition of having more than + // zero parcels available to retrieve from a portal. + conditions->flags |= IPCZ_TRAP_ABOVE_MIN_LOCAL_PARCELS; + conditions->min_local_parcels = 0; + } else if (signals & MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE) { + // Data pipe consumers often use the edge-triggered NEW_DATA_READABLE + // signal, which is effectively equivalent to NEW_LOCAL_PARCEL in ipcz. + conditions->flags |= IPCZ_TRAP_NEW_LOCAL_PARCEL; + } + + if (signals & MOJO_HANDLE_SIGNAL_PEER_CLOSED) { + conditions->flags |= IPCZ_TRAP_PEER_CLOSED; + } +} + +// Given an ipcz trap event resulting from an installed trigger, this translates +// the event into an equivalent Mojo trap event for the containing Mojo trap. +void TranslateIpczToMojoEvent(MojoHandleSignals trigger_signals, + uintptr_t trigger_context, + IpczTrapConditionFlags current_condition_flags, + const IpczPortalStatus& current_status, + MojoTrapEvent* event) { + event->flags = 0; + event->trigger_context = trigger_context; + + // In practice handles are watched for one or the other of READABALE or + // NEW_DATA_READABLE, but never both. + const MojoHandleSignals kRead = + (trigger_signals & MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE) + ? MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE + : MOJO_HANDLE_SIGNAL_READABLE; + const MojoHandleSignals kWrite = MOJO_HANDLE_SIGNAL_WRITABLE; + const MojoHandleSignals kPeerClosed = MOJO_HANDLE_SIGNAL_PEER_CLOSED; + + MojoHandleSignals& satisfied = event->signals_state.satisfied_signals; + MojoHandleSignals& satisfiable = event->signals_state.satisfiable_signals; + + satisfied = 0; + satisfiable = kPeerClosed | MOJO_HANDLE_SIGNAL_QUOTA_EXCEEDED | + MOJO_HANDLE_SIGNAL_PEER_REMOTE; + if (!(current_status.flags & IPCZ_PORTAL_STATUS_DEAD)) { + satisfiable |= kRead | kPeerClosed; + } + if (current_status.flags & IPCZ_PORTAL_STATUS_PEER_CLOSED) { + satisfied |= kPeerClosed; + } else { + satisfied |= kWrite; + satisfiable |= kWrite; + } + + if (current_status.num_local_parcels > 0) { + satisfied |= kRead; + } + + DCHECK((satisfied & satisfiable) == satisfied); + if ((satisfiable & trigger_signals) == 0) { + event->result = MOJO_RESULT_FAILED_PRECONDITION; + return; + } + + event->result = MOJO_RESULT_OK; +} + +} // namespace + +// A Trigger is used as context for every trigger added to a Mojo trap. While a +// trap is armed, each of its Triggers has installed a unique ipcz trap to watch +// for its conditions. +struct MojoTrap::Trigger : public base::RefCountedThreadSafe<Trigger> { + Trigger(scoped_refptr<MojoTrap> mojo_trap, + MojoHandle handle, + MojoHandleSignals signals, + uintptr_t trigger_context) + : mojo_trap(std::move(mojo_trap)), + handle(handle), + signals(signals), + trigger_context(trigger_context) {} + + uintptr_t ipcz_context() const { return reinterpret_cast<uintptr_t>(this); } + + static Trigger& FromEvent(const IpczTrapEvent& event) { + return *reinterpret_cast<Trigger*>(event.context); + } + + const scoped_refptr<MojoTrap> mojo_trap; + const MojoHandle handle; + const MojoHandleSignals signals; + const uintptr_t trigger_context; + IpczTrapConditions conditions = {.size = sizeof(conditions), .flags = 0}; + + // Access is effectively guarded by the owning MojoTrap's `lock_`. + bool armed = false; + bool removed = false; + + private: + friend class base::RefCountedThreadSafe<Trigger>; + + ~Trigger() = default; +}; + +MojoTrap::MojoTrap(MojoTrapEventHandler handler) : handler_(handler) {} + +MojoTrap::~MojoTrap() = default; + +MojoResult MojoTrap::AddTrigger(MojoHandle handle, + MojoHandleSignals signals, + MojoTriggerCondition condition, + uintptr_t trigger_context) { + if (!handle) { + return MOJO_RESULT_INVALID_ARGUMENT; + } + + auto trigger = + base::MakeRefCounted<Trigger>(this, handle, signals, trigger_context); + + if (condition == MOJO_TRIGGER_CONDITION_SIGNALS_UNSATISFIED) { + // There's only one user of MOJO_TRIGGER_CONDITION_SIGNALS_UNSATISFIED. It's + // used for peer remoteness tracking in Mojo bindings lazy serialization. + // That is effectively a dead feature, so we don't need to support watching + // for unsatisfied signals. + trigger->conditions.flags = IPCZ_NO_FLAGS; + } else { + GetConditionsForSignals(signals, &trigger->conditions); + } + + IpczTrapConditionFlags flags; + IpczPortalStatus status = {sizeof(status)}; + { + base::AutoLock lock(lock_); + auto [it, ok] = triggers_.try_emplace(trigger_context, trigger); + if (!ok) { + return MOJO_RESULT_ALREADY_EXISTS; + } + + next_trigger_ = triggers_.begin(); + + // Install an ipcz trap to effectively monitor the lifetime of the watched + // object referenced by `handle`. Installation of the trap should always + // succeed, and its resulting trap event will always mark the end of this + // trigger's lifetime. This trap effectively owns a ref to the Trigger, as + // added here. + trigger->AddRef(); + IpczTrapConditions removal_conditions = { + .size = sizeof(removal_conditions), + .flags = IPCZ_TRAP_REMOVED, + }; + IpczResult result = GetIpczAPI().Trap( + handle, &removal_conditions, &TrapRemovalEventHandler, + trigger->ipcz_context(), IPCZ_NO_FLAGS, nullptr, nullptr, nullptr); + CHECK_EQ(result, IPCZ_RESULT_OK); + + if (!armed_) { + return MOJO_RESULT_OK; + } + + // The Mojo trap is already armed, so attempt to install an ipcz trap for + // the new trigger immediately. + result = ArmTrigger(*trigger, &flags, &status); + if (result == IPCZ_RESULT_OK) { + return MOJO_RESULT_OK; + } + + // The new trigger already needs to fire an event. OK. + armed_ = false; + } + + MojoTrapEvent event = {.struct_size = sizeof(event)}; + TranslateIpczToMojoEvent(signals, trigger_context, flags, status, &event); + event.flags = MOJO_TRAP_EVENT_FLAG_WITHIN_API_CALL; + handler_(&event); + return MOJO_RESULT_OK; +} + +MojoResult MojoTrap::RemoveTrigger(uintptr_t trigger_context) { + scoped_refptr<Trigger> trigger; + { + base::AutoLock lock(lock_); + auto it = triggers_.find(trigger_context); + if (it == triggers_.end()) { + return MOJO_RESULT_NOT_FOUND; + } + trigger = std::move(it->second); + trigger->armed = false; + trigger->removed = true; + triggers_.erase(it); + next_trigger_ = triggers_.begin(); + } + + NotifyTriggerRemoved(*trigger); + return MOJO_RESULT_OK; +} + +MojoResult MojoTrap::Arm(MojoTrapEvent* blocking_events, + uint32_t* num_blocking_events) { + const uint32_t event_capacity = + num_blocking_events ? *num_blocking_events : 0; + if (event_capacity > 0 && !blocking_events) { + return MOJO_RESULT_INVALID_ARGUMENT; + } + + if (event_capacity > 0 && + blocking_events[0].struct_size < sizeof(blocking_events[0])) { + return MOJO_RESULT_INVALID_ARGUMENT; + } + + base::AutoLock lock(lock_); + if (armed_) { + return MOJO_RESULT_OK; + } + + if (triggers_.empty()) { + return MOJO_RESULT_NOT_FOUND; + } + + uint32_t num_events_returned = 0; + IpczTrapConditionFlags flags; + IpczPortalStatus status = {sizeof(status)}; + + auto increment_wrapped = [this](TriggerMap::iterator it) { + lock_.AssertAcquired(); + if (++it != triggers_.end()) { + return it; + } + return triggers_.begin(); + }; + + TriggerMap::iterator next_trigger = next_trigger_; + DCHECK(next_trigger != triggers_.end()); + + // We iterate over all triggers, starting just beyond wherever we started last + // time we were armed. This guards against any single trigger being starved. + const TriggerMap::iterator end_trigger = next_trigger; + do { + auto& [trigger_context, trigger] = *next_trigger; + next_trigger = increment_wrapped(next_trigger); + + const IpczResult result = ArmTrigger(*trigger, &flags, &status); + if (result == IPCZ_RESULT_OK) { + // Trap successfully installed, nothing else to do for this trigger. + continue; + } + + if (result != IPCZ_RESULT_FAILED_PRECONDITION) { + NOTREACHED(); + return result; + } + + // The ipcz trap failed to install, so this trigger's conditions are already + // met. Accumulate would-be event details if there's output space. + if (event_capacity == 0) { + return MOJO_RESULT_FAILED_PRECONDITION; + } + + TranslateIpczToMojoEvent(trigger->signals, trigger->trigger_context, flags, + status, &blocking_events[num_events_returned++]); + } while (next_trigger != end_trigger && num_events_returned < event_capacity); + + if (next_trigger != end_trigger) { + next_trigger_ = next_trigger; + } else { + next_trigger_ = increment_wrapped(next_trigger); + } + + if (num_events_returned > 0) { + *num_blocking_events = num_events_returned; + return MOJO_RESULT_FAILED_PRECONDITION; + } + + // The whole Mojo trap is collectively armed if and only if all of the + // triggers managed to install an ipcz trap. + armed_ = true; + return MOJO_RESULT_OK; +} + +void MojoTrap::Close() { + TriggerMap triggers; + { + // Effectively disable all triggers. A disabled trigger may have already + // installed an ipcz trap which hasn't yet fired an event. This ensures that + // if any such event does eventually fire, it will be ignored. + base::AutoLock lock(lock_); + std::swap(triggers, triggers_); + next_trigger_ = triggers_.begin(); + for (auto& [trigger_context, trigger] : triggers) { + trigger->armed = false; + + DCHECK(!trigger->removed); + trigger->removed = true; + } + } + + for (auto& [trigger_context, trigger] : triggers) { + NotifyTriggerRemoved(*trigger); + } +} + +// static +void MojoTrap::TrapEventHandler(const IpczTrapEvent* event) { + Trigger::FromEvent(*event).mojo_trap->HandleEvent(*event); +} + +// static +void MojoTrap::TrapRemovalEventHandler(const IpczTrapEvent* event) { + Trigger& trigger = Trigger::FromEvent(*event); + trigger.mojo_trap->HandleTrapRemoved(*event); + + // Balanced by AddRef when installing the trigger's removal ipcz trap. + trigger.Release(); +} + +void MojoTrap::HandleEvent(const IpczTrapEvent& event) { + Trigger& trigger = Trigger::FromEvent(event); + { + base::AutoLock lock(lock_); + const bool trigger_active = armed_ && trigger.armed && !trigger.removed; + const bool is_removal = (event.condition_flags & IPCZ_TRAP_REMOVED) != 0; + trigger.armed = false; + if (!trigger_active || is_removal) { + // Removal events are handled separately by ipcz traps established at + // trigger creation, allowing handle closure to trigger an event even when + // the Mojo trap isn't armed. + return; + } + + armed_ = false; + } + + MojoTrapEvent mojo_event = {.struct_size = sizeof(mojo_event)}; + TranslateIpczToMojoEvent(trigger.signals, trigger.trigger_context, + event.condition_flags, *event.status, &mojo_event); + mojo_event.flags |= MOJO_TRAP_EVENT_FLAG_WITHIN_API_CALL; + + // Balanced by AddRef when installing the trigger's ipcz trap. + trigger.Release(); + + handler_(&mojo_event); +} + +void MojoTrap::HandleTrapRemoved(const IpczTrapEvent& event) { + Trigger& trigger = Trigger::FromEvent(event); + { + base::AutoLock lock(lock_); + if (trigger.removed) { + // The Mojo trap may have already been closed, in which case this trigger + // was already removed and its handler was already notified. + return; + } + + triggers_.erase(trigger.trigger_context); + trigger.removed = true; + next_trigger_ = triggers_.begin(); + } + + NotifyTriggerRemoved(trigger); +} + +IpczResult MojoTrap::ArmTrigger(Trigger& trigger, + IpczTrapConditionFlags* satisfied_flags, + IpczPortalStatus* status) { + lock_.AssertAcquired(); + if (trigger.armed) { + return IPCZ_RESULT_OK; + } + + // Bump the ref count on the Trigger. This ref is effectively owned by the + // installed trap, if it's installed successfully. + trigger.AddRef(); + IpczResult result = GetIpczAPI().Trap( + trigger.handle, &trigger.conditions, &TrapEventHandler, + trigger.ipcz_context(), IPCZ_NO_FLAGS, nullptr, satisfied_flags, status); + if (result == IPCZ_RESULT_OK) { + trigger.armed = true; + } else { + // Balances the AddRef above, since no trap was installed. + trigger.Release(); + } + + return result; +} + +void MojoTrap::NotifyTriggerRemoved(Trigger& trigger) { + MojoTrapEvent mojo_event = { + .struct_size = sizeof(mojo_event), + .flags = MOJO_TRAP_EVENT_FLAG_WITHIN_API_CALL, + .trigger_context = trigger.trigger_context, + .result = MOJO_RESULT_CANCELLED, + .signals_state = {.satisfied_signals = 0, .satisfiable_signals = 0}, + }; + handler_(&mojo_event); +} + +} // namespace mojo::core::ipcz_driver
diff --git a/mojo/core/ipcz_driver/mojo_trap.h b/mojo/core/ipcz_driver/mojo_trap.h new file mode 100644 index 0000000..ceb77ad --- /dev/null +++ b/mojo/core/ipcz_driver/mojo_trap.h
@@ -0,0 +1,90 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MOJO_CORE_IPCZ_DRIVER_MOJO_TRAP_H_ +#define MOJO_CORE_IPCZ_DRIVER_MOJO_TRAP_H_ + +#include <cstdint> + +#include "base/containers/flat_map.h" +#include "base/containers/span.h" +#include "base/memory/scoped_refptr.h" +#include "base/synchronization/lock.h" +#include "mojo/core/ipcz_driver/object.h" +#include "mojo/public/c/system/trap.h" +#include "mojo/public/c/system/types.h" +#include "third_party/ipcz/include/ipcz/ipcz.h" + +namespace mojo::core::ipcz_driver { + +// Mojo traps are more complex than ipcz traps. A Mojo trap is approximately +// equivalent to a *collection* of ipcz traps (which Mojo would call "triggers" +// within a trap) sharing a common event handler. +// +// A Mojo trap can only be armed while all of its triggers' conditions are +// simultaneously unsatisfied. This object emulates that behavior well enough to +// suit Chromium's needs. +class MojoTrap : public Object<MojoTrap> { + public: + explicit MojoTrap(MojoTrapEventHandler handler); + + static Type object_type() { return kMojoTrap; } + + // Registers a new trigger on this trap. Each trigger corresponds to an active + // ipcz trap when this Mojo trap is armed. + MojoResult AddTrigger(MojoHandle handle, + MojoHandleSignals signals, + MojoTriggerCondition condition, + uintptr_t trigger_context); + + // Unregisters a trigger from the trap. If the trigger still has an ipcz trap + // installed on `handle`, any event it may eventually fire will be ignored. + MojoResult RemoveTrigger(uintptr_t trigger_context); + + // Attempts to arm this Mojo trap. Successful arming means that for every + // trigger added, we can install a corresponding ipcz trap. + MojoResult Arm(MojoTrapEvent* blocking_events, uint32_t* num_blocking_events); + + // ObjectBase: + void Close() override; + + private: + struct Trigger; + + ~MojoTrap() override; + + static void TrapEventHandler(const IpczTrapEvent* event); + static void TrapRemovalEventHandler(const IpczTrapEvent* event); + + void HandleEvent(const IpczTrapEvent& event); + void HandleTrapRemoved(const IpczTrapEvent& event); + + // Attempts to arm a single trigger by creating an ipcz trap for it. + IpczResult ArmTrigger(Trigger& trigger, + IpczTrapConditionFlags* satisfied_flags, + IpczPortalStatus* status); + + void NotifyTriggerRemoved(Trigger&); + + const MojoTrapEventHandler handler_; + + base::Lock lock_; + + using TriggerMap = base::flat_map<uintptr_t, scoped_refptr<Trigger>>; + TriggerMap triggers_ GUARDED_BY(lock_); + + // Trigger prioritization proceeds in a round-robin fashion across consecutive + // Arm() invocations. This iterator caches the most recently prioritized + // entry. + // + // SUBTLE: Because it is invalidated by mutations to `triggers_`, this MUST + // be reset any time a trigger is inserted or removed. + TriggerMap::iterator next_trigger_ GUARDED_BY(lock_) = triggers_.end(); + + bool armed_ GUARDED_BY(lock_) = false; +}; + +} // namespace mojo::core::ipcz_driver + +#endif // MOJO_CORE_IPCZ_DRIVER_MOJO_TRAP_H_
diff --git a/mojo/core/ipcz_driver/object.cc b/mojo/core/ipcz_driver/object.cc new file mode 100644 index 0000000..60d9d85 --- /dev/null +++ b/mojo/core/ipcz_driver/object.cc
@@ -0,0 +1,35 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/core/ipcz_driver/object.h" + +#include "base/check_op.h" +#include "mojo/core/ipcz_api.h" + +namespace mojo::core::ipcz_driver { + +ObjectBase::ObjectBase(Type type) : type_(type) {} + +ObjectBase::~ObjectBase() = default; + +void ObjectBase::Close() {} + +// static +IpczHandle ObjectBase::Box(scoped_refptr<ObjectBase> object) { + IpczDriverHandle handle = ReleaseAsHandle(std::move(object)); + IpczHandle box; + const IpczResult result = + GetIpczAPI().Box(GetIpczNode(), handle, IPCZ_NO_FLAGS, nullptr, &box); + CHECK_EQ(result, IPCZ_RESULT_OK); + return box; +} + +// static +IpczDriverHandle ObjectBase::PeekBox(IpczHandle box) { + IpczDriverHandle handle = IPCZ_INVALID_DRIVER_HANDLE; + GetIpczAPI().Unbox(box, IPCZ_UNBOX_PEEK, nullptr, &handle); + return handle; +} + +} // namespace mojo::core::ipcz_driver
diff --git a/mojo/core/ipcz_driver/object.h b/mojo/core/ipcz_driver/object.h new file mode 100644 index 0000000..9899ca4 --- /dev/null +++ b/mojo/core/ipcz_driver/object.h
@@ -0,0 +1,145 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MOJO_CORE_IPCZ_DRIVER_OBJECT_H_ +#define MOJO_CORE_IPCZ_DRIVER_OBJECT_H_ + +#include <cstddef> +#include <cstdint> + +#include "base/containers/span.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_refptr.h" +#include "build/build_config.h" +#include "mojo/core/ipcz_api.h" +#include "mojo/public/cpp/platform/platform_handle.h" +#include "third_party/ipcz/include/ipcz/ipcz.h" + +namespace mojo::core::ipcz_driver { + +// Common base class for objects managed by Mojo's ipcz driver. +class ObjectBase : public base::RefCountedThreadSafe<ObjectBase> { + public: + REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE(); + + enum Type : uint32_t { + // An ipcz transport endpoint. + kTransport, + + // A wrapped shared memory region. + kSharedBuffer, + + // An active mapping for a shared memory region. These objects are not + // serializable and cannot be transmitted over a Transport. + kSharedBufferMapping, + + // A PlatformHandle which can be transmitted as-is by the platform's Channel + // implementation, out-of-band from message data. This is the only type of + // driver object which can be emitted by the driver's Serialize(), and it's + // the only type accepted by its Transmit(). This type is unused on Windows, + // where all platform handles are encoded as inline message data during + // serialization. + kTransmissiblePlatformHandle, + + // A PlatformHandle which may or may not be transmissible by the platform's + // Channel implementation, but which can at least be transformed into + // something transmissible during serialization. + kWrappedPlatformHandle, + + // A MojoTrap instance used to emulate a Mojo trap. These objects are not + // serializable and cannot be transmitted over a Transport. + kMojoTrap, + + // An Invitation instance used to emulate Mojo process invitations. These + // objects are not serializable and cannot be transmitted over a Transport. + kInvitation, + }; + + explicit ObjectBase(Type type); + + Type type() const { return type_; } + + IpczDriverHandle handle() const { + return reinterpret_cast<IpczDriverHandle>(this); + } + + static ObjectBase* FromHandle(IpczDriverHandle handle) { + return reinterpret_cast<ObjectBase*>(handle); + } + + static IpczDriverHandle ReleaseAsHandle(scoped_refptr<ObjectBase> object) { + return reinterpret_cast<IpczDriverHandle>(object.release()); + } + + static scoped_refptr<ObjectBase> TakeFromHandle(IpczDriverHandle handle) { + scoped_refptr<ObjectBase> object(FromHandle(handle)); + if (object) { + // We're inheriting a ref previously owned by `handle`, so drop the extra + // ref we just added. + object->Release(); + } + return object; + } + + // Closes this object. + virtual void Close(); + + protected: + virtual ~ObjectBase(); + + // Boxes a reference to `object` and returns an IpczHandle for the box. + static IpczHandle Box(scoped_refptr<ObjectBase> object); + + // Peeks at `box` and returns its underlying driver handle. + static IpczDriverHandle PeekBox(IpczHandle box); + + private: + friend class base::RefCountedThreadSafe<ObjectBase>; + + const Type type_; +}; + +// Type-specific base class which builds on ObjectBase but which infers its Type +// from a static object_type() method defined by T. +template <typename T> +class Object : public ObjectBase { + public: + Object() : ObjectBase(T::object_type()) {} + + // Constructs a new T instance with the forwarded Args, and immediately boxes + // a reference to it. Returns a handle to the new box. + template <typename... Args> + static IpczHandle MakeBoxed(Args&&... args) { + return Box(base::MakeRefCounted<T>(std::forward<Args>(args)...)); + } + + static T* FromHandle(IpczDriverHandle handle) { + ObjectBase* object = ObjectBase::FromHandle(handle); + if (!object || object->type() != T::object_type()) { + return nullptr; + } + return static_cast<T*>(object); + } + + static scoped_refptr<T> TakeFromHandle(IpczDriverHandle handle) { + scoped_refptr<T> object(FromHandle(handle)); + if (object) { + // We're inheriting a ref previously owned by `handle`, so drop the extra + // ref we just added. + object->Release(); + } + return object; + } + + // Peeks at `box` and returns a pointer to its underlying T, if the underlying + // driver object is in fact a T. Does not invalidate `box`. + static T* FromBox(IpczHandle box) { return FromHandle(PeekBox(box)); } + + protected: + ~Object() override = default; +}; + +} // namespace mojo::core::ipcz_driver + +#endif // MOJO_CORE_IPCZ_DRIVER_OBJECT_H_
diff --git a/net/cookies/cookie_inclusion_status.cc b/net/cookies/cookie_inclusion_status.cc index 3dde61b..58f0e73 100644 --- a/net/cookies/cookie_inclusion_status.cc +++ b/net/cookies/cookie_inclusion_status.cc
@@ -170,28 +170,26 @@ switch (reason) { case WarningReason::WARN_STRICT_LAX_DOWNGRADE_STRICT_SAMESITE: return url_is_secure - ? ContextDowngradeMetricValues::STRICT_LAX_STRICT_SECURE - : ContextDowngradeMetricValues::STRICT_LAX_STRICT_INSECURE; + ? ContextDowngradeMetricValues::kStrictLaxStrictSecure + : ContextDowngradeMetricValues::kStrictLaxStrictInsecure; case WarningReason::WARN_STRICT_CROSS_DOWNGRADE_STRICT_SAMESITE: return url_is_secure - ? ContextDowngradeMetricValues::STRICT_CROSS_STRICT_SECURE - : ContextDowngradeMetricValues::STRICT_CROSS_STRICT_INSECURE; + ? ContextDowngradeMetricValues::kStrictCrossStrictSecure + : ContextDowngradeMetricValues::kStrictCrossStrictInsecure; case WarningReason::WARN_STRICT_CROSS_DOWNGRADE_LAX_SAMESITE: return url_is_secure - ? ContextDowngradeMetricValues::STRICT_CROSS_LAX_SECURE - : ContextDowngradeMetricValues::STRICT_CROSS_LAX_INSECURE; + ? ContextDowngradeMetricValues::kStrictCrossLaxSecure + : ContextDowngradeMetricValues::kStrictCrossLaxInsecure; case WarningReason::WARN_LAX_CROSS_DOWNGRADE_STRICT_SAMESITE: return url_is_secure - ? ContextDowngradeMetricValues::LAX_CROSS_STRICT_SECURE - : ContextDowngradeMetricValues::LAX_CROSS_STRICT_INSECURE; + ? ContextDowngradeMetricValues::kLaxCrossStrictSecure + : ContextDowngradeMetricValues::kLaxCrossStrictInsecure; case WarningReason::WARN_LAX_CROSS_DOWNGRADE_LAX_SAMESITE: - return url_is_secure - ? ContextDowngradeMetricValues::LAX_CROSS_LAX_SECURE - : ContextDowngradeMetricValues::LAX_CROSS_LAX_INSECURE; + return url_is_secure ? ContextDowngradeMetricValues::kLaxCrossLaxSecure + : ContextDowngradeMetricValues::kLaxCrossLaxInsecure; default: - return url_is_secure - ? ContextDowngradeMetricValues::NO_DOWNGRADE_SECURE - : ContextDowngradeMetricValues::NO_DOWNGRADE_INSECURE; + return url_is_secure ? ContextDowngradeMetricValues::kNoDowngradeSecure + : ContextDowngradeMetricValues::kNoDowngradeInsecure; } }
diff --git a/net/cookies/cookie_inclusion_status.h b/net/cookies/cookie_inclusion_status.h index cf03bc0..246fe02 100644 --- a/net/cookies/cookie_inclusion_status.h +++ b/net/cookies/cookie_inclusion_status.h
@@ -215,30 +215,30 @@ // These enums encode the context downgrade warnings + the secureness of the // url sending/setting the cookie. They're used for metrics only. The format - // is {context}_{schemeful_context}_{samesite_value}_{securness}. - // NO_DOWNGRADE_{securness} indicates that a cookie didn't have a breaking + // is k{context}{schemeful_context}{samesite_value}{securness}. + // kNoDowngrade{securness} indicates that a cookie didn't have a breaking // context downgrade and was A) included B) excluded only due to insufficient // same-site context. I.e. the cookie wasn't excluded due to other reasons // such as third-party cookie blocking. Keep this in line with // SameSiteCookieContextBreakingDowngradeWithSecureness in enums.xml. - enum ContextDowngradeMetricValues { - NO_DOWNGRADE_INSECURE = 0, - NO_DOWNGRADE_SECURE = 1, + enum class ContextDowngradeMetricValues { + kNoDowngradeInsecure = 0, + kNoDowngradeSecure = 1, - STRICT_LAX_STRICT_INSECURE = 2, - STRICT_CROSS_STRICT_INSECURE = 3, - STRICT_CROSS_LAX_INSECURE = 4, - LAX_CROSS_STRICT_INSECURE = 5, - LAX_CROSS_LAX_INSECURE = 6, + kStrictLaxStrictInsecure = 2, + kStrictCrossStrictInsecure = 3, + kStrictCrossLaxInsecure = 4, + kLaxCrossStrictInsecure = 5, + kLaxCrossLaxInsecure = 6, - STRICT_LAX_STRICT_SECURE = 7, - STRICT_CROSS_STRICT_SECURE = 8, - STRICT_CROSS_LAX_SECURE = 9, - LAX_CROSS_STRICT_SECURE = 10, - LAX_CROSS_LAX_SECURE = 11, + kStrictLaxStrictSecure = 7, + kStrictCrossStrictSecure = 8, + kStrictCrossLaxSecure = 9, + kLaxCrossStrictSecure = 10, + kLaxCrossLaxSecure = 11, // Keep last. - kMaxValue = LAX_CROSS_LAX_SECURE + kMaxValue = kLaxCrossLaxSecure }; using ExclusionReasonBitset =
diff --git a/services/device/geolocation/network_location_provider_unittest.cc b/services/device/geolocation/network_location_provider_unittest.cc index 0120354..19de05d4 100644 --- a/services/device/geolocation/network_location_provider_unittest.cc +++ b/services/device/geolocation/network_location_provider_unittest.cc
@@ -245,27 +245,32 @@ return pretty; } - static testing::AssertionResult JsonGetList( - const std::string& field, - const base::DictionaryValue& dict, - const base::ListValue** output_list) { - if (!dict.GetList(field, output_list)) + static std::string PrettyJson(const base::Value::Dict& dict_value) { + return PrettyJson(base::Value(dict_value.Clone())); + } + + static testing::AssertionResult JsonGetList(const std::string& field, + const base::Value::Dict& dict, + base::Value::List* output_list) { + const base::Value::List* list = dict.FindList(field); + if (!list) return testing::AssertionFailure() << "Dictionary " << PrettyJson(dict) << " is missing list field " << field; + *output_list = list->Clone(); return testing::AssertionSuccess(); } static testing::AssertionResult JsonFieldEquals( const std::string& field, - const base::DictionaryValue& expected, - const base::DictionaryValue& actual) { - const base::Value* expected_value; - const base::Value* actual_value; - if (!expected.Get(field, &expected_value)) + const base::Value::Dict& expected, + const base::Value::Dict& actual) { + const base::Value* expected_value = expected.Find(field); + const base::Value* actual_value = actual.Find(field); + if (!expected_value) return testing::AssertionFailure() << "Expected dictionary " << PrettyJson(expected) << " is missing field " << field; - if (!expected.Get(field, &actual_value)) + if (!actual_value) return testing::AssertionFailure() << "Actual dictionary " << PrettyJson(actual) << " is missing field " << field; @@ -292,9 +297,9 @@ absl::optional<base::Value> parsed_json = base::JSONReader::Read(upload_data); ASSERT_TRUE(parsed_json); + ASSERT_TRUE(parsed_json->is_dict()); - const base::DictionaryValue* request_json; - ASSERT_TRUE(parsed_json->GetAsDictionary(&request_json)); + const base::Value::Dict& request_json = parsed_json->GetDict(); if (expected_wifi_aps) { base::Value::List expected_wifi_aps_json; @@ -302,19 +307,16 @@ &expected_wifi_aps_json); EXPECT_EQ(size_t(expected_wifi_aps), expected_wifi_aps_json.size()); - const base::ListValue* wifi_aps_json; + base::Value::List wifi_aps_json; ASSERT_TRUE( - JsonGetList("wifiAccessPoints", *request_json, &wifi_aps_json)); + JsonGetList("wifiAccessPoints", request_json, &wifi_aps_json)); for (size_t i = 0; i < expected_wifi_aps_json.size(); ++i) { const base::Value& expected_json_value = expected_wifi_aps_json[i]; ASSERT_TRUE(expected_json_value.is_dict()); - const base::DictionaryValue& expected_json = - base::Value::AsDictionaryValue(expected_json_value); - const base::Value& actual_json_value = - wifi_aps_json->GetListDeprecated()[i]; + const base::Value::Dict& expected_json = expected_json_value.GetDict(); + const base::Value& actual_json_value = wifi_aps_json[i]; ASSERT_TRUE(actual_json_value.is_dict()); - const base::DictionaryValue& actual_json = - base::Value::AsDictionaryValue(actual_json_value); + const base::Value::Dict& actual_json = actual_json_value.GetDict(); ASSERT_TRUE(JsonFieldEquals("macAddress", expected_json, actual_json)); ASSERT_TRUE( JsonFieldEquals("signalStrength", expected_json, actual_json)); @@ -323,7 +325,7 @@ JsonFieldEquals("signalToNoiseRatio", expected_json, actual_json)); } } else { - ASSERT_FALSE(request_json->FindKey("wifiAccessPoints")); + ASSERT_FALSE(request_json.Find("wifiAccessPoints")); } }
diff --git a/skia/BUILD.gn b/skia/BUILD.gn index 0fc8dc72..7a096b9 100644 --- a/skia/BUILD.gn +++ b/skia/BUILD.gn
@@ -326,7 +326,7 @@ sources += skia_effects_imagefilter_public # The imported Skia gni source paths are made absolute by gn. - defines = skia_core_defines + defines = [] sources += skia_sksl_sources sources += skia_utils_sources sources += skia_xps_sources @@ -662,7 +662,7 @@ # Split out for targeted removal of the afdo_optimize_size config on Android. skia_source_set("skia_core_and_effects") { - defines = skia_core_defines + defines = [] sources = skia_core_sources sources += skia_effects_sources sources += skia_effects_imagefilter_sources
diff --git a/testing/buildbot/chromium.chromiumos.json b/testing/buildbot/chromium.chromiumos.json index 09683ab..a0ecb9b 100644 --- a/testing/buildbot/chromium.chromiumos.json +++ b/testing/buildbot/chromium.chromiumos.json
@@ -5753,21 +5753,21 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5241.0", + "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -5780,7 +5780,7 @@ }, "test": "interactive_ui_tests", "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "isolate_profile_data": true, @@ -5918,21 +5918,21 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -5944,7 +5944,7 @@ }, "test": "lacros_chrome_browsertests", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "args": [ @@ -6064,21 +6064,21 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -6090,7 +6090,7 @@ }, "test": "lacros_chrome_browsertests_run_in_series", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "isolate_profile_data": true,
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 82249e2..634875df 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -99190,21 +99190,21 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5241.0", + "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", @@ -99212,7 +99212,7 @@ }, "test": "interactive_ui_tests", "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "isolate_profile_data": true, @@ -99325,28 +99325,28 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test": "lacros_chrome_browsertests", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "args": [ @@ -99446,28 +99446,28 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test": "lacros_chrome_browsertests_run_in_series", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "isolate_profile_data": true, @@ -100805,20 +100805,20 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5241.0", + "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -100832,7 +100832,7 @@ }, "test": "interactive_ui_tests", "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "merge": { @@ -100970,20 +100970,20 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -100996,7 +100996,7 @@ }, "test": "lacros_chrome_browsertests", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "args": [ @@ -101116,20 +101116,20 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -101142,7 +101142,7 @@ }, "test": "lacros_chrome_browsertests_run_in_series", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "merge": { @@ -102638,20 +102638,20 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5241.0", + "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -102665,7 +102665,7 @@ }, "test": "interactive_ui_tests", "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "merge": { @@ -102803,20 +102803,20 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -102829,7 +102829,7 @@ }, "test": "lacros_chrome_browsertests", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "args": [ @@ -102949,20 +102949,20 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -102975,7 +102975,7 @@ }, "test": "lacros_chrome_browsertests_run_in_series", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "merge": { @@ -103710,20 +103710,20 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5241.0", + "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -103736,7 +103736,7 @@ }, "test": "interactive_ui_tests", "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" } ] }, @@ -118622,83 +118622,5 @@ "test_id_prefix": "ninja://ui/views:views_perftests/" } ] - }, - "win10.20h2-blink-rel": { - "isolated_scripts": [ - { - "args": [ - "--num-retries=3", - "--write-run-histories-to=${ISOLATED_OUTDIR}/run_histories.json", - "--git-revision=${got_revision}" - ], - "check_flakiness_for_new_tests": false, - "isolate_name": "blink_web_tests", - "merge": { - "args": [ - "--verbose" - ], - "script": "//third_party/blink/tools/merge_web_test_results.py" - }, - "name": "blink_web_tests", - "precommit_args": [ - "--gerrit-issue=${patch_issue}", - "--gerrit-patchset=${patch_set}", - "--buildbucket-id=${buildbucket_build_id}" - ], - "resultdb": { - "enable": true - }, - "results_handler": "layout tests", - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "os": "Windows-10-19042" - } - ], - "hard_timeout": 1200, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 6 - }, - "test_id_prefix": "ninja://:blink_web_tests/" - }, - { - "args": [ - "--num-retries=3", - "--write-run-histories-to=${ISOLATED_OUTDIR}/run_histories.json", - "--git-revision=${got_revision}" - ], - "check_flakiness_for_new_tests": false, - "isolate_name": "blink_wpt_tests", - "merge": { - "args": [ - "--verbose" - ], - "script": "//third_party/blink/tools/merge_web_test_results.py" - }, - "name": "blink_wpt_tests", - "precommit_args": [ - "--gerrit-issue=${patch_issue}", - "--gerrit-patchset=${patch_set}", - "--buildbucket-id=${buildbucket_build_id}" - ], - "resultdb": { - "enable": true - }, - "results_handler": "layout tests", - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "os": "Windows-10-19042" - } - ], - "hard_timeout": 1200, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 9 - }, - "test_id_prefix": "ninja://:blink_wpt_tests/" - } - ] } }
diff --git a/testing/buildbot/chromium.memory.json b/testing/buildbot/chromium.memory.json index f982a4f..f01f7cb 100644 --- a/testing/buildbot/chromium.memory.json +++ b/testing/buildbot/chromium.memory.json
@@ -20820,21 +20820,21 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5241.0", + "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -20847,7 +20847,7 @@ }, "test": "interactive_ui_tests", "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "isolate_profile_data": true, @@ -20985,21 +20985,21 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -21011,7 +21011,7 @@ }, "test": "lacros_chrome_browsertests", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "args": [ @@ -21131,21 +21131,21 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome" ], "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5241.0", + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5242.0", "swarming": { "can_use_on_swarming_builders": true, "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5241.0", - "revision": "version:106.0.5241.0" + "location": "lacros_version_skew_tests_v106.0.5242.0", + "revision": "version:106.0.5242.0" } ], "dimension_sets": [ @@ -21157,7 +21157,7 @@ }, "test": "lacros_chrome_browsertests_run_in_series", "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5241.0" + "variant_id": "Lacros version skew testing ash 106.0.5242.0" }, { "isolate_profile_data": true,
diff --git a/testing/buildbot/tryserver.blink.json b/testing/buildbot/tryserver.blink.json index e674128..4393e969 100644 --- a/testing/buildbot/tryserver.blink.json +++ b/testing/buildbot/tryserver.blink.json
@@ -255,6 +255,84 @@ } ] }, + "win10.20h2-blink-rel": { + "isolated_scripts": [ + { + "args": [ + "--num-retries=3", + "--write-run-histories-to=${ISOLATED_OUTDIR}/run_histories.json", + "--git-revision=${got_revision}" + ], + "check_flakiness_for_new_tests": false, + "isolate_name": "blink_web_tests", + "merge": { + "args": [ + "--verbose" + ], + "script": "//third_party/blink/tools/merge_web_test_results.py" + }, + "name": "blink_web_tests", + "precommit_args": [ + "--gerrit-issue=${patch_issue}", + "--gerrit-patchset=${patch_set}", + "--buildbucket-id=${buildbucket_build_id}" + ], + "resultdb": { + "enable": true + }, + "results_handler": "layout tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "os": "Windows-10-19042" + } + ], + "hard_timeout": 1200, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 6 + }, + "test_id_prefix": "ninja://:blink_web_tests/" + }, + { + "args": [ + "--num-retries=3", + "--write-run-histories-to=${ISOLATED_OUTDIR}/run_histories.json", + "--git-revision=${got_revision}" + ], + "check_flakiness_for_new_tests": false, + "isolate_name": "blink_wpt_tests", + "merge": { + "args": [ + "--verbose" + ], + "script": "//third_party/blink/tools/merge_web_test_results.py" + }, + "name": "blink_wpt_tests", + "precommit_args": [ + "--gerrit-issue=${patch_issue}", + "--gerrit-patchset=${patch_set}", + "--buildbucket-id=${buildbucket_build_id}" + ], + "resultdb": { + "enable": true + }, + "results_handler": "layout tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "os": "Windows-10-19042" + } + ], + "hard_timeout": 1200, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 9 + }, + "test_id_prefix": "ninja://:blink_wpt_tests/" + } + ] + }, "win11-blink-rel": { "isolated_scripts": [ {
diff --git a/testing/buildbot/variants.pyl b/testing/buildbot/variants.pyl index 1d3b2070..db43b654 100644 --- a/testing/buildbot/variants.pyl +++ b/testing/buildbot/variants.pyl
@@ -22,15 +22,15 @@ }, 'LACROS_VERSION_SKEW_CANARY': { 'args': [ - '--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5241.0/test_ash_chrome', + '--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5242.0/test_ash_chrome', ], - 'identifier': 'Lacros version skew testing ash 106.0.5241.0', + 'identifier': 'Lacros version skew testing ash 106.0.5242.0', 'swarming': { 'cipd_packages': [ { 'cipd_package': 'chromium/testing/linux-ash-chromium/x86_64/ash.zip', - 'location': 'lacros_version_skew_tests_v106.0.5241.0', - 'revision': 'version:106.0.5241.0', + 'location': 'lacros_version_skew_tests_v106.0.5242.0', + 'revision': 'version:106.0.5242.0', }, ], },
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index 9e6c28a..4ad72e8 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -3946,17 +3946,6 @@ 'isolated_scripts': 'chromium_win_rel_isolated_scripts', }, }, - 'win10.20h2-blink-rel': { - 'mixins': [ - 'win10', - ], - 'swarming': { - 'hard_timeout': 900, - }, - 'test_suites': { - 'isolated_scripts': 'chromium_webkit_isolated_scripts', - }, - }, }, }, { @@ -6737,6 +6726,17 @@ 'isolated_scripts': 'chromium_webkit_isolated_scripts', }, }, + 'win10.20h2-blink-rel': { + 'mixins': [ + 'win10', + ], + 'swarming': { + 'hard_timeout': 900, + }, + 'test_suites': { + 'isolated_scripts': 'chromium_webkit_isolated_scripts', + }, + }, 'win11-blink-rel': { 'mixins': [ 'win11',
diff --git a/testing/test.gni b/testing/test.gni index 0ef71de..094d4e8 100644 --- a/testing/test.gni +++ b/testing/test.gni
@@ -127,16 +127,8 @@ action("${target_name}__rts_filters") { script = "//build/add_rts_filters.py" rts_file = "${root_build_dir}/gen/rts/${invoker.target_name}.filter" - inverted_rts_file = - "${root_build_dir}/gen/rts/${invoker.target_name}_inverted.filter" - args = [ - rebase_path(rts_file, root_build_dir), - rebase_path(inverted_rts_file, root_build_dir), - ] - outputs = [ - rts_file, - inverted_rts_file, - ] + args = [ rebase_path(rts_file, root_build_dir) ] + outputs = [ rts_file ] } } @@ -1042,16 +1034,8 @@ action("${target_name}__rts_filters") { script = "//build/add_rts_filters.py" rts_file = "${root_build_dir}/gen/rts/${invoker.target_name}.filter" - inverted_rts_file = - "${root_build_dir}/gen/rts/${invoker.target_name}_inverted.filter" - args = [ - rebase_path(rts_file, root_build_dir), - rebase_path(inverted_rts_file, root_build_dir), - ] - outputs = [ - rts_file, - inverted_rts_file, - ] + args = [ rebase_path(rts_file, root_build_dir) ] + outputs = [ rts_file ] } }
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 2b0fc7a..7b1677d 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -3480,25 +3480,6 @@ ] } ], - "DesktopNtpFre": [ - { - "platforms": [ - "chromeos", - "chromeos_lacros", - "linux", - "mac", - "windows" - ], - "experiments": [ - { - "name": "Fre", - "enable_features": [ - "NtpModulesFirstRunExperience" - ] - } - ] - } - ], "DesktopNtpModules": [ { "platforms": [ @@ -4575,6 +4556,25 @@ ] } ], + "GoogleLensDesktopTransparentImagesFix": [ + { + "platforms": [ + "chromeos", + "chromeos_lacros", + "linux", + "mac", + "windows" + ], + "experiments": [ + { + "name": "Enabled", + "enable_features": [ + "LensTransparentImagesFix" + ] + } + ] + } + ], "GoogleLensIOS": [ { "platforms": [
diff --git a/third_party/blink/public/mojom/input/input_handler.mojom b/third_party/blink/public/mojom/input/input_handler.mojom index d50da9cc..994543e8 100644 --- a/third_party/blink/public/mojom/input/input_handler.mojom +++ b/third_party/blink/public/mojom/input/input_handler.mojom
@@ -405,6 +405,12 @@ kNotFocusedAndNotActive }; +// TODO(sinansahin): DidOverscrollParams and TouchActionOptional can be moved +// into this struct as well. +struct ScrollResultData { + gfx.mojom.PointF? root_scroll_offset; +}; + // Interface exposed by the renderer to the browser. This class represents // an input interface for an associated Widget object. See FrameWidgetInputHandler // for an interface at the frame level. @@ -469,7 +475,8 @@ ui.mojom.LatencyInfo updated_latency, blink.mojom.InputEventResultState state, DidOverscrollParams? overscroll, - TouchActionOptional? touch_action); + TouchActionOptional? touch_action, + ScrollResultData? scroll_result_data); // Sends a non-blocking input event to the render widget. The behaviour // of this API is the same as DispatchEvent just that there is no callback
diff --git a/third_party/blink/renderer/bindings/core/v8/module_record_test.cc b/third_party/blink/renderer/bindings/core/v8/module_record_test.cc index d66d0d68..4368fe34 100644 --- a/third_party/blink/renderer/bindings/core/v8/module_record_test.cc +++ b/third_party/blink/renderer/bindings/core/v8/module_record_test.cc
@@ -251,8 +251,10 @@ JSModuleScript::CreateForTest(modulator, module, js_url_c) ->RunScriptOnScriptStateAndReturnValue(scope.GetScriptState()); - v8::Local<v8::Value> exception1 = GetException(state, evaluation_result1); - v8::Local<v8::Value> exception2 = GetException(state, evaluation_result2); + v8::Local<v8::Value> exception1 = + GetException(state, std::move(evaluation_result1)); + v8::Local<v8::Value> exception2 = + GetException(state, std::move(evaluation_result2)); EXPECT_FALSE(exception1.IsEmpty()); EXPECT_FALSE(exception2.IsEmpty()); EXPECT_EQ(exception1, exception2); @@ -315,7 +317,8 @@ JSModuleScript::CreateForTest(modulator, module, js_url) ->RunScriptOnScriptStateAndReturnValue(scope.GetScriptState()); - v8::Local<v8::Value> exception = GetException(scope.GetScriptState(), result); + v8::Local<v8::Value> exception = + GetException(scope.GetScriptState(), std::move(result)); ASSERT_TRUE(exception->IsString()); EXPECT_EQ("bar", ToCoreString(exception.As<v8::String>())); }
diff --git a/third_party/blink/renderer/bindings/core/v8/script_evaluation_result.h b/third_party/blink/renderer/bindings/core/v8/script_evaluation_result.h index da3a586..c960f8a 100644 --- a/third_party/blink/renderer/bindings/core/v8/script_evaluation_result.h +++ b/third_party/blink/renderer/bindings/core/v8/script_evaluation_result.h
@@ -27,9 +27,10 @@ public: ScriptEvaluationResult() = delete; - ScriptEvaluationResult(const ScriptEvaluationResult& value) = default; - ScriptEvaluationResult& operator=(const ScriptEvaluationResult& value) = - default; + ScriptEvaluationResult(const ScriptEvaluationResult&) = delete; + ScriptEvaluationResult& operator=(const ScriptEvaluationResult&) = delete; + ScriptEvaluationResult(ScriptEvaluationResult&&) = default; + ScriptEvaluationResult& operator=(ScriptEvaluationResult&&) = default; ~ScriptEvaluationResult() = default; enum class ResultType {
diff --git a/third_party/blink/renderer/core/dom/element.cc b/third_party/blink/renderer/core/dom/element.cc index a548e53d..8f14880 100644 --- a/third_party/blink/renderer/core/dom/element.cc +++ b/third_party/blink/renderer/core/dom/element.cc
@@ -86,6 +86,7 @@ #include "third_party/blink/renderer/core/dom/element_rare_data.h" #include "third_party/blink/renderer/core/dom/element_traversal.h" #include "third_party/blink/renderer/core/dom/events/event_dispatch_forbidden_scope.h" +#include "third_party/blink/renderer/core/dom/events/event_dispatch_result.h" #include "third_party/blink/renderer/core/dom/events/event_dispatcher.h" #include "third_party/blink/renderer/core/dom/events/event_path.h" #include "third_party/blink/renderer/core/dom/first_letter_pseudo_element.h" @@ -2512,6 +2513,17 @@ "Invalid on already-showing or disconnected popup elements"); } + // Fire the show event (bubbles, cancelable). + Event* event = Event::CreateCancelableBubble(event_type_names::kShow); + event->SetTarget(this); + if (DispatchEvent(*event) != DispatchEventResult::kNotCanceled) + return; + + // The 'show' event handler could have changed this pop-up, e.g. by changing + // its type, removing it from the document, or calling showPopUp(). + if (!HasValidPopupAttribute() || !isConnected() || popupOpen()) + return; + bool should_restore_focus = false; auto& document = GetDocument(); if (PopupType() == PopupValueType::kAuto || @@ -2561,17 +2573,6 @@ DCHECK(!document.AllOpenPopUps().Contains(this)); document.AllOpenPopUps().insert(this); - // Fire the show event (bubbles, not cancelable). - Event* event = Event::CreateBubble(event_type_names::kShow); - event->SetTarget(this); - auto result = DispatchEvent(*event); - DCHECK_EQ(result, DispatchEventResult::kNotCanceled); - - // The 'show' event handler could have changed this pop-up, e.g. by changing - // its type, removing it from the document, or calling showPopUp(). - if (!HasValidPopupAttribute() || !isConnected() || popupOpen()) - return; - GetPopupData()->setAnimationFinishedListener(nullptr); GetPopupData()->setPreviouslyFocusedElement( should_restore_focus ? document.FocusedElement() : nullptr);
diff --git a/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.cc b/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.cc index 9635315..e45d22a 100644 --- a/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.cc +++ b/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.cc
@@ -9,6 +9,7 @@ #include "third_party/blink/renderer/core/editing/editing_utilities.h" #include "third_party/blink/renderer/core/editing/ephemeral_range.h" #include "third_party/blink/renderer/core/editing/frame_selection.h" +#include "third_party/blink/renderer/core/editing/iterators/backwards_character_iterator.h" #include "third_party/blink/renderer/core/editing/iterators/character_iterator.h" #include "third_party/blink/renderer/core/editing/selection_template.h" #include "third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.h" @@ -23,15 +24,26 @@ namespace { -const int kColdModeChunkSize = 16384; // in UTF16 code units +// in UTF16 code units +const int kColdModeFullCheckingChunkSize = 16384; +const int kColdModeLocalCheckingSize = 128; +const int kRecheckThreshold = 1024; + const int kInvalidChunkIndex = -1; +int TotalTextLength(const Element& root_editable) { + const EphemeralRange& full_range = + EphemeralRange::RangeOfContents(root_editable); + return TextIterator::RangeLength(full_range); +} + } // namespace void ColdModeSpellCheckRequester::Trace(Visitor* visitor) const { visitor->Trace(window_); visitor->Trace(root_editable_); visitor->Trace(remaining_check_range_); + visitor->Trace(fully_checked_root_editables_); } ColdModeSpellCheckRequester::ColdModeSpellCheckRequester(LocalDOMWindow& window) @@ -87,9 +99,24 @@ return; } - if (root_editable_ != current_focused) { + switch (AccumulateTextDeltaAndComputeCheckingType(*current_focused)) { + case CheckingType::kNone: + return; + case CheckingType::kLocal: + return RequestLocalChecking(*current_focused); + case CheckingType::kFull: + return RequestFullChecking(*current_focused, deadline); + } +} + +void ColdModeSpellCheckRequester::RequestFullChecking( + const Element& element_to_check, + IdleDeadline* deadline) { + TRACE_EVENT0("blink", "ColdModeSpellCheckRequester::RequestFullChecking"); + + if (root_editable_ != &element_to_check) { ClearProgress(); - root_editable_ = current_focused; + root_editable_ = &element_to_check; last_chunk_index_ = 0; remaining_check_range_ = Range::Create(root_editable_->GetDocument()); remaining_check_range_->selectNodeContents( @@ -97,11 +124,10 @@ } while (deadline->timeRemaining() > 0) { - if (FullyChecked()) { + if (FullyChecked() || !RequestCheckingForNextChunk()) { SetHasFullyChecked(); return; } - RequestCheckingForNextChunk(); } } @@ -114,8 +140,18 @@ remaining_check_range_ = nullptr; } +void ColdModeSpellCheckRequester::Deactivate() { + ClearProgress(); + fully_checked_root_editables_.clear(); +} + void ColdModeSpellCheckRequester::SetHasFullyChecked() { DCHECK(root_editable_); + DCHECK(!fully_checked_root_editables_.Contains(root_editable_)); + + fully_checked_root_editables_.Set( + root_editable_, + FullyCheckedEditableEntry{TotalTextLength(*root_editable_), 0}); last_chunk_index_ = kInvalidChunkIndex; if (!remaining_check_range_) return; @@ -123,7 +159,7 @@ remaining_check_range_ = nullptr; } -void ColdModeSpellCheckRequester::RequestCheckingForNextChunk() { +bool ColdModeSpellCheckRequester::RequestCheckingForNextChunk() { DCHECK(root_editable_); DCHECK(!FullyChecked()); @@ -132,16 +168,15 @@ remaining_range, // Same behavior used in |CalculateCharacterSubrange()| TextIteratorBehavior::EmitsObjectReplacementCharacterBehavior()); - if (remaining_length == 0) { - SetHasFullyChecked(); - return; - } + if (remaining_length == 0) + return false; const int chunk_index = last_chunk_index_ + 1; const Position chunk_start = remaining_range.StartPosition(); const Position chunk_end = - CalculateCharacterSubrange(remaining_range, 0, - std::min(remaining_length, kColdModeChunkSize)) + CalculateCharacterSubrange( + remaining_range, 0, + std::min(remaining_length, kColdModeFullCheckingChunkSize)) .EndPosition(); // Chromium spellchecker requires complete sentences to be checked. However, @@ -158,6 +193,66 @@ last_chunk_index_ = chunk_index; remaining_check_range_->setStart(check_range.EndPosition()); + return true; +} + +ColdModeSpellCheckRequester::CheckingType +ColdModeSpellCheckRequester::AccumulateTextDeltaAndComputeCheckingType( + const Element& element_to_check) { + // Do full checking if we haven't done that before + auto iter = fully_checked_root_editables_.find(&element_to_check); + if (iter == fully_checked_root_editables_.end()) + return CheckingType::kFull; + + int current_text_length = TotalTextLength(element_to_check); + int delta = + std::abs(current_text_length - iter->value.previous_checked_length); + + // Cold mode checking is not needed without plain text change (for example, + // after moving caret, changing text style, etc). + if (!delta) + return CheckingType::kNone; + + iter->value.accumulated_delta += delta; + iter->value.previous_checked_length = current_text_length; + + if (iter->value.accumulated_delta > kRecheckThreshold) { + fully_checked_root_editables_.erase(iter); + return CheckingType::kFull; + } + + return CheckingType::kLocal; +} + +void ColdModeSpellCheckRequester::RequestLocalChecking( + const Element& element_to_check) { + TRACE_EVENT0("blink", "ColdModeSpellCheckRequester::RequestLocalChecking"); + + const EphemeralRange& full_range = + EphemeralRange::RangeOfContents(element_to_check); + const Position position = + window_->GetFrame()->Selection().GetSelectionInDOMTree().Extent(); + DCHECK(position.IsNotNull()); + + TextIteratorBehavior behavior = + TextIteratorBehavior::Builder() + .SetEmitsObjectReplacementCharacter(true) + .SetEmitsPunctuationForReplacedElements(true) + .Build(); + BackwardsCharacterIterator backward_iterator( + EphemeralRange(full_range.StartPosition(), position), behavior); + if (!backward_iterator.AtEnd()) + backward_iterator.Advance(kColdModeLocalCheckingSize / 2); + const Position& chunk_start = backward_iterator.EndPosition(); + CharacterIterator forward_iterator(position, full_range.EndPosition(), + behavior); + if (!forward_iterator.AtEnd()) + forward_iterator.Advance(kColdModeLocalCheckingSize / 2); + const Position& chunk_end = forward_iterator.EndPosition(); + EphemeralRange checking_range = + ExpandRangeToSentenceBoundary(EphemeralRange(chunk_start, chunk_end)); + + GetSpellCheckRequester().RequestCheckingFor(checking_range); } } // namespace blink
diff --git a/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.h b/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.h index 8859ba6..61bb3e7c 100644 --- a/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.h +++ b/third_party/blink/renderer/core/editing/spellcheck/cold_mode_spell_check_requester.h
@@ -35,7 +35,13 @@ void Invoke(IdleDeadline*); + // Called when code mode checking is currently not needed (due to, e.g., user + // has resumed active). void ClearProgress(); + + // Called when document is detached or spellchecking is globally disabled. + void Deactivate(); + bool FullyChecked() const; void Trace(Visitor*) const; @@ -45,14 +51,24 @@ const Element* CurrentFocusedEditable() const; - void RequestCheckingForNextChunk(); + enum class CheckingType { kNone, kLocal, kFull }; + CheckingType AccumulateTextDeltaAndComputeCheckingType( + const Element& element_to_check); + + void RequestLocalChecking(const Element& element_to_check); + + void RequestFullChecking(const Element& element_to_check, IdleDeadline*); + + // Returns true if there's anything remaining to check, false otherwise + bool RequestCheckingForNextChunk(); void SetHasFullyChecked(); // The window this cold mode checker belongs to. const Member<LocalDOMWindow> window_; - // The root editable element checked in the last invocation. |nullptr| if not - // invoked yet or didn't find any root editable element to check. + // The root editable element checked in the last invocation for full checking. + // |nullptr| if not invoked yet or didn't find any root editable element for + // full checking. Member<const Element> root_editable_; // If |root_editable_| is non-null and hasn't been fully checked, the id of @@ -61,6 +77,17 @@ int last_chunk_index_; Member<Range> remaining_check_range_; + // After fully checking an element, we don't want to repeatedly check its + // content in full unless a significant amount of change has taken place. We + // heuristically measure this as the accumulated length change in the element + // since the last time it was fully checked. + struct FullyCheckedEditableEntry { + int previous_checked_length = 0; + int accumulated_delta = 0; + }; + HeapHashMap<Member<const Element>, FullyCheckedEditableEntry> + fully_checked_root_editables_; + // A test-only flag for forcing lifecycle advancing. mutable bool needs_more_invocation_for_testing_; };
diff --git a/third_party/blink/renderer/core/editing/spellcheck/idle_spell_check_controller.cc b/third_party/blink/renderer/core/editing/spellcheck/idle_spell_check_controller.cc index 1618331..8f3e11ad 100644 --- a/third_party/blink/renderer/core/editing/spellcheck/idle_spell_check_controller.cc +++ b/third_party/blink/renderer/core/editing/spellcheck/idle_spell_check_controller.cc
@@ -103,7 +103,7 @@ state_ = State::kInactive; if (cold_mode_timer_.IsActive()) cold_mode_timer_.Cancel(); - cold_mode_requester_->ClearProgress(); + cold_mode_requester_->Deactivate(); DisposeIdleCallback(); spell_check_requeseter_->Deactivate(); }
diff --git a/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.cc b/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.cc index 8f8459f3..f71adb6 100644 --- a/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.cc +++ b/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.cc
@@ -165,9 +165,7 @@ } SpellCheckRequester::SpellCheckRequester(LocalDOMWindow& window) - : window_(&window), - last_request_sequence_(0), - last_processed_sequence_(0) {} + : window_(&window) {} SpellCheckRequester::~SpellCheckRequester() = default; @@ -193,6 +191,8 @@ if (!request) return false; + spell_checked_text_length_ += request->GetText().length(); + DCHECK_EQ(request->Sequence(), SpellCheckRequest::kUnrequestedTextCheckingSequence); int sequence = ++last_request_sequence_;
diff --git a/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.h b/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.h index 5ce7e8e..dfa4e59 100644 --- a/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.h +++ b/third_party/blink/renderer/core/editing/spellcheck/spell_check_requester.h
@@ -98,6 +98,9 @@ int LastProcessedSequence() const { return last_processed_sequence_; } + // Returns the total length of all text that has been requested for checking. + int SpellCheckedTextLength() const { return spell_checked_text_length_; } + // Called to clean up pending requests when no more checking is needed. For // example, when document is closed. void Deactivate(); @@ -118,8 +121,9 @@ Member<LocalDOMWindow> window_; - int last_request_sequence_; - int last_processed_sequence_; + int last_request_sequence_ = 0; + int last_processed_sequence_ = 0; + wtf_size_t spell_checked_text_length_ = 0; TaskHandle timer_to_process_queued_request_;
diff --git a/third_party/blink/renderer/core/frame/frame_test_helpers.cc b/third_party/blink/renderer/core/frame/frame_test_helpers.cc index 89fa4c6..96d0e2bc 100644 --- a/third_party/blink/renderer/core/frame/frame_test_helpers.cc +++ b/third_party/blink/renderer/core/frame/frame_test_helpers.cc
@@ -52,6 +52,7 @@ #include "third_party/blink/public/mojom/frame/frame_replication_state.mojom.h" #include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom-blink.h" #include "third_party/blink/public/mojom/frame/tree_scope_type.mojom-blink.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-blink-forward.h" #include "third_party/blink/public/mojom/input/touch_event.mojom-blink.h" #include "third_party/blink/public/mojom/page/widget.mojom-blink.h" #include "third_party/blink/public/platform/interface_registry.h" @@ -888,7 +889,8 @@ mojom::blink::InputEventResultSource, const ui::LatencyInfo&, mojom::blink::InputEventResultState, mojom::blink::DidOverscrollParamsPtr overscroll, - mojom::blink::TouchActionOptionalPtr) { + mojom::blink::TouchActionOptionalPtr, + mojom::blink::ScrollResultDataPtr) { if (widget) widget->last_overscroll_ = std::move(overscroll); },
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc index 3974bf7..c1d5b8d 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc
@@ -768,7 +768,7 @@ SourceImageStatus status; source_image = GetSourceImageForCanvasInternal(&status); if (status != kNormalSourceImageStatus) - return; + continue; } // Here we need to use the SharedGpuContext as some of the images may @@ -1160,11 +1160,14 @@ } void HTMLCanvasElement::AddListener(CanvasDrawListener* listener) { + // The presence of a listener forces OffscrenCanvas animations to be active listeners_.insert(listener); + UpdateSuspendOffscreenCanvasAnimation(); } void HTMLCanvasElement::RemoveListener(CanvasDrawListener* listener) { listeners_.erase(listener); + UpdateSuspendOffscreenCanvasAnimation(); } bool HTMLCanvasElement::OriginClean() const { @@ -1330,17 +1333,21 @@ dirty_rect_ = gfx::RectF(); } -void HTMLCanvasElement::PageVisibilityChanged() { - bool hidden = !GetPage()->IsPageVisible(); - // If we are still painting, then continue to allow animations, even if the - // page is otherwise hidden. +void HTMLCanvasElement::UpdateSuspendOffscreenCanvasAnimation() { SetSuspendOffscreenCanvasAnimation( GetPage()->GetVisibilityState() == - mojom::blink::PageVisibilityState::kHidden); + mojom::blink::PageVisibilityState::kHidden && + !HasCanvasCapture()); +} +void HTMLCanvasElement::PageVisibilityChanged() { + // If we are still painting, then continue to allow animations, even if the + // page is otherwise hidden. + UpdateSuspendOffscreenCanvasAnimation(); if (!context_) return; + bool hidden = !GetPage()->IsPageVisible(); context_->SetIsInHiddenPage(hidden); if (hidden && (IsWebGL() || IsWebGPU())) DiscardResourceProvider();
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.h b/third_party/blink/renderer/core/html/canvas/html_canvas_element.h index 0c9d87a1..9ade760 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.h +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.h
@@ -276,6 +276,8 @@ return DispatchEvent(*event); } + void UpdateSuspendOffscreenCanvasAnimation(); + // Gets the settings of this Html Canvas Element. If there is a frame, it will // return the settings from the frame. If it is a frameless element it will // try to fetch the global dom window and get the settings from there.
diff --git a/third_party/blink/renderer/core/layout/ng/custom/layout_worklet_test.cc b/third_party/blink/renderer/core/layout/ng/custom/layout_worklet_test.cc index c8e4bdf8..68ba59bf 100644 --- a/third_party/blink/renderer/core/layout/ng/custom/layout_worklet_test.cc +++ b/third_party/blink/renderer/core/layout/ng/custom/layout_worklet_test.cc
@@ -88,7 +88,7 @@ async layout() { } }); )JS"); - EXPECT_FALSE(GetResult(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetResult(GetScriptState(), std::move(result)).IsEmpty()); LayoutWorkletGlobalScope* global_scope = GetGlobalScope(); CSSLayoutDefinition* definition = global_scope->FindDefinition("foo"); @@ -123,7 +123,7 @@ }); )JS"); - EXPECT_FALSE(GetResult(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetResult(GetScriptState(), std::move(result)).IsEmpty()); result = EvaluateScriptModule(R"JS( registerLayout('bar', class { @@ -134,7 +134,7 @@ }); )JS"); - EXPECT_FALSE(GetResult(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetResult(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_EmptyName) { @@ -145,7 +145,7 @@ )JS"); // "The empty string is not a valid name." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_Duplicate) { @@ -162,7 +162,7 @@ )JS"); // "A class with name:'foo' is already registered." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_NoIntrinsicSizes) { @@ -173,7 +173,7 @@ )JS"); // "The 'intrinsicSizes' property on the prototype does not exist." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_ThrowingPropertyGetter) { @@ -185,7 +185,7 @@ )JS"); // "Uncaught Error" - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_BadPropertyGetter) { @@ -197,7 +197,7 @@ )JS"); // "The provided value cannot be converted to a sequence." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_NoPrototype) { @@ -209,7 +209,7 @@ )JS"); // "The 'prototype' object on the class does not exist." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_BadPrototype) { @@ -221,7 +221,7 @@ )JS"); // "The 'prototype' property on the class is not an object." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_BadIntrinsicSizes) { @@ -233,7 +233,7 @@ )JS"); // "The 'intrinsicSizes' property on the prototype is not a function." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_NoLayout) { @@ -245,7 +245,7 @@ )JS"); // "The 'layout' property on the prototype does not exist." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } TEST_F(LayoutWorkletTest, RegisterLayout_BadLayout) { @@ -258,7 +258,7 @@ )JS"); // "The 'layout' property on the prototype is not a function." - EXPECT_FALSE(GetException(GetScriptState(), result).IsEmpty()); + EXPECT_FALSE(GetException(GetScriptState(), std::move(result)).IsEmpty()); } } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc index 8cdab38..871d5f0 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc
@@ -676,6 +676,12 @@ const NGLayoutResult* NGBlockNode::LayoutRepeatableRoot( const NGConstraintSpace& constraint_space, const NGBlockBreakToken* break_token) const { + // We read and write the physical fragments vector in LayoutBox here, which + // isn't allowed if side-effects are disabled. However, if side-effects are + // disabled, we shouldn't be here anyway, since we shouldn't be performing + // block fragmentation then (and therefore never repeat content). + DCHECK(!NGDisableSideEffectsScope::IsDisabled()); + // When laying out repeatable content, we cannot at the same time allow it to // break inside. DCHECK(!constraint_space.HasBlockFragmentation()); @@ -704,7 +710,7 @@ // numbers right, which is important when adding the result to the LayoutBox, // and it's also needed by pre-paint / paint. const NGBlockBreakToken* outgoing_break_token = nullptr; - if (constraint_space.IsRepeatable()) + if (constraint_space.ShouldRepeat()) outgoing_break_token = NGBlockBreakToken::CreateRepeated(*this, index); auto mutator = fragment.GetMutableForCloning(); mutator.SetBreakToken(outgoing_break_token); @@ -718,7 +724,7 @@ box_->SetLayoutResult(result, index); } - if (!constraint_space.IsRepeatable()) { + if (!constraint_space.ShouldRepeat()) { // This is the last fragment. It won't be repeated again. We have already // created fragments for the repeated nodes, but the cloning was shallow. // We're now ready to deep-clone the entire subtree for each repeated
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_node.h b/third_party/blink/renderer/core/layout/ng/ng_block_node.h index 40135f7..14d9be8 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_node.h +++ b/third_party/blink/renderer/core/layout/ng/ng_block_node.h
@@ -54,7 +54,7 @@ // element during printing, or table header / footer). To be called once for // each container fragment in which it repeats. // - // NGConstraintSpace::IsRepeatable() will tell whether the node is + // NGConstraintSpace::ShouldRepeat() will tell whether the node is // (potentially [1]) going to repeat again (in which case an outgoing "repeat" // break token will be created, or if this is the last time (no outgoing break // token will be created).
diff --git a/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc b/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc index 76ee25b..7377cf4 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.cc
@@ -682,7 +682,7 @@ DCHECK(!HasInflowChildBreakInside()); DCHECK(!DidBreakSelf()); DCHECK(!has_forced_break_); - DCHECK(ConstraintSpace().IsRepeatable() || !HasBreakTokenData()); + DCHECK(ConstraintSpace().ShouldRepeat() || !HasBreakTokenData()); DCHECK_EQ(minimal_space_shortage_, kIndefiniteSize); if (!ConstraintSpace().ShouldPropagateChildBreakValues()) { DCHECK(!initial_break_before_);
diff --git a/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h b/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h index 0bb06b1b..23f6be0 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h +++ b/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h
@@ -399,11 +399,20 @@ return HasRareData() && rare_data_->is_at_fragmentainer_start; } - // Return true if the content is repeatable inside block fragmentation, which - // is the case when an element is fixed positioned (printing only), or a + // Return true if the content will be repeated in the next fragmentainer. + // This is the case when an element is fixed positioned (printing only), or a + // repeatable table header / footer. Will return false even for repeatable + // content, if we can tell for sure that this is the last time that the node + // will repeat. + bool ShouldRepeat() const { + return HasRareData() && rare_data_->should_repeat; + } + + // Return true if we're inside repeatable content inside block fragmentation, + // which is the case when an element is fixed positioned (printing only), or a // repeatable table header / footer. - bool IsRepeatable() const { - return HasRareData() && rare_data_->is_repeatable; + bool IsInsideRepeatableContent() const { + return HasRareData() && rare_data_->is_inside_repeatable_content; } // Whether the current constraint space is for the newly established @@ -856,7 +865,8 @@ min_break_appeal(kBreakAppealLastResort), propagate_child_break_values(false), is_at_fragmentainer_start(false), - is_repeatable(false) {} + should_repeat(false), + is_inside_repeatable_content(false) {} RareData(const RareData& other) : percentage_resolution_size(other.percentage_resolution_size), replaced_percentage_resolution_block_size( @@ -885,7 +895,8 @@ min_break_appeal(other.min_break_appeal), propagate_child_break_values(other.propagate_child_break_values), is_at_fragmentainer_start(other.is_at_fragmentainer_start), - is_repeatable(other.is_repeatable) { + should_repeat(other.should_repeat), + is_inside_repeatable_content(other.is_inside_repeatable_content) { switch (GetDataUnionType()) { case DataUnionType::kNone: break; @@ -960,7 +971,8 @@ is_in_column_bfc != other.is_in_column_bfc || min_break_appeal != other.min_break_appeal || propagate_child_break_values != other.propagate_child_break_values || - is_repeatable != other.is_repeatable) + should_repeat != other.should_repeat || + is_inside_repeatable_content != other.is_inside_repeatable_content) return false; switch (GetDataUnionType()) { @@ -995,7 +1007,7 @@ should_ignore_forced_breaks || is_in_column_bfc || min_break_appeal != kBreakAppealLastResort || propagate_child_break_values || is_at_fragmentainer_start || - is_repeatable) + should_repeat || is_inside_repeatable_content) return false; switch (GetDataUnionType()) { @@ -1276,7 +1288,8 @@ unsigned min_break_appeal : kNGBreakAppealBitsNeeded; unsigned propagate_child_break_values : 1; unsigned is_at_fragmentainer_start : 1; - unsigned is_repeatable : 1; + unsigned should_repeat : 1; + unsigned is_inside_repeatable_content : 1; private: struct BlockData {
diff --git a/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h b/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h index 7454661..eb06f0fa 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h +++ b/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h
@@ -38,8 +38,9 @@ adjust_inline_size_if_needed) { if (parent_space.ShouldPropagateChildBreakValues()) SetShouldPropagateChildBreakValues(); - if (parent_space.IsRepeatable()) - SetIsRepeatable(/*is_repeatable*/ true); + if (parent_space.ShouldRepeat()) + SetShouldRepeat(true); + SetIsInsideRepeatableContent(parent_space.IsInsideRepeatableContent()); } // The setters on this builder are in the writing mode of parent_writing_mode. @@ -149,8 +150,10 @@ space_.EnsureRareData()->is_at_fragmentainer_start = true; } - void SetIsRepeatable(bool is_repeatable) { - space_.EnsureRareData()->is_repeatable = is_repeatable; + void SetShouldRepeat(bool b) { space_.EnsureRareData()->should_repeat = b; } + + void SetIsInsideRepeatableContent(bool b) { + space_.EnsureRareData()->is_inside_repeatable_content = b; } void SetIsFixedInlineSize(bool b) {
diff --git a/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.cc b/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.cc index 97be41d..4d4fa403 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.cc
@@ -126,10 +126,7 @@ child.fragment = &child_result->PhysicalFragment(); } else if (child_box->IsFragmentainerBox()) { child_box = NGPhysicalBoxFragment::Clone(*child_box); - NGFragmentRepeater child_repeater( - is_first_clone_, is_last_fragment_, - /* is_inside_nested_fragmentainer */ true); - child_repeater.CloneChildFragments(*child_box); + CloneChildFragments(*child_box); child.fragment = child_box; } } else if (child->IsLineBox()) { @@ -211,8 +208,7 @@ for (const NGLayoutResult* result : layout_box.GetLayoutResults()) { const NGBlockBreakToken* break_token = To<NGPhysicalBoxFragment>(result->PhysicalFragment()).BreakToken(); - if (!break_token || - (break_token->IsRepeated() && !is_inside_nested_fragmentainer_)) + if (!break_token || break_token->IsRepeated()) return result; } NOTREACHED();
diff --git a/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.h b/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.h index f9a0452f..590e591 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.h +++ b/third_party/blink/renderer/core/layout/ng/ng_fragment_repeater.h
@@ -26,12 +26,8 @@ STACK_ALLOCATED(); public: - explicit NGFragmentRepeater(bool is_first_clone, - bool is_last_fragment, - bool is_inside_nested_fragmentainer = false) - : is_first_clone_(is_first_clone), - is_last_fragment_(is_last_fragment), - is_inside_nested_fragmentainer_(is_inside_nested_fragmentainer) {} + NGFragmentRepeater(bool is_first_clone, bool is_last_fragment) + : is_first_clone_(is_first_clone), is_last_fragment_(is_last_fragment) {} // Deep-clone the subtree of an already shallowly cloned fragment. This will // also create new break tokens inside, in order to set unique sequence @@ -52,10 +48,6 @@ // True when at the last container fragment. No outgoing "repeat" break tokens // should be created then. bool is_last_fragment_; - - // True when we are cloning a subset of the tree in which an inner - // fragmentainer was found. - bool is_inside_nested_fragmentainer_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc index c1bd8a8..cd6ec52c 100644 --- a/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc
@@ -94,10 +94,17 @@ const NGBlockBreakToken* break_token = nullptr) { const NGLayoutResult* layout_result = caption.Layout(caption_constraint_space, break_token); - NGFragment fragment(table_constraint_space.GetWritingDirection(), - layout_result->PhysicalFragment()); - ResolveInlineMargins(caption.Style(), table_style, table_inline_size, - fragment.InlineSize(), &margins); + + if (layout_result->Status() == NGLayoutResult::kSuccess) { + NGFragment fragment(table_constraint_space.GetWritingDirection(), + layout_result->PhysicalFragment()); + ResolveInlineMargins(caption.Style(), table_style, table_inline_size, + fragment.InlineSize(), &margins); + } else { + DCHECK(caption_constraint_space.HasBlockFragmentation()); + DCHECK_EQ(layout_result->Status(), + NGLayoutResult::kOutOfFragmentainerSpace); + } return {caption, layout_result, margins}; } @@ -990,7 +997,8 @@ section_index); if (repeat_mode != kNotRepeated) { - section_space_builder.SetIsRepeatable(repeat_mode == kMayRepeatAgain); + section_space_builder.SetShouldRepeat(repeat_mode == kMayRepeatAgain); + section_space_builder.SetIsInsideRepeatableContent(true); } else if (ConstraintSpace().HasBlockFragmentation()) { SetupSpaceBuilderForFragmentation( ConstraintSpace(), section, block_offset, §ion_space_builder, @@ -1024,12 +1032,15 @@ bool has_repeated_header = false; absl::optional<LayoutUnit> pending_repeated_footer_block_size; + // Before fragmented layout we need to go through the table's children, to + // look for repeatable headers and footers. This is especially important for + // footers, since we need to reserve space for it after any preceding + // non-repeated sections (typically tbody). We'll only repeat headers / + // footers if we're not already inside repeatable content, though. + // See crbug.com/1352931 if (ConstraintSpace().HasKnownFragmentainerBlockSize() && + !ConstraintSpace().IsInsideRepeatableContent() && (grouped_children.header || grouped_children.footer)) { - // Before layout, we need to go through the table's children, to look for - // repeatable headers and footers. This is especially important for footers, - // since we need to reserve space for it after any preceding non-repeated - // sections (typically tbody). LayoutUnit max_section_block_size = ConstraintSpace().FragmentainerBlockSize() / 4; NGTableChildIterator child_iterator(grouped_children, BreakToken()); @@ -1135,6 +1146,11 @@ CaptionResult caption = LayoutCaption( ConstraintSpace(), Style(), container_builder_.InlineSize(), child_space, child, margins, child_break_token); + if (caption.layout_result->Status() != NGLayoutResult::kSuccess) { + DCHECK_EQ(caption.layout_result->Status(), + NGLayoutResult::kOutOfFragmentainerSpace); + return container_builder_.Abort(caption.layout_result->Status()); + } child_result = caption.layout_result; child_inline_offset = caption.margins.inline_start; } else {
diff --git a/third_party/blink/renderer/core/loader/document_loader.cc b/third_party/blink/renderer/core/loader/document_loader.cc index 467d6cb..187bd6a 100644 --- a/third_party/blink/renderer/core/loader/document_loader.cc +++ b/third_party/blink/renderer/core/loader/document_loader.cc
@@ -149,7 +149,7 @@ namespace blink { const base::Feature kCacheInlineScriptCode{"CacheInlineScriptCode", - base::FEATURE_ENABLED_BY_DEFAULT}; + base::FEATURE_DISABLED_BY_DEFAULT}; namespace {
diff --git a/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc b/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc index 8f7cb21..03b6968c 100644 --- a/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc +++ b/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc
@@ -85,32 +85,28 @@ TEST_P(CullRectUpdaterTest, ScaledCullRect) { SetBodyInnerHTML(R"HTML( + <style>body { margin: 0 }</style> <div id='target' style='width: 200px; height: 300px; will-change: transform; - transform: scaleX(3) scaleY(0.5)'> + transform: scaleX(2) scaleY(0.75); transform-origin: 0 0'> </div> )HTML"); // The expansion is 4000 / max(scaleX, scaleY). - // TODO(wangxianzhu): The above comment is not right. We should probably - // adjust LocalPixelDistanceToExpand() to make the comment true. - EXPECT_EQ(gfx::Rect(-7936, -8166, 16267, 17200), - GetCullRect("target").Rect()); + EXPECT_EQ(gfx::Rect(-2000, -2000, 4400, 4800), GetCullRect("target").Rect()); } TEST_P(CullRectUpdaterTest, ScaledCullRectUnderCompositedScroller) { SetBodyInnerHTML(R"HTML( <div style='width: 200px; height: 300px; overflow: scroll; background: blue; - transform: scaleX(3) scaleY(0.5)'> + transform: scaleX(2) scaleY(0.75)'> <div id='target' style='height: 400px; position: relative'></div> <div style='width: 10000px; height: 10000px'></div> </div> )HTML"); // The expansion is 4000 / max(scaleX, scaleY). - // TODO(wangxianzhu): The above comment is not right. We should probably - // adjust LocalPixelDistanceToExpand() to make the comment true. - EXPECT_EQ(gfx::Rect(0, 0, 8200, 8300), GetCullRect("target").Rect()); + EXPECT_EQ(gfx::Rect(0, 0, 2200, 2300), GetCullRect("target").Rect()); } TEST_P(CullRectUpdaterTest, ScaledAndRotatedCullRect) { @@ -123,8 +119,6 @@ // The expansion 6599 is 4000 * max_dimension(1x1 rect projected from screen // to local). - // TODO(wangxianzhu): The above comment is not right. We should probably - // adjust LocalPixelDistanceToExpand() to make the comment true. EXPECT_EQ(gfx::Rect(-6748, -6836, 14236, 14236), GetCullRect("target").Rect()); } @@ -141,8 +135,6 @@ // The expansion 6599 is 4000 * max_dimension(1x1 rect projected from screen // to local). - // TODO(wangxianzhu): The above comment is not right. We should probably - // adjust LocalPixelDistanceToExpand() to make the comment true. EXPECT_EQ(gfx::Rect(0, 0, 6799, 6899), GetCullRect("target").Rect()); EXPECT_EQ(gfx::Rect(0, 0, 6799, 6899), GetContentsCullRect("target").Rect()); } @@ -205,16 +197,17 @@ GetCullRect("target").Rect().Contains(gfx::Rect(0, 0, 2000, 3000))); } -TEST_P(CullRectUpdaterTest, 3D45DegRotatedTallCullRect) { +TEST_P(CullRectUpdaterTest, 3D60DegRotatedTallCullRect) { SetBodyInnerHTML(R"HTML( <style>body { margin: 0 }</style> <div id='target' - style='width: 200px; height: 10000px; transform: rotateY(45deg)'> + style='width: 200px; height: 10000px; transform: rotateY(60deg)'> </div> )HTML"); - EXPECT_TRUE( - GetCullRect("target").Rect().Contains(gfx::Rect(0, 0, 200, 10000))); + // The cull rect is expanded in the y direction for the root scroller, and + // x direction for |target| itself. + EXPECT_EQ(gfx::Rect(-4100, 0, 9600, 4600), GetCullRect("target").Rect()); } TEST_P(CullRectUpdaterTest, FixedPositionInNonScrollableViewCullRect) {
diff --git a/third_party/blink/renderer/core/testing/internals.cc b/third_party/blink/renderer/core/testing/internals.cc index 0305b13..fc74854 100644 --- a/third_party/blink/renderer/core/testing/internals.cc +++ b/third_party/blink/renderer/core/testing/internals.cc
@@ -2041,6 +2041,20 @@ return requester->LastProcessedSequence(); } +int Internals::spellCheckedTextLength(Document* document, + ExceptionState& exception_state) { + SpellCheckRequester* requester = GetSpellCheckRequester(document); + + if (!requester) { + exception_state.ThrowDOMException( + DOMExceptionCode::kInvalidAccessError, + "No spell check requestor can be obtained for the provided document."); + return -1; + } + + return requester->SpellCheckedTextLength(); +} + void Internals::cancelCurrentSpellCheckRequest( Document* document, ExceptionState& exception_state) {
diff --git a/third_party/blink/renderer/core/testing/internals.h b/third_party/blink/renderer/core/testing/internals.h index 736dfa0..ab009a9 100644 --- a/third_party/blink/renderer/core/testing/internals.h +++ b/third_party/blink/renderer/core/testing/internals.h
@@ -282,6 +282,7 @@ int lastSpellCheckRequestSequence(Document*, ExceptionState&); int lastSpellCheckProcessedSequence(Document*, ExceptionState&); + int spellCheckedTextLength(Document*, ExceptionState&); void cancelCurrentSpellCheckRequest(Document*, ExceptionState&); String idleTimeSpellCheckerState(Document*, ExceptionState&); void runIdleTimeSpellChecker(Document*, ExceptionState&);
diff --git a/third_party/blink/renderer/core/testing/internals.idl b/third_party/blink/renderer/core/testing/internals.idl index bed2237f..57d8d72 100644 --- a/third_party/blink/renderer/core/testing/internals.idl +++ b/third_party/blink/renderer/core/testing/internals.idl
@@ -142,6 +142,7 @@ [RaisesException] long lastSpellCheckRequestSequence(Document document); [RaisesException] long lastSpellCheckProcessedSequence(Document document); + [RaisesException] long spellCheckedTextLength(Document document); [RaisesException] void cancelCurrentSpellCheckRequest(Document document); [RaisesException] DOMString idleTimeSpellCheckerState(Document document); [RaisesException] void runIdleTimeSpellChecker(Document document);
diff --git a/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope_test.cc b/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope_test.cc index f52ec6a..3dd455b 100644 --- a/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope_test.cc +++ b/third_party/blink/renderer/modules/webaudio/audio_worklet_global_scope_test.cc
@@ -164,9 +164,9 @@ js_url) ->RunScriptOnScriptStateAndReturnValue(script_state); if (expect_success) { - EXPECT_FALSE(GetResult(script_state, result).IsEmpty()); + EXPECT_FALSE(GetResult(script_state, std::move(result)).IsEmpty()); } else { - EXPECT_FALSE(GetException(script_state, result).IsEmpty()); + EXPECT_FALSE(GetException(script_state, std::move(result)).IsEmpty()); } }
diff --git a/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread_test.cc b/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread_test.cc index ee68ceb..d6d3d72 100644 --- a/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread_test.cc +++ b/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread_test.cc
@@ -91,7 +91,7 @@ JSModuleScript::CreateForTest(Modulator::From(script_state), module, js_url) ->RunScriptOnScriptStateAndReturnValue(script_state); - EXPECT_FALSE(GetResult(script_state, result).IsEmpty()); + EXPECT_FALSE(GetResult(script_state, std::move(result)).IsEmpty()); wait_event->Signal(); } };
diff --git a/third_party/blink/renderer/platform/graphics/paint/cull_rect.cc b/third_party/blink/renderer/platform/graphics/paint/cull_rect.cc index 0c0a9708..314d34e04 100644 --- a/third_party/blink/renderer/platform/graphics/paint/cull_rect.cc +++ b/third_party/blink/renderer/platform/graphics/paint/cull_rect.cc
@@ -18,7 +18,7 @@ namespace { -constexpr int kReasonablePixelLimit = std::numeric_limits<int>::max() / 2; +constexpr int kReasonablePixelLimit = kIntMaxForLayoutUnit; constexpr int kChangedEnoughMinimumDistance = 512; // Number of pixels to expand in root coordinates for cull rect under @@ -30,11 +30,8 @@ int LocalPixelDistanceToExpand( const TransformPaintPropertyNode& root_transform, const TransformPaintPropertyNode& local_transform) { - gfx::RectF rect(0, 0, 1, 1); - GeometryMapper::SourceToDestinationRect(root_transform, local_transform, - rect); - // Now rect.Size() is the size of a screen pixel in local coordinates. - float scale = std::max(rect.width(), rect.height()); + float scale = GeometryMapper::SourceToDestinationApproximateMinimumScale( + root_transform, local_transform); // A very big scale may be caused by non-invertable near non-invertable // transforms. Fallback to scale 1. The limit is heuristic. if (scale > kReasonablePixelLimit / kPixelDistanceToExpand) @@ -136,6 +133,13 @@ const PropertyTreeState& source, const PropertyTreeState& destination, const absl::optional<CullRect>& old_cull_rect) { + // The caller should check this before calling this function. + DCHECK_NE(source, destination); + + // Only a clip can make an infinite cull rect finite. + if (IsInfinite() && &destination.Clip() == &source.Clip()) + return false; + Vector<const TransformPaintPropertyNode*, 4> scroll_translations; Vector<const ClipPaintPropertyNode*, 4> clips; bool abnormal_hierarchy = false; @@ -171,7 +175,8 @@ // Either the transform or the clip of |source| is not an ancestor of // |destination|. Map infinite rect from the root. *this = Infinite(); - return ApplyPaintProperties(root, root, destination, old_cull_rect); + return root != destination && + ApplyPaintProperties(root, root, destination, old_cull_rect); } // These are either the source transform/clip or the last scroll
diff --git a/third_party/blink/renderer/platform/graphics/paint/cull_rect_test.cc b/third_party/blink/renderer/platform/graphics/paint/cull_rect_test.cc index fe6c4207..7158311 100644 --- a/third_party/blink/renderer/platform/graphics/paint/cull_rect_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/cull_rect_test.cc
@@ -297,35 +297,6 @@ EXPECT_FALSE(ChangedEnough(gfx::Rect(300, 400, 100, 100), new_rect, bounds)); } -TEST_F(CullRectTest, ApplyPaintPropertiesSameState) { - auto transform = - CreateTransform(t0(), TransformationMatrix().Translate(1, 2)); - auto clip = CreateClip(c0(), t0(), FloatRoundedRect(1, 2, 3, 4)); - PropertyTreeState root = PropertyTreeState::Root(); - PropertyTreeState state(*transform, *clip, e0()); - - CullRect cull_rect1(gfx::Rect(1, 1, 50, 50)); - cull_rect1.ApplyPaintProperties(state, state, state, absl::nullopt); - EXPECT_EQ(gfx::Rect(1, 1, 50, 50), cull_rect1.Rect()); - cull_rect1.ApplyPaintProperties(root, state, state, absl::nullopt); - EXPECT_EQ(gfx::Rect(1, 1, 50, 50), cull_rect1.Rect()); - - CullRect old_cull_rect = cull_rect1; - old_cull_rect.Move(gfx::Vector2d(1, 1)); - CullRect cull_rect2(gfx::Rect(1, 1, 50, 50)); - // Should ignore old_cull_rect. - cull_rect2.ApplyPaintProperties(state, state, state, old_cull_rect); - EXPECT_EQ(cull_rect1, cull_rect2); - cull_rect2.ApplyPaintProperties(root, state, state, old_cull_rect); - EXPECT_EQ(cull_rect1, cull_rect2); - - CullRect infinite = CullRect::Infinite(); - infinite.ApplyPaintProperties(state, state, state, absl::nullopt); - EXPECT_TRUE(infinite.IsInfinite()); - infinite.ApplyPaintProperties(root, state, state, absl::nullopt); - EXPECT_TRUE(infinite.IsInfinite()); -} - TEST_F(CullRectTest, ApplyPaintPropertiesWithoutClipScroll) { auto t1 = CreateTransform(t0(), TransformationMatrix().Translate(1, 2)); auto t2 = CreateTransform(*t1, TransformationMatrix().Translate(10, 20)); @@ -605,15 +576,15 @@ PropertyTreeState root = PropertyTreeState::Root(); auto c1 = CreateClip(c0(), t0(), FloatRoundedRect(100, 200, 300, 400)); auto t1 = CreateTransform( - t0(), TransformationMatrix().Translate(10, 20).Scale3d(2, 3, 1), + t0(), TransformationMatrix().Translate(10, 20).Scale3d(2, 4, 1), gfx::Point3F(), CompositingReason::kWillChangeTransform); PropertyTreeState state1(*t1, *c1, e0()); CullRect cull_rect1(gfx::Rect(0, 0, 300, 500)); cull_rect1.ApplyPaintProperties(root, root, state1, absl::nullopt); // The result in NonCompositedTransformUnderClip expanded by 2000 (scaled by - // maximum of 1/2 and 1/3). - EXPECT_EQ(gfx::Rect(-1955, -1940, 4100, 4100), cull_rect1.Rect()); + // minimum of 1/2 and 1/4). + EXPECT_EQ(gfx::Rect(-955, -955, 2100, 2075), cull_rect1.Rect()); CullRect cull_rect2(gfx::Rect(0, 0, 300, 500)); CullRect old_cull_rect = cull_rect1; @@ -630,7 +601,7 @@ CullRect cull_rect4 = CullRect::Infinite(); cull_rect4.ApplyPaintProperties(root, root, state1, absl::nullopt); - EXPECT_EQ(gfx::Rect(-1955, -1940, 4150, 4134), cull_rect4.Rect()); + EXPECT_EQ(gfx::Rect(-955, -955, 2150, 2100), cull_rect4.Rect()); CullRect cull_rect5; cull_rect4.ApplyPaintProperties(root, root, state1, absl::nullopt);
diff --git a/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.cc b/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.cc index 3c63f25..dcf1f18 100644 --- a/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.cc +++ b/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.cc
@@ -200,6 +200,24 @@ return Translation2DOrMatrix(matrix); } +float GeometryMapper::SourceToDestinationApproximateMinimumScale( + const TransformPaintPropertyNode& source, + const TransformPaintPropertyNode& destination) { + if (&source == &destination) + return 1.f; + + const auto& source_cache = source.GetTransformCache(); + const auto& destination_cache = destination.GetTransformCache(); + if (source_cache.root_of_2d_translation() == + destination_cache.root_of_2d_translation()) { + return 1.f; + } + + gfx::RectF rect(0, 0, 1, 1); + SourceToDestinationRect(source, destination, rect); + return std::min(rect.width(), rect.height()); +} + bool GeometryMapper::LocalToAncestorVisualRect( const PropertyTreeState& local_state, const PropertyTreeState& ancestor_state,
diff --git a/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h b/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h index a6e6f5bb..fd64a70 100644 --- a/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h +++ b/third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h
@@ -162,6 +162,10 @@ SourceToDestinationProjection(source, destination).MapRect(mapping_rect); } + static float SourceToDestinationApproximateMinimumScale( + const TransformPaintPropertyNode& source, + const TransformPaintPropertyNode& destination); + // Returns the clip rect between |local_state| and |ancestor_state|. The clip // rect is the total clip rect that should be applied when painting contents // of |local_state| in |ancestor_state| space. Because this clip rect applies
diff --git a/third_party/blink/renderer/platform/widget/input/event_with_callback.cc b/third_party/blink/renderer/platform/widget/input/event_with_callback.cc index 60c5dc58..79b590ae 100644 --- a/third_party/blink/renderer/platform/widget/input/event_with_callback.cc +++ b/third_party/blink/renderer/platform/widget/input/event_with_callback.cc
@@ -8,6 +8,7 @@ #include "base/trace_event/trace_event.h" #include "cc/metrics/event_metrics.h" #include "third_party/blink/public/common/input/web_input_event_attribution.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-blink.h" namespace blink { @@ -79,7 +80,8 @@ const ui::LatencyInfo& latency, std::unique_ptr<InputHandlerProxy::DidOverscrollParams> did_overscroll_params, - const WebInputEventAttribution& attribution) { + const WebInputEventAttribution& attribution, + mojom::blink::ScrollResultDataPtr scroll_result_data) { // |original_events_| could be empty if this is the scroll event extracted // from the matrix multiplication. if (original_events_.size() == 0) @@ -94,7 +96,8 @@ ? std::make_unique<InputHandlerProxy::DidOverscrollParams>( *did_overscroll_params) : nullptr, - attribution, std::move(oldest_event.metrics_)); + attribution, std::move(oldest_event.metrics_), + scroll_result_data ? scroll_result_data->Clone() : nullptr); original_events_.pop_front(); // If the event was handled on the compositor thread, ack other events with @@ -124,7 +127,8 @@ ? std::make_unique<InputHandlerProxy::DidOverscrollParams>( *did_overscroll_params) : nullptr, - attribution, std::move(coalesced_event.metrics_)); + attribution, std::move(coalesced_event.metrics_), + scroll_result_data ? scroll_result_data->Clone() : nullptr); } }
diff --git a/third_party/blink/renderer/platform/widget/input/event_with_callback.h b/third_party/blink/renderer/platform/widget/input/event_with_callback.h index 707f9809..a67cce2 100644 --- a/third_party/blink/renderer/platform/widget/input/event_with_callback.h +++ b/third_party/blink/renderer/platform/widget/input/event_with_callback.h
@@ -9,6 +9,7 @@ #include "base/time/time.h" #include "third_party/blink/public/common/input/web_coalesced_input_event.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-blink-forward.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/widget/input/input_handler_proxy.h" #include "ui/latency/latency_info.h" @@ -54,7 +55,8 @@ void RunCallbacks(InputHandlerProxy::EventDisposition, const ui::LatencyInfo& latency, std::unique_ptr<InputHandlerProxy::DidOverscrollParams>, - const WebInputEventAttribution&); + const WebInputEventAttribution&, + mojom::blink::ScrollResultDataPtr scroll_result_data); const WebInputEvent& event() const { return event_->Event(); } WebInputEvent* event_pointer() { return event_->EventPointer(); }
diff --git a/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc b/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc index 65e68255..2fce75c 100644 --- a/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc +++ b/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc
@@ -34,6 +34,7 @@ #include "third_party/blink/public/common/input/web_mouse_wheel_event.h" #include "third_party/blink/public/common/input/web_pointer_event.h" #include "third_party/blink/public/common/input/web_touch_event.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-blink.h" #include "third_party/blink/renderer/platform/widget/input/compositor_thread_event_queue.h" #include "third_party/blink/renderer/platform/widget/input/cursor_control_handler.h" #include "third_party/blink/renderer/platform/widget/input/elastic_overscroll_controller.h" @@ -218,6 +219,7 @@ handling_gesture_on_impl_thread_(false), scroll_sequence_ignored_(false), current_overscroll_params_(nullptr), + current_scroll_result_data_(nullptr), has_seen_first_gesture_scroll_update_after_begin_(false), last_injected_gesture_was_begin_(false), tick_clock_(base::DefaultTickClock::GetInstance()), @@ -433,7 +435,7 @@ PerformEventAttribution(event->Event()); std::move(callback).Run(DROP_EVENT, std::move(event), /*overscroll_params=*/nullptr, attribution, - std::move(metrics)); + std::move(metrics), /*scroll_result_data=*/nullptr); } // We blocked the compositor gesture event queue while the hit test was @@ -516,7 +518,8 @@ // Will run callback for every original events. event_with_callback->RunCallbacks(disposition, monitored_latency_info, std::move(current_overscroll_params_), - attribution); + attribution, + std::move(current_scroll_result_data_)); } bool InputHandlerProxy::HasQueuedEventsReadyForDispatch() { @@ -1113,6 +1116,14 @@ if (metrics && scroll_result.needs_main_thread_repaint) metrics->set_requires_main_thread_update(); + if (scroll_result.did_scroll) { + current_scroll_result_data_ = mojom::blink::ScrollResultData::New(); + if (input_handler_->IsCurrentlyScrollingViewport()) { + current_scroll_result_data_->root_scroll_offset = + scroll_result.current_visual_offset; + } + } + return scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; }
diff --git a/third_party/blink/renderer/platform/widget/input/input_handler_proxy.h b/third_party/blink/renderer/platform/widget/input/input_handler_proxy.h index ebe136b..879e5e5 100644 --- a/third_party/blink/renderer/platform/widget/input/input_handler_proxy.h +++ b/third_party/blink/renderer/platform/widget/input/input_handler_proxy.h
@@ -13,6 +13,7 @@ #include "cc/paint/element_id.h" #include "third_party/blink/public/common/input/web_coalesced_input_event.h" #include "third_party/blink/public/common/input/web_gesture_event.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-blink.h" #include "third_party/blink/public/platform/web_common.h" #include "third_party/blink/renderer/platform/platform_export.h" @@ -150,7 +151,8 @@ std::unique_ptr<blink::WebCoalescedInputEvent> event, std::unique_ptr<DidOverscrollParams>, const blink::WebInputEventAttribution&, - std::unique_ptr<cc::EventMetrics> metrics)>; + std::unique_ptr<cc::EventMetrics> metrics, + mojom::blink::ScrollResultDataPtr)>; void HandleInputEventWithLatencyInfo( std::unique_ptr<blink::WebCoalescedInputEvent> event, std::unique_ptr<cc::EventMetrics> metrics, @@ -355,6 +357,11 @@ // bundled in the event ack, saving an IPC. std::unique_ptr<DidOverscrollParams> current_overscroll_params_; + // Used to cache the scroll result data - e.g. root scroll offset - when a + // scroll gesture is handled. This data is then passed back using + // |EventDispositionCallback|. + mojom::blink::ScrollResultDataPtr current_scroll_result_data_; + std::unique_ptr<CompositorThreadEventQueue> compositor_event_queue_; // Set only when the compositor input handler is handling a gesture. Tells
diff --git a/third_party/blink/renderer/platform/widget/input/input_handler_proxy_unittest.cc b/third_party/blink/renderer/platform/widget/input/input_handler_proxy_unittest.cc index 0d62ed5..2790c19 100644 --- a/third_party/blink/renderer/platform/widget/input/input_handler_proxy_unittest.cc +++ b/third_party/blink/renderer/platform/widget/input/input_handler_proxy_unittest.cc
@@ -482,7 +482,8 @@ std::unique_ptr<blink::WebCoalescedInputEvent> event, std::unique_ptr<InputHandlerProxy::DidOverscrollParams> callback, const WebInputEventAttribution& attribution, - std::unique_ptr<cc::EventMetrics> metrics) { + std::unique_ptr<cc::EventMetrics> metrics, + mojom::blink::ScrollResultDataPtr scroll_result_data) { event_disposition = disposition; })); return event_disposition; @@ -509,7 +510,8 @@ std::unique_ptr<blink::WebCoalescedInputEvent> event, std::unique_ptr<InputHandlerProxy::DidOverscrollParams> callback, const WebInputEventAttribution& attribution, - std::unique_ptr<cc::EventMetrics> metrics) { + std::unique_ptr<cc::EventMetrics> metrics, + mojom::blink::ScrollResultDataPtr scroll_result_data) { event_disposition = disposition; })); @@ -568,7 +570,8 @@ std::unique_ptr<WebCoalescedInputEvent> input_event, std::unique_ptr<InputHandlerProxy::DidOverscrollParams> overscroll_params, const WebInputEventAttribution& attribution, - std::unique_ptr<cc::EventMetrics> metrics) { + std::unique_ptr<cc::EventMetrics> metrics, + mojom::blink::ScrollResultDataPtr scroll_result_data) { event_disposition_recorder_.push_back(event_disposition); latency_info_recorder_.push_back(input_event->latency_info()); } @@ -2109,7 +2112,8 @@ std::unique_ptr<WebCoalescedInputEvent> input_event, std::unique_ptr<InputHandlerProxy::DidOverscrollParams> overscroll_params, const WebInputEventAttribution& attribution, - std::unique_ptr<cc::EventMetrics> metrics) { + std::unique_ptr<cc::EventMetrics> metrics, + mojom::blink::ScrollResultDataPtr scroll_result_data) { if (out_disposition) *out_disposition = event_disposition; }
diff --git a/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc b/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc index fda26c3..1c4ff88 100644 --- a/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc +++ b/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc
@@ -25,6 +25,7 @@ #include "third_party/blink/public/common/input/web_coalesced_input_event.h" #include "third_party/blink/public/common/input/web_input_event_attribution.h" #include "third_party/blink/public/common/input/web_keyboard_event.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-blink-forward.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" @@ -72,7 +73,8 @@ mojom::blink::InputEventResultState result_state, const ui::LatencyInfo& latency_info, mojom::blink::DidOverscrollParamsPtr overscroll_params, - absl::optional<cc::TouchAction> touch_action) { + absl::optional<cc::TouchAction> touch_action, + mojom::blink::ScrollResultDataPtr scroll_result_data) { ui::LatencyInfo::TraceIntermediateFlowEvents( {latency_info}, ChromeLatencyInfo::STEP_HANDLED_INPUT_EVENT_IMPL); std::move(callback).Run( @@ -80,7 +82,8 @@ result_state, std::move(overscroll_params), touch_action ? mojom::blink::TouchActionOptional::New(touch_action.value()) - : nullptr); + : nullptr, + std::move(scroll_result_data)); } mojom::blink::InputEventResultState InputEventDispositionToAck( @@ -570,9 +573,10 @@ if (suppress_input && !allow_pre_commit_input_ && !event_is_move) { if (callback) { - std::move(callback).Run( - mojom::blink::InputEventResultSource::kMainThread, ui::LatencyInfo(), - mojom::blink::InputEventResultState::kNotConsumed, nullptr, nullptr); + std::move(callback).Run(mojom::blink::InputEventResultSource::kMainThread, + ui::LatencyInfo(), + mojom::blink::InputEventResultState::kNotConsumed, + nullptr, nullptr, /*scroll_result_data=*/nullptr); } return; } @@ -624,8 +628,8 @@ std::move(callback).Run( mojom::blink::InputEventResultSource::kMainThread, ui::LatencyInfo(), - mojom::blink::InputEventResultState::kNotConsumed, nullptr, - nullptr); + mojom::blink::InputEventResultState::kNotConsumed, nullptr, nullptr, + /*scroll_result_data=*/nullptr); } return; } @@ -804,7 +808,7 @@ std::move(callback).Run(mojom::blink::InputEventResultSource::kMainThread, event->latency_info(), mojom::blink::InputEventResultState::kNotConsumed, - nullptr, nullptr); + nullptr, nullptr, nullptr); } return; } @@ -835,7 +839,7 @@ .Run(mojom::blink::InputEventResultSource::kMainThread, ui::LatencyInfo(), mojom::blink::InputEventResultState::kNotConsumed, nullptr, - nullptr); + nullptr, nullptr); return; } @@ -864,7 +868,8 @@ std::unique_ptr<WebCoalescedInputEvent> event, std::unique_ptr<InputHandlerProxy::DidOverscrollParams> overscroll_params, const WebInputEventAttribution& attribution, - std::unique_ptr<cc::EventMetrics> metrics) { + std::unique_ptr<cc::EventMetrics> metrics, + mojom::blink::ScrollResultDataPtr scroll_result_data) { TRACE_EVENT1("input", "WidgetInputHandlerManager::DidHandleInputEventSentToCompositor", "Disposition", event_disposition); @@ -974,7 +979,8 @@ ToDidOverscrollParams(overscroll_params.get()), touch_action ? mojom::blink::TouchActionOptional::New(touch_action.value()) - : nullptr); + : nullptr, + std::move(scroll_result_data)); } } @@ -1026,7 +1032,8 @@ compositor_thread_default_task_runner_->PostTask( FROM_HERE, base::BindOnce(CallCallback, std::move(callback), ack_state, latency_info, std::move(overscroll_params), - touch_action_for_ack)); + touch_action_for_ack, + /*scroll_result_data=*/nullptr)); } else { // Otherwise call the callback immediately. std::move(callback).Run( @@ -1036,7 +1043,8 @@ latency_info, ack_state, std::move(overscroll_params), touch_action_for_ack ? mojom::blink::TouchActionOptional::New( touch_action_for_ack.value()) - : nullptr); + : nullptr, + /*scroll_result_data=*/nullptr); } }
diff --git a/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h b/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h index 7467015..fd479910 100644 --- a/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h +++ b/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h
@@ -15,6 +15,7 @@ #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/shared_remote.h" +#include "third_party/blink/public/mojom/input/input_handler.mojom-blink-forward.h" #include "third_party/blink/public/mojom/input/input_handler.mojom-blink.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/widget/input/input_handler_proxy.h" @@ -240,7 +241,8 @@ std::unique_ptr<WebCoalescedInputEvent> event, std::unique_ptr<InputHandlerProxy::DidOverscrollParams> overscroll_params, const WebInputEventAttribution& attribution, - std::unique_ptr<cc::EventMetrics> metrics); + std::unique_ptr<cc::EventMetrics> metrics, + mojom::blink::ScrollResultDataPtr scroll_result_data); // Similar to the above; this is used by the main thread input handler to // communicate back the result of handling the event. Note: this may be
diff --git a/third_party/blink/web_tests/NeverFixTests b/third_party/blink/web_tests/NeverFixTests index b4664d1..89c86c0 100644 --- a/third_party/blink/web_tests/NeverFixTests +++ b/third_party/blink/web_tests/NeverFixTests
@@ -1950,7 +1950,9 @@ # The following tests never pass in the default Blink test runner due to forced # frame updates, but still pass in the full browser. They are only run in the # no-forced-frame-updates virtual test suite. +external/wpt/css/css-transitions/render-blocking/* [ Skip ] external/wpt/html/dom/render-blocking/* [ Skip ] +virtual/no-forced-frame-updates/external/wpt/css/css-transitions/render-blocking/* [ Pass ] virtual/no-forced-frame-updates/external/wpt/html/dom/render-blocking/* [ Pass ] # Tests in the virtual/origin-agent-cluster-default suite. These tests
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 6b6a49e1..b3a286a2 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -928,124 +928,11 @@ # Triage of WPT css-paint-api tests crbug.com/1299442 external/wpt/css/css-paint-api/custom-property-animation-on-main-thread.https.html [ Failure Pass ] -# Flaky virtual/off-main-thread-css-paint tests -crbug.com/1254382 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/background-image-alpha.https.html [ Failure ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/background-repeat-x.https.html [ Skip ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/color-custom-property-animation.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-001.https.html [ Failure Pass ] -crbug.com/1299442 [ Win ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-001.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-tiled-002.https.html [ Skip ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-tiled-003.https.html [ Failure Pass ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-001.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-002.https.html [ Failure Pass ] -crbug.com/1286944 [ Win ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-002.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-003.https.html [ Failure Pass ] -crbug.com/1286944 [ Win ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-003.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-004.https.html [ Skip ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-005.https.html [ Failure Pass ] -crbug.com/1286944 [ Win ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-border-image-005.https.html [ Failure Pass ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-with-float-size.https.html [ Failure Pass ] -crbug.com/1286944 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/hidpi/canvas-transform.https.html [ Failure Pass ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/hidpi/device-pixel-ratio.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-constructor-error.https.html [ Failure Pass ] -crbug.com/1286944 [ Win ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-constructor-error.https.html [ Failure Pass ] -crbug.com/1250666 [ Mac10.13 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Pass Timeout ] -crbug.com/1250666 [ Mac10.14 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Pass Timeout ] -crbug.com/1250666 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Pass Timeout ] -crbug.com/1250666 [ Mac11-arm64 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Pass Timeout ] -crbug.com/1250666 [ Mac12 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Pass Timeout ] -crbug.com/1250666 [ Mac12-arm64 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Pass Timeout ] -crbug.com/1250666 [ Win ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Pass Timeout ] -crbug.com/1250666 crbug.com/1286944 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-pending-script.https.html [ Failure Pass Timeout ] -crbug.com/1236558 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/no-op-animation.https.html [ Crash Failure Pass ] -crbug.com/1287915 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/non-registered-property-value.https.html [ Skip ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/one-custom-property-animation.https.html [ Skip ] -crbug.com/1286944 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/overdraw.https.html [ Failure Pass Timeout ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint-arguments.https.html [ Failure ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint-function-arguments-var.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint-function-arguments.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint-function-this-value.https.html [ Failure Pass ] -crbug.com/1339051 [ Linux ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-canvasFilter.tentative.https.html [ Failure ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-canvasFilter.tentative.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-conicGradient.https.html [ Failure Pass ] -crbug.com/1339051 [ Linux ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-filter.https.html [ Failure ] -crbug.com/1339051 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-filter.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-gradient.https.html [ Failure Pass ] -crbug.com/1234302 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-image.https.html [ Crash Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-rects.https.html [ Failure Pass ] -crbug.com/1286944 [ Linux ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-rects.https.html [ Failure Pass ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-shadows.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-002.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-003.https.html [ Skip ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-004.https.html [ Skip ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-005.https.html [ Failure Pass ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-007.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-008.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-009.https.html [ Failure Pass ] -crbug.com/1286944 [ Linux ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-009.https.html [ Failure Pass ] -crbug.com/1233826 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-010.https.html [ Skip ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-011.https.html [ Skip ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-012.https.html [ Skip ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-013.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-014.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-015.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-016.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-017.https.html [ Failure Pass ] -crbug.com/1242243 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-018.https.html [ Crash Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-019.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-020.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-021.https.html [ Skip ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-022.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac12 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-001.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-001.https.html [ Failure ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-002.https.html [ Skip ] -crbug.com/1341471 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-003.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-005.https.html [ Skip ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-006.https.html [ Failure ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-007.https.html [ Failure Pass ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-008.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-009.https.html [ Failure Pass ] -crbug.com/1233826 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-010.https.html [ Skip ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-invalidation-001.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-invalidation-002.https.html [ Skip ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-stylemap.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-001.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-002.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-003.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-004.https.html [ Skip ] -crbug.com/1288136 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-005.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac12 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-006.https.html [ Failure Pass ] -crbug.com/1299442 [ Win10.20h2 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-006.https.html [ Failure Pass ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-007.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-008.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-009.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-01.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-011.https.html [ Failure Pass ] -crbug.com/1233826 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-012.https.html [ Skip ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-013.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-014.https.html [ Failure Pass ] -crbug.com/1123886 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-015.https.html [ Skip ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-016.https.html [ Failure Pass ] -crbug.com/1233826 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-017.https.html [ Skip ] -crbug.com/1299442 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/roundrect.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/setTransform-001.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/setTransform-002.https.html [ Failure Pass ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/setTransform-003.https.html [ Failure Pass ] -crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/setTransform-004.https.html [ Failure Pass ] -crbug.com/1250666 crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/valid-image-after-load.https.html [ Failure Pass Timeout ] -crbug.com/1250666 crbug.com/1286944 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/valid-image-before-load.https.html [ Failure Pass Timeout ] +# Flaky virtual/off-main-thread-css-paint tests. Skipping whole test suite for now. +# Open issues: 1339051, 1288136, 1286944, 1254382, 1250666, 1233826, 1123886, 1345205, 1299442, 1288136 +virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/* [ Skip ] + crbug.com/1339051 [ Linux ] virtual/off-main-thread-css-paint/http/tests/csspaint/shadow-scale-with-page-zoom.html [ Failure ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-roundRect.https.html [ Failure ] -crbug.com/1299442 [ Mac12 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-composite.https.html [ Failure ] -crbug.com/1299442 [ Mac11 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-tiled-001.https.html [ Failure ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-010.https.html [ Failure ] -crbug.com/1299442 [ Mac ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-interpolation-004.https.html [ Failure ] -crbug.com/1299442 [ Mac11 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/invalid-image-paint-error.https.html [ Failure ] -crbug.com/1299442 [ Mac11 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-002.https.html [ Failure ] -crbug.com/1299442 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-006.https.html [ Failure ] -crbug.com/1299442 [ Mac11 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-006.https.html [ Failure ] -crbug.com/1299442 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/background-image-multiple.https.html [ Failure ] -crbug.com/1299442 [ Mac12 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-018.https.html [ Failure ] # ====== Paint team owned tests to here ====== @@ -1761,6 +1648,7 @@ crbug.com/1078927 fragmentation/fragmented-rowspan-alignment.html [ Failure ] crbug.com/1078927 fragmentation/fragmented-rowspan.html [ Failure ] crbug.com/1078927 fragmentation/no-repeating-table-header-after-sections.html [ Failure ] +crbug.com/1352931 fragmentation/repeating-thead-under-repeating-thead.html [ Failure ] crbug.com/1335870 fragmentation/single-line-cells-multiple-tables-repeating-thead-with-border-spacing-at-top-of-row.html [ Failure ] crbug.com/1078927 fragmentation/table-overlapping-rowspan.html [ Failure ] @@ -3390,10 +3278,6 @@ crbug.com/626703 [ Win ] virtual/partitioned-cookies/http/tests/inspector-protocol/network/disabled-cache-navigation.js [ Failure ] # ====== New tests from wpt-importer added here ====== -crbug.com/626703 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/parse-input-arguments-001.https.html [ Failure ] -crbug.com/626703 [ Mac11 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/registered-property-value-018.https.html [ Failure ] -crbug.com/626703 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/background-image-tiled.https.html [ Failure ] -crbug.com/626703 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/dynamic-import.https.html [ Failure ] crbug.com/626703 external/wpt/custom-elements/form-associated/ElementInternals-target-element-is-held-strongly.html [ Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-same-document.window.html [ Failure Timeout ] crbug.com/626703 external/wpt/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-xml-parser.xhtml [ Crash ] @@ -7046,7 +6930,6 @@ # Sheriff 2022-07-18 crbug.com/1345192 accessibility/aria-combo-box-with-delay-add.html [ Skip ] -crbug.com/1345205 virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/style-background-image.https.html [ Skip ] crbug.com/1345235 external/wpt/content-security-policy/style-src/stylehash-basic-blocked.sub.html [ Skip ] crbug.com/1334674 [ Mac11 ] http/tests/devtools/oopif/oopif-presentation-console-messages.js [ Failure Pass ] @@ -7057,11 +6940,6 @@ crbug.com/1346158 crbug.com/1346158 external/wpt/dom/events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-window.html [ Failure Pass ] # Sheriff 2022-07-25 -crbug.com/1346822 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-002.https.html [ Failure Pass ] -crbug.com/1346822 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-composite.https.html [ Failure Pass ] -crbug.com/1346822 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/paint2d-reset.https.html [ Failure Pass ] -crbug.com/1346822 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/geometry-background-image-tiled-001.https.html [ Failure Pass ] -crbug.com/1346822 [ Mac10.15 ] virtual/off-main-thread-css-paint/external/wpt/css/css-paint-api/top-level-await.https.html [ Failure Pass ] crbug.com/1343935 [ Mac10.15 ] external/wpt/dom/events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-body.html [ Failure Pass ] # Sheriff 2022-07-26 @@ -7120,7 +6998,7 @@ # Sheriff 2022-08-12 crbug.com/1350611 [ Mac10.15 ] external/wpt/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-same-document.window.html [ Failure Pass ] -crbug.com/1352248 [ Mac10.15 ] virtual/disable-frequency-capping-for-overlay-popup-detection/http/tests/subresource_filter/overlay_popup_ad/overlay-popup-non-ad-followed-by-ad.html [ Failure Pass ] +crbug.com/1352248 virtual/disable-frequency-capping-for-overlay-popup-detection/http/tests/subresource_filter/overlay_popup_ad/overlay-popup-non-ad-followed-by-ad.html [ Failure Pass ] crbug.com/1352543 [ Linux ] http/tests/devtools/elements/styles-3/styles-disable-then-delete.js [ Failure Pass ] crbug.com/1352545 [ Linux ] external/wpt/html/cross-origin-opener-policy/coop-sandbox-redirects-cuts-opener.https.html [ Failure Pass ] crbug.com/1352545 [ Linux ] external/wpt/html/interaction/focus/chrome-object-tab-focus-bug.html [ Failure Pass ]
diff --git a/third_party/blink/web_tests/VirtualTestSuites b/third_party/blink/web_tests/VirtualTestSuites index a8072f1..68f38c5 100644 --- a/third_party/blink/web_tests/VirtualTestSuites +++ b/third_party/blink/web_tests/VirtualTestSuites
@@ -1231,7 +1231,10 @@ { "prefix": "no-forced-frame-updates", "platforms": ["Linux", "Mac", "Win"], - "bases": ["external/wpt/html/dom/render-blocking"], + "bases": [ + "external/wpt/css/css-transitions/render-blocking", + "external/wpt/html/dom/render-blocking" + ], "args": ["--enable-features=NoForcedFrameUpdatesForWebTests"] }, {
diff --git a/third_party/blink/web_tests/editing/spelling/cold_mode_no_repeated_full_testing.html b/third_party/blink/web_tests/editing/spelling/cold_mode_no_repeated_full_testing.html new file mode 100644 index 0000000..e50c9c0 --- /dev/null +++ b/third_party/blink/web_tests/editing/spelling/cold_mode_no_repeated_full_testing.html
@@ -0,0 +1,76 @@ +<!doctype html> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<script src="../assert_selection.js"></script> +<script src="spellcheck_test.js"></script> +<script> +// This test asserts that in an editor with a large amount of text, spell +// checker does not repeatedly check the editor in full after trivial +// operations (e.g., selection move), and does so only after significant +// changes have taken place. + +const n = 100; +const text = 'zz zz zz zz.'; +const checkedText = '#zz# #zz# #zz# #zz#.' +const markup = `<div>${text}</div>`; +const checkedMarkup = `<div>${checkedText}</div>`; + +let checkedTextLengthBefore = 0; + +const step1 = () => spellcheck_test( + `<div contenteditable>${markup.repeat(n)}</div>`, + document => document.querySelector('div').focus(), + `<div contenteditable>${checkedMarkup.repeat(n)}</div>`, + { + title: 'Step 1: Cold mode checks full contenteditable for the first pass', + needsFullCheck: true, + callback: step2, + } +); + +const step2 = sample => spellcheck_test( + sample, + () => { + checkedTextLengthBefore = + internals.spellCheckedTextLength(sample.document); + sample.selection.modify('move', 'forward', 'line'); + }, + `<div contenteditable>${checkedMarkup.repeat(n)}</div>`, + { + title: 'Step 2: Selection move', + // Note: needsFullCheck means spinning spellchecker lifecycle until idle, + // not forcing spellchecker to check the editor in full. + needsFullCheck: true, + callback: step3, + } +); + +const step3 = sample => spellcheck_test( + sample, + () => { + let recheckedTextLength = + internals.spellCheckedTextLength(sample.document) - checkedTextLengthBefore; + assert_less_than_equal(recheckedTextLength, text.length); + }, + `<div contenteditable>${checkedMarkup.repeat(n)}</div>`, + { + title: 'Step 3: Spell checker does not recheck more than one line', + callback: step4, + } +); + +const step4 = sample => spellcheck_test( + sample, + () => { + const document = sample.document; + document.execCommand('InsertText', false, (text + '\n').repeat(n)); + }, + `<div contenteditable>${checkedMarkup.repeat(n * 2)}</div>`, + { + title: 'Step 4: Spell checker rechecks text in full after significant changes', + needsFullCheck: true, + } +); + +step1(); +</script>
diff --git a/third_party/blink/web_tests/external/Version b/third_party/blink/web_tests/external/Version index 46e341e0..df4b0e4 100644 --- a/third_party/blink/web_tests/external/Version +++ b/third_party/blink/web_tests/external/Version
@@ -1 +1 @@ -Version: bf2c52b45a91ad5ab195a91e9e6d0447f7d3cbeb +Version: fc6f5a80c8fd1411e0eb2e97eb5cfc43503f3413
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json index 3f0b16a..3a6f942 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
@@ -2194,6 +2194,20 @@ {} ] ], + "table-caption-change-descendant-display-type.html": [ + "c44fcca5acd5c4672c9c12bd7f0f4b520bd71c35", + [ + null, + {} + ] + ], + "table-caption-inline-block-remove-child.html": [ + "721f1e888903759ba5fd38281cf26e1674df48f5", + [ + null, + {} + ] + ], "table-cell-writing-mode-root.html": [ "394989e00970e713ca9244ccbf0b2bf42c5b7d42", [ @@ -320589,7 +320603,7 @@ [] ], "test-helper.js": [ - "78215b2d017ac8cc1e647540245da859ae29e452", + "f6a6a30cc516f44f4c55813706eae87e73a3288c", [] ] },
diff --git a/third_party/blink/web_tests/external/wpt/css/css-multicol/crashtests/nested-with-multicol-table-caption.html b/third_party/blink/web_tests/external/wpt/css/css-multicol/crashtests/nested-with-multicol-table-caption.html new file mode 100644 index 0000000..7ef78394 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-multicol/crashtests/nested-with-multicol-table-caption.html
@@ -0,0 +1,11 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1347141"> +<div style="columns:3; column-fill:auto; height:100px;"> + <div style="height:100px;"></div> + <div style="display:table;"> + <div style="display:table-caption; columns:2;"> + Blargh, I'm dead! + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-multicol/crashtests/repeated-section-in-nested-table-nested-multicol.html b/third_party/blink/web_tests/external/wpt/css/css-multicol/crashtests/repeated-section-in-nested-table-nested-multicol.html new file mode 100644 index 0000000..e48854a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-multicol/crashtests/repeated-section-in-nested-table-nested-multicol.html
@@ -0,0 +1,15 @@ +<!DOCTYPE html> +<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> +<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1348774"> +<div style="columns:2; column-fill:auto; height:160px; background:yellow;"> + <div style="display:table;"> + <div style="display:table;"> + <div style="contain:size; height:150px;"></div> + <div style="display:table-footer-group; break-inside:avoid;"> + <div style="columns:2;"> + x AAAAAAAAAAAAAAAAAAAA x + </div> + </div> + </div> + </div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transitions/no-transition-from-ua-to-blocking-stylesheet-ref.html b/third_party/blink/web_tests/external/wpt/css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet-ref.html similarity index 100% rename from third_party/blink/web_tests/external/wpt/css/css-transitions/no-transition-from-ua-to-blocking-stylesheet-ref.html rename to third_party/blink/web_tests/external/wpt/css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet-ref.html
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transitions/no-transition-from-ua-to-blocking-stylesheet.html b/third_party/blink/web_tests/external/wpt/css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet.html similarity index 83% rename from third_party/blink/web_tests/external/wpt/css/css-transitions/no-transition-from-ua-to-blocking-stylesheet.html rename to third_party/blink/web_tests/external/wpt/css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet.html index 4967eabd..d59118c6 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-transitions/no-transition-from-ua-to-blocking-stylesheet.html +++ b/third_party/blink/web_tests/external/wpt/css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet.html
@@ -2,5 +2,5 @@ <title>CSS Transitions Test: No color transition from initial to blocking stylesheet value</title> <link rel="help" href="https://drafts.csswg.org/css-transitions/#style-change-event"> <link rel="match" href="no-transition-from-ua-to-blocking-stylesheet-ref.html"> -<link rel="stylesheet" href="support/a-green-transition.css"> +<link rel="stylesheet" href="../support/a-green-transition.css"> <div class="a">This text should be green on load.</div>
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/popups/popup-events.tentative.html b/third_party/blink/web_tests/external/wpt/html/semantics/popups/popup-events.tentative.html index b82e1c7..4e2051f 100644 --- a/third_party/blink/web_tests/external/wpt/html/semantics/popups/popup-events.tentative.html +++ b/third_party/blink/web_tests/external/wpt/html/semantics/popups/popup-events.tentative.html
@@ -10,31 +10,54 @@ <div popup>Popup</div> <script> -promise_test(async t => { - const popup = document.querySelector('[popup]'); - let showCount = 0; - let hideCount = 0; - await new Promise(resolve => window.addEventListener('load',() => resolve())); - assert_false(popup.matches(':top-layer')); - document.addEventListener('show',() => ++showCount); - document.addEventListener('hide',() => ++hideCount); - assert_equals(0,showCount); - assert_equals(0,hideCount); - popup.showPopUp(); - assert_true(popup.matches(':top-layer')); - assert_equals(1,showCount); - assert_equals(0,hideCount); - await waitForRender(); - assert_true(popup.matches(':top-layer')); - popup.hidePopUp(); - assert_false(popup.matches(':top-layer')); - assert_equals(1,showCount); - assert_equals(1,hideCount); - await waitForRender(); - // No additional events after animation frame - assert_false(popup.matches(':top-layer')); - assert_equals(1,showCount); - assert_equals(1,hideCount); -}, 'Show and hide events get properly dispatched for popups'); +window.onload = () => { + promise_test(async t => { + const popup = document.querySelector('[popup]'); + let showCount = 0; + let hideCount = 0; + assert_false(popup.matches(':top-layer')); + const controller = new AbortController(); + const signal = controller.signal; + t.add_cleanup(() => controller.abort()); + document.addEventListener('show',() => ++showCount, {signal}); + document.addEventListener('hide',() => ++hideCount, {signal}); + assert_equals(0,showCount); + assert_equals(0,hideCount); + popup.showPopUp(); + assert_true(popup.matches(':top-layer')); + assert_equals(1,showCount); + assert_equals(0,hideCount); + await waitForRender(); + assert_true(popup.matches(':top-layer')); + popup.hidePopUp(); + assert_false(popup.matches(':top-layer')); + assert_equals(1,showCount); + assert_equals(1,hideCount); + await waitForRender(); + // No additional events after animation frame + assert_false(popup.matches(':top-layer')); + assert_equals(1,showCount); + assert_equals(1,hideCount); + }, 'Show and hide events get properly dispatched for popups'); + promise_test(async t => { + const popUp = document.querySelector('[popup]'); + const controller = new AbortController(); + const signal = controller.signal; + t.add_cleanup(() => controller.abort()); + let cancel = true; + popUp.addEventListener('show',(e) => { + if (cancel) + e.preventDefault(); + }, {signal}); + assert_false(popUp.matches(':top-layer')); + popUp.showPopUp(); + assert_false(popUp.matches(':top-layer'),'The "show" event should be cancelable'); + cancel = false; + popUp.showPopUp(); + assert_true(popUp.matches(':top-layer')); + popUp.hidePopUp(); + assert_false(popUp.matches(':top-layer')); + }, 'Show event is cancelable'); +}; </script>
diff --git a/third_party/blink/web_tests/external/wpt/import-maps/resources/test-helper.js b/third_party/blink/web_tests/external/wpt/import-maps/resources/test-helper.js index 78215b2..f6a6a30c 100644 --- a/third_party/blink/web_tests/external/wpt/import-maps/resources/test-helper.js +++ b/third_party/blink/web_tests/external/wpt/import-maps/resources/test-helper.js
@@ -107,15 +107,7 @@ <script src="/resources/testharness.js"></script> <script src="/import-maps/resources/test-helper.js"></script> <base href="${importMapBaseURL}"> - `; - if (importMapString) { - content += ` - <script type="importmap"> - ${importMapString} - </sc` + `ript> - `; - } - content += ` + <script type="importmap">${importMapString}</script> <body> <script> setup({ allow_uncaught_exception: true }); @@ -180,16 +172,9 @@ <script src="/resources/testharness.js"></script> <script src="/import-maps/resources/test-helper.js"></script> <script src="/import-maps/resources/inject-base.js?pipe=sub&baseurl=${importMapBaseURL}"></script> - `; - - if (importMapString) { - content += ` - <script type="importmap"> + <script type="importmap"> ${importMapString} - </sc` + `ript> - `; - } - content += ` + </script> <body> <script> setup({ allow_uncaught_exception: true });
diff --git a/tools/mb/mb.py b/tools/mb/mb.py index 5777527..00b02a2 100755 --- a/tools/mb/mb.py +++ b/tools/mb/mb.py
@@ -485,12 +485,10 @@ exe += '.exe' args = [ - exe, - 'select', - '-gen-inverse', - '-model-dir', model_dir, \ - '-out', self.PathJoin(self.ToAbsPath(self.args.path), self.rts_out_dir), - '-checkout', self.chromium_src_dir, + exe, 'select', + '-model-dir', model_dir, \ + '-out', self.PathJoin(self.ToAbsPath(self.args.path), self.rts_out_dir), + '-checkout', self.chromium_src_dir, ] if self.args.rts_target_change_recall: if (self.args.rts_target_change_recall < 0 @@ -1336,6 +1334,11 @@ if 'is_skylab=true' in vals['gn_args']: runtime_deps = self._FilterOutUnneededSkylabDeps(runtime_deps) + # For more info about RTS, please see + # //docs/testing/regression-test-selection.md + if self.args.rts: + self.AddFilterFileArg(target, build_dir, command) + canonical_target = target.replace(':','_').replace('/','_') ret = self.WriteIsolateFiles(build_dir, command, canonical_target, runtime_deps, vals, extra_files) @@ -1343,17 +1346,17 @@ return ret return 0 - def AddFilterFileArg(self, target, build_dir, command, inverted=False): - filter_file = ('%s_inverted' % target if inverted else target) + '.filter' - filter_file_path = self.PathJoin(self.rts_out_dir, filter_file) - abs_filter_file_path = self.ToAbsPath(build_dir, filter_file_path) + def AddFilterFileArg(self, target, build_dir, command): + if target in self.banned_from_rts: + self.Print('%s is banned for RTS on this builder' % target) + else: + filter_file = target + '.filter' + filter_file_path = self.PathJoin(self.rts_out_dir, filter_file) + abs_filter_file_path = self.ToAbsPath(build_dir, filter_file_path) - filter_exists = self.Exists(abs_filter_file_path) - if filter_exists: - command.append('--test-launcher-filter-file=%s' % filter_file_path) - self.Print('added RTS filter file to command: %s' % filter_file) - - return filter_exists + if self.Exists(abs_filter_file_path): + command.append('--test-launcher-filter-file=%s' % filter_file_path) + self.Print('added RTS filter file to command: %s' % filter_file) def PossibleRuntimeDepsPaths(self, vals, ninja_targets, isolate_map): """Returns a map of targets to possible .runtime_deps paths. @@ -1553,31 +1556,13 @@ 'list files in directory instead for:' + err) return 1 - isolate = { + self.WriteFile(isolate_path, + json.dumps({ 'variables': { - 'command': command, - 'files': files, + 'command': command, + 'files': files, } - } - # For more info about RTS, please see - # //docs/testing/regression-test-selection.md - if self.args.rts: - if target in self.banned_from_rts: - self.Print('%s is banned for RTS on this builder' % target) - isolate['variables']['command'] = command - else: - inverted_command = command.copy() - self.AddFilterFileArg(target, build_dir, command, inverted=False) - isolate['variables']['command'] = command - - inverted_filter_exists = self.AddFilterFileArg(target, - build_dir, - inverted_command, - inverted=True) - if inverted_filter_exists: - isolate['variables']['inverted_command'] = inverted_command - - self.WriteFile(isolate_path, json.dumps(isolate, sort_keys=True) + '\n') + }, sort_keys=True) + '\n') self.WriteJSON( {
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index a7702d7..bb515d0 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -2416,6 +2416,16 @@ <int value="17" label="Utility process foreground OOM"/> <int value="18" label="All utility process crashes"/> <int value="19" label="Renderer shutdown from RenderProcessHost::Shutdown"/> + <int value="20" + label="Invisible renderer in foreground app with visible binding killed"/> + <int value="21" + label="Invisible renderer in foreground app with visible binding oom"/> + <int value="22" + label="Invisible renderer in foreground app with not perceptible + binding killed"/> + <int value="23" + label="Invisible renderer in foreground app with not perceptible + binding oom"/> </enum> <enum name="AndroidProcessedMinidumps"> @@ -41228,7 +41238,7 @@ <int value="1" label="TooManyRequests"/> <int value="2" label="Aborted"/> <int value="3" label="UnhandledRequest"/> - <int value="4" label="NoNetworkManager"/> + <int value="4" label="RpNotPotentiallyTrustworthy"/> <int value="5" label="NotSelectAccount"/> <int value="6" label="ManifestHttpNotFound"/> <int value="7" label="ManifestNoResponse"/> @@ -58850,6 +58860,8 @@ <int value="-218843425" label="auto-framing-override"/> <int value="-217930860" label="EnableAutomaticSnooze:disabled"/> <int value="-217885320" label="CdmFactoryDaemon:disabled"/> + <int value="-217352290" + label="BindingManagerUseNotPerceptibleBinding:disabled"/> <int value="-216219963" label="ash-shelf-color-scheme"/> <int value="-216189310" label="DebugHistoryInterventionNoUserActivation:enabled"/> @@ -59499,6 +59511,8 @@ <int value="193865288" label="EnableSuggestedLocalFiles:enabled"/> <int value="194573877" label="MacViewsNativeDialogs:disabled"/> <int value="194645300" label="FileTransferEnterpriseConnector:disabled"/> + <int value="194822286" + label="BindingManagerUseNotPerceptibleBinding:enabled"/> <int value="194895489" label="passive-listeners-default"/> <int value="195112080" label="DeskTemplateSync:enabled"/> <int value="195335115" label="AudioWorkletRealtimeThread:disabled"/> @@ -65758,6 +65772,7 @@ <int value="31" label="ExternalNavigation"/> <int value="32" label="FramebustBlocked"/> <int value="33" label="DesktopSiteGlobalDefaultOptOut"/> + <int value="34" label="DesktopSiteGlobalOptIn"/> </enum> <enum name="MessageLoopProblems">
diff --git a/tools/metrics/histograms/metadata/android/histograms.xml b/tools/metrics/histograms/metadata/android/histograms.xml index fc735781..a6acc79 100644 --- a/tools/metrics/histograms/metadata/android/histograms.xml +++ b/tools/metrics/histograms/metadata/android/histograms.xml
@@ -58,11 +58,16 @@ <variants name="ChildProcessConnectionMetricsBindingState"> <variant name="ContentModerate" summary="Moderate binding excluding BindingManager bindings"/> + <variant name="ContentVisible" + summary="Visible binding excluding BindingManager bindings"/> <variant name="ContentWaived" summary="Waived binding excluding BindingManager bindings"/> <variant name="Moderate" summary="strongest binding of Moderate"/> + <variant name="Not Perceptible" + summary="strongest binding of Not Perceptible"/> <variant name="Strong" summary="strongest binding of Strong"/> - <variant name="Waivable" summary="Moderate binding only from BindingManager"/> + <variant name="Visible" summary="strongest binding of Visible"/> + <variant name="Waivable" summary="binding only from BindingManager"/> <variant name="Waived" summary="strongest binding of Waived"/> </variants> @@ -93,6 +98,7 @@ <variant name=".AutoDarkWebContents"/> <variant name=".ChromeSurvey"/> <variant name=".DesktopSiteGlobalDefaultOptOut"/> + <variant name=".DesktopSiteGlobalOptIn"/> <variant name=".DownloadProgress"/> <variant name=".ExternalNavigation"/> <variant name=".FramebustBlocked"/> @@ -2288,6 +2294,9 @@ <histogram name="Android.ModerateBindingCount" units="bindings" expires_after="M77"> + <obsolete> + Expired in M77. See Android.ChildProcessBinding.* + </obsolete> <owner>tedchoc@chromium.org</owner> <owner>clank-team@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/blink/histograms.xml b/tools/metrics/histograms/metadata/blink/histograms.xml index c988da6..2510c463 100644 --- a/tools/metrics/histograms/metadata/blink/histograms.xml +++ b/tools/metrics/histograms/metadata/blink/histograms.xml
@@ -1859,8 +1859,9 @@ </histogram> <histogram name="Blink.Navigator.ReducedUserAgent" enum="Boolean" - expires_after="2022-09-25"> + expires_after="M110"> <owner>miketaylr@chromium.org</owner> + <owner>victortan@chromium.org</owner> <owner>potassium-katabolism@google.com</owner> <summary> Whether the navigator.userAgent and navigator.appVersion JavaScript getters
diff --git a/tools/metrics/histograms/metadata/feature_engagement/OWNERS b/tools/metrics/histograms/metadata/feature_engagement/OWNERS index f14c1c42..bf17b01 100644 --- a/tools/metrics/histograms/metadata/feature_engagement/OWNERS +++ b/tools/metrics/histograms/metadata/feature_engagement/OWNERS
@@ -4,3 +4,6 @@ # Use chromium-metrics-reviews@google.com as a backup. nyquist@chromium.org shaktisahu@chromium.org + +# For User Education/Feature Engagement on desktop platforms: +dfried@chromium.org \ No newline at end of file
diff --git a/tools/metrics/histograms/metadata/media/histograms.xml b/tools/metrics/histograms/metadata/media/histograms.xml index c24ab9e..032387f 100644 --- a/tools/metrics/histograms/metadata/media/histograms.xml +++ b/tools/metrics/histograms/metadata/media/histograms.xml
@@ -2369,7 +2369,7 @@ <histogram name="Media.EME.MediaFoundationCdm.Widevine.HardwareSecure.FirstInitialize" - enum="Hresult" expires_after="2022-08-21"> + enum="Hresult" expires_after="2023-05-07"> <owner>xhwang@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary> @@ -3297,7 +3297,7 @@ </histogram> <histogram name="Media.MediaFoundationRenderer.ErrorReason" - enum="MediaFoundationRendererErrorReason" expires_after="2022-08-30"> + enum="MediaFoundationRendererErrorReason" expires_after="2023-05-07"> <owner>xhwang@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary> @@ -5346,7 +5346,7 @@ </histogram> <histogram name="Media.VideoHeight.Initial.{PlaybackType}" units="pixels" - expires_after="2022-08-22"> + expires_after="2023-05-07"> <owner>xhwang@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/others/histograms.xml b/tools/metrics/histograms/metadata/others/histograms.xml index 3a6d0d5..20af7090 100644 --- a/tools/metrics/histograms/metadata/others/histograms.xml +++ b/tools/metrics/histograms/metadata/others/histograms.xml
@@ -5880,6 +5880,28 @@ </summary> </histogram> +<histogram name="Feedback.ChromeOSApp.ViewedImage" units="boolean" + expires_after="2023-07-27"> + <owner>longbowei@google.com</owner> + <owner>xiangdongkong@google.com</owner> + <owner>cros-feedback-app@google.com</owner> + <summary> + Record number of times the user viewed the attached image. Fires when user + clicks the thumbnail and views the larger image. + </summary> +</histogram> + +<histogram name="Feedback.ChromeOSApp.ViewedMetrics" units="boolean" + expires_after="2023-07-27"> + <owner>longbowei@google.com</owner> + <owner>xiangdongkong@google.com</owner> + <owner>cros-feedback-app@google.com</owner> + <summary> + Record number of times the user viewed the metrics. Fires when user clicks + metrics link and views metrics. + </summary> +</histogram> + <histogram name="Feedback.ChromeOSApp.ViewedScreenshot" units="boolean" expires_after="2023-07-27"> <owner>longbowei@google.com</owner> @@ -5891,6 +5913,17 @@ </summary> </histogram> +<histogram name="Feedback.ChromeOSApp.ViewedSystemAndAppInfo" units="boolean" + expires_after="2023-07-27"> + <owner>longbowei@google.com</owner> + <owner>xiangdongkong@google.com</owner> + <owner>cros-feedback-app@google.com</owner> + <summary> + Record number of times the user viewed the system and app information. Fires + when system and app info link is clicked. + </summary> +</histogram> + <histogram name="Feedback.Duration.FetchSystemInformation" units="ms" expires_after="2023-03-25"> <owner>xiangdongkong@google.com</owner>
diff --git a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc index 783ea90..8733b4c 100644 --- a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc +++ b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc
@@ -257,10 +257,12 @@ if (pointer_grabber_for_window_drag_) { DCHECK(drag_source_.has_value()); - if (*drag_source_ == DragSource::kMouse) - pointer_delegate_->OnPointerFocusChanged(window, location); - else + if (*drag_source_ == DragSource::kMouse) { + pointer_delegate_->OnPointerFocusChanged( + window, location, wl::EventDispatchPolicy::kImmediate); + } else { touch_delegate_->OnTouchFocusChanged(window); + } pointer_grabber_for_window_drag_ = window_manager_->GetCurrentPointerOrTouchFocusedWindow();
diff --git a/ui/ozone/platform/wayland/host/wayland_event_source.cc b/ui/ozone/platform/wayland/host/wayland_event_source.cc index 6b1e53d8..a0c8398 100644 --- a/ui/ozone/platform/wayland/host/wayland_event_source.cc +++ b/ui/ozone/platform/wayland/host/wayland_event_source.cc
@@ -250,8 +250,10 @@ return DispatchEvent(&event); } -void WaylandEventSource::OnPointerFocusChanged(WaylandWindow* window, - const gfx::PointF& location) { +void WaylandEventSource::OnPointerFocusChanged( + WaylandWindow* window, + const gfx::PointF& location, + wl::EventDispatchPolicy dispatch_policy) { bool focused = !!window; if (focused) { // Save new pointer location. @@ -259,17 +261,29 @@ window_manager_->SetPointerFocusedWindow(window); } + auto closure = focused ? base::NullCallback() + : base::BindOnce( + [](WaylandWindowManager* wwm) { + wwm->SetPointerFocusedWindow(nullptr); + }, + window_manager_); + auto* target = window_manager_->GetCurrentPointerFocusedWindow(); if (target) { EventType type = focused ? ET_MOUSE_ENTERED : ET_MOUSE_EXITED; MouseEvent event(type, pointer_location_, pointer_location_, EventTimeForNow(), pointer_flags_, 0); - SetTargetAndDispatchEvent(&event, target); + if (dispatch_policy == wl::EventDispatchPolicy::kImmediate) { + SetTargetAndDispatchEvent(&event, target); + } else { + pointer_frames_.push_back( + std::make_unique<PointerFrame>(event, std::move(closure))); + return; + } } - if (!focused) { - window_manager_->SetPointerFocusedWindow(nullptr); - } + if (!closure.is_null()) + std::move(closure).Run(); } void WaylandEventSource::OnPointerButtonEvent(EventType type,
diff --git a/ui/ozone/platform/wayland/host/wayland_event_source.h b/ui/ozone/platform/wayland/host/wayland_event_source.h index c9b3357..50b85057 100644 --- a/ui/ozone/platform/wayland/host/wayland_event_source.h +++ b/ui/ozone/platform/wayland/host/wayland_event_source.h
@@ -113,7 +113,8 @@ // WaylandPointer::Delegate void OnPointerFocusChanged(WaylandWindow* window, - const gfx::PointF& location) override; + const gfx::PointF& location, + wl::EventDispatchPolicy dispatch_policy) override; void OnPointerButtonEvent(EventType evtype, int changed_button, WaylandWindow* window = nullptr) override;
diff --git a/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc b/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc index 78412f6..eeb38c1 100644 --- a/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc
@@ -89,6 +89,7 @@ wl_resource* pointer_res = server_.seat()->pointer()->resource(); wl_pointer_send_enter(pointer_res, serial++, surface_res, 0, 0); + wl_pointer_send_frame(pointer_res); wl_pointer_send_button(pointer_res, serial++, tstamp++, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); EXPECT_CALL(delegate, DispatchEvent(_)).Times(2);
diff --git a/ui/ozone/platform/wayland/host/wayland_pointer.cc b/ui/ozone/platform/wayland/host/wayland_pointer.cc index 747181f..f0fa9e7 100644 --- a/ui/ozone/platform/wayland/host/wayland_pointer.cc +++ b/ui/ozone/platform/wayland/host/wayland_pointer.cc
@@ -11,6 +11,7 @@ #include "ui/events/types/event_type.h" #include "ui/ozone/platform/wayland/common/wayland_util.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" +#include "ui/ozone/platform/wayland/host/wayland_event_source.h" #include "ui/ozone/platform/wayland/host/wayland_serial_tracker.h" #include "ui/ozone/platform/wayland/host/wayland_window.h" @@ -35,7 +36,8 @@ // Even though, WaylandPointer::Leave is always called when Wayland destroys // wl_pointer, it's better to be explicit as some Wayland compositors may have // bugs. - delegate_->OnPointerFocusChanged(nullptr, {}); + delegate_->OnPointerFocusChanged(nullptr, {}, + wl::EventDispatchPolicy::kImmediate); delegate_->OnResetPointerFlags(); } @@ -55,7 +57,8 @@ static_cast<float>(wl_fixed_to_double(surface_y))}; pointer->delegate_->OnPointerFocusChanged( - window, pointer->connection_->MaybeConvertLocation(location, window)); + window, pointer->connection_->MaybeConvertLocation(location, window), + wl::EventDispatchPolicy::kOnFrame); } // static @@ -67,8 +70,12 @@ pointer->connection_->serial_tracker().ResetSerial( wl::SerialType::kMouseEnter); + // TODO(https://crrev.com/c/1352584): Switch from kImmediate to kOnFrame when + // Exo comply with other compositors in how it isolates each + // wl_pointer.enter|leave event with their respective wl_pointer.frame. pointer->delegate_->OnPointerFocusChanged( - nullptr, pointer->delegate_->GetPointerLocation()); + nullptr, pointer->delegate_->GetPointerLocation(), + wl::EventDispatchPolicy::kImmediate); } // static
diff --git a/ui/ozone/platform/wayland/host/wayland_pointer.h b/ui/ozone/platform/wayland/host/wayland_pointer.h index f3ff5d6..d1789a1 100644 --- a/ui/ozone/platform/wayland/host/wayland_pointer.h +++ b/ui/ozone/platform/wayland/host/wayland_pointer.h
@@ -17,6 +17,10 @@ class Vector2dF; } // namespace gfx +namespace wl { +enum class EventDispatchPolicy; +} // namespace wl + namespace ui { class WaylandConnection; @@ -109,8 +113,10 @@ class WaylandPointer::Delegate { public: - virtual void OnPointerFocusChanged(WaylandWindow* window, - const gfx::PointF& location) = 0; + virtual void OnPointerFocusChanged( + WaylandWindow* window, + const gfx::PointF& location, + wl::EventDispatchPolicy dispatch_policy) = 0; virtual void OnPointerButtonEvent(EventType evtype, int changed_button, WaylandWindow* window = nullptr) = 0;
diff --git a/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc b/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc index cfda16e..3b563cd 100644 --- a/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc
@@ -99,6 +99,7 @@ TEST_P(WaylandPointerTest, Enter) { wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0); + wl_pointer_send_frame(pointer_->resource()); std::unique_ptr<Event> event; EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event)); @@ -134,9 +135,15 @@ ASSERT_TRUE(other_surface); wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0); + wl_pointer_send_frame(pointer_->resource()); + wl_pointer_send_leave(pointer_->resource(), 2, surface_->resource()); + wl_pointer_send_frame(pointer_->resource()); + wl_pointer_send_enter(pointer_->resource(), 3, other_surface->resource(), 0, 0); + wl_pointer_send_frame(pointer_->resource()); + wl_pointer_send_button(pointer_->resource(), 4, 1004, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); EXPECT_CALL(delegate_, DispatchEvent(_)).Times(2); @@ -205,6 +212,7 @@ TEST_P(WaylandPointerTest, AxisSourceTypes) { uint32_t time = 1001; wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0); + wl_pointer_send_frame(pointer_->resource()); Sync(); // We're interested only in checking axis source types events in this // test case, so skip Enter event here. @@ -251,7 +259,7 @@ TEST_P(WaylandPointerTest, Axis) { wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), wl_fixed_from_int(0), wl_fixed_from_int(0)); - + wl_pointer_send_frame(pointer_->resource()); Sync(); for (uint32_t axis : @@ -290,6 +298,7 @@ TEST_P(WaylandPointerTest, SetBitmap) { wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), wl_fixed_from_int(10), wl_fixed_from_int(10)); + wl_pointer_send_frame(pointer_->resource()); Sync(); SkBitmap dummy_cursor; @@ -331,6 +340,7 @@ wl_pointer_send_enter(pointer_->resource(), ++serial, surface_->resource(), wl_fixed_from_int(10), wl_fixed_from_int(10)); + wl_pointer_send_frame(pointer_->resource()); Sync(); // Set a cursor. @@ -341,6 +351,7 @@ connection_->ScheduleFlush(); wl_pointer_send_leave(pointer_->resource(), ++serial, surface_->resource()); + wl_pointer_send_frame(pointer_->resource()); Sync(); Mock::VerifyAndClearExpectations(pointer_); @@ -353,6 +364,7 @@ EXPECT_CALL(*pointer_, SetCursor(Ne(nullptr), 5, 8)); wl_pointer_send_enter(pointer_->resource(), ++serial, surface_->resource(), wl_fixed_from_int(50), wl_fixed_from_int(75)); + wl_pointer_send_frame(pointer_->resource()); Sync(); connection_->ScheduleFlush(); @@ -362,6 +374,7 @@ // Reset the focus for the next iteration. wl_pointer_send_leave(pointer_->resource(), ++serial, surface_->resource()); + wl_pointer_send_frame(pointer_->resource()); Sync(); connection_->ScheduleFlush(); Sync(); @@ -375,9 +388,10 @@ uint32_t time = 1001; wl_pointer_send_enter(pointer_->resource(), ++serial, surface_->resource(), wl_fixed_from_int(50), wl_fixed_from_int(75)); + wl_pointer_send_frame(pointer_->resource()); + wl_pointer_send_button(pointer_->resource(), ++serial, ++time, BTN_RIGHT, WL_POINTER_BUTTON_STATE_PRESSED); - Sync(); std::unique_ptr<Event> event1, event2, event3; @@ -429,9 +443,10 @@ uint32_t time = 1001; wl_pointer_send_enter(pointer_->resource(), ++serial, surface_->resource(), wl_fixed_from_int(50), wl_fixed_from_int(75)); + wl_pointer_send_frame(pointer_->resource()); + wl_pointer_send_button(pointer_->resource(), ++serial, ++time, BTN_RIGHT, WL_POINTER_BUTTON_STATE_PRESSED); - Sync(); std::unique_ptr<Event> event1, event2, event3; @@ -483,9 +498,10 @@ uint32_t time = 1001; wl_pointer_send_enter(pointer_->resource(), ++serial, surface_->resource(), wl_fixed_from_int(50), wl_fixed_from_int(75)); + wl_pointer_send_frame(pointer_->resource()); + wl_pointer_send_button(pointer_->resource(), ++serial, ++time, BTN_RIGHT, WL_POINTER_BUTTON_STATE_PRESSED); - Sync(); std::unique_ptr<Event> event1, event2, event3, event4; @@ -549,9 +565,10 @@ uint32_t time = 1001; wl_pointer_send_enter(pointer_->resource(), ++serial, surface_->resource(), wl_fixed_from_int(50), wl_fixed_from_int(75)); + wl_pointer_send_frame(pointer_->resource()); + wl_pointer_send_button(pointer_->resource(), ++serial, ++time, BTN_RIGHT, WL_POINTER_BUTTON_STATE_PRESSED); - Sync(); std::unique_ptr<Event> event1, event2, event3;
diff --git a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc index 2a63eed..7ac5199 100644 --- a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
@@ -638,6 +638,7 @@ uint32_t time = 1002; wl_pointer_send_enter(pointer->resource(), ++serial, surface->resource(), 0, 0); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_motion(pointer->resource(), ++time, wl_fixed_from_int(10), wl_fixed_from_int(20)); @@ -651,8 +652,10 @@ ASSERT_TRUE(second_surface); // Now, leave the first surface and enter second one. wl_pointer_send_leave(pointer->resource(), ++serial, surface->resource()); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_enter(pointer->resource(), ++serial, second_surface->resource(), 0, 0); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_motion(pointer->resource(), ++time, wl_fixed_from_int(20), wl_fixed_from_int(10)); @@ -664,6 +667,7 @@ // Clear pointer focus. wl_pointer_send_leave(pointer->resource(), ++serial, second_surface->resource()); + wl_pointer_send_frame(pointer->resource()); Sync(); @@ -694,6 +698,7 @@ wl_pointer_send_enter(pointer->resource(), ++serial, menu_surface->resource(), 0, 0); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_motion(pointer->resource(), ++time, wl_fixed_from_int(2), wl_fixed_from_int(1)); @@ -709,8 +714,10 @@ // Leave the menu window and enter the top level window. wl_pointer_send_leave(pointer->resource(), ++serial, menu_surface->resource()); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_enter(pointer->resource(), ++serial, second_surface->resource(), 0, 0); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_motion(pointer->resource(), ++time, wl_fixed_from_int(1912), wl_fixed_from_int(1071)); @@ -722,6 +729,7 @@ wl_pointer_send_leave(pointer->resource(), ++serial, second_surface->resource()); + wl_pointer_send_frame(pointer->resource()); // Now, create a nested menu window and make sure that the cursor screen point // still has been correct. The location of the window is on the right side of @@ -741,6 +749,7 @@ wl_pointer_send_enter(pointer->resource(), ++serial, nested_menu_surface->resource(), 0, 0); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_motion(pointer->resource(), ++time, wl_fixed_from_int(2), wl_fixed_from_int(3)); @@ -752,8 +761,10 @@ // point still must be reported correctly. wl_pointer_send_leave(pointer->resource(), ++serial, nested_menu_surface->resource()); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_enter(pointer->resource(), ++serial, menu_surface->resource(), 0, 0); + wl_pointer_send_frame(pointer->resource()); wl_pointer_send_motion(pointer->resource(), ++time, wl_fixed_from_int(2), wl_fixed_from_int(1));
diff --git a/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc b/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc index f9cca4af..191d7e0 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc +++ b/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc
@@ -230,10 +230,12 @@ DCHECK(drag_source_.has_value()); // Check if this is necessary. - if (*drag_source_ == DragSource::kMouse) - pointer_delegate_->OnPointerFocusChanged(window, location); - else + if (*drag_source_ == DragSource::kMouse) { + pointer_delegate_->OnPointerFocusChanged( + window, location, wl::EventDispatchPolicy::kImmediate); + } else { touch_delegate_->OnTouchFocusChanged(window); + } DVLOG(1) << "OnEnter. widget=" << window->GetWidget(); @@ -376,8 +378,9 @@ if (*drag_source_ == DragSource::kMouse) { // TODO: check if this usage is correct. - pointer_delegate_->OnPointerFocusChanged(dragged_window_, - pointer_location_); + pointer_delegate_->OnPointerFocusChanged( + dragged_window_, pointer_location_, + wl::EventDispatchPolicy::kImmediate); } else { touch_delegate_->OnTouchFocusChanged(dragged_window_); }
diff --git a/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc b/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc index 579163a..08e2d159 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc +++ b/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc
@@ -108,6 +108,7 @@ wl::MockSurface* surface = server_.GetObject<wl::MockSurface>( window1->root_surface()->GetSurfaceId()); wl_pointer_send_enter(pointer->resource(), 1, surface->resource(), 0, 0); + wl_pointer_send_frame(pointer->resource()); Sync(); @@ -118,6 +119,7 @@ EXPECT_TRUE(window1.get() == manager_->GetCurrentPointerFocusedWindow()); wl_pointer_send_leave(pointer->resource(), 2, surface->resource()); + wl_pointer_send_frame(pointer->resource()); Sync();
diff --git a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc index f7b68a4..c2374d0 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
@@ -3110,6 +3110,7 @@ auto* pointer_resource = server_.seat()->pointer()->resource(); wl_pointer_send_enter(pointer_resource, 3u /*serial*/, server_root_menu_surface->resource(), 0, 0); + wl_pointer_send_frame(pointer_resource); wl_pointer_send_button(pointer_resource, 4u /*serial*/, 1, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); EXPECT_CALL(delegate, DispatchEvent(_)).Times(2); @@ -3133,6 +3134,7 @@ wl_pointer_send_leave(pointer_resource, 5u /*serial*/, server_root_menu_surface->resource()); + wl_pointer_send_frame(pointer_resource); Sync(); }
diff --git a/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc b/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc index 9c1397c..e1c390ff 100644 --- a/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc +++ b/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc
@@ -71,6 +71,7 @@ window->root_surface()->GetSurfaceId()); wl_pointer_send_enter(pointer_->resource(), NextSerial(), surface->resource(), 0, 0); + wl_pointer_send_frame(pointer_->resource()); } void WaylandDragDropTest::SendPointerLeave( @@ -80,6 +81,7 @@ window->root_surface()->GetSurfaceId()); wl_pointer_send_leave(pointer_->resource(), NextSerial(), surface->resource()); + wl_pointer_send_frame(pointer_->resource()); } void WaylandDragDropTest::SendPointerButton(
diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc index 4ac102b..2976510 100644 --- a/ui/views/test/views_test_base.cc +++ b/ui/views/test/views_test_base.cc
@@ -135,8 +135,13 @@ std::unique_ptr<Widget> ViewsTestBase::CreateTestWidget( Widget::InitParams::Type type) { + return CreateTestWidget(CreateParamsForTestWidget(type)); +} + +std::unique_ptr<Widget> ViewsTestBase::CreateTestWidget( + Widget::InitParams params) { std::unique_ptr<Widget> widget = AllocateTestWidget(); - widget->Init(CreateParamsForTestWidget(type)); + widget->Init(std::move(params)); return widget; }
diff --git a/ui/views/test/views_test_base.h b/ui/views/test/views_test_base.h index da9d5d164..54f6fdb0 100644 --- a/ui/views/test/views_test_base.h +++ b/ui/views/test/views_test_base.h
@@ -92,6 +92,8 @@ Widget::InitParams::Type type = Widget::InitParams::TYPE_WINDOW_FRAMELESS); + virtual std::unique_ptr<Widget> CreateTestWidget(Widget::InitParams params); + bool HasCompositingManager() const; // Simulate an OS-level destruction of the native window held by |widget|.