diff --git a/DEPS b/DEPS index 9598f5dc..28cc6b8 100644 --- a/DEPS +++ b/DEPS
@@ -228,11 +228,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': 'b6d60183850f85ac100dcc5433d4009bc54fdf87', + 'skia_revision': 'addccaf9cfb6fa66f5a8b007e52def5d0cf7d7be', # 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': '218b9eeaa0d624accaf5d9441c8b9c6a2c85f677', + 'v8_revision': 'f2f38b7d2a93678921f5f772f784cdd9a3962674', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling swarming_client # and whatever else without interference from each other. @@ -240,7 +240,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': 'f016c4352f5203c10511df078b1ed5359afc1b35', + 'angle_revision': '1f0e2916e59c47bbc475444928d139261183474c', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -299,7 +299,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': '3c7d4d8aae77dad633cfda01dbb1f1744013855e', + 'catapult_revision': '56c45f54dedbfedec98c1e4a7d11c1968b56e782', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -307,7 +307,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling devtools-frontend # and whatever else without interference from each other. - 'devtools_frontend_revision': 'fa99abbab5e2242fa719d481d4936d8377c5536d', + 'devtools_frontend_revision': '2df80116cfa5bc7d532362bf90b4156a2bc6d34f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libprotobuf-mutator # and whatever else without interference from each other. @@ -347,7 +347,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': '858e585cce6052cf043c04e4c0df73893af46617', + 'dawn_revision': 'a0b92db396d85781c1bef7fbbaff3dd1b7057b81', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -680,7 +680,7 @@ 'packages': [ { 'package': 'chromium/rts/model/linux-amd64', - 'version': '1URU-9iILPccuJwgENTSMUJmx3PdNRt4uniDnIMcMLkC', + 'version': 'Z310k_o2wUDpzozowIbSDYKVUUD2FXcZony_OfZhuYEC', }, ], 'dep_type': 'cipd', @@ -691,7 +691,7 @@ 'packages': [ { 'package': 'chromium/rts/model/mac-amd64', - 'version': 'wSU83B5QT_7vWnrJ8Gkecgy0kvaSMw4JwL70S1m4c_4C', + 'version': '4WMVlG_2vyjrMm8FKP3-v2cTtx6mjzJdm9QIJlSEDYwC', }, ], 'dep_type': 'cipd', @@ -702,7 +702,7 @@ 'packages': [ { 'package': 'chromium/rts/model/windows-amd64', - 'version': 'yFEgyjVypfPYm7pgT7EnKPoOqa3otepPvE9duGQbJzEC', + 'version': 'mq-VCBtJT23TY1UhG_5MpbyiByEr34wfsmz6uIZoJKYC', }, ], 'dep_type': 'cipd', @@ -767,7 +767,7 @@ 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'kJ-Oj1Wdw4nbj8PVnlEe9bsmXERGvXJ16-R5o54YQ84C', + 'version': 'yBqUm9V81rpvY4pY_cgtkc_eCKPE0Imj3MnzzGoWliwC', }, ], 'condition': 'checkout_android', @@ -983,7 +983,7 @@ # Tools used when building Chrome for Chrome OS. This affects both the Simple # Chrome workflow, as well as the chromeos-chrome ebuild. 'src/third_party/chromite': { - 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '923a131e2a899aa635805f583e71e599c099c5c3', + 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '349dde1f1c62340a4af4a6fe19a273f21c0ff817', 'condition': 'checkout_chromeos', }, @@ -998,7 +998,7 @@ # For Linux and Chromium OS. 'src/third_party/cros_system_api': { - 'url': Var('chromium_git') + '/chromiumos/platform2/system_api.git' + '@' + '53663a4749e92260ff05fb559e17662630795f6e', + 'url': Var('chromium_git') + '/chromiumos/platform2/system_api.git' + '@' + '22cd4b423a8c3f345916a1f83789345db807b9dd', 'condition': 'checkout_linux', }, @@ -1389,7 +1389,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + 'f94e497acc562fab07b1cbe20e973c8e150900ec', + Var('android_git') + '/platform/external/perfetto.git' + '@' + 'a6966e3445f5dc2a0d9f735b8c689c5078e4c33e', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1478,7 +1478,7 @@ 'packages': [ { 'package': 'fuchsia/third_party/aemu/linux-amd64', - 'version': 'DxCnfY154Xn-UYrZ-GF8FewyGfo29cYHkKdDMgpEHJkC' + 'version': 'XXuqQyUTKH3AEKtaMdRvFnqYJNahJ64RJtSsAz1fBEAC' }, ], 'condition': 'host_os == "linux" and checkout_fuchsia', @@ -1621,7 +1621,7 @@ Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '6881e0cd401986aa80bdbf132ca4ab434bc1d7d7', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + 'bdf35afa3992d8208a1744d64559225d56718fe7', + Var('webrtc_git') + '/src.git' + '@' + 'df7156965b4bb30fb4b606f6b12bb0a949f3962f', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'), @@ -1682,7 +1682,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@4a4f3e5129fcdc5f4932900566fe2d9ef639037d', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@3ec09248df7f10ee4eb1add6475efb57be79d994', 'condition': 'checkout_src_internal', }, @@ -1701,7 +1701,7 @@ 'packages': [ { 'package': 'chromeos_internal/apps/help_app/app', - 'version': 'CXEQ-cXnS4zMzaASwBsQPC18ZbY69QxeHjiil4vn87kC', + 'version': 'I0s7tCYkmwlpeVqYmdUvvTqps-PKk9fVxTkSIh0z02AC', }, ], 'condition': 'checkout_chromeos and checkout_src_internal', @@ -1712,7 +1712,7 @@ 'packages': [ { 'package': 'chromeos_internal/apps/media_app/app', - 'version': 'WOaciqMMXpXSwqvqLCdrelp36W5o0UTlPeTuT27iyR0C', + 'version': 'MxkVEJShNua0g9HdYs_dXsdFsUFQ_S_6sOScm7AuAE0C', }, ], 'condition': 'checkout_chromeos and checkout_src_internal',
diff --git a/android_webview/browser/cookie_manager.cc b/android_webview/browser/cookie_manager.cc index 7d71b1c..b89e33689 100644 --- a/android_webview/browser/cookie_manager.cc +++ b/android_webview/browser/cookie_manager.cc
@@ -465,7 +465,8 @@ host, value, workaround_http_secure_cookies_, &should_allow_cookie); std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create( - new_host, value, base::Time::Now(), absl::nullopt /* server_time */)); + new_host, value, base::Time::Now(), absl::nullopt /* server_time */, + net::CookiePartitionKey::Todo())); if (!cc || !should_allow_cookie) { MaybeRunCookieCallback(std::move(callback), false);
diff --git a/ash/app_list/views/app_list_item_view.cc b/ash/app_list/views/app_list_item_view.cc index 61dadc1d..be159123 100644 --- a/ash/app_list/views/app_list_item_view.cc +++ b/ash/app_list/views/app_list_item_view.cc
@@ -410,7 +410,7 @@ SetIcon(icon_image_); layer()->SetTransform(gfx::GetScaleTransform( GetContentsBounds().CenterPoint(), 1 / kDragDropAppIconScale)); - } else if (grid_delegate_->IsDraggedView(this)) { + } else if (drag_state_ != DragState::kNone) { // If a drag view has been created for this icon, the item transition to // target bounds is handled by the apps grid view bounds animator. At the // end of that animation, the layer will be destroyed, causing the @@ -436,7 +436,7 @@ } else { if (is_folder_) { layer()->SetTransform(gfx::Transform()); - } else if (!grid_delegate_->IsDraggedView(this)) { + } else if (drag_state_ == DragState::kNone) { // To avoid poor quality icons, update icon image with the correct scale // after the transform animation is completed. settings.AddObserver(this); @@ -480,10 +480,48 @@ const gfx::Point& tap_down_location, const gfx::Point& tap_down_root_location) { // Show scaled up app icon to indicate draggable state. - grid_delegate_->InitiateDrag(this, tap_down_location, tap_down_root_location); + if (!InitiateDrag(tap_down_location, tap_down_root_location)) + return; SetTouchDragging(true); } +bool AppListItemView::InitiateDrag(const gfx::Point& location, + const gfx::Point& root_location) { + if (!grid_delegate_->InitiateDrag( + this, location, root_location, + base::BindOnce(&AppListItemView::OnDragStarted, + weak_ptr_factory_.GetWeakPtr()), + base::BindOnce(&AppListItemView::OnDragEnded, + weak_ptr_factory_.GetWeakPtr()))) { + return false; + } + drag_state_ = DragState::kInitialized; + return true; +} + +void AppListItemView::OnDragStarted() { + DCHECK_EQ(DragState::kInitialized, drag_state_); + + mouse_drag_timer_.Stop(); + touch_drag_timer_.Stop(); + drag_state_ = DragState::kStarted; + SetUIState(UI_STATE_DRAGGING); + CancelContextMenu(); +} + +void AppListItemView::OnDragEnded() { + DCHECK_NE(drag_state_, DragState::kNone); + + mouse_dragging_ = false; + mouse_drag_timer_.Stop(); + + touch_dragging_ = false; + touch_drag_timer_.Stop(); + + SetUIState(UI_STATE_NORMAL); + drag_state_ = DragState::kNone; +} + void AppListItemView::CancelContextMenu() { if (!context_menu_) return; @@ -492,12 +530,6 @@ context_menu_->Cancel(); } -void AppListItemView::OnDragEnded() { - mouse_drag_timer_.Stop(); - touch_drag_timer_.Stop(); - SetUIState(UI_STATE_NORMAL); -} - gfx::Point AppListItemView::GetDragImageOffset() { gfx::Point image = icon_->GetImageBounds().origin(); return gfx::Point(icon_->x() + image.x(), icon_->y() + image.y()); @@ -577,7 +609,7 @@ // to complete. If a menu is shown after the icon has moved, |grid_delegate_| // gets put in a bad state because the context menu begins to receive drag // events, interrupting the app icon drag. - if (grid_delegate_->IsDragViewMoved(*this)) + if (drag_state_ == DragState::kStarted) return; menu_show_initiated_from_key_ = source_type == ui::MENU_SOURCE_KEYBOARD; @@ -642,7 +674,7 @@ } void AppListItemView::PaintButtonContents(gfx::Canvas* canvas) { - if (grid_delegate_->IsDraggedView(this)) + if (drag_state_ != DragState::kNone) return; // TODO(ginko) focus and selection should be unified. @@ -694,13 +726,12 @@ if (!ShouldEnterPushedState(event)) return true; - grid_delegate_->InitiateDrag(this, event.location(), event.root_location()); + if (!InitiateDrag(event.location(), event.root_location())) + return true; - if (grid_delegate_->IsDraggedView(this)) { - mouse_drag_timer_.Start( - FROM_HERE, base::TimeDelta::FromMilliseconds(kMouseDragUIDelayInMs), - this, &AppListItemView::OnMouseDragTimer); - } + mouse_drag_timer_.Start( + FROM_HERE, base::TimeDelta::FromMilliseconds(kMouseDragUIDelayInMs), this, + &AppListItemView::OnMouseDragTimer); return true; } @@ -749,7 +780,7 @@ SetMouseDragging(false); // EndDrag may delete |this|. - grid_delegate_->EndDrag(false /*cancel*/); + grid_delegate_->EndDrag(/*cancel=*/false); } void AppListItemView::OnMouseCaptureLost() { @@ -757,12 +788,12 @@ SetMouseDragging(false); // EndDrag may delete |this|. - grid_delegate_->EndDrag(true /*cancel*/); + grid_delegate_->EndDrag(/*cancel=*/true); } bool AppListItemView::OnMouseDragged(const ui::MouseEvent& event) { Button::OnMouseDragged(event); - if (grid_delegate_->IsDraggedView(this) && mouse_dragging_) { + if (drag_state_ != DragState::kNone && mouse_dragging_) { // Update the drag location of the drag proxy if it has been created. // If the drag is no longer happening, it could be because this item // got removed, in which case this item has been destroyed. So, bail out @@ -774,13 +805,6 @@ if (!grid_delegate_->IsSelectedView(this)) grid_delegate_->ClearSelectedView(); - - // Show dragging UI when it's confirmed without waiting for the timer. - if (ui_state_ != UI_STATE_DRAGGING && grid_delegate_->IsDragging() && - grid_delegate_->IsDraggedView(this)) { - mouse_drag_timer_.Stop(); - SetUIState(UI_STATE_DRAGGING); - } return true; } @@ -806,7 +830,6 @@ switch (event->type()) { case ui::ET_GESTURE_SCROLL_BEGIN: if (touch_dragging_) { - CancelContextMenu(); grid_delegate_->StartDragAndDropHostDragAfterLongPress(); event->SetHandled(); } else { @@ -814,7 +837,7 @@ } break; case ui::ET_GESTURE_SCROLL_UPDATE: - if (touch_dragging_ && grid_delegate_->IsDraggedView(this)) { + if (touch_dragging_ && drag_state_ != DragState::kNone) { grid_delegate_->UpdateDragFromItem(/*is_touch=*/true, *event); event->SetHandled(); } @@ -1001,10 +1024,6 @@ icon_->SetVisible(visible); } -void AppListItemView::SetDragUIState() { - SetUIState(UI_STATE_DRAGGING); -} - void AppListItemView::EnterCardifyState() { in_cardified_grid_ = true; gfx::FontList font_size = GetAppListConfig().app_title_font(); @@ -1019,10 +1038,6 @@ in_cardified_grid_ = false; } -void AppListItemView::SetNormalUIState() { - SetUIState(UI_STATE_NORMAL); -} - // static gfx::Rect AppListItemView::GetIconBoundsForTargetViewBounds( const AppListConfig& config,
diff --git a/ash/app_list/views/app_list_item_view.h b/ash/app_list/views/app_list_item_view.h index c4ea4d7..69672c19 100644 --- a/ash/app_list/views/app_list_item_view.h +++ b/ash/app_list/views/app_list_item_view.h
@@ -40,6 +40,11 @@ class AppListMenuModelAdapter; class AppListViewDelegate; +namespace test { +class AppsGridViewDragAndDropTestBase; +class AppListMainViewTest; +} // namespace test + // An application icon and title. Commonly part of the AppsGridView, but may be // used in other contexts. Supports dragging and keyboard selection via the // GridDelegate interface. @@ -64,20 +69,30 @@ virtual void ClearSelectedView() = 0; virtual bool IsSelectedView(const AppListItemView* view) const = 0; - virtual void InitiateDrag(AppListItemView* view, + // Registers `view` as a dragged item with the apps grid. Called when the + // user presses the mouse, or starts touch interaction with the view (both + // of which may transition into a drag operation). + // `location` - The pointer location in the view's bounds. + // `root_location` - The pointer location in the root window coordinates. + // `drag_start_callback` - Callback that gets called when the mouse/touch + // interaction transitions into a drag (i.e. when the "drag" item starts + // moving. + // `drag_end_callback` - Callback that gets called when drag interaction + // ends. + // Returns whether `view` has been registered as a dragged view. Callbacks + // should be ignored if the method returns false. If the method returns + // true, it's expected to eventually run `drag_end_callback`. + virtual bool InitiateDrag(AppListItemView* view, const gfx::Point& location, - const gfx::Point& root_location) = 0; + const gfx::Point& root_location, + base::OnceClosure drag_start_callback, + base::OnceClosure drag_end_callback) = 0; virtual void StartDragAndDropHostDragAfterLongPress() = 0; // Called from AppListItemView when it receives a drag event. Returns true // if the drag is still happening. virtual bool UpdateDragFromItem(bool is_touch, const ui::LocatedEvent& event) = 0; virtual void EndDrag(bool cancel) = 0; - virtual bool IsDragging() const = 0; - virtual bool IsDraggedView(const AppListItemView* view) const = 0; - - // Whether |view| is being dragged and is not in its drag start position. - virtual bool IsDragViewMoved(const AppListItemView& view) const = 0; // Provided as a callback for AppListItemView to notify of activation via // press/click/return key. @@ -109,7 +124,6 @@ void CancelContextMenu(); - void OnDragEnded(); gfx::Point GetDragImageOffset(); void SetAsAttemptedFolderTarget(bool is_target_folder); @@ -141,11 +155,6 @@ // Sets the icon's visibility. void SetIconVisible(bool visible); - // Sets UI state to dragging state. - void SetDragUIState(); - // Sets UI state to normal state. - void SetNormalUIState(); - // Handles the icon's scaling and animation for a cardified grid. void EnterCardifyState(); void ExitCardifyState(); @@ -199,6 +208,9 @@ GridDelegate* grid_delegate_for_test() { return grid_delegate_; } private: + friend class test::AppsGridViewDragAndDropTestBase; + friend class test::AppListMainViewTest; + class IconImageView; class AppNotificationIndicatorView; @@ -208,6 +220,24 @@ UI_STATE_DROPPING_IN_FOLDER, // Folder dropping preview UI }; + // Describes the app list item view drag state. + enum class DragState { + // Item is not being dragged. + kNone, + + // Drag is initialized for the item (the owning apps grid considers the view + // to be the dragged view), but the item is still not being dragged. + // Depending on mouse/touch drag timers, UI may be in either normal, or + // dragging state. + kInitialized, + + // The item drag is in progress. While in this state, the owning apps grid + // view will generally hide the item view, and replace it with a drag icon + // widget. The UI should be in dragging state (scaled up and with title + // hidden). + kStarted, + }; + // gfx::AnimationDelegate: void AnimationProgressed(const gfx::Animation* animation) override; @@ -242,6 +272,18 @@ void OnTouchDragTimer(const gfx::Point& tap_down_location, const gfx::Point& tap_down_root_location); + // Registers this view as a dragged view with the grid delegate. + bool InitiateDrag(const gfx::Point& location, + const gfx::Point& root_location); + + // Called when the drag registered for this view starts moving. + // `drag_start_callback` passed to `GridDelegate::InitiateDrag()`. + void OnDragStarted(); + + // Called when the drag registered for this view ends. + // `drag_end_callback` passed to `GridDelegate::InitiateDrag()`. + void OnDragEnded(); + // Callback invoked when a context menu is received after calling // |AppListViewDelegate::GetContextMenuModel|. void OnContextMenuModelReceived( @@ -354,6 +396,9 @@ // The bitmap image for this app list item. gfx::ImageSkia icon_image_; + // The current item's drag state. + DragState drag_state_ = DragState::kNone; + // The scaling factor for displaying the app icon. float icon_scale_ = 1.0f;
diff --git a/ash/app_list/views/app_list_main_view_unittest.cc b/ash/app_list/views/app_list_main_view_unittest.cc index d625e0d..8f098cb 100644 --- a/ash/app_list/views/app_list_main_view_unittest.cc +++ b/ash/app_list/views/app_list_main_view_unittest.cc
@@ -39,6 +39,8 @@ const int kInitialItems = 2; +} // namespace + class AppListMainViewTest : public views::ViewsTestBase, public testing::WithParamInterface<bool> { public: @@ -118,7 +120,7 @@ gfx::Point root_window_point = point; views::View::ConvertPointToWidget(grid_view, &root_window_point); - grid_view->InitiateDrag(view, root_window_point, point); + view->InitiateDrag(point, root_window_point); return view; } @@ -134,7 +136,7 @@ gfx::Point root_window_point = point; views::View::ConvertPointToWidget(grid_view, &root_window_point); - ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, root_window_point, point, + ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point, root_window_point, ui::EventTimeForNow(), 0, 0); grid_view->UpdateDragFromItem(pointer, drag_event); @@ -248,8 +250,6 @@ INSTANTIATE_TEST_SUITE_P(All, AppListMainViewTest, testing::Bool()); -} // namespace - // Tests that the close button becomes invisible after close button is clicked. TEST_F(AppListMainViewTest, CloseButtonInvisibleAfterCloseButtonClicked) { PressKeyInSearchBox(ui::VKEY_A);
diff --git a/ash/app_list/views/apps_grid_view.cc b/ash/app_list/views/apps_grid_view.cc index 02dffe58..d737ebd6 100644 --- a/ash/app_list/views/apps_grid_view.cc +++ b/ash/app_list/views/apps_grid_view.cc
@@ -445,12 +445,17 @@ return selected_view_ == view; } -void AppsGridView::InitiateDrag(AppListItemView* view, +bool AppsGridView::InitiateDrag(AppListItemView* view, const gfx::Point& location, - const gfx::Point& root_location) { + const gfx::Point& root_location, + base::OnceClosure drag_start_callback, + base::OnceClosure drag_end_callback) { DCHECK(view); if (drag_view_ || pulsing_blocks_model_.view_size()) - return; + return false; + + drag_start_callback_ = std::move(drag_start_callback); + drag_end_callback_ = std::move(drag_end_callback); // Finalize previous drag icon animation if it's still in progress. drag_view_hider_.reset(); @@ -469,6 +474,7 @@ reorder_placeholder_ = drag_view_init_index_; ExtractDragLocation(root_location, &drag_start_grid_view_); drag_view_start_ = gfx::Point(drag_view_->x(), drag_view_->y()); + return true; } void AppsGridView::StartDragAndDropHostDragAfterLongPress() { @@ -488,6 +494,9 @@ if (!dragging_for_reparent_item_) StartDragAndDropHostDrag(); + + if (drag_start_callback_) + std::move(drag_start_callback_).Run(); } bool AppsGridView::UpdateDragFromItem(bool is_touch, @@ -750,7 +759,6 @@ gfx::Point converted_origin = drag_view_rect.origin(); ConvertPointToTarget(this, items_container_, &converted_origin); drag_view_->SetBoundsRect(gfx::Rect(converted_origin, drag_view_rect.size())); - drag_view_->SetDragUIState(); // Hide the title of the drag_view_. // Hide the drag_view_ for drag icon proxy when a native drag is responsible // for showing the icon. @@ -791,10 +799,6 @@ return drag_view_ == view; } -bool AppsGridView::IsDragViewMoved(const AppListItemView& view) const { - return IsDraggedView(&view) && drag_view_start_ != view.origin(); -} - void AppsGridView::ClearDragState() { current_ghost_location_ = GridIndex(); last_folder_dropping_a11y_event_location_ = GridIndex(); @@ -810,7 +814,6 @@ host_drag_start_timer_.AbandonAndStop(); if (drag_view_) { - drag_view_->OnDragEnded(); if (IsDraggingForReparentInRootLevelGridView()) { const int drag_view_index = view_model_.GetIndexOfView(drag_view_); CHECK_EQ(view_model_.view_size() - 1, drag_view_index); @@ -820,6 +823,10 @@ drag_view_ = nullptr; dragging_for_reparent_item_ = false; extra_page_opened_ = false; + + drag_start_callback_.Reset(); + if (drag_end_callback_) + std::move(drag_end_callback_).Run(); } void AppsGridView::SetDragAndDropHostOfCurrentAppList( @@ -1748,7 +1755,6 @@ // By setting |drag_view_| to nullptr here, we prevent ClearDragState() from // cleaning up the newly created AppListItemView, effectively claiming // ownership of the newly created drag view. - drag_view_->OnDragEnded(); released_drag_view = drag_view_; drag_view_ = nullptr; }
diff --git a/ash/app_list/views/apps_grid_view.h b/ash/app_list/views/apps_grid_view.h index b20a49a..4d5d6ea 100644 --- a/ash/app_list/views/apps_grid_view.h +++ b/ash/app_list/views/apps_grid_view.h
@@ -145,16 +145,18 @@ void SetSelectedView(AppListItemView* view) override; void ClearSelectedView() override; bool IsSelectedView(const AppListItemView* view) const override; - void InitiateDrag(AppListItemView* view, + bool InitiateDrag(AppListItemView* view, const gfx::Point& location, - const gfx::Point& root_location) override; + const gfx::Point& root_location, + base::OnceClosure drag_start_callback, + base::OnceClosure drag_end_callback) override; void StartDragAndDropHostDragAfterLongPress() override; bool UpdateDragFromItem(bool is_touch, const ui::LocatedEvent& event) override; void EndDrag(bool cancel) override; - bool IsDragging() const override; - bool IsDraggedView(const AppListItemView* view) const override; - bool IsDragViewMoved(const AppListItemView& view) const override; + + bool IsDragging() const; + bool IsDraggedView(const AppListItemView* view) const; void ClearDragState(); @@ -426,6 +428,17 @@ // Subclasses need non-const access. AppListItemView* drag_view_ = nullptr; + // If set, a callback called when the dragged item starts moving during a drag + // (i.e. when the drag icon proxy gets created). + // Registered in `InitiateDrag()` + base::OnceClosure drag_start_callback_; + + // If set, a callback called when an item drag ends, and drag state is + // cleared. It may get called before the drag icon proxy drop animation + // finishes. + // Registered in `InitiateDrag()`. + base::OnceClosure drag_end_callback_; + // If app item drag is in progress, the icon proxy created for the app list // item. std::unique_ptr<AppDragIconProxy> drag_icon_proxy_;
diff --git a/ash/app_list/views/apps_grid_view_unittest.cc b/ash/app_list/views/apps_grid_view_unittest.cc index 910c8b72..1e6ce180 100644 --- a/ash/app_list/views/apps_grid_view_unittest.cc +++ b/ash/app_list/views/apps_grid_view_unittest.cc
@@ -498,7 +498,7 @@ // Ensure that the |root_from| point is correct if RTL. root_from.set_x(apps_grid_view->GetMirroredXInView(root_from.x())); - apps_grid_view->InitiateDrag(view, root_from, root_from); + view->InitiateDrag(root_from, root_from); current_drag_location_ = root_from; // Call UpdateDrag to trigger |apps_grid_view| change to cardified_state. UpdateDrag(pointer, from, apps_grid_view);
diff --git a/ash/app_list/views/recent_apps_view.cc b/ash/app_list/views/recent_apps_view.cc index 4276b32..c38787b 100644 --- a/ash/app_list/views/recent_apps_view.cc +++ b/ash/app_list/views/recent_apps_view.cc
@@ -114,22 +114,19 @@ bool IsSelectedView(const AppListItemView* view) const override { return view == selected_view_; } - void InitiateDrag(AppListItemView* view, + bool InitiateDrag(AppListItemView* view, const gfx::Point& location, - const gfx::Point& root_location) override {} + const gfx::Point& root_location, + base::OnceClosure drag_start_callback, + base::OnceClosure drag_end_callback) override { + return false; + } void StartDragAndDropHostDragAfterLongPress() override {} bool UpdateDragFromItem(bool is_touch, const ui::LocatedEvent& event) override { return false; } void EndDrag(bool cancel) override {} - bool IsDragging() const override { return false; } - bool IsDraggedView(const AppListItemView* view) const override { - return false; - } - bool IsDragViewMoved(const AppListItemView& view) const override { - return false; - } void OnAppListItemViewActivated(AppListItemView* pressed_item_view, const ui::Event& event) override { // TODO(crbug.com/1216594): Add a new launch type for "recent apps".
diff --git a/ash/quick_pair/pairing/BUILD.gn b/ash/quick_pair/pairing/BUILD.gn index 34547dc..091e145 100644 --- a/ash/quick_pair/pairing/BUILD.gn +++ b/ash/quick_pair/pairing/BUILD.gn
@@ -13,12 +13,15 @@ "fast_pair/decrypted_passkey.h", "fast_pair/decrypted_response.cc", "fast_pair/decrypted_response.h", + "fast_pair/fake_fast_pair_gatt_service_client.cc", + "fast_pair/fake_fast_pair_gatt_service_client.h", "fast_pair/fast_pair_data_parser.cc", "fast_pair/fast_pair_data_parser.h", "fast_pair/fast_pair_encryption.cc", "fast_pair/fast_pair_encryption.h", - "fast_pair/fast_pair_gatt_service_client.cc", "fast_pair/fast_pair_gatt_service_client.h", + "fast_pair/fast_pair_gatt_service_client_impl.cc", + "fast_pair/fast_pair_gatt_service_client_impl.h", "fast_pair/fast_pair_key_pair.cc", "fast_pair/fast_pair_key_pair.h", "fast_pair/fast_pair_pairer.cc",
diff --git a/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.cc b/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.cc new file mode 100644 index 0000000..3cd252c --- /dev/null +++ b/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.cc
@@ -0,0 +1,34 @@ +// 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 "ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h" +#include "ash/quick_pair/common/logging.h" +#include "base/callback_helpers.h" +#include "device/bluetooth/bluetooth_adapter.h" +#include "device/bluetooth/bluetooth_device.h" + +namespace ash { +namespace quick_pair { + +FakeFastPairGattServiceClient::FakeFastPairGattServiceClient( + device::BluetoothDevice* device, + scoped_refptr<device::BluetoothAdapter> adapter, + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback) + : on_initialized_callback_(std::move(on_initialized_callback)) {} + +FakeFastPairGattServiceClient::~FakeFastPairGattServiceClient() = default; + +void FakeFastPairGattServiceClient::RunOnGattClientInitializedCallback( + absl::optional<PairFailure> failure) { + std::move(on_initialized_callback_).Run(failure); +} + +device::BluetoothRemoteGattService* +FakeFastPairGattServiceClient::gatt_service() { + return nullptr; +} + +} // namespace quick_pair +} // namespace ash
diff --git a/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h b/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h new file mode 100644 index 0000000..86ebbb0 --- /dev/null +++ b/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h
@@ -0,0 +1,47 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ +#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ + +#include "ash/quick_pair/common/pair_failure.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "base/callback.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace device { + +class BluetothAdapter; +class BluetoothDevice; + +} // namespace device + +namespace ash { +namespace quick_pair { + +// This class fakes FastPairGattServiceClient and permits setting which +// PairFailure, if any, is run with the callback. +class FakeFastPairGattServiceClient : public FastPairGattServiceClient { + public: + FakeFastPairGattServiceClient( + device::BluetoothDevice* device, + scoped_refptr<device::BluetoothAdapter> adapter, + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback); + ~FakeFastPairGattServiceClient() override; + + device::BluetoothRemoteGattService* gatt_service() override; + + void RunOnGattClientInitializedCallback( + absl::optional<PairFailure> failure = absl::nullopt); + + private: + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback_; +}; + +} // namespace quick_pair +} // namespace ash + +#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h index 945ac59..8936a69 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h
@@ -5,24 +5,7 @@ #ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_H_ #define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_H_ -#include "ash/quick_pair/common/pair_failure.h" -#include "base/callback.h" -#include "base/memory/scoped_refptr.h" -#include "base/memory/weak_ptr.h" -#include "base/scoped_observation.h" -#include "base/timer/timer.h" #include "device/bluetooth/bluetooth_adapter.h" -#include "third_party/abseil-cpp/absl/types/optional.h" - -namespace device { - -class BluetoothDevice; -class BluetoothGattConnection; -class BluetoothRemoteGattService; -class BluetoothGattNotifySession; -class BluetoothRemoteGattService; - -} // namespace device namespace ash { namespace quick_pair { @@ -32,87 +15,8 @@ // during initialization. class FastPairGattServiceClient : public device::BluetoothAdapter::Observer { public: - class Factory { - public: - static std::unique_ptr<FastPairGattServiceClient> Create( - device::BluetoothDevice* device, - scoped_refptr<device::BluetoothAdapter> adapter, - base::OnceCallback<void(absl::optional<PairFailure>)> - on_initialized_callback); - static void SetFactoryForTesting(Factory* test_factory); - - protected: - virtual ~Factory(); - virtual std::unique_ptr<FastPairGattServiceClient> CreateInstance( - device::BluetoothDevice* device, - scoped_refptr<device::BluetoothAdapter> adapter, - base::OnceCallback<void(absl::optional<PairFailure>)> - on_initialized_callback) = 0; - - private: - static Factory* g_test_factory_; - }; - - device::BluetoothRemoteGattService* gatt_service() { return gatt_service_; } - - ~FastPairGattServiceClient() override; - - private: - FastPairGattServiceClient( - device::BluetoothDevice* device, - scoped_refptr<device::BluetoothAdapter> adapter, - base::OnceCallback<void(absl::optional<PairFailure>)> - on_initialized_callback); - FastPairGattServiceClient(const FastPairGattServiceClient&) = delete; - FastPairGattServiceClient& operator=(const FastPairGattServiceClient&) = - delete; - - // Callback from the adapter's call to create GATT connection. - void OnGattConnection( - std::unique_ptr<device::BluetoothGattConnection> gatt_connection, - absl::optional<device::BluetoothDevice::ConnectErrorCode> error_code); - - // Invokes the callback with the proper PairFailure and clears local state. - void NotifyError(PairFailure failure); - - // BluetoothAdapter::Observer - void GattDiscoveryCompleteForService( - device::BluetoothAdapter* adapter, - device::BluetoothRemoteGattService* service) override; - - void FindGattCharacteristicsAndStartNotifySessions(); - - std::vector<device::BluetoothRemoteGattCharacteristic*> - GetCharacteristicsByUUIDs(const device::BluetoothUUID& uuidV1, - const device::BluetoothUUID& uuidV2); - - // BluetoothRemoteGattCharacteristic StartNotifySession callbacks - void OnNotifySession( - std::unique_ptr<device::BluetoothGattNotifySession> session); - void OnGattError(PairFailure failure, - device::BluetoothGattService::GattErrorCode error); - - base::OneShotTimer gatt_service_discovery_timer_; - base::OneShotTimer passkey_notify_session_timer_; - base::OneShotTimer keybased_notify_session_timer_; - - std::string device_address_; - device::BluetoothRemoteGattCharacteristic* key_based_characteristic_ = - nullptr; - device::BluetoothRemoteGattCharacteristic* passkey_characteristic_ = nullptr; - device::BluetoothRemoteGattCharacteristic* account_key_characteristic_ = - nullptr; - std::vector<std::unique_ptr<device::BluetoothGattNotifySession>> - bluetooth_gatt_notify_sessions_; - base::OnceCallback<void(absl::optional<PairFailure>)> - on_initialized_callback_; - scoped_refptr<device::BluetoothAdapter> adapter_; - std::unique_ptr<device::BluetoothGattConnection> gatt_connection_; - device::BluetoothRemoteGattService* gatt_service_ = nullptr; - base::ScopedObservation<device::BluetoothAdapter, - device::BluetoothAdapter::Observer> - adapter_observation_{this}; - base::WeakPtrFactory<FastPairGattServiceClient> weak_ptr_factory_{this}; + ~FastPairGattServiceClient() override = default; + virtual device::BluetoothRemoteGattService* gatt_service() = 0; }; } // namespace quick_pair
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.cc b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.cc similarity index 83% rename from ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.cc rename to ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.cc index c51260c..0f35591 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.cc +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" #include "ash/quick_pair/common/constants.h" #include "ash/quick_pair/common/logging.h" @@ -35,12 +35,12 @@ namespace quick_pair { // static -FastPairGattServiceClient::Factory* - FastPairGattServiceClient::Factory::g_test_factory_ = nullptr; +FastPairGattServiceClientImpl::Factory* + FastPairGattServiceClientImpl::Factory::g_test_factory_ = nullptr; // static std::unique_ptr<FastPairGattServiceClient> -FastPairGattServiceClient::Factory::Create( +FastPairGattServiceClientImpl::Factory::Create( device::BluetoothDevice* device, scoped_refptr<device::BluetoothAdapter> adapter, base::OnceCallback<void(absl::optional<PairFailure>)> @@ -49,43 +49,43 @@ return g_test_factory_->CreateInstance(device, adapter, std::move(on_initialized_callback)); } - return absl::WrapUnique(new FastPairGattServiceClient( + return absl::WrapUnique(new FastPairGattServiceClientImpl( device, adapter, std::move(on_initialized_callback))); } // static -void FastPairGattServiceClient::Factory::SetFactoryForTesting( +void FastPairGattServiceClientImpl::Factory::SetFactoryForTesting( Factory* g_test_factory) { g_test_factory_ = g_test_factory; } -FastPairGattServiceClient::Factory::~Factory() = default; +FastPairGattServiceClientImpl::Factory::~Factory() = default; -FastPairGattServiceClient::FastPairGattServiceClient( +FastPairGattServiceClientImpl::FastPairGattServiceClientImpl( device::BluetoothDevice* device, scoped_refptr<device::BluetoothAdapter> adapter, base::OnceCallback<void(absl::optional<PairFailure>)> on_initialized_callback) - : device_address_(device->GetAddress()), - on_initialized_callback_(std::move(on_initialized_callback)), + : on_initialized_callback_(std::move(on_initialized_callback)), + device_address_(device->GetAddress()), adapter_(std::move(adapter)) { adapter_observation_.Observe(adapter_.get()); QP_LOG(VERBOSE) << "Starting the GATT connection to device at address:[" << device_address_ << "]."; device->CreateGattConnection( - base::BindOnce(&FastPairGattServiceClient::OnGattConnection, + base::BindOnce(&FastPairGattServiceClientImpl::OnGattConnection, weak_ptr_factory_.GetWeakPtr()), kFastPairBluetoothUuid); gatt_service_discovery_timer_.Start( FROM_HERE, kConnectingTimeout, - base::BindOnce(&FastPairGattServiceClient::NotifyError, + base::BindOnce(&FastPairGattServiceClientImpl::NotifyError, weak_ptr_factory_.GetWeakPtr(), PairFailure::kGattServiceDiscoveryTimeout)); } -FastPairGattServiceClient::~FastPairGattServiceClient() = default; +FastPairGattServiceClientImpl::~FastPairGattServiceClientImpl() = default; -void FastPairGattServiceClient::OnGattConnection( +void FastPairGattServiceClientImpl::OnGattConnection( std::unique_ptr<device::BluetoothGattConnection> gatt_connection, absl::optional<device::BluetoothDevice::ConnectErrorCode> error_code) { if (error_code) { @@ -100,7 +100,7 @@ } } -void FastPairGattServiceClient::NotifyError(PairFailure failure) { +void FastPairGattServiceClientImpl::NotifyError(PairFailure failure) { adapter_.reset(); adapter_observation_.Reset(); gatt_connection_.reset(); @@ -116,7 +116,7 @@ std::move(on_initialized_callback_).Run(failure); } -void FastPairGattServiceClient::GattDiscoveryCompleteForService( +void FastPairGattServiceClientImpl::GattDiscoveryCompleteForService( device::BluetoothAdapter* adapter, device::BluetoothRemoteGattService* service) { gatt_service_discovery_timer_.Stop(); @@ -133,7 +133,7 @@ } std::vector<device::BluetoothRemoteGattCharacteristic*> -FastPairGattServiceClient::GetCharacteristicsByUUIDs( +FastPairGattServiceClientImpl::GetCharacteristicsByUUIDs( const device::BluetoothUUID& uuidV1, const device::BluetoothUUID& uuidV2) { if (!gatt_service_) @@ -147,7 +147,7 @@ return characteristics; } -void FastPairGattServiceClient:: +void FastPairGattServiceClientImpl:: FindGattCharacteristicsAndStartNotifySessions() { std::vector<device::BluetoothRemoteGattCharacteristic*> key_based_characteristics = GetCharacteristicsByUUIDs( @@ -177,33 +177,33 @@ keybased_notify_session_timer_.Start( FROM_HERE, kConnectingTimeout, base::BindOnce( - &FastPairGattServiceClient::NotifyError, + &FastPairGattServiceClientImpl::NotifyError, weak_ptr_factory_.GetWeakPtr(), PairFailure::kKeyBasedPairingCharacteristicNotifySessionTimeout)); passkey_notify_session_timer_.Start( FROM_HERE, kConnectingTimeout, - base::BindOnce(&FastPairGattServiceClient::NotifyError, + base::BindOnce(&FastPairGattServiceClientImpl::NotifyError, weak_ptr_factory_.GetWeakPtr(), PairFailure::kPasskeyCharacteristicNotifySessionTimeout)); key_based_characteristic_ = key_based_characteristics[0]; key_based_characteristic_->StartNotifySession( - base::BindOnce(&FastPairGattServiceClient::OnNotifySession, + base::BindOnce(&FastPairGattServiceClientImpl::OnNotifySession, weak_ptr_factory_.GetWeakPtr()), - base::BindOnce(&FastPairGattServiceClient::OnGattError, + base::BindOnce(&FastPairGattServiceClientImpl::OnGattError, weak_ptr_factory_.GetWeakPtr(), PairFailure::kKeyBasedPairingCharacteristicNotifySession)); passkey_characteristic_ = passkey_characteristics[0]; passkey_characteristic_->StartNotifySession( - base::BindOnce(&FastPairGattServiceClient::OnNotifySession, + base::BindOnce(&FastPairGattServiceClientImpl::OnNotifySession, weak_ptr_factory_.GetWeakPtr()), - base::BindOnce(&FastPairGattServiceClient::OnGattError, + base::BindOnce(&FastPairGattServiceClientImpl::OnGattError, weak_ptr_factory_.GetWeakPtr(), PairFailure::kPasskeyCharacteristicNotifySession)); } -void FastPairGattServiceClient::OnNotifySession( +void FastPairGattServiceClientImpl::OnNotifySession( std::unique_ptr<device::BluetoothGattNotifySession> session) { // Check which characteristic the session corresponds to and stop the relevant // timer. @@ -232,12 +232,17 @@ } } -void FastPairGattServiceClient::OnGattError( +void FastPairGattServiceClientImpl::OnGattError( PairFailure failure, device::BluetoothGattService::GattErrorCode error) { QP_LOG(VERBOSE) << "StartNotifySession failed due to GATT error."; NotifyError(failure); } +device::BluetoothRemoteGattService* +FastPairGattServiceClientImpl::gatt_service() { + return gatt_service_; +} + } // namespace quick_pair } // namespace ash
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h new file mode 100644 index 0000000..4111a7f --- /dev/null +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h
@@ -0,0 +1,122 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_ +#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_ + +#include "ash/quick_pair/common/pair_failure.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "base/callback.h" +#include "base/memory/scoped_refptr.h" +#include "base/memory/weak_ptr.h" +#include "base/scoped_observation.h" +#include "base/timer/timer.h" +#include "device/bluetooth/bluetooth_adapter.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace device { + +class BluetoothDevice; +class BluetoothGattConnection; +class BluetoothRemoteGattService; +class BluetoothGattNotifySession; +class BluetoothRemoteGattService; + +} // namespace device + +namespace ash { +namespace quick_pair { + +// This class is responsible for connecting to the Fast Pair GATT service for a +// device and invoking a callback when ready, or when an error is discovered +// during initialization. +class FastPairGattServiceClientImpl : public FastPairGattServiceClient { + public: + class Factory { + public: + static std::unique_ptr<FastPairGattServiceClient> Create( + device::BluetoothDevice* device, + scoped_refptr<device::BluetoothAdapter> adapter, + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback); + static void SetFactoryForTesting(Factory* test_factory); + + protected: + virtual ~Factory(); + virtual std::unique_ptr<FastPairGattServiceClient> CreateInstance( + device::BluetoothDevice* device, + scoped_refptr<device::BluetoothAdapter> adapter, + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback) = 0; + + private: + static Factory* g_test_factory_; + }; + + ~FastPairGattServiceClientImpl() override; + + device::BluetoothRemoteGattService* gatt_service() override; + + private: + FastPairGattServiceClientImpl( + device::BluetoothDevice* device, + scoped_refptr<device::BluetoothAdapter> adapter, + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback); + FastPairGattServiceClientImpl(const FastPairGattServiceClientImpl&) = delete; + FastPairGattServiceClientImpl& operator=( + const FastPairGattServiceClientImpl&) = delete; + + // Callback from the adapter's call to create GATT connection. + void OnGattConnection( + std::unique_ptr<device::BluetoothGattConnection> gatt_connection, + absl::optional<device::BluetoothDevice::ConnectErrorCode> error_code); + + // Invokes the callback with the proper PairFailure and clears local state. + void NotifyError(PairFailure failure); + + // BluetoothAdapter::Observer + void GattDiscoveryCompleteForService( + device::BluetoothAdapter* adapter, + device::BluetoothRemoteGattService* service) override; + + void FindGattCharacteristicsAndStartNotifySessions(); + + std::vector<device::BluetoothRemoteGattCharacteristic*> + GetCharacteristicsByUUIDs(const device::BluetoothUUID& uuidV1, + const device::BluetoothUUID& uuidV2); + + // BluetoothRemoteGattCharacteristic StartNotifySession callbacks + void OnNotifySession( + std::unique_ptr<device::BluetoothGattNotifySession> session); + void OnGattError(PairFailure failure, + device::BluetoothGattService::GattErrorCode error); + + base::OneShotTimer gatt_service_discovery_timer_; + base::OneShotTimer passkey_notify_session_timer_; + base::OneShotTimer keybased_notify_session_timer_; + + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback_; + std::string device_address_; + device::BluetoothRemoteGattCharacteristic* key_based_characteristic_ = + nullptr; + device::BluetoothRemoteGattCharacteristic* passkey_characteristic_ = nullptr; + device::BluetoothRemoteGattCharacteristic* account_key_characteristic_ = + nullptr; + std::vector<std::unique_ptr<device::BluetoothGattNotifySession>> + bluetooth_gatt_notify_sessions_; + scoped_refptr<device::BluetoothAdapter> adapter_; + std::unique_ptr<device::BluetoothGattConnection> gatt_connection_; + device::BluetoothRemoteGattService* gatt_service_ = nullptr; + base::ScopedObservation<device::BluetoothAdapter, + device::BluetoothAdapter::Observer> + adapter_observation_{this}; + base::WeakPtrFactory<FastPairGattServiceClientImpl> weak_ptr_factory_{this}; +}; + +} // namespace quick_pair +} // namespace ash + +#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_unittest.cc b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_unittest.cc index 0228665e..df5df0df 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_unittest.cc +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" #include <stddef.h> @@ -211,7 +211,7 @@ device_ = CreateTestBluetoothDevice( adapter_.get(), ash::quick_pair::kFastPairBluetoothUuid); adapter_->AddMockDevice(std::move(device_)); - gatt_service_client_ = FastPairGattServiceClient::Factory::Create( + gatt_service_client_ = FastPairGattServiceClientImpl::Factory::Create( adapter_->GetDevice(kTestBleDeviceAddress), adapter_.get(), base::BindRepeating( &::ash::quick_pair::FastPairGattServiceClientTest::TestCallback, @@ -224,7 +224,7 @@ adapter_.get(), ash::quick_pair::kFastPairBluetoothUuid); device_->SetError(true); adapter_->AddMockDevice(std::move(device_)); - gatt_service_client_ = FastPairGattServiceClient::Factory::Create( + gatt_service_client_ = FastPairGattServiceClientImpl::Factory::Create( adapter_->GetDevice(kTestBleDeviceAddress), adapter_.get(), base::BindRepeating( &::ash::quick_pair::FastPairGattServiceClientTest::TestCallback, @@ -235,7 +235,7 @@ adapter_ = base::MakeRefCounted<FakeBluetoothAdapter>(); device_ = CreateTestBluetoothDevice(adapter_.get(), kNonFastPairUuid); adapter_->AddMockDevice(std::move(device_)); - gatt_service_client_ = FastPairGattServiceClient::Factory::Create( + gatt_service_client_ = FastPairGattServiceClientImpl::Factory::Create( adapter_->GetDevice(kTestBleDeviceAddress), adapter_.get(), base::BindRepeating( &::ash::quick_pair::FastPairGattServiceClientTest::TestCallback,
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc index 6a16d93..0090c34 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc
@@ -8,6 +8,7 @@ #include "ash/quick_pair/common/device.h" #include "ash/quick_pair/common/logging.h" #include "ash/quick_pair/common/pair_failure.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" #include "base/callback.h" #include "device/bluetooth/bluetooth_adapter.h" @@ -29,19 +30,23 @@ pair_failed_callback_(std::move(pair_failed_callback)), account_key_failure_callback_(std::move(account_key_failure_callback)), pairing_procedure_complete_(std::move(pairing_procedure_complete)) { - StartPairing(); + fast_pair_gatt_service_client_ = + FastPairGattServiceClientImpl::Factory::Create( + adapter_->GetDevice(device_->address), adapter_, + base::BindRepeating(&FastPairPairer::OnGattClientInitializedCallback, + weak_ptr_factory_.GetWeakPtr())); } -FastPairPairer::FastPairPairer(FastPairPairer&&) = default; - -FastPairPairer& FastPairPairer::operator=(FastPairPairer&&) = default; - FastPairPairer::~FastPairPairer() = default; -void FastPairPairer::StartPairing() { - QP_LOG(INFO) << __func__ << ": " << device_; - std::move(paired_callback_).Run(device_); - std::move(pairing_procedure_complete_).Run(device_); +void FastPairPairer::OnGattClientInitializedCallback( + absl::optional<PairFailure> failure) { + if (failure) { + std::move(pair_failed_callback_).Run(device_, failure.value()); + return; + } + + QP_LOG(VERBOSE) << "Fast Pair GATT service client initialization successful."; } } // namespace quick_pair
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h index f137c35..f8388ac 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h
@@ -5,8 +5,12 @@ #ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_PAIRER_H_ #define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_PAIRER_H_ +#include "ash/quick_pair/common/pair_failure.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" #include "base/callback.h" #include "base/memory/scoped_refptr.h" +#include "base/memory/weak_ptr.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace device { @@ -37,12 +41,12 @@ pairing_procedure_complete); FastPairPairer(const FastPairPairer&) = delete; FastPairPairer& operator=(const FastPairPairer&) = delete; - FastPairPairer(FastPairPairer&&); - FastPairPairer& operator=(FastPairPairer&&); + FastPairPairer(FastPairPairer&&) = delete; + FastPairPairer& operator=(FastPairPairer&&) = delete; ~FastPairPairer(); private: - void StartPairing(); + void OnGattClientInitializedCallback(absl::optional<PairFailure> failure); scoped_refptr<device::BluetoothAdapter> adapter_; scoped_refptr<Device> device_; @@ -52,6 +56,8 @@ base::OnceCallback<void(scoped_refptr<Device>, AccountKeyFailure)> account_key_failure_callback_; base::OnceCallback<void(scoped_refptr<Device>)> pairing_procedure_complete_; + std::unique_ptr<FastPairGattServiceClient> fast_pair_gatt_service_client_; + base::WeakPtrFactory<FastPairPairer> weak_ptr_factory_{this}; }; } // namespace quick_pair
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc index 2f50df3..e508457 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc
@@ -10,28 +10,105 @@ #include "ash/quick_pair/common/device.h" #include "ash/quick_pair/common/pair_failure.h" #include "ash/quick_pair/common/protocol.h" +#include "ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" #include "base/memory/scoped_refptr.h" #include "base/test/mock_callback.h" #include "device/bluetooth/test/mock_bluetooth_adapter.h" +#include "device/bluetooth/test/mock_bluetooth_device.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace { constexpr char kMetadataId[] = "test_metadata_id"; constexpr char kAddress[] = "test_address"; +constexpr char kDeviceName[] = "test_device_name"; + +class FakeBluetoothAdapter + : public testing::NiceMock<device::MockBluetoothAdapter> { + public: + FakeBluetoothAdapter() = default; + + // Move-only class + FakeBluetoothAdapter(const FakeBluetoothAdapter&) = delete; + FakeBluetoothAdapter& operator=(const FakeBluetoothAdapter&) = delete; + + device::BluetoothDevice* GetDevice(const std::string& address) override { + for (const auto& it : mock_devices_) { + if (it->GetAddress() == address) + return it.get(); + } + return nullptr; + } + + void NotifyGattDiscoveryCompleteForService( + device::BluetoothRemoteGattService* service) { + device::BluetoothAdapter::NotifyGattDiscoveryComplete(service); + } + + protected: + ~FakeBluetoothAdapter() override = default; +}; } // namespace namespace ash { namespace quick_pair { +class FakeFastPairGattServiceClientImplFactory + : public FastPairGattServiceClientImpl::Factory { + public: + FakeFastPairGattServiceClientImplFactory() = default; + ~FakeFastPairGattServiceClientImplFactory() override = default; + + FakeFastPairGattServiceClient* fake_fast_pair_gatt_service_client() { + return fake_fast_pair_gatt_service_client_; + } + + private: + // FastPairGattServiceClientImpl::Factory: + std::unique_ptr<FastPairGattServiceClient> CreateInstance( + device::BluetoothDevice* device, + scoped_refptr<device::BluetoothAdapter> adapter, + base::OnceCallback<void(absl::optional<PairFailure>)> + on_initialized_callback) override { + auto fake_fast_pair_gatt_service_client = + std::make_unique<FakeFastPairGattServiceClient>( + device, adapter, std::move(on_initialized_callback)); + fake_fast_pair_gatt_service_client_ = + fake_fast_pair_gatt_service_client.get(); + return fake_fast_pair_gatt_service_client; + } + + FakeFastPairGattServiceClient* fake_fast_pair_gatt_service_client_ = nullptr; +}; + class FastPairPairerTest : public testing::Test { public: void SetUp() override { device_ = base::MakeRefCounted<Device>(kMetadataId, kAddress, Protocol::kFastPair); - adapter_ = - base::MakeRefCounted<testing::NiceMock<device::MockBluetoothAdapter>>(); + adapter_ = base::MakeRefCounted<FakeBluetoothAdapter>(); + + // Need to add a matching mock device to the bluetooth adapter with the + // same address to mock the relationship between Device and + // device::BluetoothDevice. + mock_device_ = + std::make_unique<testing::NiceMock<device::MockBluetoothDevice>>( + adapter_.get(), 0, kDeviceName, kAddress, /*paired=*/true, + /*connected*/ false); + adapter_->AddMockDevice(std::move(mock_device_)); + + FastPairGattServiceClientImpl::Factory::SetFactoryForTesting( + &fast_pair_gatt_service_factory_); + } + + void RunOnGattClientInitializedCallback( + absl::optional<PairFailure> failure = absl::nullopt) { + fast_pair_gatt_service_factory_.fake_fast_pair_gatt_service_client() + ->RunOnGattClientInitializedCallback(failure); } protected: @@ -42,7 +119,8 @@ account_key_failure_callback_.Get(), pairing_procedure_complete_.Get()); } - scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> adapter_; + std::unique_ptr<testing::NiceMock<device::MockBluetoothDevice>> mock_device_; + scoped_refptr<FakeBluetoothAdapter> adapter_; scoped_refptr<Device> device_; base::MockCallback<base::OnceCallback<void(scoped_refptr<Device>)>> paired_callback_; @@ -54,12 +132,20 @@ account_key_failure_callback_; base::MockCallback<base::OnceCallback<void(scoped_refptr<Device>)>> pairing_procedure_complete_; + FakeFastPairGattServiceClientImplFactory fast_pair_gatt_service_factory_; std::unique_ptr<FastPairPairer> pairer_; }; -TEST_F(FastPairPairerTest, PairingProcedureCompleteCallbackIsInvoked) { - EXPECT_CALL(pairing_procedure_complete_, Run); +TEST_F(FastPairPairerTest, NoCallbackIsInvokedOnGattSuccess) { + EXPECT_CALL(pair_failed_callback_, Run).Times(0); CreatePairer(); + RunOnGattClientInitializedCallback(); +} + +TEST_F(FastPairPairerTest, PairFailedCallbackIsInvokedOnGattFailure) { + EXPECT_CALL(pair_failed_callback_, Run); + CreatePairer(); + RunOnGattClientInitializedCallback(PairFailure::kCreateGattConnection); } } // namespace quick_pair
diff --git a/ash/shelf/scrollable_shelf_view_unittest.cc b/ash/shelf/scrollable_shelf_view_unittest.cc index 583ee24..a596bf5 100644 --- a/ash/shelf/scrollable_shelf_view_unittest.cc +++ b/ash/shelf/scrollable_shelf_view_unittest.cc
@@ -601,9 +601,10 @@ EXPECT_EQ(0, secondary_scrollable_shelf_view->first_tappable_app_index()); } +// TODO(crbug.com/1236067): This test is flaky. Re-enable once fixed. // Verifies that the scrollable shelf in oveflow mode has the correct layout // after switching to tablet mode (https://crbug.com/1017979). -TEST_P(ScrollableShelfViewRTLTest, CorrectUIAfterSwitchingToTablet) { +TEST_P(ScrollableShelfViewRTLTest, DISABLED_CorrectUIAfterSwitchingToTablet) { // Add enough app shortcuts to ensure that at least three pages of icons show. for (int i = 0; i < 25; i++) AddAppShortcut();
diff --git a/ash/webui/scanning/mojom/scanning.mojom b/ash/webui/scanning/mojom/scanning.mojom index 3121c49..aabc8ca 100644 --- a/ash/webui/scanning/mojom/scanning.mojom +++ b/ash/webui/scanning/mojom/scanning.mojom
@@ -135,6 +135,10 @@ // Called when canceling the current scan job is complete. |success| // indicates whether the scan job was cancelled successfully. OnCancelComplete(bool success); + + // Called when a scan in a multi-page scan session fails. This does not end + // the multi-page scan session. The user is allowed to attempt the scan again. + OnMultiPageScanFail(ScanResult result); }; // Interface used to obtain information about and interact with connected @@ -158,7 +162,33 @@ StartScan(mojo_base.mojom.UnguessableToken scanner_id, ScanSettings settings, pending_remote<ScanJobObserver> observer) => (bool success); + // Starts a multi-page scan session with the scanner identified by + // |scanner_id| using the provided |settings|. Scan job events are reported to + // the client via the |observer|. |success| indicates whether the first scan + // started successfully. All subsequent multi-page scan actions are made + // through the |controller|. There can only be one multi-page scan session + // started at at a time. + StartMultiPageScan(mojo_base.mojom.UnguessableToken scanner_id, + ScanSettings settings, pending_remote<ScanJobObserver> observer) + => (pending_remote<MultiPageScanController>? controller); + // Attempts to cancel the currently running scan job. The success of the // cancel attempt is reported through the ScanJobObserver. CancelScan(); }; + +// Interface used for performing the actions in a multi-page scan session. It is +// exposed to the Scan app only after a successful call to +// ScanService::StartMultiPageScan(). Closing the message pipe for this +// interface without calling CompleteMultiPageScan() cancels the current +// multipage scan session. The previously scanned images from that session +// will be discarded. +interface MultiPageScanController { + // Scans the next page in a multi-page scan session. |success| indicates + // whether the scan started successfully. + ScanNextPage(mojo_base.mojom.UnguessableToken scanner_id, + ScanSettings settings) => (bool success); + + // Ends a multi-page scan session and saves the scan to disk. + CompleteMultiPageScan(); +};
diff --git a/ash/webui/scanning/resources/scanning_app.js b/ash/webui/scanning/resources/scanning_app.js index 560cd4c..7f68798 100644 --- a/ash/webui/scanning/resources/scanning_app.js +++ b/ash/webui/scanning/resources/scanning_app.js
@@ -474,6 +474,12 @@ }, /** + * Overrides ash.scanning.mojom.ScanJobObserverInterface. + * @param {!ash.scanning.mojom.ScanResult} result + */ + onMultiPageScanFail(result) {}, + + /** * @param {string} selectedSource * @return {!Array<ash.scanning.mojom.PageSize>} * @private
diff --git a/base/BUILD.gn b/base/BUILD.gn index bc2b2ee..2301025 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn
@@ -4228,6 +4228,8 @@ "test/android/junit/src/org/chromium/base/test/params/ParameterizedRunnerTest.java", "test/android/junit/src/org/chromium/base/test/params/ParameterizedTestNameTest.java", "test/android/junit/src/org/chromium/base/test/util/AnnotationProcessingUtilsTest.java", + "test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsNoClassAnnotationCheckTest.java", + "test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsWithClassAnnotationCheckTest.java", "test/android/junit/src/org/chromium/base/test/util/DisableIfTest.java", "test/android/junit/src/org/chromium/base/test/util/MinAndroidSdkLevelSkipCheckTest.java", "test/android/junit/src/org/chromium/base/test/util/RestrictionSkipCheckTest.java",
diff --git a/base/android/java/src/org/chromium/base/compat/ApiHelperForS.java b/base/android/java/src/org/chromium/base/compat/ApiHelperForS.java index 11cbbe05..6792ce8 100644 --- a/base/android/java/src/org/chromium/base/compat/ApiHelperForS.java +++ b/base/android/java/src/org/chromium/base/compat/ApiHelperForS.java
@@ -48,6 +48,14 @@ } /** + * Return true if {@link ClipDescription#getClassificationStatus()} returns + * ClipDescription.CLASSIFICATION_COMPLETE. + */ + public static boolean isGetClassificationStatusIsComplete(ClipDescription clipDescription) { + return clipDescription.getClassificationStatus() == ClipDescription.CLASSIFICATION_COMPLETE; + } + + /** * See {@link ClipData.Item#getTextLinks()}. */ public static TextLinks getTextLinks(ClipData.Item item) {
diff --git a/base/test/android/javatests/src/org/chromium/base/test/util/CommandLineFlags.java b/base/test/android/javatests/src/org/chromium/base/test/util/CommandLineFlags.java index 9c30e400..8dc9db9 100644 --- a/base/test/android/javatests/src/org/chromium/base/test/util/CommandLineFlags.java +++ b/base/test/android/javatests/src/org/chromium/base/test/util/CommandLineFlags.java
@@ -9,6 +9,9 @@ import org.junit.Assert; import org.junit.Rule; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; import org.chromium.base.ActivityState; import org.chromium.base.ApplicationStatus; @@ -38,18 +41,30 @@ /** * Provides annotations related to command-line flag handling. * - * Uses of these annotations on a derived class will take precedence over uses on its base classes, - * so a derived class can add a command-line flag that a base class has removed (or vice versa). - * Similarly, uses of these annotations on a test method will take precedence over uses on the - * containing class. + * <p>This can be used in either an on-device instrumentation test or a junit (robolectric) test + * running on the host. To use in an instrumentation test, just {@code RunWith} {@link + * BaseJUnit4ClassRunner} (or a runner which extends that class). To use from a robolectric test, + * add the following test rule to your class: + * + * <pre> + * @Rule + * TestRule mRule = CommandLineFlags.getTestRule(); + * </pre> + * + * <p>Then you can annotate the test class, test methods, or test rules with {@code + * CommandLineFlags.Add} or {@code CommandLineFlags.Remove}. Uses of these annotations on a derived + * class will take precedence over uses on its base classes, so a derived class can add a + * command-line flag that a base class has removed (or vice versa). Similarly, uses of these + * annotations on a test method will take precedence over uses on the containing class. + * * <p> * These annonations may also be used on Junit4 Rule classes and on their base classes. Note, * however that the annotation processor only looks at the declared type of the Rule, not its actual * type, so in, for example: * * <pre> - * @Rule - * TestRule mRule = new ChromeActivityTestRule(); + * @Rule + * TestRule mRule = new ChromeActivityTestRule(); * </pre> * * will only look for CommandLineFlags annotations on TestRule, not for CommandLineFlags annotations @@ -261,6 +276,31 @@ throw new AssertionError("CommandLineFlags is a non-instantiable class"); } + private static class CommandLineFlagsTestRule implements TestRule { + @Override + public Statement apply(final Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + try { + Class clazz = description.getTestClass(); + CommandLineFlags.setUpClass(clazz); + CommandLineFlags.setUpMethod(clazz.getMethod(description.getMethodName())); + + base.evaluate(); + } finally { + CommandLineFlags.tearDownMethod(); + CommandLineFlags.tearDownClass(); + } + } + }; + } + } + + public static TestRule getTestRule() { + return new CommandLineFlagsTestRule(); + } + public static TestHook getPreTestHook() { return (targetContext, testMethod) -> CommandLineFlags.setUpMethod(testMethod.getMethod()); }
diff --git a/base/test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsNoClassAnnotationCheckTest.java b/base/test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsNoClassAnnotationCheckTest.java new file mode 100644 index 0000000..b67957b --- /dev/null +++ b/base/test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsNoClassAnnotationCheckTest.java
@@ -0,0 +1,59 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base.test.util; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; +import org.robolectric.annotation.Config; + +import org.chromium.base.CommandLine; +import org.chromium.base.test.BaseRobolectricTestRunner; + +/** + * Unit tests for {@link CommandLineFlags} annotations. This is for testing when there is no + * annotation on the class level. + */ +@RunWith(BaseRobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class CommandLineFlagsNoClassAnnotationCheckTest { + @Rule + public TestRule mCommandLineFlagsRule = CommandLineFlags.getTestRule(); + + @Test + public void testNoAnnotation() throws Throwable { + Assert.assertTrue("CommandLine switches should be empty by default", + CommandLine.getInstance().getSwitches().isEmpty()); + } + + @Test + @CommandLineFlags.Add("some-switch") + public void testAddSwitch_method() throws Throwable { + Assert.assertTrue("some-switch should be appended", + CommandLine.getInstance().hasSwitch("some-switch")); + } + + @Test + @CommandLineFlags.Add("some-switch") + @CommandLineFlags.Remove("some-switch") + public void testAddThenRemoveSwitch_method() throws Throwable { + Assert.assertTrue( + "CommandLine switches should be empty after adding and removing the same switch", + CommandLine.getInstance().getSwitches().isEmpty()); + } + + @Test + @CommandLineFlags.Remove("some-switch") + @CommandLineFlags.Add("some-switch") + public void testRemoveThenAddSwitch_method() throws Throwable { + // ".Add" rules apply before ".Remove" rules when annotating the same method/class, + // regardless of the order the annotations are written. + Assert.assertTrue( + "CommandLine switches should be empty after removing and adding the same switch", + CommandLine.getInstance().getSwitches().isEmpty()); + } +}
diff --git a/base/test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsWithClassAnnotationCheckTest.java b/base/test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsWithClassAnnotationCheckTest.java new file mode 100644 index 0000000..5fd40a4 --- /dev/null +++ b/base/test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsWithClassAnnotationCheckTest.java
@@ -0,0 +1,40 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base.test.util; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; +import org.robolectric.annotation.Config; + +import org.chromium.base.CommandLine; +import org.chromium.base.test.BaseRobolectricTestRunner; + +/** + * Unit tests for {@link CommandLineFlags} annotations. This is for testing what happens when a flag + * is added at the class level. + */ +@RunWith(BaseRobolectricTestRunner.class) +@Config(manifest = Config.NONE) +@CommandLineFlags.Add("some-switch") +public class CommandLineFlagsWithClassAnnotationCheckTest { + @Rule + public TestRule mCommandLineFlagsRule = CommandLineFlags.getTestRule(); + + @Test + public void testOnlyClassAnnotation() throws Throwable { + Assert.assertTrue("some-switch should be appended by the class", + CommandLine.getInstance().hasSwitch("some-switch")); + } + + @Test + @CommandLineFlags.Remove("some-switch") + public void testRemoveSwitch_method() throws Throwable { + Assert.assertTrue("CommandLine switches should be removed by the method", + CommandLine.getInstance().getSwitches().isEmpty()); + } +}
diff --git a/build/android/adb_logcat_monitor.py b/build/android/adb_logcat_monitor.py index a919722..de1573c 100755 --- a/build/android/adb_logcat_monitor.py +++ b/build/android/adb_logcat_monitor.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/adb_logcat_printer.py b/build/android/adb_logcat_printer.py index a715170..daa4ddb 100755 --- a/build/android/adb_logcat_printer.py +++ b/build/android/adb_logcat_printer.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/asan_symbolize.py b/build/android/asan_symbolize.py index 65850898..60d4d44d 100755 --- a/build/android/asan_symbolize.py +++ b/build/android/asan_symbolize.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/diff_resource_sizes.py b/build/android/diff_resource_sizes.py index eefb6cd..f9f7b8c 100755 --- a/build/android/diff_resource_sizes.py +++ b/build/android/diff_resource_sizes.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/build/android/download_doclava.py b/build/android/download_doclava.py index 1982fdb8..059d1cb 100755 --- a/build/android/download_doclava.py +++ b/build/android/download_doclava.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2016 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/build/android/gradle/gn_to_cmake.py b/build/android/gradle/gn_to_cmake.py index d3e80ae..7289825 100755 --- a/build/android/gradle/gn_to_cmake.py +++ b/build/android/gradle/gn_to_cmake.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2016 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/build/android/gyp/create_apk_operations_script.py b/build/android/gyp/create_apk_operations_script.py index 660567f0..82a6e5b 100755 --- a/build/android/gyp/create_apk_operations_script.py +++ b/build/android/gyp/create_apk_operations_script.py
@@ -12,7 +12,7 @@ from util import build_utils SCRIPT_TEMPLATE = string.Template("""\ -#!/usr/bin/env python +#!/usr/bin/env python3 # # This file was generated by build/android/gyp/create_apk_operations_script.py
diff --git a/build/android/gyp/create_bundle_wrapper_script.py b/build/android/gyp/create_bundle_wrapper_script.py index 282e206..1bdb767 100755 --- a/build/android/gyp/create_bundle_wrapper_script.py +++ b/build/android/gyp/create_bundle_wrapper_script.py
@@ -13,7 +13,7 @@ from util import build_utils SCRIPT_TEMPLATE = string.Template("""\ -#!/usr/bin/env python +#!/usr/bin/env python3 # # This file was generated by build/android/gyp/create_bundle_wrapper_script.py
diff --git a/build/android/gyp/create_java_binary_script.py b/build/android/gyp/create_java_binary_script.py index 5bc9d08..91fe600 100755 --- a/build/android/gyp/create_java_binary_script.py +++ b/build/android/gyp/create_java_binary_script.py
@@ -21,7 +21,7 @@ # to the directory that the script is written in and then, when run, must # recalculate the paths relative to the current directory. script_template = """\ -#!/usr/bin/env python +#!/usr/bin/env python3 # # This file was generated by build/android/gyp/create_java_binary_script.py
diff --git a/build/android/incremental_install/generate_android_manifest.py b/build/android/incremental_install/generate_android_manifest.py index e069dab..8b938a3 100755 --- a/build/android/incremental_install/generate_android_manifest.py +++ b/build/android/incremental_install/generate_android_manifest.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/incremental_install/write_installer_json.py b/build/android/incremental_install/write_installer_json.py index cf1d2d4..ce88e8a 100755 --- a/build/android/incremental_install/write_installer_json.py +++ b/build/android/incremental_install/write_installer_json.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/lighttpd_server.py b/build/android/lighttpd_server.py index 42fbcdbe6..e656e860 100755 --- a/build/android/lighttpd_server.py +++ b/build/android/lighttpd_server.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/method_count.py b/build/android/method_count.py index a39a390..80d0073 100755 --- a/build/android/method_count.py +++ b/build/android/method_count.py
@@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/build/android/native_flags/argcapture.py b/build/android/native_flags/argcapture.py index 159b03ab..b0e2acd9 100755 --- a/build/android/native_flags/argcapture.py +++ b/build/android/native_flags/argcapture.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2021 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/build/android/pylib/dex/dex_parser.py b/build/android/pylib/dex/dex_parser.py index be5f1af..1ff8d252 100755 --- a/build/android/pylib/dex/dex_parser.py +++ b/build/android/pylib/dex/dex_parser.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2019 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/build/android/pylib/results/presentation/standard_gtest_merge.py b/build/android/pylib/results/presentation/standard_gtest_merge.py index 64f40e6..d458223 100755 --- a/build/android/pylib/results/presentation/standard_gtest_merge.py +++ b/build/android/pylib/results/presentation/standard_gtest_merge.py
@@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/pylib/results/presentation/test_results_presentation.py b/build/android/pylib/results/presentation/test_results_presentation.py index 2fd98b11..fc14b8b 100755 --- a/build/android/pylib/results/presentation/test_results_presentation.py +++ b/build/android/pylib/results/presentation/test_results_presentation.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/pylib/symbols/apk_lib_dump.py b/build/android/pylib/symbols/apk_lib_dump.py index 933a0ab..f40c758 100755 --- a/build/android/pylib/symbols/apk_lib_dump.py +++ b/build/android/pylib/symbols/apk_lib_dump.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be
diff --git a/build/android/update_deps/update_third_party_deps.py b/build/android/update_deps/update_third_party_deps.py index 3a869c4..c03fec5d 100755 --- a/build/android/update_deps/update_third_party_deps.py +++ b/build/android/update_deps/update_third_party_deps.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2016 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/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index d0546a6..abb14c2 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc
@@ -307,6 +307,8 @@ } else if (gpu_raster) { flags |= gpu::SHARED_IMAGE_USAGE_GLES2 | gpu::SHARED_IMAGE_USAGE_GLES2_FRAMEBUFFER_HINT; + } else { + flags |= gpu::SHARED_IMAGE_USAGE_GLES2; } if (backing->overlay_candidate) flags |= gpu::SHARED_IMAGE_USAGE_SCANOUT;
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn index b55b08f..a8d88ea 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn
@@ -970,7 +970,6 @@ "//chrome/browser/signin/ui/android:junit", "//chrome/browser/tab:java", "//chrome/browser/tab:junit", - "//chrome/browser/tab:optimization_guide_protos_java", "//chrome/browser/tab_group:java", "//chrome/browser/tab_group:junit", "//chrome/browser/tabmodel:factory_java", @@ -1020,6 +1019,7 @@ "//components/browser_ui/site_settings/android:java", "//components/browser_ui/util/android:java", "//components/browser_ui/widget/android:java", + "//components/commerce/core:proto_java", "//components/content_capture/android:java", "//components/content_settings/android:content_settings_enums_java", "//components/dom_distiller/core/android:dom_distiller_core_java", @@ -1289,7 +1289,6 @@ "//chrome/browser/signin/ui/android:javatests", "//chrome/browser/tab:critical_persisted_tab_data_proto_java", "//chrome/browser/tab:java", - "//chrome/browser/tab:optimization_guide_protos_java", "//chrome/browser/tab_group:java", "//chrome/browser/tabmodel:java", "//chrome/browser/tabmodel/internal:java", @@ -1350,6 +1349,7 @@ "//components/browser_ui/widget/android:java", "//components/browser_ui/widget/android:javatests", "//components/browser_ui/widget/android:test_support_java", + "//components/commerce/core:proto_java", "//components/content_settings/android:content_settings_enums_java", "//components/content_settings/android:java", "//components/crash/android:java",
diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtils.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtils.java index 0e5f1350..5faa9267 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtils.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtils.java
@@ -46,6 +46,7 @@ public static void maybeShowIPH(@FeatureConstants String featureName, View view, @Nullable BottomSheetController bottomSheetController) { + if (view == null) return; // For tab group, all three IPHs are valid. For conditional tab strip, the only valid IPH // below is TAB_GROUPS_TAP_TO_SEE_ANOTHER_TAB_FEATURE. if (!TabUiFeatureUtilities.isTabGroupsAndroidEnabled(view.getContext()) @@ -54,9 +55,6 @@ FeatureConstants.TAB_GROUPS_TAP_TO_SEE_ANOTHER_TAB_FEATURE))) { return; } - if (TabUiFeatureUtilities.isLaunchPolishEnabled() && view == null) { - return; - } @StringRes int textId;
diff --git a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabListViewHolderTest.java b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabListViewHolderTest.java index f25e789..bcd9875 100644 --- a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabListViewHolderTest.java +++ b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabListViewHolderTest.java
@@ -56,10 +56,6 @@ import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.tab.MockTab; import org.chromium.chrome.browser.tab.Tab; -import org.chromium.chrome.browser.tab.proto.PriceTracking.BuyableProduct; -import org.chromium.chrome.browser.tab.proto.PriceTracking.PriceTrackingData; -import org.chromium.chrome.browser.tab.proto.PriceTracking.ProductPrice; -import org.chromium.chrome.browser.tab.proto.PriceTracking.ProductPriceUpdate; import org.chromium.chrome.browser.tab.state.CriticalPersistedTabData; import org.chromium.chrome.browser.tab.state.LevelDBPersistedDataStorage; import org.chromium.chrome.browser.tab.state.LevelDBPersistedDataStorageJni; @@ -69,6 +65,10 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.DummyUiChromeActivityTestCase; import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelegate; +import org.chromium.components.commerce.PriceTracking.BuyableProduct; +import org.chromium.components.commerce.PriceTracking.PriceTrackingData; +import org.chromium.components.commerce.PriceTracking.ProductPrice; +import org.chromium.components.commerce.PriceTracking.ProductPriceUpdate; import org.chromium.components.embedder_support.browser_context.BrowserContextHandle; import org.chromium.components.embedder_support.util.UrlUtilities; import org.chromium.components.embedder_support.util.UrlUtilitiesJni;
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java index 1b6d46a..bb54c033 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediatorUnitTest.java
@@ -108,9 +108,6 @@ import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabLaunchType; import org.chromium.chrome.browser.tab.TabObserver; -import org.chromium.chrome.browser.tab.proto.PriceTracking.BuyableProduct; -import org.chromium.chrome.browser.tab.proto.PriceTracking.PriceTrackingData; -import org.chromium.chrome.browser.tab.proto.PriceTracking.ProductPrice; import org.chromium.chrome.browser.tab.state.CriticalPersistedTabData; import org.chromium.chrome.browser.tab.state.PersistedTabDataConfiguration; import org.chromium.chrome.browser.tab.state.ShoppingPersistedTabData; @@ -132,6 +129,9 @@ import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration; import org.chromium.chrome.tab_ui.R; import org.chromium.chrome.test.util.browser.Features; +import org.chromium.components.commerce.PriceTracking.BuyableProduct; +import org.chromium.components.commerce.PriceTracking.PriceTrackingData; +import org.chromium.components.commerce.PriceTracking.ProductPrice; import org.chromium.components.embedder_support.util.UrlUtilities; import org.chromium.components.embedder_support.util.UrlUtilitiesJni; import org.chromium.components.feature_engagement.EventConstants;
diff --git a/chrome/android/java/res/layout/account_chooser_dialog_item.xml b/chrome/android/java/res/layout/account_chooser_dialog_item.xml index 3fc4add..df47bff 100644 --- a/chrome/android/java/res/layout/account_chooser_dialog_item.xml +++ b/chrome/android/java/res/layout/account_chooser_dialog_item.xml
@@ -12,7 +12,10 @@ android:minHeight="64dp" android:paddingStart="@dimen/account_chooser_dialog_item_margin" android:paddingEnd="@dimen/account_chooser_dialog_item_margin" - android:orientation="horizontal" > + android:orientation="horizontal" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:focusable="true"> <ImageView android:id="@+id/profile_image" android:layout_width="40dp"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java index 11818bca..635768f8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
@@ -25,10 +25,8 @@ import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; - import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; - import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.NativeMethods; import org.chromium.chrome.R; @@ -114,6 +112,11 @@ LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.account_chooser_dialog_item, parent, false); + convertView.setOnClickListener(view -> { + mCredential = mCredentials[position]; + if (mDialog != null) mDialog.dismiss(); + }); + convertView.setSelected(false); } convertView.setTag(position);
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/NavigateTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/NavigateTest.java index 667bfc2..94474cd 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/NavigateTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/NavigateTest.java
@@ -74,7 +74,6 @@ public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule(); private static final String HTTPS_SCHEME = "https://"; - private static final String NEW_TAB_PAGE = "chrome-native://newtab/"; private EmbeddedTestServer mTestServer; @@ -391,14 +390,8 @@ */ @Test @MediumTest - @DisabledTest(message = "https://crbug.com/1233114") @Feature({"Navigation"}) public void testIntentFallbackRedirection() throws Exception { - InstrumentationRegistry.getInstrumentation().waitForIdleSync(); - Assert.assertEquals(NEW_TAB_PAGE, - ChromeTabUtils.getUrlStringOnUiThread( - mActivityTestRule.getActivity().getActivityTab())); - final String fallbackUrl = mTestServer.getURL("/chrome/test/data/android/redirect/about.html"); final String redirectUrl = "intent://non_existent/#Intent;scheme=non_existent;" @@ -407,12 +400,19 @@ mTestServer.getURL("/chrome/test/data/android/redirect/js_redirect.html" + "?replace_text=" + Base64.encodeToString( - ApiCompatibilityUtils.getBytesUtf8("PARAM_URL"), Base64.URL_SAFE) + ApiCompatibilityUtils.getBytesUtf8("PARAM_URL"), Base64.URL_SAFE) + ":" - + Base64.encodeToString(ApiCompatibilityUtils.getBytesUtf8(redirectUrl), - Base64.URL_SAFE)); - final String targetUrl = - mTestServer.getURL("/chrome/test/data/android/redirect/one.html"); + + Base64.encodeToString( + ApiCompatibilityUtils.getBytesUtf8(redirectUrl), Base64.URL_SAFE)); + final String targetUrl = mTestServer.getURL("/chrome/test/data/android/redirect/one.html"); + + InstrumentationRegistry.getInstrumentation().waitForIdleSync(); + + // We should start on the homepage, which is something other than our test page. + String originalUrl = ChromeTabUtils.getUrlStringOnUiThread( + mActivityTestRule.getActivity().getActivityTab()); + Criteria.checkThat(originalUrl, Matchers.not(targetUrl)); + typeInOmniboxAndNavigate(initialUrl, null); // Now intent fallback should be triggered assuming 'non_existent' scheme cannot be handled. @@ -440,7 +440,7 @@ .getEntryAtIndex(0) .getUrl() .getSpec(); - Assert.assertEquals(NEW_TAB_PAGE, previousNavigationUrl); + Assert.assertEquals(originalUrl, previousNavigationUrl); } /**
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabDataTestUtils.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabDataTestUtils.java index d292fc5c..5f5b132 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabDataTestUtils.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabDataTestUtils.java
@@ -28,10 +28,10 @@ import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.tab.MockTab; import org.chromium.chrome.browser.tab.Tab; -import org.chromium.chrome.browser.tab.proto.PriceTracking.BuyableProduct; -import org.chromium.chrome.browser.tab.proto.PriceTracking.PriceTrackingData; -import org.chromium.chrome.browser.tab.proto.PriceTracking.ProductPrice; -import org.chromium.chrome.browser.tab.proto.PriceTracking.ProductPriceUpdate; +import org.chromium.components.commerce.PriceTracking.BuyableProduct; +import org.chromium.components.commerce.PriceTracking.PriceTrackingData; +import org.chromium.components.commerce.PriceTracking.ProductPrice; +import org.chromium.components.commerce.PriceTracking.ProductPriceUpdate; import org.chromium.components.optimization_guide.OptimizationGuideDecision; import org.chromium.components.optimization_guide.proto.CommonTypesProto.Any; import org.chromium.components.optimization_guide.proto.HintsProto;
diff --git a/chrome/android/webapk/README.md b/chrome/android/webapk/README.md index a691632d..6c3262d 100644 --- a/chrome/android/webapk/README.md +++ b/chrome/android/webapk/README.md
@@ -36,10 +36,9 @@ server. On Android, build -//chrome/android/webapk/shell_apk:new_splash_webapk -(new_splash='Android') +//chrome/android/webapk/shell_apk:webapk On ChromeOS, build -//chrome/android/webapk/shell_apk:webapk +//chrome/android/webapk/shell_apk:webapk_chromeos Both can be customized via [shell_apk/manifest/bound_manifest_config.json](https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/webapk/shell_apk/manifest/bound_manifest_config.json)
diff --git a/chrome/android/webapk/shell_apk/BUILD.gn b/chrome/android/webapk/shell_apk/BUILD.gn index a868020..c2b1dce 100644 --- a/chrome/android/webapk/shell_apk/BUILD.gn +++ b/chrome/android/webapk/shell_apk/BUILD.gn
@@ -22,18 +22,18 @@ sources = [ "src/org/chromium/webapk/lib/runtime_library/IWebApkApi.java" ] } -mustache_pass("generate_old_style_manifest_for_upload") { +mustache_pass("generate_chromeos_manifest_for_upload") { input = "AndroidManifest.xml" - output = generate_old_style_manifest_for_upload_output + output = generate_chromeos_manifest_for_upload_output extra_variables = [ "shell_apk_version=$current_shell_apk_version", "use_new_splash=false", ] } -mustache_pass("generate_new_style_manifest_for_upload") { +mustache_pass("generate_manifest_for_upload") { input = "AndroidManifest.xml" - output = generate_new_style_manifest_for_upload_output + output = generate_manifest_for_upload_output extra_variables = [ "shell_apk_version=$current_shell_apk_version", "use_new_splash=true", @@ -297,16 +297,16 @@ # Template for WebAPK. When a WebAPK is generated: # - Android manifest is customized to the website. # - App icon is extracted from the website and added to the APK's resources. -webapk_tmpl("webapk") { +webapk_tmpl("webapk_chromeos") { config_file = "manifest/bound_manifest_config.json" - manifest_to_upload_dep = ":generate_old_style_manifest_for_upload" - apk_name = "WebApk" - apk_package_name = "org.chromium.webapk" + manifest_to_upload_dep = ":generate_chromeos_manifest_for_upload" + apk_name = "WebApkChromeos" + apk_package_name = "org.chromium.webapk.chromeos" } webapk_tmpl("maps_go_webapk") { config_file = "manifest/maps_go_manifest_config.json" - manifest_to_upload_dep = ":generate_old_style_manifest_for_upload" + manifest_to_upload_dep = ":generate_manifest_for_upload" apk_name = "MapsWebApk" apk_package_name = "org.chromium.maps_go_webapk" } @@ -314,7 +314,7 @@ webapk_tmpl("uiautomator_maps_go_webapk") { testonly = true config_file = "manifest/maps_go_manifest_config.json" - manifest_to_upload_dep = ":generate_old_style_manifest_for_upload" + manifest_to_upload_dep = ":generate_manifest_for_upload" apk_name = "JavatestsMapsWebApk" delta_config_file = "manifest/javatest_maps_go_manifest_config_delta.json" apk_package_name = "org.chromium.test.maps_go_webapk" @@ -322,23 +322,27 @@ webapk_tmpl("unbound_webapk") { config_file = "manifest/unbound_manifest_config.json" - manifest_to_upload_dep = ":generate_old_style_manifest_for_upload" + manifest_to_upload_dep = ":generate_manifest_for_upload" apk_name = "UnboundWebApk" apk_package_name = "org.chromium.arbitrarypackage" } -webapk_tmpl("new_splash_webapk") { +webapk_tmpl("webapk") { config_file = "manifest/bound_manifest_config.json" - manifest_to_upload_dep = ":generate_new_style_manifest_for_upload" - apk_name = "NewSplashWebApk" - apk_package_name = "org.chromium.webapk.new_splash" + manifest_to_upload_dep = ":generate_manifest_for_upload" + apk_name = "WebApk" + apk_package_name = "org.chromium.webapk" +} + +group("new_splash_webapk") { + deps = [ ":webapk" ] } # Used by javatests webapk_tmpl("javatests_webapk") { testonly = true config_file = "manifest/bound_manifest_config.json" - manifest_to_upload_dep = ":generate_new_style_manifest_for_upload" + manifest_to_upload_dep = ":generate_manifest_for_upload" delta_config_file = "manifest/javatest_manifest_config_delta.json" apk_name = "JavatestsWebApk" apk_package_name = "org.chromium.webapk.test" @@ -347,7 +351,7 @@ # Used by webapk_shell_apk_h2o_junit_tests webapk_tmpl("h2o_j_unit_webapk") { config_file = "manifest/bound_manifest_config.json" - manifest_to_upload_dep = ":generate_new_style_manifest_for_upload" + manifest_to_upload_dep = ":generate_manifest_for_upload" apk_name = "H2OJUnitWebApk" apk_package_name = "org.chromium.webapk.h2o.junit_webapk" manifest_output = h2o_junit_manifest_output @@ -361,7 +365,7 @@ "javatests/src/org/chromium/webapk/shell_apk/h2o/SplashUtilsTest.java", ] deps = [ - ":new_splash_webapk_generated_webapk_java", + ":webapk_generated_webapk_java", "//base:base_java", "//base:base_java_test_support", "//chrome/android/webapk/libs/common:common_java",
diff --git a/chrome/android/webapk/shell_apk/generate_manifest_for_upload_outputs.gni b/chrome/android/webapk/shell_apk/generate_manifest_for_upload_outputs.gni index a4528ae..a3f4b29 100644 --- a/chrome/android/webapk/shell_apk/generate_manifest_for_upload_outputs.gni +++ b/chrome/android/webapk/shell_apk/generate_manifest_for_upload_outputs.gni
@@ -2,8 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Output for ":generate_old_style_manifest_for_upload" -generate_old_style_manifest_for_upload_output = "${root_gen_dir}/chrome/android/webapk/shell_apk/webapk_manifest_to_upload/AndroidManifest.xml" +# Output for ":generate_chromeos_manifest_for_upload" +generate_chromeos_manifest_for_upload_output = "${root_gen_dir}/chrome/android/webapk/shell_apk/webapk_chromeos_manifest_to_upload/AndroidManifest.xml" -# Output for ":generate_new_style_manifest_for_upload" -generate_new_style_manifest_for_upload_output = "${root_gen_dir}/chrome/android/webapk/shell_apk/webapk_new_style_manifest_to_upload/AndroidManifest.xml" +# Output for ":generate_manifest_for_upload" +generate_manifest_for_upload_output = "${root_gen_dir}/chrome/android/webapk/shell_apk/webapk_manifest_to_upload/AndroidManifest.xml"
diff --git a/chrome/android/webapk/shell_apk/prepare_upload_dir/BUILD.gn b/chrome/android/webapk/shell_apk/prepare_upload_dir/BUILD.gn index 02e223d..f1983c8 100644 --- a/chrome/android/webapk/shell_apk/prepare_upload_dir/BUILD.gn +++ b/chrome/android/webapk/shell_apk/prepare_upload_dir/BUILD.gn
@@ -51,10 +51,10 @@ copy_ex("copy_extra_files_to_upload_dir") { dest = upload_dir - renaming_sources = [ generate_old_style_manifest_for_upload_output ] + renaming_sources = [ generate_chromeos_manifest_for_upload_output ] renaming_destinations = [ "AndroidManifest.xml" ] - renaming_sources += [ generate_new_style_manifest_for_upload_output ] + renaming_sources += [ generate_manifest_for_upload_output ] renaming_destinations += [ "new_style_AndroidManifest.xml" ] _strings_target = "//chrome/android/webapk/shell_apk:webapk_strings_grd" @@ -63,8 +63,8 @@ renaming_destinations += [ "res/strings.zip" ] deps = [ - "//chrome/android/webapk/shell_apk:generate_new_style_manifest_for_upload", - "//chrome/android/webapk/shell_apk:generate_old_style_manifest_for_upload", + "//chrome/android/webapk/shell_apk:generate_chromeos_manifest_for_upload", + "//chrome/android/webapk/shell_apk:generate_manifest_for_upload", "//chrome/android/webapk/shell_apk:webapk_strings_grd", ] }
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index dac49c65..0f436cd 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -620,9 +620,6 @@ <message name="IDS_RESET_SCREEN_ICON_TITLE" desc="Accessible title of the reset screen icon depicting exclamation mark."> Exclamation mark icon </message> - <message name="IDS_RESET_SCREEN_ILLUSTRATION_TITLE" desc="Accessible title of the reset screen illustration depicting powerwash."> - Powerwash illustration - </message> <message name="IDS_UPDATING_SCREEN_TITLE" desc="Title of the OOBE screen displayed while system update is being dowloaded."> Updating... </message> @@ -1778,18 +1775,12 @@ <message name="IDS_ENABLE_ARC_ADB_SIDELOADING_SETUP_MESSAGE" desc="Setup message in dialog for enabling ARC ADB Sideloading."> Continuing will enable ADB debugging for creating and testing Android apps. Note that this action allows installation of Android apps that haven't been verified by Google, and requires a factory reset to disable. </message> - <message name="IDS_ENABLE_ARC_ADB_SIDELOADING_SETUP_ILLUSTRATION_TITLE" desc="Accessible title of ARC ADB sideloading illustration depicting the setup screen."> - Enabling adb to create apps illustration - </message> <message name="IDS_ENABLE_ARC_ADB_SIDELOADING_ERROR_TITLE" desc="Title message when enabling of ARC ADB Sideloading fails."> Something went wrong </message> <message name="IDS_ENABLE_ARC_ADB_SIDELOADING_ERROR_MESSAGE" desc="Error message when enabling of ARC ADB Sideloading fails."> Couldn't enable ADB debugging. Go to Settings and try again. </message> - <message name="IDS_ENABLE_ARC_ADB_SIDELOADING_ERROR_ILLUSTRATION_TITLE" desc="Accessible title of ARC ADB sideloading illustration depicting the error screen."> - Failed to enable ADB illustration - </message> <message name="IDS_ENABLE_ARC_ADB_SIDELOADING_LEARN_MORE" desc="Learn more link text in the enable ARC ADB Sideloading dialog."> Learn more </message> @@ -2857,9 +2848,6 @@ <message name="IDS_ENTERPRISE_ENROLLMENT_ERROR_TITLE" desc="Title of the screen to be shown upon an error during enterprise enrollment."> Enrollment Error </message> - <message name="IDS_ENTERPRISE_ENROLLMENT_ERROR_ILLUSTRATION_TITLE" desc="Accessible title of the enterprise enrollment screen illustration depicting error during enrollment."> - Enrollment error illustration - </message> <message name="IDS_ENTERPRISE_ENROLLMENT_RETRY" desc="Label for the retry button on the error step in the enterprise enrollment dialog."> Try again </message> @@ -2878,9 +2866,6 @@ <message name="IDS_ENTERPRISE_ENROLLMENT_SUCCESS" desc="Success message to be shown once enterprise enrollment completes."> Your <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> has successfully been enrolled for enterprise management. </message> - <message name="IDS_ENTERPRISE_ENROLLMENT_SUCCESS_ILLUSTRATION_TITLE" desc="Accessible title of the enterprise enrollment screen illustration depicting successful enrollment."> - Successful enrollment illustration - </message> <message name="IDS_ENTERPRISE_ENROLLMENT_SUCCESS_DOMAIN" desc="Success message to be shown once enterprise enrollment completes. MANAGER can be a domain or an email address."> This <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> will be managed by <ph name="MANAGER">$2<ex>acmecorp.com</ex></ph>. </message>
diff --git a/chrome/browser/android/search_permissions/search_permissions_service.cc b/chrome/browser/android/search_permissions/search_permissions_service.cc index cf0f4ee7c..3461d9c 100644 --- a/chrome/browser/android/search_permissions/search_permissions_service.cc +++ b/chrome/browser/android/search_permissions/search_permissions_service.cc
@@ -23,6 +23,7 @@ #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/permissions/features.h" #include "components/permissions/permission_decision_auto_blocker.h" +#include "components/permissions/permission_uma_util.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_service.h" #include "components/search_engines/template_url.h" @@ -224,6 +225,8 @@ void SearchPermissionsService::OnDSEChanged() { InitializeSettingsIfNeeded(); + RecordEffectiveDSEOriginPermissions(); + // If we didn't initialize properly because there is no DSE don't do anything. if (!pref_service_->HasPrefPath(prefs::kDSEPermissionsSettings)) return; @@ -346,13 +349,25 @@ PrefValue pref = GetDSEPref(); GURL old_dse_origin(pref.dse_origin); - RestoreOldSettingAndReturnPrevious( + + ContentSetting effective_setting = RestoreOldSettingAndReturnPrevious( old_dse_origin, ContentSettingsType::GEOLOCATION, pref.geolocation_setting_to_restore, !disabled_by_policy); + if (!disabled_by_policy) { + RecordAutoDSEPermissionReverted(ContentSettingsType::GEOLOCATION, + pref.geolocation_setting_to_restore, + effective_setting, dse_origin); + } + if (pref.notifications_setting_to_restore != CONTENT_SETTING_DEFAULT) { - RestoreOldSettingAndReturnPrevious( + effective_setting = RestoreOldSettingAndReturnPrevious( old_dse_origin, ContentSettingsType::NOTIFICATIONS, pref.notifications_setting_to_restore, !disabled_by_policy); + if (!disabled_by_policy) { + RecordAutoDSEPermissionReverted(ContentSettingsType::NOTIFICATIONS, + pref.notifications_setting_to_restore, + effective_setting, dse_origin); + } } pref_service_->ClearPref(prefs::kDSEPermissionsSettings); } @@ -518,3 +533,27 @@ delegate_->SetDSEChangedCallback(base::BindRepeating( &SearchPermissionsService::OnDSEChanged, base::Unretained(this))); } + +void SearchPermissionsService::RecordAutoDSEPermissionReverted( + ContentSettingsType permission_type, + ContentSetting backed_up_setting, + ContentSetting effective_setting, + const GURL& origin) { + ContentSetting end_state_setting = GetContentSetting(origin, permission_type); + permissions::PermissionUmaUtil::RecordAutoDSEPermissionReverted( + permission_type, backed_up_setting, effective_setting, end_state_setting); +} + +void SearchPermissionsService::RecordEffectiveDSEOriginPermissions() { + GURL dse_origin = delegate_->GetDSEOrigin().GetURL(); + if (!dse_origin.is_valid()) + return; + + permissions::PermissionUmaUtil::RecordDSEEffectiveSetting( + ContentSettingsType::NOTIFICATIONS, + GetContentSetting(dse_origin, ContentSettingsType::NOTIFICATIONS)); + + permissions::PermissionUmaUtil::RecordDSEEffectiveSetting( + ContentSettingsType::GEOLOCATION, + GetContentSetting(dse_origin, ContentSettingsType::GEOLOCATION)); +}
diff --git a/chrome/browser/android/search_permissions/search_permissions_service.h b/chrome/browser/android/search_permissions/search_permissions_service.h index 91d0f39..7192b97 100644 --- a/chrome/browser/android/search_permissions/search_permissions_service.h +++ b/chrome/browser/android/search_permissions/search_permissions_service.h
@@ -149,6 +149,17 @@ ContentSettingsType type, ContentSetting setting); + // Record how the content setting transitions when DSE permissions autogrant + // is disabled via feature. + void RecordAutoDSEPermissionReverted(ContentSettingsType permission_type, + ContentSetting backed_up_setting, + ContentSetting effective_setting, + const GURL& origin); + + // Record the content settings for notifications and geolocation on the DSE + // origin. Called at initialization or when the DSE origin changes. + void RecordEffectiveDSEOriginPermissions(); + void SetSearchEngineDelegateForTest( std::unique_ptr<SearchEngineDelegate> delegate);
diff --git a/chrome/browser/android/search_permissions/search_permissions_service_unittest.cc b/chrome/browser/android/search_permissions/search_permissions_service_unittest.cc index 366b6b88..8415fc3 100644 --- a/chrome/browser/android/search_permissions/search_permissions_service_unittest.cc +++ b/chrome/browser/android/search_permissions/search_permissions_service_unittest.cc
@@ -9,7 +9,9 @@ #include "base/callback.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" +#include "base/values.h" #include "chrome/browser/android/search_permissions/search_geolocation_disclosure_tab_helper.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/permissions/permission_decision_auto_blocker_factory.h" @@ -22,6 +24,7 @@ #include "components/permissions/features.h" #include "components/permissions/permission_decision_auto_blocker.h" #include "components/permissions/permission_result.h" +#include "components/permissions/permission_uma_util.h" #include "components/prefs/pref_service.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/test/browser_task_environment.h" @@ -32,10 +35,10 @@ const char kDSESettingKeyDeprecated[] = "dse_setting"; -const char kGoogleURL[] = "https://www.google.com"; -const char kGoogleAusURL[] = "https://www.google.com.au"; -const char kGoogleHTTPURL[] = "http://www.google.com"; -const char kExampleURL[] = "https://www.example.com"; +const char kGoogleURL[] = "https://www.google.com/"; +const char kGoogleAusURL[] = "https://www.google.com.au/"; +const char kGoogleHTTPURL[] = "http://www.google.com/"; +const char kExampleURL[] = "https://www.example.com/"; url::Origin ToOrigin(const char* url) { return url::Origin::Create(GURL(url)); @@ -982,7 +985,8 @@ // Test disabling DSE via the `RevertDSEAutomaticPermissions` feature after the // DSE origin has changed at least once. -TEST_F(SearchPermissionsServiceTest, DSEDisabledAfterOriginChange) { +TEST_F(SearchPermissionsServiceTest, + AutoDSEPermissionRevertedAfterOriginChange) { for (const auto type : {ContentSettingsType::GEOLOCATION, ContentSettingsType::NOTIFICATIONS}) { test_delegate()->ChangeDSEOrigin(kGoogleURL); @@ -1012,3 +1016,111 @@ EXPECT_EQ(CONTENT_SETTING_ASK, GetContentSetting(kGoogleURL, type)); } } + +// Test that the appropriate UMA metrics have been recorded when the DSE is +// disabled. +TEST_F(SearchPermissionsServiceTest, + MetricsAndPrefsAreRecordedWhenAutoDSEPermissionReverted) { + constexpr struct { + ContentSetting initial_setting; + ContentSetting updated_setting; + permissions::AutoDSEPermissionRevertTransition expected_transition; + } kTests[] = { + {CONTENT_SETTING_ASK, CONTENT_SETTING_ALLOW, + permissions::AutoDSEPermissionRevertTransition::NO_DECISION_ASK}, + {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_ALLOW}, + {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW, + permissions::AutoDSEPermissionRevertTransition::CONFLICT_ASK}, + {CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_ASK}, + {CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_ALLOW}, + {CONTENT_SETTING_BLOCK, CONTENT_SETTING_BLOCK, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_BLOCK}, + }; + + for (const auto& test : kTests) { + for (const auto& type : {ContentSettingsType::NOTIFICATIONS, + ContentSettingsType::GEOLOCATION}) { + // Notifications can not be set to ASK on Android as notification channels + // explicitly rely on the state being only BLOCK/ALLOW/DEFAULT. + if (test.initial_setting == CONTENT_SETTING_ASK && + type == ContentSettingsType::NOTIFICATIONS) { + continue; + } + + ClearContentSettings(type); + SetContentSetting(kGoogleURL, type, test.initial_setting); + ReinitializeService(true /* clear_pref */); + SetContentSetting(kGoogleURL, type, test.updated_setting); + ReinitializeService(false /* clear_pref */); + + // Enable `RevertDSEAutomaticPermissions`. DSE stops being controlled by + // the SearchPermissionsService. + { + base::HistogramTester histograms; + base::test::ScopedFeatureList features( + permissions::features::kRevertDSEAutomaticPermissions); + ReinitializeService(false /* clear_pref */); + + // Test that the expected samples are recorded in histograms. + for (auto sample = static_cast<int>( + permissions::AutoDSEPermissionRevertTransition:: + NO_DECISION_ASK); + sample < + static_cast<int>( + permissions::AutoDSEPermissionRevertTransition::kMaxValue); + ++sample) { + std::string histogram = + "Permissions.DSE.AutoPermissionRevertTransition."; + histogram += type == ContentSettingsType::NOTIFICATIONS + ? "Notifications" + : "Geolocation"; + histograms.ExpectBucketCount( + histogram, sample, + static_cast<int>(test.expected_transition) == sample ? 1 : 0); + } + } + + // If DSE starts being controlled again by the `SearchPermissionService`, + // the pref is cleared. + ReinitializeService(false /* clear_pref */); + } + } +} + +// Records DSE origin settings whenever the service is initialized. +TEST_F(SearchPermissionsServiceTest, DSEEffectiveSettingMetric) { + base::HistogramTester histograms; + ClearContentSettings(ContentSettingsType::NOTIFICATIONS); + ClearContentSettings(ContentSettingsType::GEOLOCATION); + ReinitializeService(true /* clear_pref */); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Notifications", + CONTENT_SETTING_ALLOW, 1); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Geolocation", + CONTENT_SETTING_ALLOW, 1); + + SetContentSetting(kGoogleURL, ContentSettingsType::NOTIFICATIONS, + CONTENT_SETTING_BLOCK); + ReinitializeService(false /* clear_pref */); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Notifications", + CONTENT_SETTING_ALLOW, 1); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Notifications", + CONTENT_SETTING_BLOCK, 1); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Geolocation", + CONTENT_SETTING_ALLOW, 2); + + base::test::ScopedFeatureList features( + permissions::features::kRevertDSEAutomaticPermissions); + ReinitializeService(false /* clear_pref */); + + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Notifications", + CONTENT_SETTING_ALLOW, 1); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Notifications", + CONTENT_SETTING_BLOCK, 2); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Geolocation", + CONTENT_SETTING_ALLOW, 2); + histograms.ExpectBucketCount("Permissions.DSE.EffectiveSetting.Geolocation", + CONTENT_SETTING_ASK, 1); +}
diff --git a/chrome/browser/ash/scanning/scan_service.cc b/chrome/browser/ash/scanning/scan_service.cc index 17e9f27..1a3862d 100644 --- a/chrome/browser/ash/scanning/scan_service.cc +++ b/chrome/browser/ash/scanning/scan_service.cc
@@ -203,18 +203,53 @@ mojo::PendingRemote<mojo_ipc::ScanJobObserver> observer, StartScanCallback callback) { ClearScanState(); - scan_job_observer_.reset(); - scan_job_observer_.Bind(std::move(observer)); - // Unretained is safe here, because `this` owns `scan_job_observer_`, and no - // reply callbacks will be invoked once the mojo::Remote is destroyed. - scan_job_observer_.set_disconnect_handler( - base::BindOnce(&ScanService::CancelScan, base::Unretained(this))); - - std::move(callback).Run(SendScanRequest(scanner_id, std::move(settings))); + SetScanJobObserver(std::move(observer)); + std::move(callback).Run( + SendScanRequest(scanner_id, std::move(settings), + base::BindOnce(&ScanService::OnScanCompleted, + weak_ptr_factory_.GetWeakPtr()))); } -bool ScanService::SendScanRequest(const base::UnguessableToken& scanner_id, - mojo_ipc::ScanSettingsPtr settings) { +void ScanService::StartMultiPageScan( + const base::UnguessableToken& scanner_id, + scanning::mojom::ScanSettingsPtr settings, + mojo::PendingRemote<scanning::mojom::ScanJobObserver> observer, + StartMultiPageScanCallback callback) { + DCHECK( + base::FeatureList::IsEnabled(chromeos::features::kScanAppMultiPageScan)); + if (multi_page_controller_receiver_.is_bound()) { + LOG(ERROR) << "Unable to start multi-page scan, controller already bound."; + std::move(callback).Run(mojo::NullRemote()); + return; + } + + ClearScanState(); + SetScanJobObserver(std::move(observer)); + const bool success = + SendScanRequest(scanner_id, std::move(settings), + base::BindOnce(&ScanService::OnMultiPageScanPageCompleted, + weak_ptr_factory_.GetWeakPtr())); + if (!success) { + std::move(callback).Run(mojo::NullRemote()); + return; + } + + mojo::PendingRemote<scanning::mojom::MultiPageScanController> pending_remote = + multi_page_controller_receiver_.BindNewPipeAndPassRemote(); + // Unretained is safe here, because `this` owns + // `multi_page_controller_receiver_`, and no endpoints will be invoked once + // the mojo::Receiver is destroyed. This allows a multi-page scan session to + // be cancelled by resetting the message pipe. + multi_page_controller_receiver_.set_disconnect_handler(base::BindOnce( + &ScanService::ResetMultiPageScanController, base::Unretained(this))); + std::move(callback).Run(std::move(pending_remote)); +} + +bool ScanService::SendScanRequest( + const base::UnguessableToken& scanner_id, + mojo_ipc::ScanSettingsPtr settings, + base::OnceCallback<void(lorgnette::ScanFailureMode failure_mode)> + completion_callback) { const std::string scanner_name = GetScannerName(scanner_id); if (scanner_name.empty()) { RecordScanJobResult(false, scanning::ScanJobFailureReason::kScannerNotFound, @@ -243,8 +278,7 @@ base::BindRepeating(&ScanService::OnPageReceived, weak_ptr_factory_.GetWeakPtr(), settings->scan_to_path, settings->file_type), - base::BindOnce(&ScanService::OnScanCompleted, - weak_ptr_factory_.GetWeakPtr())); + std::move(completion_callback)); return true; } @@ -253,6 +287,20 @@ &ScanService::OnCancelCompleted, weak_ptr_factory_.GetWeakPtr())); } +void ScanService::ScanNextPage(const base::UnguessableToken& scanner_id, + scanning::mojom::ScanSettingsPtr settings, + ScanNextPageCallback callback) { + std::move(callback).Run( + SendScanRequest(scanner_id, std::move(settings), + base::BindOnce(&ScanService::OnMultiPageScanPageCompleted, + weak_ptr_factory_.GetWeakPtr()))); +} + +void ScanService::CompleteMultiPageScan() { + OnScanCompleted(lorgnette::SCAN_FAILURE_MODE_NO_FAILURE); + multi_page_controller_receiver_.reset(); +} + void ScanService::BindInterface( mojo::PendingReceiver<mojo_ipc::ScanService> pending_receiver) { receiver_.Bind(std::move(pending_receiver)); @@ -261,6 +309,7 @@ void ScanService::Shutdown() { lorgnette_scanner_manager_ = nullptr; receiver_.reset(); + multi_page_controller_receiver_.reset(); weak_ptr_factory_.InvalidateWeakPtrs(); } @@ -375,6 +424,21 @@ weak_ptr_factory_.GetWeakPtr())); } +void ScanService::OnMultiPageScanPageCompleted( + lorgnette::ScanFailureMode failure_mode) { + if (failure_mode == + lorgnette::ScanFailureMode::SCAN_FAILURE_MODE_NO_FAILURE) { + return; + } + + // TODO(crbug.com/1234861): Setup mojo TypeMaps so we can remove calling the + // EnumTraits directly. + scan_job_observer_->OnMultiPageScanFail( + mojo::EnumTraits<ash::scanning::mojom::ScanResult, + lorgnette::ScanFailureMode>:: + ToMojom(static_cast<lorgnette::ScanFailureMode>(failure_mode))); +} + void ScanService::OnCancelCompleted(bool success) { if (success) ClearScanState(); @@ -429,6 +493,21 @@ num_pages_scanned_ = 0; } +void ScanService::SetScanJobObserver( + mojo::PendingRemote<mojo_ipc::ScanJobObserver> observer) { + scan_job_observer_.reset(); + scan_job_observer_.Bind(std::move(observer)); + // Unretained is safe here, because `this` owns `scan_job_observer_`, and no + // reply callbacks will be invoked once the mojo::Remote is destroyed. + scan_job_observer_.set_disconnect_handler( + base::BindOnce(&ScanService::CancelScan, base::Unretained(this))); +} + +void ScanService::ResetMultiPageScanController() { + multi_page_controller_receiver_.reset(); + ClearScanState(); +} + std::string ScanService::GetScannerName( const base::UnguessableToken& scanner_id) { const auto it = scanner_names_.find(scanner_id);
diff --git a/chrome/browser/ash/scanning/scan_service.h b/chrome/browser/ash/scanning/scan_service.h index 3000310..8d85a659 100644 --- a/chrome/browser/ash/scanning/scan_service.h +++ b/chrome/browser/ash/scanning/scan_service.h
@@ -40,7 +40,9 @@ // Implementation of the ash::scanning::mojom::ScanService interface. Used // by the scanning WebUI (chrome://scanning) to get connected scanners, obtain // scanner capabilities, and perform scans. -class ScanService : public scanning::mojom::ScanService, public KeyedService { +class ScanService : public scanning::mojom::ScanService, + public scanning::mojom::MultiPageScanController, + public KeyedService { public: ScanService(LorgnetteScannerManager* lorgnette_scanner_manager, base::FilePath my_files_path, @@ -59,8 +61,19 @@ scanning::mojom::ScanSettingsPtr settings, mojo::PendingRemote<scanning::mojom::ScanJobObserver> observer, StartScanCallback callback) override; + void StartMultiPageScan( + const base::UnguessableToken& scanner_id, + scanning::mojom::ScanSettingsPtr settings, + mojo::PendingRemote<scanning::mojom::ScanJobObserver> observer, + StartMultiPageScanCallback callback) override; void CancelScan() override; + // scanning::mojom::MultiPageScanController: + void ScanNextPage(const base::UnguessableToken& scanner_id, + scanning::mojom::ScanSettingsPtr settings, + ScanNextPageCallback callback) override; + void CompleteMultiPageScan() override; + // Binds receiver_ by consuming |pending_receiver|. void BindInterface( mojo::PendingReceiver<scanning::mojom::ScanService> pending_receiver); @@ -98,6 +111,10 @@ // succeeds; otherwise, its value indicates what caused the scan to fail. void OnScanCompleted(lorgnette::ScanFailureMode failure_mode); + // For a multi-page scan, when a page scan completes, report a failure if it + // exists. + void OnMultiPageScanPageCompleted(lorgnette::ScanFailureMode failure_mode); + // Processes the final result of calling // LorgnetteScannerManager::CancelScan(). void OnCancelCompleted(bool success); @@ -109,8 +126,11 @@ void OnPageSaved(const base::FilePath& saved_file_path); // Sends the scan request to the scanner. - bool SendScanRequest(const base::UnguessableToken& scanner_id, - scanning::mojom::ScanSettingsPtr settings); + bool SendScanRequest( + const base::UnguessableToken& scanner_id, + scanning::mojom::ScanSettingsPtr settings, + base::OnceCallback<void(lorgnette::ScanFailureMode failure_mode)> + completion_callback); // Called once the task runner finishes saving the last page of a scan. void OnAllPagesSaved(lorgnette::ScanFailureMode failure_mode); @@ -118,6 +138,13 @@ // Sets the local member variables back to their initial empty state. void ClearScanState(); + // Sets the ScanJobOberver for a new scan. + void SetScanJobObserver( + mojo::PendingRemote<scanning::mojom::ScanJobObserver> observer); + + // Resets the mojo::Receiver |multi_page_controller_receiver_|. + void ResetMultiPageScanController(); + // Determines whether the service supports saving scanned images to // |file_path|. bool FilePathSupported(const base::FilePath& file_path); @@ -134,6 +161,11 @@ // ash::scanning::mojom::ScanService interface. mojo::Receiver<scanning::mojom::ScanService> receiver_{this}; + // Receives and dispatches method calls to this implementation of the + // ash::scanning::mojom::MultiPageScanController interface. + mojo::Receiver<scanning::mojom::MultiPageScanController> + multi_page_controller_receiver_{this}; + // Used to send scan job events to an observer. The remote is bound when a // scan job is started and is disconnected when the scan job is complete. mojo::Remote<scanning::mojom::ScanJobObserver> scan_job_observer_;
diff --git a/chrome/browser/ash/scanning/scan_service_unittest.cc b/chrome/browser/ash/scanning/scan_service_unittest.cc index 88fa7b1..e2cddda 100644 --- a/chrome/browser/ash/scanning/scan_service_unittest.cc +++ b/chrome/browser/ash/scanning/scan_service_unittest.cc
@@ -21,6 +21,7 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/test/metrics/histogram_tester.h" +#include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "base/time/time.h" #include "base/unguessable_token.h" @@ -216,6 +217,10 @@ cancel_scan_success_ = success; } + void OnMultiPageScanFail(mojo_ipc::ScanResult result) override { + multi_page_scan_result_ = result; + } + // Creates a pending remote that can be passed in calls to // ScanService::StartScan(). mojo::PendingRemote<mojo_ipc::ScanJobObserver> GenerateRemote() { @@ -239,6 +244,11 @@ // Returns the result of the scan job. mojo_ipc::ScanResult scan_result() const { return scan_result_; } + // Returns the result of the multi-page scan job. + mojo_ipc::ScanResult multi_page_scan_result() const { + return multi_page_scan_result_; + } + // Returns file paths of the saved scan files. std::vector<base::FilePath> scanned_file_paths() const { return scanned_file_paths_; @@ -248,6 +258,8 @@ uint32_t progress_ = 0; bool page_complete_ = false; mojo_ipc::ScanResult scan_result_ = mojo_ipc::ScanResult::kUnknownError; + mojo_ipc::ScanResult multi_page_scan_result_ = + mojo_ipc::ScanResult::kUnknownError; bool cancel_scan_success_ = false; std::vector<base::FilePath> scanned_file_paths_; mojo::Receiver<mojo_ipc::ScanJobObserver> receiver_{this}; @@ -314,12 +326,46 @@ return success; } + // Starts a multi-page scan with the scanner identified by |scanner_id| with + // the given |settings| by calling ScanService::StartMultiPageScan() via the + // mojo::Remote. Binds the returned MultiPageScanController + // mojo::PendingRemote. + bool StartMultiPageScan(const base::UnguessableToken& scanner_id, + mojo_ipc::ScanSettingsPtr settings) { + mojo::PendingRemote<mojo_ipc::MultiPageScanController> pending_remote; + mojo_ipc::ScanServiceAsyncWaiter(scan_service_remote_.get()) + .StartMultiPageScan(scanner_id, std::move(settings), + fake_scan_job_observer_.GenerateRemote(), + &pending_remote); + if (!pending_remote.is_valid()) + return false; + + multi_page_scan_controller_remote_.Bind(std::move(pending_remote)); + task_environment_.RunUntilIdle(); + return true; + } + + bool ScanNextPage(const base::UnguessableToken& scanner_id, + mojo_ipc::ScanSettingsPtr settings) { + bool success; + mojo_ipc::MultiPageScanControllerAsyncWaiter( + multi_page_scan_controller_remote_.get()) + .ScanNextPage(scanner_id, std::move(settings), &success); + task_environment_.RunUntilIdle(); + return success; + } + // Performs a cancel scan request. void CancelScan() { scan_service_remote_->CancelScan(); task_environment_.RunUntilIdle(); } + void CompleteMultiPageScan() { + multi_page_scan_controller_remote_->CompleteMultiPageScan(); + task_environment_.RunUntilIdle(); + } + protected: // A `BrowserTaskEnvironment` allows the test to create a `TestingProfile`. content::BrowserTaskEnvironment task_environment_{ @@ -333,9 +379,12 @@ ash::FakeChromeUserManager* const user_manager_; user_manager::ScopedUserManager user_manager_owner_; std::unique_ptr<ScanService> scan_service_; + base::test::ScopedFeatureList scoped_feature_list_; private: mojo::Remote<mojo_ipc::ScanService> scan_service_remote_; + mojo::Remote<mojo_ipc::MultiPageScanController> + multi_page_scan_controller_remote_; }; // Test that no scanners are returned when there are no scanner names. @@ -724,4 +773,112 @@ } } +// Test that a multi-page scan can be performed successfully. +TEST_F(ScanServiceTest, MultiPageScan) { + base::HistogramTester histogram_tester; + scoped_feature_list_.InitWithFeatures( + {chromeos::features::kScanAppMultiPageScan}, {}); + + fake_lorgnette_scanner_manager_.SetGetScannerNamesResponse( + {kFirstTestScannerName}); + const std::vector<std::string> scan_data = {CreatePng()}; + fake_lorgnette_scanner_manager_.SetScanResponse(scan_data); + auto scanners = GetScanners(); + ASSERT_EQ(scanners.size(), 1u); + + base::Time::Exploded scan_time; + // Since we're using mock time, this is deterministic. + base::Time::Now().LocalExplode(&scan_time); + const std::vector<base::FilePath> saved_scan_paths = + CreateSavedScanPaths(scanned_files_mount_->GetRootPath(), scan_time, + mojo_ipc::FileType::kPdf, scan_data.size()); + for (const auto& saved_scan_path : saved_scan_paths) + EXPECT_FALSE(base::PathExists(saved_scan_path)); + + mojo_ipc::ScanSettings settings = CreateScanSettings( + scanned_files_mount_->GetRootPath(), mojo_ipc::FileType::kPdf); + + // Scan the first page without completing the scan. + EXPECT_TRUE(StartMultiPageScan(scanners[0]->id, settings.Clone())); + for (const auto& saved_scan_path : saved_scan_paths) + EXPECT_FALSE(base::PathExists(saved_scan_path)); + EXPECT_FALSE(fake_scan_job_observer_.scan_success()); + EXPECT_TRUE(fake_scan_job_observer_.scanned_file_paths().empty()); + + // Scan the second page without completing the scan. + EXPECT_TRUE(ScanNextPage(scanners[0]->id, settings.Clone())); + for (const auto& saved_scan_path : saved_scan_paths) + EXPECT_FALSE(base::PathExists(saved_scan_path)); + EXPECT_FALSE(fake_scan_job_observer_.scan_success()); + EXPECT_TRUE(fake_scan_job_observer_.scanned_file_paths().empty()); + + // Complete the multi-page scan expecting 2 pages to be scanned and a single + // PDF to be created. + CompleteMultiPageScan(); + for (const auto& saved_scan_path : saved_scan_paths) + EXPECT_TRUE(base::PathExists(saved_scan_path)); + EXPECT_TRUE(fake_scan_job_observer_.scan_success()); + EXPECT_EQ(saved_scan_paths, fake_scan_job_observer_.scanned_file_paths()); + histogram_tester.ExpectUniqueSample("Scanning.NumPagesScanned", 2, 1); +} + +// Test that when a multi-page scan fails, the scan job is marked as failed. +TEST_F(ScanServiceTest, MultiPageScanFails) { + scoped_feature_list_.InitWithFeatures( + {chromeos::features::kScanAppMultiPageScan}, {}); + + fake_lorgnette_scanner_manager_.SetGetScannerNamesResponse( + {kFirstTestScannerName}); + const std::vector<std::string> scan_data = {CreatePng()}; + fake_lorgnette_scanner_manager_.SetScanResponse(scan_data); + auto scanners = GetScanners(); + ASSERT_EQ(scanners.size(), 1u); + + mojo_ipc::ScanSettings settings = CreateScanSettings( + scanned_files_mount_->GetRootPath(), mojo_ipc::FileType::kPdf); + + // The first scan should pass with no failure. + EXPECT_TRUE(StartMultiPageScan(scanners[0]->id, settings.Clone())); + EXPECT_FALSE(fake_scan_job_observer_.scan_success()); + EXPECT_EQ(mojo_ipc::ScanResult::kUnknownError, + fake_scan_job_observer_.multi_page_scan_result()); + EXPECT_TRUE(fake_scan_job_observer_.scanned_file_paths().empty()); + + // Set scan data to empty vector in FakeLorgnetteScannerManager so the next + // scan will fail. + fake_lorgnette_scanner_manager_.SetScanResponse({}); + EXPECT_TRUE(ScanNextPage(scanners[0]->id, settings.Clone())); + EXPECT_FALSE(fake_scan_job_observer_.scan_success()); + EXPECT_EQ(mojo_ipc::ScanResult::kDeviceBusy, + fake_scan_job_observer_.multi_page_scan_result()); + EXPECT_TRUE(fake_scan_job_observer_.scanned_file_paths().empty()); +} + +// Test that attempting to start a second multi-page scan while another +// multi-page scan session is going will fail. +TEST_F(ScanServiceTest, StartingAnotherMultiPageScan) { + scoped_feature_list_.InitWithFeatures( + {chromeos::features::kScanAppMultiPageScan}, {}); + + fake_lorgnette_scanner_manager_.SetGetScannerNamesResponse( + {kFirstTestScannerName}); + const std::vector<std::string> scan_data = {CreatePng()}; + fake_lorgnette_scanner_manager_.SetScanResponse(scan_data); + auto scanners = GetScanners(); + ASSERT_EQ(scanners.size(), 1u); + + mojo_ipc::ScanSettings settings = CreateScanSettings( + scanned_files_mount_->GetRootPath(), mojo_ipc::FileType::kPdf); + + // The first scan should pass with no failure. + EXPECT_TRUE(StartMultiPageScan(scanners[0]->id, settings.Clone())); + EXPECT_FALSE(fake_scan_job_observer_.scan_success()); + EXPECT_EQ(mojo_ipc::ScanResult::kUnknownError, + fake_scan_job_observer_.multi_page_scan_result()); + EXPECT_TRUE(fake_scan_job_observer_.scanned_file_paths().empty()); + + // The second attempt should fail. + EXPECT_FALSE(StartMultiPageScan(scanners[0]->id, settings.Clone())); +} + } // namespace ash
diff --git a/chrome/browser/browsing_data/access_context_audit_service_unittest.cc b/chrome/browser/browsing_data/access_context_audit_service_unittest.cc index 1b88195..b7a8c5b 100644 --- a/chrome/browser/browsing_data/access_context_audit_service_unittest.cc +++ b/chrome/browser/browsing_data/access_context_audit_service_unittest.cc
@@ -200,10 +200,12 @@ auto test_cookie = net::CanonicalCookie::Create( kTestCookieURL, kTestCookieName + "=1; max-age=3600", kAccessTime1, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); auto test_non_persistent_cookie = net::CanonicalCookie::Create( kTestCookieURL, kTestNonPersistentCookieName + "=1", kAccessTime1, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Record access to these cookies against a URL. url::Origin kTopFrameOrigin = url::Origin::Create(GURL("https://test.com")); @@ -288,7 +290,8 @@ const GURL kTestURL("https://test.com"); auto test_cookie_expired = net::CanonicalCookie::Create( kTestURL, "test_1=1; expires=Thu, 01 Jan 1970 00:00:00 GMT", - base::Time::Now(), absl::nullopt /* server_time */); + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); service()->RecordCookieAccess({*test_cookie_expired}, url::Origin::Create(kTestURL)); @@ -306,7 +309,8 @@ service()->RecordCookieAccess( {*net::CanonicalCookie::Create(kTestUrl, "foo=bar; max-age=3600", kAccessTime1, - absl::nullopt /* server_time */)}, + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, kTopFrameOrigin); url::Origin kTestOrigin = url::Origin::Create(kTestUrl); service()->RecordStorageAPIAccess( @@ -350,7 +354,8 @@ service()->RecordCookieAccess( {*net::CanonicalCookie::Create(kTestUrl, "foo=bar; max-age=3600", kAccessTime1, - absl::nullopt /* server_time */)}, + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, kTopFrameOrigin); service()->RecordStorageAPIAccess( kTestOrigin, AccessContextAuditDatabase::StorageAPIType::kLocalStorage, @@ -433,7 +438,8 @@ auto test_cookie = net::CanonicalCookie::Create( kTestCookieURL, kTestCookieName + "=1; max-age=3600", kAccessTime, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Record access for two top level origins for the same storage and cookie. service()->RecordCookieAccess({*test_cookie}, kHistoryEntriesRemainingOrigin); @@ -492,12 +498,14 @@ service()->RecordCookieAccess( {*net::CanonicalCookie::Create(GURL("https://foo.com"), "foo=1; max-age=3600", base::Time::Now(), - absl::nullopt /* server_time */)}, + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, kHistoryEntryOrigin); service()->RecordCookieAccess( {*net::CanonicalCookie::Create(GURL("https://bar.com"), "bar=1; max-age=3600", base::Time::Now(), - absl::nullopt /* server_time */)}, + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, kNoHistoryEntryOrigin); service()->RecordStorageAPIAccess( url::Origin::Create(GURL("https://foo.com")), @@ -562,10 +570,12 @@ // Record accesses to cookies both inside and outside the deletion range. auto cookie_accessed_in_range = net::CanonicalCookie::Create( kTestCookieURL, "inside=1; max-age=3600", kInsideTimeRange, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); auto cookie_accessed_outside_range = net::CanonicalCookie::Create( kTestCookieURL, "outside=1; max-age=3600", kOutsideTimeRange, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); clock()->SetNow(kInsideTimeRange); service()->RecordCookieAccess({*cookie_accessed_in_range}, kOrigin1); @@ -618,19 +628,22 @@ // Create a cookie that will persist after shutdown. auto test_cookie_persistent = net::CanonicalCookie::Create( kTestPersistentURL, kTestCookieName + "=1; max-age=3600", kAccessTime, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Create a cookie that will persist (be cleared on next startup) because it // is explicitly session only. auto test_cookie_session_only_explicit = net::CanonicalCookie::Create( kTestSessionOnlyExplicitURL, kTestCookieName + "=1", kAccessTime, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Create a cookie that will be cleared because the content setting associated // with the cookie domain is set to session only. auto test_cookie_session_only_content_setting = net::CanonicalCookie::Create( kTestSessionOnlyContentSettingURL, kTestCookieName + "=1; max-age=3600", - kAccessTime, absl::nullopt /* server_time */); + kAccessTime, absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); service()->RecordCookieAccess( {*test_cookie_persistent, *test_cookie_session_only_explicit, @@ -752,7 +765,8 @@ // Check that records which have opaque top frame origins are not recorded. auto test_cookie = net::CanonicalCookie::Create( GURL("https://example.com"), "test_1=1; max-age=3600", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); service()->RecordCookieAccess({*test_cookie}, url::Origin()); service()->RecordStorageAPIAccess( url::Origin::Create(GURL("https://example.com")), @@ -774,7 +788,8 @@ auto test_cookie = net::CanonicalCookie::Create( kTestCookieURL, kTestCookieName + "=1; max-age=3600", kAccessTime1, - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Record access to the cookie via a helper. auto helper = std::make_unique<AccessContextAuditService::CookieAccessHelper>( @@ -830,14 +845,16 @@ // Third-party data clearing does not depend on the access context auditing // service to determine which cookies to clear, so these should get deleted. service()->RecordCookieAccess( - {*net::CanonicalCookie::Create(top_level_url, "same=site; max-age=3600", - base::Time::Now(), - absl::nullopt /* server_time */)}, + {*net::CanonicalCookie::Create( + top_level_url, "same=site; max-age=3600", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, top_level_origin); service()->RecordCookieAccess( {*net::CanonicalCookie::Create( cross_site_url, "cross=site; max-age=3600", base::Time::Now(), - absl::nullopt /* server_time */)}, + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, top_level_origin); // Set a same-site storage access record. This should get deleted. @@ -940,14 +957,16 @@ service()->RecordCookieAccess( {*net::CanonicalCookie::Create( kOutsideTimeRangeURL, "same=site; max-age=3600", kOutsideTimeRange, - absl::nullopt /* server_time */)}, + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, kTopLevelOrigin); clock()->SetNow(kInsideTimeRange); // A cookie record inside the time range should be deleted. service()->RecordCookieAccess( {*net::CanonicalCookie::Create( kInsideTimeRangeURL, "cross=site; max-age=3600", kInsideTimeRange, - absl::nullopt /* server_time */)}, + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)}, kTopLevelOrigin); // A same-site storage record in the time range should be deleted. service()->RecordStorageAPIAccess(
diff --git a/chrome/browser/browsing_data/browsing_data_remover_browsertest.cc b/chrome/browser/browsing_data/browsing_data_remover_browsertest.cc index 8f01293..380d730f 100644 --- a/chrome/browser/browsing_data/browsing_data_remover_browsertest.cc +++ b/chrome/browser/browsing_data/browsing_data_remover_browsertest.cc
@@ -8,85 +8,50 @@ #include "base/bind.h" #include "base/callback.h" -#include "base/files/file_enumerator.h" -#include "base/files/file_path.h" -#include "base/files/file_util.h" -#include "base/logging.h" #include "base/path_service.h" #include "base/run_loop.h" -#include "base/strings/string_util.h" #include "base/test/bind.h" -#include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" -#include "base/threading/thread_restrictions.h" #include "base/time/time.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/browsing_data/browsing_data_file_system_util.h" #include "chrome/browser/browsing_data/browsing_data_remover_browsertest_base.h" #include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h" -#include "chrome/browser/browsing_data/cookies_tree_model.h" #include "chrome/browser/browsing_data/counters/cache_counter.h" #include "chrome/browser/browsing_data/counters/site_data_counting_helper.h" #include "chrome/browser/browsing_data/local_data_container.h" -#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/external_protocol/external_protocol_handler.h" -#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/account_reconcilor_factory.h" #include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" -#include "components/browsing_data/content/browsing_data_helper.h" -#include "components/browsing_data/core/browsing_data_utils.h" -#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/metrics/content/subprocess_metrics_provider.h" #include "components/password_manager/core/browser/password_manager_features_util.h" #include "components/password_manager/core/common/password_manager_features.h" #include "components/prefs/pref_service.h" #include "components/signin/core/browser/account_reconcilor.h" -#include "components/signin/public/base/signin_buildflags.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_test_utils.h" #include "components/sync/driver/test_sync_service.h" -#include "content/public/browser/browser_context.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_filter_builder.h" -#include "content/public/browser/browsing_data_remover.h" -#include "content/public/browser/download_manager.h" -#include "content/public/browser/network_service_instance.h" #include "content/public/browser/storage_partition.h" -#include "content/public/browser/web_contents.h" #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "content/public/common/network_service_util.h" #include "content/public/test/browser_test.h" -#include "content/public/test/browser_test_utils.h" #include "content/public/test/browsing_data_remover_test_util.h" -#include "content/public/test/download_test_observer.h" -#include "content/public/test/simple_url_loader_test_helper.h" -#include "google_apis/gaia/gaia_urls.h" #include "google_apis/gaia/google_service_auth_error.h" #include "media/base/media_switches.h" #include "media/mojo/mojom/media_types.mojom.h" #include "media/mojo/services/video_decode_perf_history.h" -#include "net/cookies/canonical_cookie.h" -#include "net/cookies/cookie_access_result.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" -#include "services/network/public/cpp/features.h" -#include "services/network/public/cpp/simple_url_loader.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/public/common/features.h" -#include "third_party/leveldatabase/env_chromium.h" -#include "third_party/re2/src/re2/re2.h" #include "url/gurl.h" #if BUILDFLAG(ENABLE_LIBRARY_CDMS) @@ -113,189 +78,6 @@ static const char* kLocalHost = "localhost"; static const base::Time kLastHour = base::Time::Now() - base::TimeDelta::FromHours(1); - -// Check if |file| matches any regex in |ignore_file_patterns|. -bool ShouldIgnoreFile(const std::string& file, - const std::vector<std::string>& ignore_file_patterns) { - for (const std::string& pattern : ignore_file_patterns) { - if (RE2::PartialMatch(file, pattern)) - return true; - } - return false; -} - -// Searches the user data directory for files that contain |hostname| in the -// filename or as part of the content. Returns the number of files that -// do not match any regex in |ignore_file_patterns|. -bool CheckUserDirectoryForString( - const std::string& hostname, - const std::vector<std::string>& ignore_file_patterns) { - base::FilePath user_data_dir = - g_browser_process->profile_manager()->user_data_dir(); - base::ScopedAllowBlockingForTesting allow_blocking; - base::FileEnumerator enumerator( - user_data_dir, true /* recursive */, - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); - int found = 0; - for (base::FilePath path = enumerator.Next(); !path.empty(); - path = enumerator.Next()) { - // Remove |user_data_dir| part from path. - std::string file = - path.NormalizePathSeparatorsTo('/').AsUTF8Unsafe().substr( - user_data_dir.AsUTF8Unsafe().length()); - - // Check file name. - if (file.find(hostname) != std::string::npos) { - if (ShouldIgnoreFile(file, ignore_file_patterns)) { - LOG(INFO) << "Ignored: " << file; - } else { - found++; - LOG(WARNING) << "Found file name: " << file; - } - } - - // Check leveldb content. - if (path.BaseName().AsUTF8Unsafe() == "CURRENT") { - // LevelDB instances consist of a folder where most files have variable - // names that contain a revision number. - // All leveldb folders have a "CURRENT" file that points to the current - // manifest. We consider all folders with a CURRENT file to be leveldb - // instances and try to open them. - std::unique_ptr<leveldb::DB> db; - std::string db_file = path.DirName().AsUTF8Unsafe(); - auto status = leveldb_env::OpenDB(leveldb_env::Options(), db_file, &db); - if (status.ok()) { - std::unique_ptr<leveldb::Iterator> it( - db->NewIterator(leveldb::ReadOptions())); - for (it->SeekToFirst(); it->Valid(); it->Next()) { - std::string entry = - it->key().ToString() + ":" + it->value().ToString(); - if (entry.find(hostname) != std::string::npos) { - LOG(WARNING) << "Found leveldb entry: " << file << " " << entry; - found++; - } - } - } else { - // TODO(crbug.com/846297): Some databases are already open and the LOCK - // prevents us from accessing them. - LOG(INFO) << "Could not open: " << file << " " << status.ToString(); - } - } - - // TODO(crbug.com/846297): Add support for sqlite and other formats that - // possibly contain non-plaintext data. - - // Check file content. - if (enumerator.GetInfo().IsDirectory()) - continue; - std::string content; - if (!base::ReadFileToString(path, &content)) { - LOG(INFO) << "Could not read: " << file; - continue; - } - size_t pos = content.find(hostname); - if (pos != std::string::npos) { - if (ShouldIgnoreFile(file, ignore_file_patterns)) { - LOG(INFO) << "Ignored: " << file; - continue; - } - found++; - // Print surrounding text of the match. - std::string partial_content = content.substr( - pos < 30 ? 0 : pos - 30, - std::min(content.size() - 1, pos + hostname.size() + 30)); - LOG(WARNING) << "Found file content: " << file << "\n" - << partial_content << "\n"; - } - } - return found; -} - -class CookiesTreeObserver : public CookiesTreeModel::Observer { - public: - explicit CookiesTreeObserver(base::OnceClosure quit_closure) - : quit_closure_(std::move(quit_closure)) {} - - void TreeModelBeginBatch(CookiesTreeModel* model) override {} - - void TreeModelEndBatch(CookiesTreeModel* model) override { - std::move(quit_closure_).Run(); - } - - void TreeNodesAdded(ui::TreeModel* model, - ui::TreeModelNode* parent, - size_t start, - size_t count) override {} - void TreeNodesRemoved(ui::TreeModel* model, - ui::TreeModelNode* parent, - size_t start, - size_t count) override {} - void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node) override { - } - - private: - base::OnceClosure quit_closure_; -}; - -// Returns the sum of the number of datatypes per host. -int GetCookiesTreeModelCount(const CookieTreeNode* root) { - int count = 0; - for (const auto& node : root->children()) { - EXPECT_GE(node->children().size(), 1u); - count += std::count_if(node->children().cbegin(), node->children().cend(), - [](const auto& child) { - // TODO(crbug.com/642955): Include quota nodes. - return child->GetDetailedInfo().node_type != - CookieTreeNode::DetailedInfo::TYPE_QUOTA; - }); - } - return count; -} - -// Returns a string with information about the content of the -// cookie tree model. -std::string GetCookiesTreeModelInfo(const CookieTreeNode* root) { - std::stringstream info; - info << "CookieTreeModel: " << std::endl; - for (const auto& node : root->children()) { - info << node->GetTitle() << std::endl; - for (const auto& child : node->children()) { - // Quota nodes are not included in the UI due to crbug.com/642955. - const auto node_type = child->GetDetailedInfo().node_type; - if (node_type != CookieTreeNode::DetailedInfo::TYPE_QUOTA) - info << " " << child->GetTitle() << " " << node_type << std::endl; - } - } - return info.str(); -} - -#if BUILDFLAG(ENABLE_DICE_SUPPORT) -// Sets the APISID Gaia cookie, which is monitored by the AccountReconcilor. -bool SetGaiaCookieForProfile(Profile* profile) { - GURL google_url = GaiaUrls::GetInstance()->secure_google_url(); - auto cookie = net::CanonicalCookie::CreateUnsafeCookieForTesting( - "SAPISID", std::string(), "." + google_url.host(), "/", base::Time(), - base::Time(), base::Time(), true /* secure */, false /* httponly */, - net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_DEFAULT, - false /* same_party */); - bool success = false; - base::RunLoop loop; - base::OnceCallback<void(net::CookieAccessResult)> callback = - base::BindLambdaForTesting([&success, &loop](net::CookieAccessResult r) { - success = r.status.IsInclude(); - loop.Quit(); - }); - network::mojom::CookieManager* cookie_manager = - profile->GetDefaultStoragePartition() - ->GetCookieManagerForBrowserProcess(); - cookie_manager->SetCanonicalCookie(*cookie, google_url, - net::CookieOptions::MakeAllInclusive(), - std::move(callback)); - loop.Run(); - return success; -} -#endif - } // namespace class BrowsingDataRemoverBrowserTest @@ -415,7 +197,7 @@ #endif inline void ExpectCookieTreeModelCount(int expected) { - std::unique_ptr<CookiesTreeModel> model = GetCookiesTreeModel(); + std::unique_ptr<CookiesTreeModel> model = GetCookiesTreeModel(GetBrowser()); EXPECT_EQ(expected, GetCookiesTreeModelCount(model->GetRoot())) << GetCookiesTreeModelInfo(model->GetRoot()); } @@ -452,44 +234,6 @@ run_loop->Quit(); } - std::unique_ptr<CookiesTreeModel> GetCookiesTreeModel() { - Profile* profile = GetBrowser()->profile(); - content::StoragePartition* storage_partition = - profile->GetDefaultStoragePartition(); - content::ServiceWorkerContext* service_worker_context = - storage_partition->GetServiceWorkerContext(); - storage::FileSystemContext* file_system_context = - storage_partition->GetFileSystemContext(); - content::NativeIOContext* native_io_context = - storage_partition->GetNativeIOContext(); - auto container = std::make_unique<LocalDataContainer>( - new browsing_data::CookieHelper( - storage_partition, - CookiesTreeModel::GetCookieDeletionDisabledCallback(profile)), - new browsing_data::DatabaseHelper(profile), - new browsing_data::LocalStorageHelper(profile), - /*session_storage_helper=*/nullptr, - new browsing_data::AppCacheHelper( - storage_partition->GetAppCacheService()), - new browsing_data::IndexedDBHelper(storage_partition), - browsing_data::FileSystemHelper::Create( - file_system_context, - browsing_data_file_system_util::GetAdditionalFileSystemTypes(), - native_io_context), - BrowsingDataQuotaHelper::Create(profile), - new browsing_data::ServiceWorkerHelper(service_worker_context), - new browsing_data::SharedWorkerHelper(storage_partition), - new browsing_data::CacheStorageHelper(storage_partition), - BrowsingDataMediaLicenseHelper::Create(file_system_context)); - base::RunLoop run_loop; - CookiesTreeObserver observer(run_loop.QuitClosure()); - auto model = std::make_unique<CookiesTreeModel>( - std::move(container), profile->GetExtensionSpecialStoragePolicy()); - model->AddCookiesTreeObserver(&observer); - run_loop.Run(); - return model; - } - void SetUpCommandLine(base::CommandLine* command_line) override { #if BUILDFLAG(ENABLE_LIBRARY_CDMS) // Testing MediaLicenses requires additional command line parameters as
diff --git a/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.cc b/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.cc index 9ec7bf3..9d44a90 100644 --- a/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.cc +++ b/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.cc
@@ -9,12 +9,18 @@ #include <vector> #include "base/callback.h" +#include "base/files/file_enumerator.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/path_service.h" #include "base/test/bind.h" -#include "chrome/browser/browsing_data/cookies_tree_model.h" +#include "build/buildflag.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/browsing_data/browsing_data_file_system_util.h" #include "chrome/browser/browsing_data/counters/site_data_counting_helper.h" #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -24,8 +30,11 @@ #include "content/public/common/content_paths.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/download_test_observer.h" +#include "google_apis/gaia/gaia_urls.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" +#include "third_party/leveldatabase/env_chromium.h" +#include "third_party/re2/src/re2/re2.h" #include "ui/base/models/tree_model.h" namespace { @@ -60,6 +69,44 @@ bool initialized_; content::DownloadManager* download_manager_; }; + +class CookiesTreeObserver : public CookiesTreeModel::Observer { + public: + explicit CookiesTreeObserver(base::OnceClosure quit_closure) + : quit_closure_(std::move(quit_closure)) {} + ~CookiesTreeObserver() override = default; + + void TreeModelBeginBatch(CookiesTreeModel* model) override {} + + void TreeModelEndBatch(CookiesTreeModel* model) override { + std::move(quit_closure_).Run(); + } + + void TreeNodesAdded(ui::TreeModel* model, + ui::TreeModelNode* parent, + size_t start, + size_t count) override {} + void TreeNodesRemoved(ui::TreeModel* model, + ui::TreeModelNode* parent, + size_t start, + size_t count) override {} + void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node) override { + } + + private: + base::OnceClosure quit_closure_; +}; + +// Check if |file| matches any regex in |ignore_file_patterns|. +bool ShouldIgnoreFile(const std::string& file, + const std::vector<std::string>& ignore_file_patterns) { + for (const std::string& pattern : ignore_file_patterns) { + if (RE2::PartialMatch(file, pattern)) + return true; + } + return false; +} + } // namespace BrowsingDataRemoverBrowserTestBase::BrowsingDataRemoverBrowserTestBase() = @@ -79,6 +126,13 @@ incognito_browser_ = CreateIncognitoBrowser(); } +void BrowsingDataRemoverBrowserTestBase::RestartIncognitoBrowser() { + ASSERT_NE(nullptr, incognito_browser_); + CloseBrowserSynchronously(incognito_browser_); + incognito_browser_ = nullptr; + UseIncognitoBrowser(); +} + Browser* BrowsingDataRemoverBrowserTestBase::GetBrowser() const { return incognito_browser_ ? incognito_browser_ : browser(); } @@ -92,24 +146,32 @@ void BrowsingDataRemoverBrowserTestBase::RunScriptAndCheckResult( const std::string& script, - const std::string& result) { + const std::string& result, + Browser* browser) { + if (!browser) + browser = GetBrowser(); std::string data; ASSERT_TRUE(content::ExecuteScriptAndExtractString( - GetBrowser()->tab_strip_model()->GetActiveWebContents(), script, &data)); + browser->tab_strip_model()->GetActiveWebContents(), script, &data)); ASSERT_EQ(data, result); } bool BrowsingDataRemoverBrowserTestBase::RunScriptAndGetBool( - const std::string& script) { + const std::string& script, + Browser* browser) { + EXPECT_TRUE(browser); bool data; EXPECT_TRUE(content::ExecuteScriptAndExtractBool( - GetBrowser()->tab_strip_model()->GetActiveWebContents(), script, &data)); + browser->tab_strip_model()->GetActiveWebContents(), script, &data)); return data; } -void BrowsingDataRemoverBrowserTestBase::VerifyDownloadCount(size_t expected) { +void BrowsingDataRemoverBrowserTestBase::VerifyDownloadCount(size_t expected, + Browser* browser) { + if (!browser) + browser = GetBrowser(); content::DownloadManager* download_manager = - GetBrowser()->profile()->GetDownloadManager(); + browser->profile()->GetDownloadManager(); DownloadManagerWaiter download_manager_waiter(download_manager); download_manager_waiter.WaitForInitialized(); std::vector<download::DownloadItem*> downloads; @@ -135,21 +197,27 @@ VerifyDownloadCount(1u); } -bool BrowsingDataRemoverBrowserTestBase::HasDataForType( - const std::string& type) { - return RunScriptAndGetBool("has" + type + "()"); +bool BrowsingDataRemoverBrowserTestBase::HasDataForType(const std::string& type, + Browser* browser) { + if (!browser) + browser = GetBrowser(); + return RunScriptAndGetBool("has" + type + "()", browser); } -void BrowsingDataRemoverBrowserTestBase::SetDataForType( - const std::string& type) { - ASSERT_TRUE(RunScriptAndGetBool("set" + type + "()")) +void BrowsingDataRemoverBrowserTestBase::SetDataForType(const std::string& type, + Browser* browser) { + if (!browser) + browser = GetBrowser(); + ASSERT_TRUE(RunScriptAndGetBool("set" + type + "()", browser)) << "Couldn't create data for: " << type; } -int BrowsingDataRemoverBrowserTestBase::GetSiteDataCount() { +int BrowsingDataRemoverBrowserTestBase::GetSiteDataCount(Browser* browser) { + if (!browser) + browser = GetBrowser(); base::RunLoop run_loop; int count = -1; - (new SiteDataCountingHelper(GetBrowser()->profile(), base::Time(), + (new SiteDataCountingHelper(browser->profile(), base::Time(), base::Time::Max(), base::BindLambdaForTesting([&](int c) { count = c; @@ -167,3 +235,184 @@ ->GetDefaultStoragePartition() ->GetNetworkContext(); } + +bool BrowsingDataRemoverBrowserTestBase::CheckUserDirectoryForString( + const std::string& hostname, + const std::vector<std::string>& ignore_file_patterns) { + base::FilePath user_data_dir = + g_browser_process->profile_manager()->user_data_dir(); + base::ScopedAllowBlockingForTesting allow_blocking; + base::FileEnumerator enumerator( + user_data_dir, true /* recursive */, + base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); + int found = 0; + for (base::FilePath path = enumerator.Next(); !path.empty(); + path = enumerator.Next()) { + // Remove |user_data_dir| part from path. + std::string file = + path.NormalizePathSeparatorsTo('/').AsUTF8Unsafe().substr( + user_data_dir.AsUTF8Unsafe().length()); + + // Check file name. + if (file.find(hostname) != std::string::npos) { + if (ShouldIgnoreFile(file, ignore_file_patterns)) { + LOG(INFO) << "Ignored: " << file; + } else { + found++; + LOG(WARNING) << "Found file name: " << file; + } + } + + // Check leveldb content. + if (path.BaseName().AsUTF8Unsafe() == "CURRENT") { + // LevelDB instances consist of a folder where most files have variable + // names that contain a revision number. + // All leveldb folders have a "CURRENT" file that points to the current + // manifest. We consider all folders with a CURRENT file to be leveldb + // instances and try to open them. + std::unique_ptr<leveldb::DB> db; + std::string db_file = path.DirName().AsUTF8Unsafe(); + auto status = leveldb_env::OpenDB(leveldb_env::Options(), db_file, &db); + if (status.ok()) { + std::unique_ptr<leveldb::Iterator> it( + db->NewIterator(leveldb::ReadOptions())); + for (it->SeekToFirst(); it->Valid(); it->Next()) { + std::string entry = + it->key().ToString() + ":" + it->value().ToString(); + if (entry.find(hostname) != std::string::npos) { + LOG(WARNING) << "Found leveldb entry: " << file << " " << entry; + found++; + } + } + } else { + // TODO(crbug.com/846297): Some databases are already open and the LOCK + // prevents us from accessing them. + LOG(INFO) << "Could not open: " << file << " " << status.ToString(); + } + } + + // TODO(crbug.com/846297): Add support for sqlite and other formats that + // possibly contain non-plaintext data. + + // Check file content. + if (enumerator.GetInfo().IsDirectory()) + continue; + std::string content; + if (!base::ReadFileToString(path, &content)) { + LOG(INFO) << "Could not read: " << file; + continue; + } + size_t pos = content.find(hostname); + if (pos != std::string::npos) { + if (ShouldIgnoreFile(file, ignore_file_patterns)) { + LOG(INFO) << "Ignored: " << file; + continue; + } + found++; + // Print surrounding text of the match. + std::string partial_content = content.substr( + pos < 30 ? 0 : pos - 30, + std::min(content.size() - 1, pos + hostname.size() + 30)); + LOG(WARNING) << "Found file content: " << file << "\n" + << partial_content << "\n"; + } + } + return found; +} + +int BrowsingDataRemoverBrowserTestBase::GetCookiesTreeModelCount( + const CookieTreeNode* root) { + int count = 0; + for (const auto& node : root->children()) { + EXPECT_GE(node->children().size(), 1u); + count += std::count_if(node->children().cbegin(), node->children().cend(), + [](const auto& child) { + // TODO(crbug.com/642955): Include quota nodes. + return child->GetDetailedInfo().node_type != + CookieTreeNode::DetailedInfo::TYPE_QUOTA; + }); + } + return count; +} + +std::string BrowsingDataRemoverBrowserTestBase::GetCookiesTreeModelInfo( + const CookieTreeNode* root) { + std::stringstream info; + info << "CookieTreeModel: " << std::endl; + for (const auto& node : root->children()) { + info << node->GetTitle() << std::endl; + for (const auto& child : node->children()) { + // Quota nodes are not included in the UI due to crbug.com/642955. + const auto node_type = child->GetDetailedInfo().node_type; + if (node_type != CookieTreeNode::DetailedInfo::TYPE_QUOTA) + info << " " << child->GetTitle() << " " << node_type << std::endl; + } + } + return info.str(); +} + +std::unique_ptr<CookiesTreeModel> +BrowsingDataRemoverBrowserTestBase::GetCookiesTreeModel(Browser* browser) { + Profile* profile = browser->profile(); + content::StoragePartition* storage_partition = + profile->GetDefaultStoragePartition(); + content::ServiceWorkerContext* service_worker_context = + storage_partition->GetServiceWorkerContext(); + storage::FileSystemContext* file_system_context = + storage_partition->GetFileSystemContext(); + content::NativeIOContext* native_io_context = + storage_partition->GetNativeIOContext(); + auto container = std::make_unique<LocalDataContainer>( + new browsing_data::CookieHelper( + storage_partition, + CookiesTreeModel::GetCookieDeletionDisabledCallback(profile)), + new browsing_data::DatabaseHelper(profile), + new browsing_data::LocalStorageHelper(profile), + /*session_storage_helper=*/nullptr, + new browsing_data::AppCacheHelper( + storage_partition->GetAppCacheService()), + new browsing_data::IndexedDBHelper(storage_partition), + browsing_data::FileSystemHelper::Create( + file_system_context, + browsing_data_file_system_util::GetAdditionalFileSystemTypes(), + native_io_context), + BrowsingDataQuotaHelper::Create(profile), + new browsing_data::ServiceWorkerHelper(service_worker_context), + new browsing_data::SharedWorkerHelper(storage_partition), + new browsing_data::CacheStorageHelper(storage_partition), + BrowsingDataMediaLicenseHelper::Create(file_system_context)); + base::RunLoop run_loop; + CookiesTreeObserver observer(run_loop.QuitClosure()); + auto model = std::make_unique<CookiesTreeModel>( + std::move(container), profile->GetExtensionSpecialStoragePolicy()); + model->AddCookiesTreeObserver(&observer); + run_loop.Run(); + return model; +} + +#if BUILDFLAG(ENABLE_DICE_SUPPORT) +bool BrowsingDataRemoverBrowserTestBase::SetGaiaCookieForProfile( + Profile* profile) { + GURL google_url = GaiaUrls::GetInstance()->secure_google_url(); + auto cookie = net::CanonicalCookie::CreateUnsafeCookieForTesting( + "SAPISID", std::string(), "." + google_url.host(), "/", base::Time(), + base::Time(), base::Time(), true /* secure */, false /* httponly */, + net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_DEFAULT, + false /* same_party */); + bool success = false; + base::RunLoop loop; + base::OnceCallback<void(net::CookieAccessResult)> callback = + base::BindLambdaForTesting([&success, &loop](net::CookieAccessResult r) { + success = r.status.IsInclude(); + loop.Quit(); + }); + network::mojom::CookieManager* cookie_manager = + profile->GetDefaultStoragePartition() + ->GetCookieManagerForBrowserProcess(); + cookie_manager->SetCanonicalCookie(*cookie, google_url, + net::CookieOptions::MakeAllInclusive(), + std::move(callback)); + loop.Run(); + return success; +} +#endif
diff --git a/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.h b/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.h index 7b46b3e..7611150b 100644 --- a/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.h +++ b/chrome/browser/browsing_data/browsing_data_remover_browsertest_base.h
@@ -7,7 +7,9 @@ #include <string> #include "base/test/scoped_feature_list.h" +#include "chrome/browser/browsing_data/cookies_tree_model.h" #include "chrome/test/base/in_process_browser_test.h" +#include "components/signin/public/base/signin_buildflags.h" class BrowsingDataRemoverBrowserTestBase : public InProcessBrowserTest { public: @@ -18,21 +20,54 @@ Browser* GetBrowser() const; void SetUpOnMainThread() override; + // If |browser| is not specified, |GetBrowser| will be used. void RunScriptAndCheckResult(const std::string& script, - const std::string& result); - bool RunScriptAndGetBool(const std::string& script); - void VerifyDownloadCount(size_t expected); - void DownloadAnItem(); - bool HasDataForType(const std::string& type); + const std::string& result, + Browser* browser = nullptr); + bool RunScriptAndGetBool(const std::string& script, Browser* browser); - void SetDataForType(const std::string& type); - int GetSiteDataCount(); + // If |browser| is not specified, |GetBrowser| will be used. + void VerifyDownloadCount(size_t expected, Browser* browser = nullptr); + void DownloadAnItem(); + + // If |browser| is not specified, |GetBrowser| will be used. + bool HasDataForType(const std::string& type, Browser* browser = nullptr); + + // If |browser| is not specified, |GetBrowser| will be used. + void SetDataForType(const std::string& type, Browser* browser = nullptr); + + // If |browser| is not specified, |GetBrowser| will be used. + int GetSiteDataCount(Browser* browser = nullptr); void UseIncognitoBrowser(); bool IsIncognito() { return incognito_browser_ != nullptr; } + void RestartIncognitoBrowser(); network::mojom::NetworkContext* network_context() const; + protected: + // Searches the user data directory for files that contain |hostname| in the + // filename or as part of the content. Returns the number of files that + // do not match any regex in |ignore_file_patterns|. + bool CheckUserDirectoryForString( + const std::string& hostname, + const std::vector<std::string>& ignore_file_patterns); + + // Returns the cookie tree model for the browser. + std::unique_ptr<CookiesTreeModel> GetCookiesTreeModel(Browser* browser); + + // Returns the sum of the number of datatypes per host. + int GetCookiesTreeModelCount(const CookieTreeNode* root); + + // Returns a string with information about the content of the + // cookie tree model. + std::string GetCookiesTreeModelInfo(const CookieTreeNode* root); + +#if BUILDFLAG(ENABLE_DICE_SUPPORT) + // Sets the APISID Gaia cookie, which is monitored by the AccountReconcilor. + bool SetGaiaCookieForProfile(Profile* profile); +#endif + private: base::test::ScopedFeatureList feature_list_; Browser* incognito_browser_ = nullptr;
diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc index be44fe6..43acb627 100644 --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
@@ -292,7 +292,8 @@ void AddCookie() { base::RunLoop run_loop; auto cookie = net::CanonicalCookie::Create( - cookie_url_, "A=1", base::Time::Now(), absl::nullopt /* server_time */); + cookie_url_, "A=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cookie_manager_->SetCanonicalCookie( *cookie, cookie_url_, net::CookieOptions::MakeAllInclusive(), base::BindLambdaForTesting([&](net::CookieAccessResult result) {
diff --git a/chrome/browser/browsing_data/cookies_tree_model.cc b/chrome/browser/browsing_data/cookies_tree_model.cc index e1ca5e5..a8ca674c 100644 --- a/chrome/browser/browsing_data/cookies_tree_model.cc +++ b/chrome/browser/browsing_data/cookies_tree_model.cc
@@ -482,8 +482,10 @@ local_storage_info_->origin, AccessContextAuditDatabase::StorageAPIType::kLocalStorage); - container->local_storage_helper_->DeleteOrigin( - local_storage_info_->origin, base::DoNothing()); + container->local_storage_helper_->DeleteStorageKey( + // TODO(https://crbug.com/1199077): Pass the real StorageKey into this + // function directly. + blink::StorageKey(local_storage_info_->origin), base::DoNothing()); container->local_storage_info_list_.erase(local_storage_info_); } }
diff --git a/chrome/browser/browsing_data/incognito_browsing_data_browsertest.cc b/chrome/browser/browsing_data/incognito_browsing_data_browsertest.cc new file mode 100644 index 0000000..a39a43ea --- /dev/null +++ b/chrome/browser/browsing_data/incognito_browsing_data_browsertest.cc
@@ -0,0 +1,577 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <stddef.h> +#include <memory> +#include <string> + +#include "base/bind.h" +#include "base/callback.h" +#include "base/path_service.h" +#include "base/run_loop.h" +#include "base/test/bind.h" +#include "base/test/scoped_feature_list.h" +#include "base/time/time.h" +#include "build/build_config.h" +#include "build/chromeos_buildflags.h" +#include "chrome/browser/browsing_data/browsing_data_remover_browsertest_base.h" +#include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h" +#include "chrome/browser/browsing_data/counters/cache_counter.h" +#include "chrome/browser/browsing_data/counters/site_data_counting_helper.h" +#include "chrome/browser/browsing_data/local_data_container.h" +#include "chrome/browser/external_protocol/external_protocol_handler.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/common/pref_names.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/ui_test_utils.h" +#include "components/prefs/pref_service.h" +#include "content/public/browser/storage_partition.h" +#include "content/public/common/content_paths.h" +#include "content/public/common/content_switches.h" +#include "content/public/test/browser_test.h" +#include "media/base/media_switches.h" +#include "media/mojo/mojom/media_types.mojom.h" +#include "media/mojo/services/video_decode_perf_history.h" +#include "net/dns/mock_host_resolver.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "url/gurl.h" + +#if BUILDFLAG(ENABLE_LIBRARY_CDMS) +#if defined(OS_MAC) +#include "base/threading/platform_thread.h" +#endif +#include "base/memory/scoped_refptr.h" +#include "chrome/browser/browsing_data/browsing_data_media_license_helper.h" +#include "chrome/browser/media/library_cdm_test_helper.h" +#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) + +#if BUILDFLAG(IS_CHROMEOS_ASH) +#include "chrome/browser/browser_process.h" +#include "chrome/browser/browser_process_platform_part.h" +#endif // BUILDFLAG(IS_CHROMEOS_ASH) + +using content::BrowserThread; +using content::BrowsingDataFilterBuilder; + +namespace { +static const char* kExampleHost = "example.com"; +static const char* kLocalHost = "localhost"; +} // namespace + +class IncognitoBrowsingDataBrowserTest + : public BrowsingDataRemoverBrowserTestBase { + public: + IncognitoBrowsingDataBrowserTest() { + std::vector<base::Feature> enabled_features = {}; +#if BUILDFLAG(ENABLE_LIBRARY_CDMS) + enabled_features.push_back(media::kExternalClearKeyForTesting); +#endif + InitFeatureList(std::move(enabled_features)); + } + + void SetUpOnMainThread() override { + BrowsingDataRemoverBrowserTestBase::SetUpOnMainThread(); + host_resolver()->AddRule(kExampleHost, "127.0.0.1"); + UseIncognitoBrowser(); + } + + Browser* GetRegularBrowser() { return browser(); } + + Browser* GetIncognitoBrowser() { return GetBrowser(); } + + // Test a data type by creating a value in Incognito mode and checking it is + // counted by the Incognito cookie counter and not by the regular mode one. + // Then closing Incognito mode and ensuring it is not affecting a new + // Incognito profile. + void TestSiteData(const std::string& type) { + Browser* regular_browser = GetRegularBrowser(); + Browser* incognito_browser = GetIncognitoBrowser(); + + EXPECT_TRUE(regular_browser->profile()->IsRegularProfile()); + EXPECT_TRUE(incognito_browser->profile()->IsIncognitoProfile()); + + // Ensure there is no prior data. + EXPECT_EQ(0, GetSiteDataCount(regular_browser)); + EXPECT_EQ(0, GetSiteDataCount(incognito_browser)); + GURL url = embedded_test_server()->GetURL("/browsing_data/site_data.html"); + ui_test_utils::NavigateToURL(incognito_browser, url); + ui_test_utils::NavigateToURL(regular_browser, url); + + // Even after navigation. + EXPECT_EQ(0, GetSiteDataCount(incognito_browser)); + ExpectCookieTreeModelCount(incognito_browser, 0); + EXPECT_FALSE(HasDataForType(type, incognito_browser)); + + // Set data type in Incognito mode, ensure only Incognito mode is affected. + SetDataForType(type, incognito_browser); + EXPECT_EQ(0, GetSiteDataCount(regular_browser)); + EXPECT_EQ(1, GetSiteDataCount(incognito_browser)); + ExpectCookieTreeModelCount(regular_browser, 0); + ExpectCookieTreeModelCount(incognito_browser, 1); + EXPECT_FALSE(HasDataForType(type, regular_browser)); + EXPECT_TRUE(HasDataForType(type, incognito_browser)); + + // Restart Incognito and ensure it is empty. + RestartIncognitoBrowser(); + incognito_browser = GetIncognitoBrowser(); + ui_test_utils::NavigateToURL(incognito_browser, url); + + EXPECT_EQ(0, GetSiteDataCount(incognito_browser)); + ExpectCookieTreeModelCount(incognito_browser, 0); + EXPECT_FALSE(HasDataForType(type, incognito_browser)); + } + + // Test that storage systems like filesystem and websql, where just an access + // creates an empty store, are counted and deleted correctly. + void TestEmptySiteData(const std::string& type) { + Browser* regular_browser = GetRegularBrowser(); + Browser* incognito_browser = GetIncognitoBrowser(); + + EXPECT_EQ(0, GetSiteDataCount(regular_browser)); + EXPECT_EQ(0, GetSiteDataCount(incognito_browser)); + ExpectCookieTreeModelCount(regular_browser, 0); + ExpectCookieTreeModelCount(incognito_browser, 0); + + GURL url = embedded_test_server()->GetURL("/browsing_data/site_data.html"); + ui_test_utils::NavigateToURL(incognito_browser, url); + EXPECT_EQ(0, GetSiteDataCount(incognito_browser)); + ExpectCookieTreeModelCount(incognito_browser, 0); + // Opening a store of this type creates a site data entry in Incognito only. + EXPECT_FALSE(HasDataForType(type, incognito_browser)); + EXPECT_EQ(0, GetSiteDataCount(regular_browser)); + EXPECT_EQ(1, GetSiteDataCount(incognito_browser)); + ExpectCookieTreeModelCount(regular_browser, 0); + ExpectCookieTreeModelCount(incognito_browser, 1); + + // Restart Incognito, ensure there is no residue from previous one. + RestartIncognitoBrowser(); + incognito_browser = GetIncognitoBrowser(); + EXPECT_EQ(0, GetSiteDataCount(incognito_browser)); + ExpectCookieTreeModelCount(incognito_browser, 0); + } + +#if BUILDFLAG(ENABLE_LIBRARY_CDMS) + int GetMediaLicenseCount(Browser* browser = nullptr) { + if (!browser) + browser = GetBrowser(); + base::RunLoop run_loop; + int count = -1; + content::StoragePartition* partition = + browser->profile()->GetDefaultStoragePartition(); + scoped_refptr<BrowsingDataMediaLicenseHelper> media_license_helper = + BrowsingDataMediaLicenseHelper::Create( + partition->GetFileSystemContext()); + media_license_helper->StartFetching(base::BindLambdaForTesting( + [&](const std::list<BrowsingDataMediaLicenseHelper::MediaLicenseInfo>& + licenses) { + count = licenses.size(); + LOG(INFO) << "Found " << count << " licenses."; + for (const auto& license : licenses) + LOG(INFO) << license.last_modified_time; + run_loop.Quit(); + })); + run_loop.Run(); + return count; + } +#endif + + inline void ExpectCookieTreeModelCount(Browser* browser, int expected) { + std::unique_ptr<CookiesTreeModel> model = GetCookiesTreeModel(browser); + EXPECT_EQ(expected, GetCookiesTreeModelCount(model->GetRoot())) + << GetCookiesTreeModelInfo(model->GetRoot()); + } + + void OnVideoDecodePerfInfo(base::RunLoop* run_loop, + bool* out_is_smooth, + bool* out_is_power_efficient, + bool is_smooth, + bool is_power_efficient) { + *out_is_smooth = is_smooth; + *out_is_power_efficient = is_power_efficient; + run_loop->QuitWhenIdle(); + } + + network::mojom::NetworkContext* network_context() const { + return GetBrowser() + ->profile() + ->GetDefaultStoragePartition() + ->GetNetworkContext(); + } + + private: + void OnCacheSizeResult( + base::RunLoop* run_loop, + browsing_data::BrowsingDataCounter::ResultInt* out_size, + std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { + if (!result->Finished()) + return; + + *out_size = + static_cast<browsing_data::BrowsingDataCounter::FinishedResult*>( + result.get()) + ->Value(); + run_loop->Quit(); + } + + void SetUpCommandLine(base::CommandLine* command_line) override { +#if BUILDFLAG(ENABLE_LIBRARY_CDMS) + // Testing MediaLicenses requires additional command line parameters as + // it uses the External Clear Key CDM. + RegisterClearKeyCdm(command_line); +#endif + command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures, + "StorageFoundationAPI"); + } +}; + +// Test BrowsingDataRemover for downloads. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, Download) { + DownloadAnItem(); + VerifyDownloadCount(0u, GetRegularBrowser()); + + // Restart Incognito, ensure no residue. + RestartIncognitoBrowser(); + VerifyDownloadCount(0u, GetIncognitoBrowser()); +} + +// Test that the salt for media device IDs is reset between Incognito sessions. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, MediaDeviceIdSalt) { + std::string original_salt = GetBrowser()->profile()->GetMediaDeviceIDSalt(); + + RestartIncognitoBrowser(); + + std::string new_salt = GetBrowser()->profile()->GetMediaDeviceIDSalt(); + EXPECT_NE(original_salt, new_salt); +} + +// Verify VideoDecodePerfHistory is cleared after restarting Incognito session +// and is not affecting regular mode. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + VideoDecodePerfHistory) { + media::VideoDecodePerfHistory* video_decode_perf_history = + GetBrowser()->profile()->GetVideoDecodePerfHistory(); + + // Save a video decode record. Note: we avoid using a web page to generate the + // stats as this takes at least 5 seconds and even then is not a guarantee + // depending on scheduler. Manual injection is quick and non-flaky. + const media::VideoCodecProfile kProfile = media::VP9PROFILE_PROFILE0; + const gfx::Size kSize(100, 200); + const int kFrameRate = 30; + const int kFramesDecoded = 1000; + const int kFramesDropped = .9 * kFramesDecoded; + const int kFramesPowerEfficient = 0; + const url::Origin kOrigin = url::Origin::Create(GURL("http://example.com")); + const bool kIsTopFrame = true; + const uint64_t kPlayerId = 1234u; + + media::mojom::PredictionFeatures prediction_features; + prediction_features.profile = kProfile; + prediction_features.video_size = kSize; + prediction_features.frames_per_sec = kFrameRate; + + media::mojom::PredictionTargets prediction_targets; + prediction_targets.frames_decoded = kFramesDecoded; + prediction_targets.frames_dropped = kFramesDropped; + prediction_targets.frames_power_efficient = kFramesPowerEfficient; + + { + base::RunLoop run_loop; + video_decode_perf_history->GetSaveCallback().Run( + ukm::kInvalidSourceId, media::learning::FeatureValue(0), kIsTopFrame, + prediction_features, prediction_targets, kPlayerId, + run_loop.QuitWhenIdleClosure()); + run_loop.Run(); + } + + // Verify history exists. + // Expect |is_smooth| = false and |is_power_efficient| = false given that 90% + // of recorded frames were dropped and 0 were power efficient. + bool is_smooth = true; + bool is_power_efficient = true; + { + base::RunLoop run_loop; + video_decode_perf_history->GetPerfInfo( + media::mojom::PredictionFeatures::New(prediction_features), + base::BindOnce(&IncognitoBrowsingDataBrowserTest::OnVideoDecodePerfInfo, + base::Unretained(this), &run_loop, &is_smooth, + &is_power_efficient)); + run_loop.Run(); + } + EXPECT_FALSE(is_smooth); + EXPECT_FALSE(is_power_efficient); + + // Verify it has not affected regular mode. Both |is_smooth| and + // |is_power_efficient| should report true because the VideoDecodePerfHistory + // optimistically returns true when it has no data. + media::VideoDecodePerfHistory* regular_mode_video_decode_perf_history = + GetRegularBrowser()->profile()->GetVideoDecodePerfHistory(); + { + base::RunLoop run_loop; + regular_mode_video_decode_perf_history->GetPerfInfo( + media::mojom::PredictionFeatures::New(prediction_features), + base::BindOnce(&IncognitoBrowsingDataBrowserTest::OnVideoDecodePerfInfo, + base::Unretained(this), &run_loop, &is_smooth, + &is_power_efficient)); + run_loop.Run(); + } + EXPECT_TRUE(is_smooth); + EXPECT_TRUE(is_power_efficient); + + // Restart Incognito. + RestartIncognitoBrowser(); + video_decode_perf_history = + GetBrowser()->profile()->GetVideoDecodePerfHistory(); + + // Verify history no longer exists. Both |is_smooth| and |is_power_efficient| + // should now report true because the VideoDecodePerfHistory optimistically + // returns true when it has no data. + { + base::RunLoop run_loop; + video_decode_perf_history->GetPerfInfo( + media::mojom::PredictionFeatures::New(prediction_features), + base::BindOnce(&IncognitoBrowsingDataBrowserTest::OnVideoDecodePerfInfo, + base::Unretained(this), &run_loop, &is_smooth, + &is_power_efficient)); + run_loop.Run(); + } + EXPECT_TRUE(is_smooth); + EXPECT_TRUE(is_power_efficient); +} + +// Verify database is reset after Incognito restart. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, Database) { + GURL url = embedded_test_server()->GetURL("/simple_database.html"); + ui_test_utils::NavigateToURL(GetBrowser(), url); + + RunScriptAndCheckResult("createTable()", "done"); + RunScriptAndCheckResult("insertRecord('text')", "done"); + RunScriptAndCheckResult("getRecords()", "text"); + + RestartIncognitoBrowser(); + + ui_test_utils::NavigateToURL(GetBrowser(), url); + RunScriptAndCheckResult("createTable()", "done"); + RunScriptAndCheckResult("insertRecord('text2')", "done"); + RunScriptAndCheckResult("getRecords()", "text2"); +} + +// Verifies that cache is reset after restarting Incognito. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, Cache) { + // Load several resources. + GURL url1 = embedded_test_server()->GetURL("/cachetime"); + GURL url2 = embedded_test_server()->GetURL(kExampleHost, "/cachetime"); + ASSERT_FALSE(url::IsSameOriginWith(url1, url2)); + + EXPECT_EQ(net::OK, content::LoadBasicRequest(network_context(), url1)); + EXPECT_EQ(net::OK, content::LoadBasicRequest(network_context(), url2)); + + // Check that the cache has been populated by revisiting these pages with the + // server stopped. + ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); + EXPECT_EQ(net::OK, content::LoadBasicRequest(network_context(), url1)); + EXPECT_EQ(net::OK, content::LoadBasicRequest(network_context(), url2)); + + RestartIncognitoBrowser(); + + // The cache should be empty. + EXPECT_NE(net::OK, content::LoadBasicRequest(network_context(), url1)); + EXPECT_NE(net::OK, content::LoadBasicRequest(network_context(), url2)); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + ExternalProtocolHandlerPerOriginPrefs) { + Profile* profile = GetBrowser()->profile(); + url::Origin test_origin = url::Origin::Create(GURL("https://example.test/")); + const std::string serialized_test_origin = test_origin.Serialize(); + base::DictionaryValue origin_pref; + origin_pref.SetKey(serialized_test_origin, + base::Value(base::Value::Type::DICTIONARY)); + base::Value* allowed_protocols_for_origin = + origin_pref.FindDictKey(serialized_test_origin); + allowed_protocols_for_origin->SetBoolKey("tel", true); + profile->GetPrefs()->Set(prefs::kProtocolHandlerPerOriginAllowedProtocols, + origin_pref); + ExternalProtocolHandler::BlockState block_state = + ExternalProtocolHandler::GetBlockState("tel", &test_origin, profile); + ASSERT_EQ(ExternalProtocolHandler::DONT_BLOCK, block_state); + + // Regular profile should be unaffected. + block_state = ExternalProtocolHandler::GetBlockState( + "tel", &test_origin, GetRegularBrowser()->profile()); + ASSERT_EQ(ExternalProtocolHandler::UNKNOWN, block_state); + + RestartIncognitoBrowser(); + profile = GetBrowser()->profile(); + + block_state = + ExternalProtocolHandler::GetBlockState("tel", &test_origin, profile); + ASSERT_EQ(ExternalProtocolHandler::UNKNOWN, block_state); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, CookieDeletion) { + TestSiteData("Cookie"); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + SessionCookieDeletion) { + TestSiteData("SessionCookie"); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, LocalStorageDeletion) { + TestSiteData("LocalStorage"); +} + +// TODO(crbug.com/772337): DISABLED until session storage is working correctly. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + DISABLED_SessionStorageDeletion) { + TestSiteData("SessionStorage"); +} + +// SessionStorage is not supported by site data counting and the cookie tree +// model but we can test the web visible behavior. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + SessionStorageDeletionWebOnly) { + GURL url = embedded_test_server()->GetURL("/browsing_data/site_data.html"); + ui_test_utils::NavigateToURL(GetBrowser(), url); + const std::string type = "SessionStorage"; + EXPECT_FALSE(HasDataForType(type)); + SetDataForType(type); + EXPECT_TRUE(HasDataForType(type)); + + // No residue in regular mode. + ui_test_utils::NavigateToURL(GetRegularBrowser(), url); + EXPECT_FALSE(HasDataForType(type, GetRegularBrowser())); + + RestartIncognitoBrowser(); + ui_test_utils::NavigateToURL(GetBrowser(), url); + EXPECT_FALSE(HasDataForType(type)); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + ServiceWorkerDeletion) { + TestSiteData("ServiceWorker"); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, CacheStorageDeletion) { + TestSiteData("CacheStorage"); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, FileSystemDeletion) { + TestSiteData("FileSystem"); +} + +// Test that empty filesystems are deleted correctly. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + EmptyFileSystemDeletion) { + TestEmptySiteData("FileSystem"); +} + +// Storage foundation is not supported in Incognito. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + DISABLED_NativeIODeletion) { + TestSiteData("StorageFoundation"); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, WebSqlDeletion) { + TestSiteData("WebSql"); +} + +// Test that empty websql dbs are deleted correctly. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, EmptyWebSqlDeletion) { + TestEmptySiteData("WebSql"); +} + +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, IndexedDbDeletion) { + TestSiteData("IndexedDb"); +} + +// Test that empty indexed dbs are deleted correctly. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, EmptyIndexedDb) { + TestEmptySiteData("IndexedDb"); +} + +#if BUILDFLAG(ENABLE_LIBRARY_CDMS) +// Test Media Licenses by creating one and checking it is counted by the +// cookie counter. Then delete it and check that the cookie counter is back +// to zero. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, MediaLicenseDeletion) { + const std::string kMediaLicenseType = "MediaLicense"; + + EXPECT_EQ(0, GetSiteDataCount()); + EXPECT_EQ(0, GetMediaLicenseCount()); + GURL url = + embedded_test_server()->GetURL("/browsing_data/media_license.html"); + ui_test_utils::NavigateToURL(GetBrowser(), url); + + EXPECT_EQ(0, GetSiteDataCount()); + EXPECT_EQ(0, GetMediaLicenseCount()); + ExpectCookieTreeModelCount(GetBrowser(), 0); + EXPECT_FALSE(HasDataForType(kMediaLicenseType)); + + SetDataForType(kMediaLicenseType); + EXPECT_EQ(1, GetSiteDataCount()); + EXPECT_EQ(1, GetMediaLicenseCount()); + ExpectCookieTreeModelCount(GetBrowser(), 1); + EXPECT_TRUE(HasDataForType(kMediaLicenseType)); + + // No residue in regular mode. + ui_test_utils::NavigateToURL(GetRegularBrowser(), url); + EXPECT_EQ(0, GetMediaLicenseCount(GetRegularBrowser())); + EXPECT_FALSE(HasDataForType(kMediaLicenseType, GetRegularBrowser())); + + // Restart Incognito. + RestartIncognitoBrowser(); + ui_test_utils::NavigateToURL(GetBrowser(), url); + + EXPECT_EQ(0, GetSiteDataCount()); + EXPECT_EQ(0, GetMediaLicenseCount()); + ExpectCookieTreeModelCount(GetBrowser(), 0); + EXPECT_FALSE(HasDataForType(kMediaLicenseType)); +} +#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) + +// Note that |"StorageFoundation"| is not supported in Incognito. +const std::vector<std::string> kStorageTypes{ + "Cookie", "LocalStorage", "FileSystem", "SessionStorage", + "IndexedDb", "WebSql", "ServiceWorker", "CacheStorage"}; + +// Test that storage doesn't leave any traces on disk. +IN_PROC_BROWSER_TEST_F(IncognitoBrowsingDataBrowserTest, + StorageDoesntWriteToDisk) { + ASSERT_EQ(0, CheckUserDirectoryForString(kLocalHost, {})); + ASSERT_EQ(0, GetSiteDataCount()); + ExpectCookieTreeModelCount(GetBrowser(), 0); + + // To use secure-only features on a host name, we need an https server. + net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); + https_server.SetSSLConfig( + net::EmbeddedTestServer::CERT_COMMON_NAME_IS_DOMAIN); + base::FilePath path; + base::PathService::Get(content::DIR_TEST_DATA, &path); + https_server.ServeFilesFromDirectory(path); + ASSERT_TRUE(https_server.Start()); + + GURL url = https_server.GetURL(kLocalHost, "/browsing_data/site_data.html"); + ui_test_utils::NavigateToURL(GetBrowser(), url); + + for (const std::string& type : kStorageTypes) { + SetDataForType(type); + EXPECT_TRUE(HasDataForType(type)); + } + // TODO(crbug.com/846297): Add more datatypes for testing. E.g. notifications, + // payment handler, content settings, autofill, ...? + + int found = CheckUserDirectoryForString(kLocalHost, {}); + EXPECT_EQ(0, found) << "A file contains the hostname."; + + EXPECT_EQ(0, GetSiteDataCount(GetRegularBrowser())); + ExpectCookieTreeModelCount(GetRegularBrowser(), 0); + + RestartIncognitoBrowser(); + + EXPECT_EQ(0, GetSiteDataCount()); + ExpectCookieTreeModelCount(GetBrowser(), 0); +}
diff --git a/chrome/browser/captive_portal/captive_portal_browsertest.cc b/chrome/browser/captive_portal/captive_portal_browsertest.cc index cee5913..c8d3ac4 100644 --- a/chrome/browser/captive_portal/captive_portal_browsertest.cc +++ b/chrome/browser/captive_portal/captive_portal_browsertest.cc
@@ -2061,8 +2061,7 @@ CaptivePortalObserver portal_observer(browser()->profile()); captive_portal::CaptivePortalService* captive_portal_service = CaptivePortalServiceFactory::GetForProfile(browser()->profile()); - captive_portal_service->DetectCaptivePortal( - captive_portal::CaptivePortalProbeReason::kCertificateError); + captive_portal_service->DetectCaptivePortal(); portal_observer.WaitForResults(1); EXPECT_EQ(SSLBlockingPage::kTypeForTesting, GetInterstitialType(broken_tab_contents)); @@ -2071,8 +2070,7 @@ // captive portal interstitial should still not get recreated. SetBehindCaptivePortal(true); CaptivePortalObserver final_portal_observer(browser()->profile()); - captive_portal_service->DetectCaptivePortal( - captive_portal::CaptivePortalProbeReason::kCertificateError); + captive_portal_service->DetectCaptivePortal(); final_portal_observer.WaitForResults(1); EXPECT_EQ(SSLBlockingPage::kTypeForTesting, GetInterstitialType(broken_tab_contents)); @@ -2122,8 +2120,7 @@ CaptivePortalObserver portal_observer2(browser()->profile()); captive_portal::CaptivePortalService* captive_portal_service = CaptivePortalServiceFactory::GetForProfile(browser()->profile()); - captive_portal_service->DetectCaptivePortal( - captive_portal::CaptivePortalProbeReason::kCertificateError); + captive_portal_service->DetectCaptivePortal(); portal_observer2.WaitForResults(1); EXPECT_FALSE(IsShowingInterstitial(broken_tab_contents)); @@ -2178,8 +2175,7 @@ CaptivePortalObserver portal_observer2(browser()->profile()); captive_portal::CaptivePortalService* captive_portal_service = CaptivePortalServiceFactory::GetForProfile(browser()->profile()); - captive_portal_service->DetectCaptivePortal( - captive_portal::CaptivePortalProbeReason::kCertificateError); + captive_portal_service->DetectCaptivePortal(); portal_observer2.WaitForResults(1); EXPECT_FALSE(IsShowingInterstitial(broken_tab_contents)); @@ -2239,8 +2235,7 @@ CaptivePortalObserver portal_observer2(browser()->profile()); captive_portal::CaptivePortalService* captive_portal_service = CaptivePortalServiceFactory::GetForProfile(browser()->profile()); - captive_portal_service->DetectCaptivePortal( - captive_portal::CaptivePortalProbeReason::kCertificateError); + captive_portal_service->DetectCaptivePortal(); portal_observer2.WaitForResults(1); EXPECT_FALSE(IsShowingInterstitial(broken_tab_contents));
diff --git a/chrome/browser/extensions/api/automation/automation_apitest.cc b/chrome/browser/extensions/api/automation/automation_apitest.cc index b3a0471..9450043a 100644 --- a/chrome/browser/extensions/api/automation/automation_apitest.cc +++ b/chrome/browser/extensions/api/automation/automation_apitest.cc
@@ -444,7 +444,13 @@ << message_; } -IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopFocusIframe) { +// TODO(http://crbug.com/1229213): flaky on ChromeOS. +#if defined(OS_CHROMEOS) +#define MAYBE_DesktopFocusIframe DISABLED_DesktopFocusIframe +#else +#define MAYBE_DesktopFocusIframe DesktopFocusIframe +#endif +IN_PROC_BROWSER_TEST_F(AutomationApiTest, MAYBE_DesktopFocusIframe) { StartEmbeddedTestServer(); ASSERT_TRUE(RunExtensionTest("automation/tests/desktop", {.page_url = "focus_iframe.html"}))
diff --git a/chrome/browser/extensions/api/cookies/cookies_unittest.cc b/chrome/browser/extensions/api/cookies/cookies_unittest.cc index f3dadbe..1c31973 100644 --- a/chrome/browser/extensions/api/cookies/cookies_unittest.cc +++ b/chrome/browser/extensions/api/cookies/cookies_unittest.cc
@@ -195,7 +195,8 @@ std::unique_ptr<net::CanonicalCookie> canonical_cookie( net::CanonicalCookie::Create( GURL("http://test.com"), "=011Q255bNX_1!yd\203e+;path=/path\203", - base::Time::Now(), absl::nullopt /* server_time */)); + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_NE(nullptr, canonical_cookie.get()); Cookie cookie = cookies_helpers::CreateCookie(*canonical_cookie, "some cookie store");
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index bd72bc3..a883719 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -5079,7 +5079,8 @@ ASSERT_TRUE(cookie_store); auto cookie = net::CanonicalCookie::Create(ext_url, "dummy=value", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cookie_store->SetCanonicalCookieAsync( std::move(cookie), ext_url, net::CookieOptions::MakeAllInclusive(), base::BindOnce(&ExtensionCookieCallback::SetCookieCallback, @@ -5245,7 +5246,8 @@ std::unique_ptr<net::CanonicalCookie> cc( net::CanonicalCookie::Create(origin1, "dummy=value", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cc.get()); {
diff --git a/chrome/browser/lacros/cert_db_initializer_factory.cc b/chrome/browser/lacros/cert_db_initializer_factory.cc index a41888f..fb125b2 100644 --- a/chrome/browser/lacros/cert_db_initializer_factory.cc +++ b/chrome/browser/lacros/cert_db_initializer_factory.cc
@@ -48,6 +48,6 @@ } CertDbInitializerImpl* result = new CertDbInitializerImpl(profile); - result->Start(IdentityManagerFactory::GetForProfile(profile)); + result->Start(); return result; }
diff --git a/chrome/browser/lacros/cert_db_initializer_impl.cc b/chrome/browser/lacros/cert_db_initializer_impl.cc index 396ab36..00cbab8 100644 --- a/chrome/browser/lacros/cert_db_initializer_impl.cc +++ b/chrome/browser/lacros/cert_db_initializer_impl.cc
@@ -13,7 +13,6 @@ #include "chrome/browser/profiles/profile.h" #include "chromeos/crosapi/cpp/crosapi_constants.h" #include "chromeos/crosapi/mojom/cert_database.mojom.h" -#include "components/signin/public/identity_manager/identity_manager.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "crypto/chaps_support.h" @@ -60,42 +59,11 @@ } // namespace -class IdentityManagerObserver : public signin::IdentityManager::Observer { - public: - explicit IdentityManagerObserver(signin::IdentityManager* identity_manager) - : identity_manager_(identity_manager) { - DCHECK(identity_manager_); - identity_manager_->AddObserver(this); - } - - IdentityManagerObserver(const IdentityManagerObserver&) = delete; - IdentityManagerObserver& operator==(const IdentityManagerObserver&) = delete; - - ~IdentityManagerObserver() override { - identity_manager_->RemoveObserver(this); - } - - void WaitForRefreshTokensLoaded(base::OnceClosure callback) { - DCHECK(callback_.is_null()); - callback_ = std::move(callback); - } - - private: - void OnRefreshTokensLoaded() override { - if (!callback_) { - return; - } - std::move(callback_).Run(); // NOTE: may delete `this`. - } - - signin::IdentityManager* identity_manager_ = nullptr; - base::OnceClosure callback_; -}; - // ============================================================================= CertDbInitializerImpl::CertDbInitializerImpl(Profile* profile) : profile_(profile) { + DCHECK(profile_); DCHECK(chromeos::LacrosService::Get() ->IsAvailable<crosapi::mojom::CertDatabase>()); } @@ -106,45 +74,7 @@ OnCertDbInitializationFinished(false); } -void CertDbInitializerImpl::Start(signin::IdentityManager* identity_manager) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - - DCHECK(identity_manager); - // TODO(crbug.com/1148300): This is temporary. Until ~2021 - // `Profile::IsMainProfile()` method can return a false negative response if - // called before refresh tokens are loaded. This should be removed together - // with the entire usage of `IdentityManager` in this class when it is not the - // case anymore. - if (!identity_manager->AreRefreshTokensLoaded()) { - identity_manager_observer_ = - std::make_unique<IdentityManagerObserver>(identity_manager); - identity_manager_observer_->WaitForRefreshTokensLoaded( - base::BindOnce(&CertDbInitializerImpl::OnRefreshTokensLoaded, - weak_factory_.GetWeakPtr())); - return; - } - WaitForCertDbReady(); -} - -base::CallbackListSubscription CertDbInitializerImpl::WaitUntilReady( - ReadyCallback callback) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - - if (is_ready_.has_value()) { - std::move(callback).Run(is_ready_.value()); - return {}; - } - - return callbacks_.Add(std::move(callback)); -} - -void CertDbInitializerImpl::OnRefreshTokensLoaded() { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - identity_manager_observer_.reset(); - WaitForCertDbReady(); -} - -void CertDbInitializerImpl::WaitForCertDbReady() { +void CertDbInitializerImpl::Start() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (!profile_->IsMainProfile()) { @@ -159,6 +89,18 @@ weak_factory_.GetWeakPtr())); } +base::CallbackListSubscription CertDbInitializerImpl::WaitUntilReady( + ReadyCallback callback) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + if (is_ready_.has_value()) { + std::move(callback).Run(is_ready_.value()); + return {}; + } + + return callbacks_.Add(std::move(callback)); +} + void CertDbInitializerImpl::OnCertDbInfoReceived( crosapi::mojom::GetCertDatabaseInfoResultPtr cert_db_info) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
diff --git a/chrome/browser/lacros/cert_db_initializer_impl.h b/chrome/browser/lacros/cert_db_initializer_impl.h index 9a4e3a0..ded8637 100644 --- a/chrome/browser/lacros/cert_db_initializer_impl.h +++ b/chrome/browser/lacros/cert_db_initializer_impl.h
@@ -11,11 +11,9 @@ #include "chromeos/crosapi/mojom/cert_database.mojom.h" #include "chromeos/lacros/lacros_service.h" #include "components/keyed_service/core/keyed_service.h" -#include "components/signin/public/identity_manager/identity_manager.h" #include "mojo/public/cpp/bindings/remote.h" class Profile; -class IdentityManagerObserver; // Initializes certificate database in Lacros-Chrome. Public methods should be // called from the UI thread. Relies on CertDatabase mojo interface to be @@ -25,18 +23,14 @@ explicit CertDbInitializerImpl(Profile* profile); ~CertDbInitializerImpl() override; - // Starts the initialization. The first step is to wait for - // IdentityManager. - void Start(signin::IdentityManager* identity_manager); + // Starts the initialization. + void Start(); // CertDbInitializer base::CallbackListSubscription WaitUntilReady( ReadyCallback callback) override; private: - // It is called when IdentityManager is ready. - void OnRefreshTokensLoaded(); - // Checks that the current profile is the main profile and, if yes, makes a // mojo request to Ash-Chrome to get information about certificate database. void WaitForCertDbReady(); @@ -53,7 +47,6 @@ // This class is a `KeyedService` based on the `Profile`. An instance is // created together with a new profile and never outlives it.` Profile* profile_ = nullptr; - std::unique_ptr<IdentityManagerObserver> identity_manager_observer_; absl::optional<bool> is_ready_; base::OnceCallbackList<ReadyCallback::RunType> callbacks_;
diff --git a/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc b/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc index 9293124..c390e1c 100644 --- a/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc +++ b/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc
@@ -1789,7 +1789,7 @@ // Test UseCounter Features observed in multiple child frames are recorded, // exactly once per feature. IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, - UseCounterFeaturesInIframes) { + UseCounterFeaturesInMultipleIframes) { ASSERT_TRUE(embedded_test_server()->Start()); auto waiter = CreatePageLoadMetricsTestWaiter(); @@ -1856,7 +1856,7 @@ // Test UseCounter CSS Properties observed in multiple child frames are // recorded, exactly once per feature. IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, - UseCounterCSSPropertiesInIframes) { + UseCounterCSSPropertiesInMultipleIframes) { ASSERT_TRUE(embedded_test_server()->Start()); auto waiter = CreatePageLoadMetricsTestWaiter(); @@ -1907,7 +1907,7 @@ // Test UseCounter CSS Properties observed in multiple child frames are // recorded, exactly once per feature. IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, - UseCounterAnimatedCSSPropertiesInIframes) { + UseCounterAnimatedCSSPropertiesInMultipleIframes) { ASSERT_TRUE(embedded_test_server()->Start()); auto waiter = CreatePageLoadMetricsTestWaiter(); @@ -1944,6 +1944,7 @@ static_cast<int32_t>(WebFeature::kPageVisits), 1); } +// Test UseCounter Permissions Policy Usages in main frame. IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, UseCounterPermissionsPolicyUsageInMainFrame) { auto test_feature = static_cast<blink::UseCounterFeature::EnumValue>( @@ -1964,8 +1965,12 @@ histogram_tester_->ExpectBucketCount( internal::kPermissionsPolicyViolationHistogramName, test_feature, 1); + histogram_tester_->ExpectBucketCount( + internal::kPermissionsPolicyHeaderHistogramName, test_feature, 1); } +// Test UseCounter Permissions Policy Usages observed in child frame +// are recorded, exactly once per feature. IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, UseCounterPermissionsPolicyUsageInIframe) { auto test_feature = static_cast<blink::UseCounterFeature::EnumValue>( @@ -1986,10 +1991,17 @@ histogram_tester_->ExpectBucketCount( internal::kPermissionsPolicyViolationHistogramName, test_feature, 1); + histogram_tester_->ExpectBucketCount( + internal::kPermissionsPolicyHeaderHistogramName, test_feature, 1); + histogram_tester_->ExpectBucketCount( + internal::kPermissionsPolicyIframeAttributeHistogramName, test_feature, + 1); } +// Test UseCounter Permissions Policy Usages observed in multiple child frames +// are recorded, exactly once per feature. IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, - UseCounterPermissionsPolicyUsageInIframes) { + UseCounterPermissionsPolicyUsageInMultipleIframes) { auto test_feature = static_cast<blink::UseCounterFeature::EnumValue>( blink::mojom::PermissionsPolicyFeature::kFullscreen); @@ -2009,6 +2021,11 @@ histogram_tester_->ExpectBucketCount( internal::kPermissionsPolicyViolationHistogramName, test_feature, 1); + histogram_tester_->ExpectBucketCount( + internal::kPermissionsPolicyHeaderHistogramName, test_feature, 1); + histogram_tester_->ExpectBucketCount( + internal::kPermissionsPolicyIframeAttributeHistogramName, test_feature, + 1); } IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, LoadingMetrics) {
diff --git a/chrome/browser/permissions/chrome_permissions_client.h b/chrome/browser/permissions/chrome_permissions_client.h index 004b5d8d..739f064 100644 --- a/chrome/browser/permissions/chrome_permissions_client.h +++ b/chrome/browser/permissions/chrome_permissions_client.h
@@ -12,6 +12,9 @@ class ChromePermissionsClient : public permissions::PermissionsClient { public: + ChromePermissionsClient(const ChromePermissionsClient&) = delete; + ChromePermissionsClient& operator=(const ChromePermissionsClient&) = delete; + static ChromePermissionsClient* GetInstance(); // PermissionsClient: @@ -92,9 +95,6 @@ friend base::NoDestructor<ChromePermissionsClient>; ChromePermissionsClient() = default; - - ChromePermissionsClient(const ChromePermissionsClient&) = delete; - ChromePermissionsClient& operator=(const ChromePermissionsClient&) = delete; }; #endif // CHROME_BROWSER_PERMISSIONS_CHROME_PERMISSIONS_CLIENT_H_
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc index b28d8f17..8f37d68 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc
@@ -337,7 +337,8 @@ ->GetNetworkContext() ->GetCookieManager(cookie_manager.BindNewPipeAndPassReceiver()); std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create( - url, value, base::Time::Now(), absl::nullopt /* server_time */)); + url, value, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); EXPECT_TRUE(cc.get()); net::CookieOptions options;
diff --git a/chrome/browser/resources/chromeos/accessibility/accessibility_common/magnifier/magnifier_test.js b/chrome/browser/resources/chromeos/accessibility/accessibility_common/magnifier/magnifier_test.js index c9854ba2..b8e867cb 100644 --- a/chrome/browser/resources/chromeos/accessibility/accessibility_common/magnifier/magnifier_test.js +++ b/chrome/browser/resources/chromeos/accessibility/accessibility_common/magnifier/magnifier_test.js
@@ -182,7 +182,8 @@ }); }); -TEST_F('MagnifierE2ETest', 'MagnifierCenterOnPoint', function() { +// Disabled - failing on ASan: crbug.com/1236009 +TEST_F('MagnifierE2ETest', 'DISABLED_MagnifierCenterOnPoint', function() { this.runWithLoadedTree('', async function(root) { const targetPoint = {x: 100, y: 100}; const targetBounds = {left: 100, top: 100, width: 0, height: 0};
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/background_test.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/background_test.js index d27e6fd..c1434eb 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/background_test.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/background_test.js
@@ -3670,3 +3670,14 @@ contentEditable.focus(); }); }); + +TEST_F('ChromeVoxBackgroundTest', 'ShowContextMenuOnViewsTab', function() { + const mockFeedback = this.createMockFeedback(); + const site = `<p>test</p>`; + this.runWithLoadedTree(site, function(root) { + const tabs = root.findAll({Role: RoleType.TAB}); + assertTrue(tabs.length > 0); + tabs[0].showContextMenu(); + mockFeedback.expectSpeech(/menu opened/).replay(); + }); +});
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/base_automation_handler.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/base_automation_handler.js index 7ca4c9ab..3edfda5 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/base_automation_handler.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/base_automation_handler.js
@@ -104,7 +104,7 @@ if (!DesktopAutomationHandler.announceActions && (prevRange && !prevRange.requiresRecovery()) && evt.eventFrom === 'action' && - evt.eventFromAction !== ActionType.DO_DEFAULT) { + !BaseAutomationHandler.allowEventFromAction_(evt.eventFromAction)) { return; } @@ -123,5 +123,15 @@ ChromeVoxState.instance.currentRange, prevRange, evt.type); output.go(); } + + /** + * @param {ActionType} eventFromAction + * @return {boolean} + * @private + */ + static allowEventFromAction_(eventFromAction) { + return eventFromAction === ActionType.DO_DEFAULT || + eventFromAction === ActionType.SHOW_CONTEXT_MENU; + } }; }); // goog.scope
diff --git a/chrome/browser/resources/chromeos/login/enterprise_enrollment.html b/chrome/browser/resources/chromeos/login/enterprise_enrollment.html index 56244bf..9cf493d 100644 --- a/chrome/browser/resources/chromeos/login/enterprise_enrollment.html +++ b/chrome/browser/resources/chromeos/login/enterprise_enrollment.html
@@ -101,8 +101,6 @@ class="flex layout vertical center center-justified"> <img srcset="images/1x/error.svg 1x, images/2x/error.svg 2x" - alt$="[[i18nDynamic(locale, - 'enrollmentErrorIllustrationTitle')]]" class="oobe-illustration"> </div> <div slot="back-navigation"> @@ -165,16 +163,10 @@ <div slot="content" class="flex layout vertical center center-justified"> <img srcset="images/enrollment_success_illustration_1x.png 1x, images/enrollment_success_illustration_2x.png 2x" - alt$="[[i18nDynamic(locale, - 'enrollmentSuccessIllustrationTitle')]]" class="oobe-illustration illustration-old"> <img src="images/enrollment_complete.svg" - alt$="[[i18nDynamic(locale, - 'enrollmentSuccessIllustrationTitle')]]" class="oobe-illustration illustration" hidden="[[isMeet_]]"> <img src="images/cfm/enrollment.svg" - alt$="[[i18nDynamic(locale, - 'enrollmentSuccessIllustrationTitle')]]" class="oobe-illustration illustration" hidden="[[!isMeet_]]"> </div> <div slot="bottom-buttons">
diff --git a/chrome/browser/resources/chromeos/login/family_link_notice.html b/chrome/browser/resources/chromeos/login/family_link_notice.html index 8290d829..4ed0592 100644 --- a/chrome/browser/resources/chromeos/login/family_link_notice.html +++ b/chrome/browser/resources/chromeos/login/family_link_notice.html
@@ -32,8 +32,7 @@ </div> <div slot="content" class="flex layout vertical center center-justified"> <img srcset="images/1x/parental_control.svg 1x, - images/2x/parental_control.svg 2x" class="oobe-illustration" - alt$="[[i18nDynamic(locale, 'familyLinkDialogTitle')]]"> + images/2x/parental_control.svg 2x" class="oobe-illustration"> </div> <div slot="bottom-buttons"> <oobe-next-button id="continueButton"
diff --git a/chrome/browser/resources/chromeos/login/oobe_adb_sideloading_screen.html b/chrome/browser/resources/chromeos/login/oobe_adb_sideloading_screen.html index cbb177a1..e9bb4a04 100644 --- a/chrome/browser/resources/chromeos/login/oobe_adb_sideloading_screen.html +++ b/chrome/browser/resources/chromeos/login/oobe_adb_sideloading_screen.html
@@ -38,9 +38,7 @@ <div slot="content" class="flex layout vertical center center-justified"> <img srcset="images/1x/arc_sideloading_illustration.svg 1x, images/2x/arc_sideloading_illustration.svg 2x" - class="oobe-illustration" - alt="[[i18nDynamic(locale, - 'enableAdbSideloadingIllustrationTitle')]]"> + class="oobe-illustration"> </div> <div slot="bottom-buttons"> <oobe-text-button border on-click="onCancelTap_" @@ -69,9 +67,7 @@ <div slot="content" class="flex layout vertical center center-justified"> <img srcset="images/1x/error.svg 1x, images/2x/error.svg 2x" - class="oobe-illustration" - alt="[[i18nDynamic(locale, - 'enableAdbSideloadingErrorIllustrationTitle')]]"> + class="oobe-illustration"> </div> <div slot="bottom-buttons"> <oobe-text-button inverse on-click="onCancelTap_" class="focus-on-show"
diff --git a/chrome/browser/resources/chromeos/login/oobe_reset.html b/chrome/browser/resources/chromeos/login/oobe_reset.html index 81983a3..b16431b 100644 --- a/chrome/browser/resources/chromeos/login/oobe_reset.html +++ b/chrome/browser/resources/chromeos/login/oobe_reset.html
@@ -95,10 +95,8 @@ <!-- Reset screen illustration --> <img srcset="images/1x/reset_illustration_1x.svg 1x, images/2x/reset_illustration_2x.svg 2x" - class="illustration-old" - alt$="[[i18nDynamic(locale, 'resetScreenIllustrationTitle')]]"> - <img src="images/powerwash.svg" class="illustration" - alt$="[[i18nDynamic(locale, 'resetScreenIllustrationTitle')]]"> + class="illustration-old"> + <img src="images/powerwash.svg" class="illustration"> <!-- TPM Update - Only shown during powerwash state --> <div id="tpmFirmwareUpdate" class="layout horizontal" hidden="[[!inPowerwashState_]]">
diff --git a/chrome/browser/resources/chromeos/login/parental_handoff.html b/chrome/browser/resources/chromeos/login/parental_handoff.html index 8682b6fe..f32f827 100644 --- a/chrome/browser/resources/chromeos/login/parental_handoff.html +++ b/chrome/browser/resources/chromeos/login/parental_handoff.html
@@ -32,8 +32,8 @@ </p> <div slot="content" class="flex layout vertical center center-justified"> <img srcset="images/1x/kids_turn.svg 1x, - images/2x/kids_turn.svg 2x" class="oobe-illustration" - alt$="[[i18nDynamic(locale, 'parentalHandoffDialogTitle', username_)]]"> + images/2x/kids_turn.svg 2x" + class="oobe-illustration"> </div> <div slot="bottom-buttons"> <oobe-next-button id="nextButton"
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/packaged_license.html b/chrome/browser/resources/chromeos/login/screens/oobe/packaged_license.html index d91bfb4..d3c505e 100644 --- a/chrome/browser/resources/chromeos/login/screens/oobe/packaged_license.html +++ b/chrome/browser/resources/chromeos/login/screens/oobe/packaged_license.html
@@ -37,8 +37,7 @@ </p> <div slot="content" class="flex layout vertical center center-justified"> <img src="../../images/enrollment_complete.svg" - class="oobe-illustration" - alt$="[[i18nDynamic(locale, 'oobePackagedLicenseTitle')]]"> + class="oobe-illustration"> </div> <div slot="bottom-buttons"> <oobe-text-button id="dont-enroll-button"
diff --git a/chrome/browser/sync/test/integration/enable_disable_test.cc b/chrome/browser/sync/test/integration/enable_disable_test.cc index a07c35a..1f510be 100644 --- a/chrome/browser/sync/test/integration/enable_disable_test.cc +++ b/chrome/browser/sync/test/integration/enable_disable_test.cc
@@ -31,7 +31,6 @@ using syncer::ModelTypeFromString; using syncer::ModelTypeSet; using syncer::ModelTypeToString; -using syncer::ProxyTypes; using syncer::SyncUserSettings; using syncer::UserSelectableType; using syncer::UserSelectableTypeSet; @@ -63,8 +62,8 @@ return multi; } -// This test enables and disables types and verifies the type is sufficiently -// affected by checking for existence of a root node. +// This test enables and disables types and verifies the type is active via +// SyncService::GetActiveDataTypes(). class EnableDisableSingleClientTest : public SyncTest { public: EnableDisableSingleClientTest() : SyncTest(SINGLE_CLIENT) {} @@ -73,33 +72,8 @@ // Don't use self-notifications as they can trigger additional sync cycles. bool TestUsesSelfNotifications() override { return false; } - bool ModelTypeExists(ModelType type) { - base::RunLoop loop; - std::unique_ptr<base::ListValue> all_nodes; - GetSyncService(0)->GetAllNodesForDebugging( - base::BindLambdaForTesting([&](std::unique_ptr<base::ListValue> nodes) { - all_nodes = std::move(nodes); - loop.Quit(); - })); - loop.Run(); - // Look for the root node corresponding to |type|. - for (const base::Value& value : all_nodes->GetList()) { - DCHECK(value.is_dict()); - const base::Value* nodes = value.FindKey("nodes"); - DCHECK(nodes); - DCHECK(nodes->is_list()); - // Ignore types that are empty, because we expect the root node. - if (nodes->GetList().empty()) { - continue; - } - const base::Value* model_type = value.FindKey("type"); - DCHECK(model_type); - DCHECK(model_type->is_string()); - if (type == ModelTypeFromString(model_type->GetString())) { - return true; - } - } - return false; + bool IsModelTypeActive(ModelType type) { + return GetSyncService(0)->GetActiveDataTypes().Has(type); } void InjectSyncedBookmark() { @@ -136,7 +110,6 @@ ModelTypeSet grouped_types = syncer::SyncUserSettingsImpl::ResolvePreferredTypesForTesting({type}); grouped_types.RetainAll(registered_data_types_); - grouped_types.RemoveAll(ProxyTypes()); return grouped_types; } @@ -158,10 +131,17 @@ // Setup sync with no enabled types. SetupTest(/*all_types_enabled=*/false); + // Certain datatypes like SESSIONS can be configured by multiple + // user-selectable types. Hence, enabling a new user-selectable type doesn't + // necessarily mean that the datatype (SESSIONS) will be newly-configured. In + // this particular test, this influences whether the engine will issue UMA + // corresponding to the configuration cycle. + syncer::ModelTypeSet previously_active_types; + for (UserSelectableType type : registered_selectable_types_) { const ModelTypeSet grouped_types = ResolveGroup(type); for (ModelType single_grouped_type : WithoutMultiTypes(grouped_types)) { - ASSERT_FALSE(ModelTypeExists(single_grouped_type)) + ASSERT_FALSE(IsModelTypeActive(single_grouped_type)) << " for " << GetUserSelectableTypeName(type); } @@ -169,15 +149,21 @@ EXPECT_TRUE(GetClient(0)->EnableSyncForType(type)); for (ModelType grouped_type : grouped_types) { - EXPECT_TRUE(ModelTypeExists(grouped_type)) + EXPECT_TRUE(IsModelTypeActive(grouped_type)) << " for " << GetUserSelectableTypeName(type); - if (syncer::CommitOnlyTypes().Has(grouped_type)) { + if (!syncer::ProtocolTypes().Has(grouped_type) || + syncer::CommitOnlyTypes().Has(grouped_type)) { EXPECT_EQ(0, histogram_tester.GetBucketCount( "Sync.PostedDataTypeGetUpdatesRequest", static_cast<int>(ModelTypeHistogramValue(grouped_type)))) << " for " << ModelTypeToString(grouped_type); + } else if (previously_active_types.Has(grouped_type)) { + // If the type was already configured, no additional configuration cycle + // is expected, but it's impossible to rule out that the type has issued + // a GetUpdates request for different reasons (since it's actively + // sync-ing). } else { EXPECT_NE(0, histogram_tester.GetBucketCount( @@ -185,6 +171,8 @@ static_cast<int>(ModelTypeHistogramValue(grouped_type)))) << " for " << ModelTypeToString(grouped_type); } + + previously_active_types.Put(grouped_type); } } } @@ -196,14 +184,14 @@ for (UserSelectableType type : registered_selectable_types_) { const ModelTypeSet grouped_types = ResolveGroup(type); for (ModelType grouped_type : grouped_types) { - ASSERT_TRUE(ModelTypeExists(grouped_type)) + ASSERT_TRUE(IsModelTypeActive(grouped_type)) << " for " << GetUserSelectableTypeName(type); } EXPECT_TRUE(GetClient(0)->DisableSyncForType(type)); for (ModelType single_grouped_type : WithoutMultiTypes(grouped_types)) { - EXPECT_FALSE(ModelTypeExists(single_grouped_type)) + EXPECT_FALSE(IsModelTypeActive(single_grouped_type)) << " for " << GetUserSelectableTypeName(type); } } @@ -211,7 +199,7 @@ // Lastly make sure that all the multi grouped times are all gone, since we // did not check these after disabling inside the above loop. for (ModelType multi_grouped_type : multi_grouped_types_) { - EXPECT_FALSE(ModelTypeExists(multi_grouped_type)) + EXPECT_FALSE(IsModelTypeActive(multi_grouped_type)) << " for " << ModelTypeToString(multi_grouped_type); } } @@ -225,7 +213,7 @@ const ModelTypeSet grouped_types = ResolveGroup(type); const ModelTypeSet single_grouped_types = WithoutMultiTypes(grouped_types); for (ModelType single_grouped_type : single_grouped_types) { - ASSERT_FALSE(ModelTypeExists(single_grouped_type)) + ASSERT_FALSE(IsModelTypeActive(single_grouped_type)) << " for " << GetUserSelectableTypeName(type); } @@ -235,7 +223,7 @@ EXPECT_TRUE(GetClient(0)->DisableSyncForType(type)); for (ModelType single_grouped_type : single_grouped_types) { - EXPECT_FALSE(ModelTypeExists(single_grouped_type)) + EXPECT_FALSE(IsModelTypeActive(single_grouped_type)) << " for " << GetUserSelectableTypeName(type); } } @@ -243,7 +231,7 @@ // Lastly make sure that all the multi grouped times are all gone, since we // did not check these after disabling inside the above loop. for (ModelType multi_grouped_type : multi_grouped_types_) { - EXPECT_FALSE(ModelTypeExists(multi_grouped_type)) + EXPECT_FALSE(IsModelTypeActive(multi_grouped_type)) << " for " << ModelTypeToString(multi_grouped_type); } } @@ -256,7 +244,7 @@ for (UserSelectableType type : registered_selectable_types_) { const ModelTypeSet grouped_types = ResolveGroup(type); for (ModelType grouped_type : grouped_types) { - ASSERT_TRUE(ModelTypeExists(grouped_type)) + ASSERT_TRUE(IsModelTypeActive(grouped_type)) << " for " << GetUserSelectableTypeName(type); } @@ -266,7 +254,7 @@ EXPECT_TRUE(GetClient(0)->EnableSyncForType(type)); for (ModelType grouped_type : grouped_types) { - EXPECT_TRUE(ModelTypeExists(grouped_type)) + EXPECT_TRUE(IsModelTypeActive(grouped_type)) << " for " << GetUserSelectableTypeName(type); } } @@ -281,7 +269,7 @@ const ModelTypeSet single_grouped_types = WithoutMultiTypes(ResolveGroup(type)); for (ModelType single_grouped_type : single_grouped_types) { - ASSERT_FALSE(ModelTypeExists(single_grouped_type)) + ASSERT_FALSE(IsModelTypeActive(single_grouped_type)) << " for " << GetUserSelectableTypeName(type); } @@ -292,7 +280,7 @@ EXPECT_TRUE(GetClient(0)->EnableSyncForType(type)); for (ModelType single_grouped_type : single_grouped_types) { - EXPECT_TRUE(ModelTypeExists(single_grouped_type)) + EXPECT_TRUE(IsModelTypeActive(single_grouped_type)) << " for " << GetUserSelectableTypeName(type); } } @@ -309,7 +297,7 @@ for (UserSelectableType type : UserSelectableTypeSet::All()) { for (ModelType grouped_type : ResolveGroup(type)) { - EXPECT_FALSE(ModelTypeExists(grouped_type)) + EXPECT_FALSE(IsModelTypeActive(grouped_type)) << " for " << GetUserSelectableTypeName(type); } } @@ -326,7 +314,7 @@ for (UserSelectableType type : UserSelectableTypeSet::All()) { for (ModelType model_type : ResolveGroup(type)) { - EXPECT_TRUE(ModelTypeExists(model_type)) + EXPECT_TRUE(IsModelTypeActive(model_type)) << " for " << ModelTypeToString(model_type); } } @@ -344,7 +332,7 @@ for (UserSelectableType type : UserSelectableTypeSet::All()) { for (ModelType model_type : ResolveGroup(type)) { - EXPECT_TRUE(ModelTypeExists(model_type)) + EXPECT_TRUE(IsModelTypeActive(model_type)) << " for " << ModelTypeToString(model_type); } }
diff --git a/chrome/browser/tab/BUILD.gn b/chrome/browser/tab/BUILD.gn index da7a8bc..962cb52 100644 --- a/chrome/browser/tab/BUILD.gn +++ b/chrome/browser/tab/BUILD.gn
@@ -62,7 +62,6 @@ deps = [ ":critical_persisted_tab_data_proto_java", ":java_resources", - ":optimization_guide_protos_java", "//base:base_java", "//chrome/browser/android/crypto:java", "//chrome/browser/contextmenu:java", @@ -75,6 +74,7 @@ "//chrome/browser/ui/android/native_page:java", "//chrome/browser/ui/android/strings:ui_strings_grd", "//components/browser_ui/util/android:java", + "//components/commerce/core:proto_java", "//components/embedder_support/android:browser_context_java", "//components/embedder_support/android:content_view_java", "//components/embedder_support/android:util_java", @@ -130,11 +130,6 @@ ] } -proto_java_library("optimization_guide_protos_java") { - proto_path = "java/src/org/chromium/chrome/browser/tab/state/proto" - sources = [ "$proto_path/price_tracking.proto" ] -} - android_library("junit") { bypass_platform_checks = true testonly = true
diff --git a/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabData.java b/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabData.java index 49dd5de..0f94acf 100644 --- a/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabData.java +++ b/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/state/ShoppingPersistedTabData.java
@@ -26,10 +26,10 @@ import org.chromium.chrome.browser.page_annotations.ProductPriceUpdatePageAnnotation; import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.Tab; -import org.chromium.chrome.browser.tab.proto.PriceTracking.BuyableProduct; -import org.chromium.chrome.browser.tab.proto.PriceTracking.PriceTrackingData; -import org.chromium.chrome.browser.tab.proto.PriceTracking.ProductPriceUpdate; import org.chromium.chrome.browser.tab.proto.ShoppingPersistedTabData.ShoppingPersistedTabDataProto; +import org.chromium.components.commerce.PriceTracking.BuyableProduct; +import org.chromium.components.commerce.PriceTracking.PriceTrackingData; +import org.chromium.components.commerce.PriceTracking.ProductPriceUpdate; import org.chromium.components.optimization_guide.OptimizationGuideDecision; import org.chromium.components.optimization_guide.proto.HintsProto; import org.chromium.components.payments.CurrencyFormatter;
diff --git a/chrome/browser/ui/android/toolbar/BUILD.gn b/chrome/browser/ui/android/toolbar/BUILD.gn index 5485ecb2..593f012 100644 --- a/chrome/browser/ui/android/toolbar/BUILD.gn +++ b/chrome/browser/ui/android/toolbar/BUILD.gn
@@ -264,7 +264,6 @@ "java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarButtonControllerTest.java", "java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarStatePredictorTest.java", "java/src/org/chromium/chrome/browser/toolbar/adaptive/OptionalNewTabButtonControllerUnitTest.java", - "java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragmentUnitTest.java", "java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuButtonCoordinatorTest.java", "java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuButtonMediatorTest.java", "java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuButtonTest.java", @@ -305,11 +304,8 @@ "//third_party/android_deps:guava_android_java", "//third_party/android_deps:robolectric_all_java", "//third_party/android_support_test_runner:runner_java", - "//third_party/androidx:androidx_fragment_fragment_java", - "//third_party/androidx:androidx_recyclerview_recyclerview_java", "//third_party/androidx:androidx_test_core_java", "//third_party/androidx:androidx_test_runner_java", - "//third_party/androidx:androidx_viewpager2_viewpager2_java", "//third_party/hamcrest:hamcrest_library_java", "//third_party/junit", "//third_party/mockito:mockito_java",
diff --git a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragment.java b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragment.java index fb378ed..da0c083d 100644 --- a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragment.java +++ b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragment.java
@@ -85,6 +85,6 @@ @VisibleForTesting /*package*/ void setCanUseVoiceSearchForTesting(boolean canUseVoiceSearch) { - mRadioButtonGroup.setCanUseVoiceSearch(canUseVoiceSearch); + mRadioButtonGroup.setCanUseVoiceSearch(false); } }
diff --git a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragmentUnitTest.java b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragmentUnitTest.java deleted file mode 100644 index 8da9cefe..0000000 --- a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragmentUnitTest.java +++ /dev/null
@@ -1,124 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.chrome.browser.toolbar.adaptive.settings; - -import static org.junit.Assert.assertEquals; - -import android.os.Looper; -import android.util.Pair; -import android.view.View; - -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; -import androidx.viewpager2.adapter.FragmentStateAdapter; -import androidx.viewpager2.widget.ViewPager2; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; -import org.robolectric.Robolectric; -import org.robolectric.Shadows; -import org.robolectric.annotation.Config; -import org.robolectric.annotation.LooperMode; - -import org.chromium.base.test.BaseRobolectricTestRunner; -import org.chromium.chrome.browser.flags.ChromeFeatureList; -import org.chromium.chrome.browser.toolbar.adaptive.AdaptiveToolbarFeatures; -import org.chromium.chrome.browser.toolbar.adaptive.AdaptiveToolbarFeatures.AdaptiveToolbarButtonVariant; -import org.chromium.chrome.browser.toolbar.adaptive.AdaptiveToolbarStatePredictor; -import org.chromium.chrome.test.util.browser.Features; -import org.chromium.chrome.test.util.browser.Features.DisableFeatures; -import org.chromium.chrome.test.util.browser.Features.EnableFeatures; -import org.chromium.components.browser_ui.widget.RadioButtonWithDescription; - -/** - * Unit tests for {@link AdaptiveToolbarPreferenceFragment} and {@link - * RadioButtonGroupAdaptiveToolbarPreference}. - */ -@RunWith(BaseRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@LooperMode(LooperMode.Mode.PAUSED) -public class AdaptiveToolbarPreferenceFragmentUnitTest { - @Rule - public TestRule mProcessor = new Features.JUnitProcessor(); - - private FragmentActivity mTestActivity; - private AdaptiveToolbarPreferenceFragment mFragment; - - private static class TestFragmentAdapter extends FragmentStateAdapter { - private AdaptiveToolbarPreferenceFragment mLastFragment; - - public TestFragmentAdapter(FragmentActivity fragmentActivity) { - super(fragmentActivity); - } - - @Override - public Fragment createFragment(int i) { - mLastFragment = new AdaptiveToolbarPreferenceFragment(); - return mLastFragment; - } - - public AdaptiveToolbarPreferenceFragment getLastFragment() { - return mLastFragment; - } - - @Override - public int getItemCount() { - return 1; - } - } - - @Before - public void setUp() { - AdaptiveToolbarStatePredictor.setSegmentationResultsForTesting( - new Pair<>(true, AdaptiveToolbarButtonVariant.NEW_TAB)); - - mTestActivity = Robolectric.setupActivity(FragmentActivity.class); - ViewPager2 view = new ViewPager2(mTestActivity); - mTestActivity.setContentView(view); - - TestFragmentAdapter adapter = new TestFragmentAdapter(mTestActivity); - view.setAdapter(adapter); - Shadows.shadowOf(Looper.getMainLooper()).idle(); - mFragment = adapter.getLastFragment(); - } - - @After - public void tearDown() { - AdaptiveToolbarStatePredictor.setSegmentationResultsForTesting(null); - AdaptiveToolbarFeatures.clearParsedParamsForTesting(); - } - - @Test - @EnableFeatures({ChromeFeatureList.ADAPTIVE_BUTTON_IN_TOP_TOOLBAR_CUSTOMIZATION}) - @DisableFeatures({ChromeFeatureList.VOICE_SEARCH_AUDIO_CAPTURE_POLICY}) - public void testCanUseVoiceSearch_enabled() { - mFragment.setCanUseVoiceSearchForTesting(true); - - RadioButtonGroupAdaptiveToolbarPreference radioButtonGroup = mFragment.findPreference( - AdaptiveToolbarPreferenceFragment.PREF_ADAPTIVE_RADIO_GROUP); - RadioButtonWithDescription voiceButton = - radioButtonGroup.getButton(AdaptiveToolbarButtonVariant.VOICE); - - assertEquals(View.VISIBLE, voiceButton.getVisibility()); - } - - @Test - @EnableFeatures({ChromeFeatureList.ADAPTIVE_BUTTON_IN_TOP_TOOLBAR_CUSTOMIZATION}) - @DisableFeatures({ChromeFeatureList.VOICE_SEARCH_AUDIO_CAPTURE_POLICY}) - public void testCanUseVoiceSearch_disabled() { - mFragment.setCanUseVoiceSearchForTesting(false); - - RadioButtonGroupAdaptiveToolbarPreference radioButtonGroup = mFragment.findPreference( - AdaptiveToolbarPreferenceFragment.PREF_ADAPTIVE_RADIO_GROUP); - RadioButtonWithDescription voiceButton = - radioButtonGroup.getButton(AdaptiveToolbarButtonVariant.VOICE); - - assertEquals(View.GONE, voiceButton.getVisibility()); - } -}
diff --git a/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.cc b/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.cc index 1084f19..2263173 100644 --- a/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.cc +++ b/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.h" +#include "ash/constants/ash_features.h" #include "ash/public/cpp/shell_window_ids.h" #include "ash/root_window_controller.h" #include "chrome/browser/apps/platform_apps/app_window_registry_util.h" @@ -61,6 +62,19 @@ CHECK(!views::WidgetObserver::IsInObserverList()); } +void ChromeKeyboardBoundsObserver::OnKeyboardVisibleBoundsChanged( + const gfx::Rect& screen_bounds) { + if (base::FeatureList::IsEnabled(chromeos::features::kVirtualKeyboardApi)) { + std::unique_ptr<content::RenderWidgetHostIterator> hosts( + content::RenderWidgetHost::GetRenderWidgetHosts()); + + while (content::RenderWidgetHost* host = hosts->GetNextHost()) { + content::RenderWidgetHostView* view = host->GetView(); + view->NotifyVirtualKeyboardOverlayRect(screen_bounds); + } + } +} + void ChromeKeyboardBoundsObserver::OnKeyboardOccludedBoundsChanged( const gfx::Rect& screen_bounds) { DVLOG(1) << "OnKeyboardOccludedBoundsChanged: " << screen_bounds.ToString();
diff --git a/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.h b/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.h index e6d3d5f1..2b74d8a 100644 --- a/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.h +++ b/chrome/browser/ui/ash/keyboard/chrome_keyboard_bounds_observer.h
@@ -27,6 +27,7 @@ // keyboard::ChromeKeyboardControllerClient::Observer: void OnKeyboardVisibilityChanged(bool visible) override {} + void OnKeyboardVisibleBoundsChanged(const gfx::Rect& screen_bounds) override; void OnKeyboardOccludedBoundsChanged(const gfx::Rect& screen_bounds) override; private:
diff --git a/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.cc b/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.cc index b6b96a5..221ec5b 100644 --- a/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.cc +++ b/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.cc
@@ -324,6 +324,10 @@ if (keyboard_contents_) keyboard_contents_->SetInitialContentsSize(screen_bounds.size()); + for (auto& observer : observers_) { + observer.OnKeyboardVisibleBoundsChanged(screen_bounds); + } + if (!GetKeyboardWindow()) return;
diff --git a/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h b/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h index aa2ede1..bf550bfa 100644 --- a/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h +++ b/chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h
@@ -46,6 +46,9 @@ // This is used by oobe and login to adjust the UI. virtual void OnKeyboardVisibilityChanged(bool visible) {} + virtual void OnKeyboardVisibleBoundsChanged( + const gfx::Rect& screen_bounds) {} + // Forwards the 'OnKeyboardOccludedBoundsChanged' observer method. // This is used to update the insets of browser and app windows when the // keyboard is shown.
diff --git a/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc b/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc index 9e20760..c1e7872 100644 --- a/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc +++ b/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc
@@ -62,7 +62,7 @@ // Send this event immediately to push the initial desktop tree state. pending_events_.push_back({tree_->GetRoot()->GetUniqueId(), ax::mojom::Event::kLoadComplete, -1, - is_performing_action_}); + currently_performing_action_}); SendPendingEvents(); // Intentionally not reset at shutdown since we cannot rely on the shutdown // ordering of two base::Singletons. @@ -172,13 +172,13 @@ void AutomationManagerAura::PerformAction(const ui::AXActionData& data) { CHECK(enabled_); - base::AutoReset<bool> reset_is_performing_action(&is_performing_action_, - true); + base::AutoReset<ax::mojom::Action> reset_currently_performing_action( + ¤tly_performing_action_, data.action); // Exclude the do default action, which can trigger too many important events // that should not be ignored by clients like focus. if (data.action == ax::mojom::Action::kDoDefault) - is_performing_action_ = false; + currently_performing_action_ = ax::mojom::Action::kNone; // Unlike all of the other actions, a hit test requires determining the // node to perform the action on first. @@ -244,7 +244,7 @@ ax::mojom::Event event_type, int action_request_id) { pending_events_.push_back( - {id, event_type, action_request_id, is_performing_action_}); + {id, event_type, action_request_id, currently_performing_action_}); if (processing_posted_) return; @@ -296,8 +296,10 @@ ui::AXEvent event; event.id = aura_obj->GetUniqueId(); event.event_type = event_type; - if (event_copy.is_performing_action) + if (event_copy.currently_performing_action != ax::mojom::Action::kNone) { event.event_from = ax::mojom::EventFrom::kAction; + event.event_from_action = event_copy.currently_performing_action; + } event.action_request_id = event_copy.action_request_id; events.push_back(event); }
diff --git a/chrome/browser/ui/aura/accessibility/automation_manager_aura.h b/chrome/browser/ui/aura/accessibility/automation_manager_aura.h index be0c7b2..6f3bb0d2 100644 --- a/chrome/browser/ui/aura/accessibility/automation_manager_aura.h +++ b/chrome/browser/ui/aura/accessibility/automation_manager_aura.h
@@ -131,7 +131,7 @@ int id; ax::mojom::Event event_type; int action_request_id; - bool is_performing_action; + ax::mojom::Action currently_performing_action; }; std::vector<Event> pending_events_; @@ -145,7 +145,7 @@ std::unique_ptr<views::AXAuraObjCache> cache_; - bool is_performing_action_ = false; + ax::mojom::Action currently_performing_action_ = ax::mojom::Action::kNone; base::ScopedObservation<extensions::AutomationEventRouter, extensions::AutomationEventRouterObserver>
diff --git a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc index 39e654f3..6a924e2 100644 --- a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc
@@ -196,7 +196,8 @@ GURL origin("http://google.com"); std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( - origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie); PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame()) ->OnCookiesAccessed({content::CookieAccessDetails::Type::kChange,
diff --git a/chrome/browser/ui/views/menu_item_view_interactive_uitest.cc b/chrome/browser/ui/views/menu_item_view_interactive_uitest.cc index 84895724..fc678fe 100644 --- a/chrome/browser/ui/views/menu_item_view_interactive_uitest.cc +++ b/chrome/browser/ui/views/menu_item_view_interactive_uitest.cc
@@ -218,7 +218,13 @@ VIEW_TEST(MenuItemViewTestInsertWithSubmenu0, InsertItemWithSubmenu0) // If this flakes, disable and log details in http://crbug.com/523255. -VIEW_TEST(MenuItemViewTestInsertWithSubmenu1, InsertItemWithSubmenu1) +// Failing on Linux Ozone Tester (Wayland) (See crbug.com/1236048). +#if defined(USE_OZONE) +#define MAYBE_InsertItemWithSubmenu1 DISABLED_InsertItemWithSubmenu1 +#else +#define MAYBE_InsertItemWithSubmenu1 InsertItemWithSubmenu1 +#endif +VIEW_TEST(MenuItemViewTestInsertWithSubmenu1, MAYBE_InsertItemWithSubmenu1) // Test class for removing a menu item while the menu is open. template <int REMOVE_INDEX, int SELECT_INDEX>
diff --git a/chrome/browser/ui/views/overlay/back_to_tab_label_button.cc b/chrome/browser/ui/views/overlay/back_to_tab_label_button.cc index 4a6cb79a..701d212 100644 --- a/chrome/browser/ui/views/overlay/back_to_tab_label_button.cc +++ b/chrome/browser/ui/views/overlay/back_to_tab_label_button.cc
@@ -57,23 +57,20 @@ SetBackground(views::CreateRoundedRectBackground(kBackToTabBackgroundColor, kBackToTabBorderRadius)); + const std::u16string back_to_tab_button_label(l10n_util::GetStringUTF16( + IDS_PICTURE_IN_PICTURE_BACK_TO_TAB_CONTROL_TEXT)); + SetText(back_to_tab_button_label); + SetEnabledTextColors(kPipWindowTextColor); SetTextColor(views::Button::STATE_DISABLED, kPipWindowTextColor); // Accessibility. - const std::u16string back_to_tab_button_label(l10n_util::GetStringUTF16( - IDS_PICTURE_IN_PICTURE_BACK_TO_TAB_CONTROL_TEXT)); SetAccessibleName(back_to_tab_button_label); SetInstallFocusRingOnFocus(true); } BackToTabLabelButton::~BackToTabLabelButton() = default; -void BackToTabLabelButton::SetText(const std::u16string& text) { - views::LabelButton::SetText(text); - UpdateSizingAndPosition(); -} - void BackToTabLabelButton::SetWindowSize(const gfx::Size& window_size) { if (window_size_.has_value() && window_size_.value() == window_size) return; @@ -82,10 +79,6 @@ UpdateSizingAndPosition(); } -bool BackToTabLabelButton::IsTextElidedForTesting() { - return label()->IsDisplayTextTruncated(); -} - void BackToTabLabelButton::UpdateSizingAndPosition() { if (!window_size_.has_value()) return;
diff --git a/chrome/browser/ui/views/overlay/back_to_tab_label_button.h b/chrome/browser/ui/views/overlay/back_to_tab_label_button.h index 1b581b0..79ec57f8 100644 --- a/chrome/browser/ui/views/overlay/back_to_tab_label_button.h +++ b/chrome/browser/ui/views/overlay/back_to_tab_label_button.h
@@ -19,15 +19,9 @@ BackToTabLabelButton& operator=(const BackToTabLabelButton&) = delete; ~BackToTabLabelButton() override; - // views::LabelButton: - void SetText(const std::u16string& text) override; - // Updates the position of this button within the new bounds of the window. void SetWindowSize(const gfx::Size& window_size); - // Returns true if the underlying label has elided text. - bool IsTextElidedForTesting(); - private: void UpdateSizingAndPosition();
diff --git a/chrome/browser/ui/views/overlay/overlay_window_views.cc b/chrome/browser/ui/views/overlay/overlay_window_views.cc index d437976f..5464e3e 100644 --- a/chrome/browser/ui/views/overlay/overlay_window_views.cc +++ b/chrome/browser/ui/views/overlay/overlay_window_views.cc
@@ -853,11 +853,6 @@ } void OverlayWindowViews::ShowInactive() { - if (back_to_tab_label_button_) { - back_to_tab_label_button_->SetText(l10n_util::GetStringUTF16( - IDS_PICTURE_IN_PICTURE_BACK_TO_TAB_CONTROL_TEXT)); - } - views::Widget::ShowInactive(); views::Widget::SetVisibleOnAllWorkspaces(true);
diff --git a/chrome/browser/ui/views/overlay/overlay_window_views_unittest.cc b/chrome/browser/ui/views/overlay/overlay_window_views_unittest.cc index 8a1c513..31b3edaf 100644 --- a/chrome/browser/ui/views/overlay/overlay_window_views_unittest.cc +++ b/chrome/browser/ui/views/overlay/overlay_window_views_unittest.cc
@@ -5,18 +5,12 @@ #include <memory> #include <utility> -#include "base/test/scoped_feature_list.h" -#include "chrome/browser/ui/views/overlay/back_to_tab_label_button.h" #include "chrome/browser/ui/views/overlay/overlay_window_views.h" #include "chrome/browser/ui/views/overlay/track_image_button.h" -#include "chrome/grit/generated_resources.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/views/chrome_views_test_base.h" #include "content/public/browser/picture_in_picture_window_controller.h" #include "content/public/test/test_web_contents_factory.h" -#include "content/public/test/web_contents_tester.h" -#include "media/base/media_switches.h" -#include "ui/base/l10n/l10n_util.h" #include "ui/compositor/layer.h" #include "ui/display/test/scoped_screen_override.h" #include "ui/display/test/test_screen.h" @@ -343,32 +337,3 @@ EXPECT_EQ(non_client_view->frame_view()->HitTestPoint(point), false); EXPECT_EQ(non_client_view->HitTestPoint(point), true); } - -// Tests with MediaSessionWebRTC enabled. -class OverlayWindowViewsMediaSessionWebRTCTest : public OverlayWindowViewsTest { - public: - // OverlayWindowViewsTest: - void SetUp() override { - OverlayWindowViewsTest::SetUp(); - } - - void NavigateTo(const GURL& url) { - content::WebContentsTester::For(web_contents())->SetLastCommittedURL(url); - } - - private: - // |feature_list_| needs to be initialized as early as possible to avoid data - // races with other threads checking if a feature is enabled. - base::test::ScopedFeatureList feature_list_{media::kMediaSessionWebRTC}; -}; - -TEST_F(OverlayWindowViewsMediaSessionWebRTCTest, - BackToTabLabelButtonDisplaysText) { - // Navigation does not affect the text displayed on the button. - NavigateTo(GURL("https://foo.com/bar?baz=1")); - overlay_window().UpdateVideoSize({200, 200}); - overlay_window().ShowInactive(); - EXPECT_EQ(l10n_util::GetStringUTF16( - IDS_PICTURE_IN_PICTURE_BACK_TO_TAB_CONTROL_TEXT), - overlay_window().back_to_tab_label_button_for_testing()->GetText()); -}
diff --git a/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc index 3525f9c..9fbf321 100644 --- a/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc
@@ -61,14 +61,10 @@ IDS_ENABLE_ARC_ADB_SIDELOADING_SETUP_TITLE); builder->Add("enableAdbSideloadingSetupMessage", IDS_ENABLE_ARC_ADB_SIDELOADING_SETUP_MESSAGE); - builder->Add("enableAdbSideloadingIllustrationTitle", - IDS_ENABLE_ARC_ADB_SIDELOADING_SETUP_ILLUSTRATION_TITLE); builder->Add("enableAdbSideloadingErrorTitle", IDS_ENABLE_ARC_ADB_SIDELOADING_ERROR_TITLE); builder->Add("enableAdbSideloadingErrorMessage", IDS_ENABLE_ARC_ADB_SIDELOADING_ERROR_MESSAGE); - builder->Add("enableAdbSideloadingErrorIllustrationTitle", - IDS_ENABLE_ARC_ADB_SIDELOADING_ERROR_ILLUSTRATION_TITLE); builder->Add("enableAdbSideloadingLearnMore", IDS_ENABLE_ARC_ADB_SIDELOADING_LEARN_MORE); builder->Add("enableAdbSideloadingConfirmButton",
diff --git a/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc index d418461..74e0d1c 100644 --- a/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
@@ -631,10 +631,6 @@ builder->Add("oauthEnrollSuccessTitle", IDS_ENTERPRISE_ENROLLMENT_SUCCESS_TITLE); builder->Add("oauthEnrollErrorTitle", IDS_ENTERPRISE_ENROLLMENT_ERROR_TITLE); - builder->Add("enrollmentSuccessIllustrationTitle", - IDS_ENTERPRISE_ENROLLMENT_SUCCESS_ILLUSTRATION_TITLE); - builder->Add("enrollmentErrorIllustrationTitle", - IDS_ENTERPRISE_ENROLLMENT_ERROR_ILLUSTRATION_TITLE); builder->Add("oauthEnrollDeviceInformation", IDS_ENTERPRISE_ENROLLMENT_DEVICE_INFORMATION); builder->Add("oauthEnrollExplainAttributeLink",
diff --git a/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc b/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc index fb3d6e6..92b8c8e 100644 --- a/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc +++ b/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc
@@ -74,7 +74,7 @@ const GURL& gaia_url = GaiaUrls::GetInstance()->gaia_url(); std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create( gaia_url, gaps_cookie_value, base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, net::CookiePartitionKey::Todo())); if (!cc) return;
diff --git a/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc index 7560b08..3cccc4f 100644 --- a/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
@@ -57,8 +57,6 @@ ::login::LocalizedValuesBuilder* builder) { builder->Add("resetScreenAccessibleTitle", IDS_RESET_SCREEN_TITLE); builder->Add("resetScreenIconTitle", IDS_RESET_SCREEN_ICON_TITLE); - builder->Add("resetScreenIllustrationTitle", - IDS_RESET_SCREEN_ILLUSTRATION_TITLE); builder->Add("cancelButton", IDS_CANCEL); builder->Add("resetButtonRestart", IDS_RELAUNCH_BUTTON);
diff --git a/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc b/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc index 2d20ed82..9583b0d 100644 --- a/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc +++ b/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc
@@ -13,6 +13,7 @@ #include "components/browsing_data/content/mock_cookie_helper.h" #include "components/browsing_data/content/mock_local_storage_helper.h" #include "content/public/test/test_web_ui.h" +#include "third_party/blink/public/common/storage_key/storage_key.h" namespace { @@ -69,10 +70,10 @@ auto mock_cookies_tree_model = std::make_unique<CookiesTreeModel>( std::move(container), profile()->GetExtensionSpecialStoragePolicy()); - mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin( - url::Origin::Create(GURL(kTestOrigin1)), 2); - mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin( - url::Origin::Create(GURL(kTestOrigin2)), 3); + mock_browsing_data_local_storage_helper->AddLocalStorageForStorageKey( + blink::StorageKey::CreateFromStringForTesting(kTestOrigin1), 2); + mock_browsing_data_local_storage_helper->AddLocalStorageForStorageKey( + blink::StorageKey::CreateFromStringForTesting(kTestOrigin2), 3); mock_browsing_data_cookie_helper->AddCookieSamples(GURL(kTestOrigin1), kTestCookie1);
diff --git a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc index d762086..2c66b99 100644 --- a/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc +++ b/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc
@@ -66,6 +66,7 @@ #include "ppapi/buildflags/buildflags.h" #include "services/device/public/cpp/test/fake_usb_device_manager.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/public/common/storage_key/storage_key.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/text/bytes_formatting.h" #include "ui/webui/webui_allowlist.h" @@ -449,11 +450,15 @@ auto mock_cookies_tree_model = std::make_unique<CookiesTreeModel>( std::move(container), profile()->GetExtensionSpecialStoragePolicy()); - mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin( - url::Origin::Create(GURL("https://www.example.com/")), 2); + mock_browsing_data_local_storage_helper->AddLocalStorageForStorageKey( + blink::StorageKey::CreateFromStringForTesting( + "https://www.example.com/"), + 2); - mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin( - url::Origin::Create(GURL("https://www.google.com/")), 50000000000); + mock_browsing_data_local_storage_helper->AddLocalStorageForStorageKey( + blink::StorageKey::CreateFromStringForTesting( + "https://www.google.com/"), + 50000000000); mock_browsing_data_local_storage_helper->Notify(); mock_browsing_data_cookie_helper->AddCookieSamples(
diff --git a/chrome/browser/web_share_target/OWNERS b/chrome/browser/web_share_target/OWNERS index ecb809e..6b7800e2 100644 --- a/chrome/browser/web_share_target/OWNERS +++ b/chrome/browser/web_share_target/OWNERS
@@ -1 +1,4 @@ file://chrome/browser/android/webapk/OWNERS + +# Additional owners: +ericwilligers@chromium.org
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 8a6d9bf2..6545ad6 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -1422,6 +1422,7 @@ "../browser/browsing_data/counters/history_counter_browsertest.cc", "../browser/browsing_data/counters/passwords_counter_browsertest.cc", "../browser/browsing_data/counters/sync_aware_counter_browsertest.cc", + "../browser/browsing_data/incognito_browsing_data_browsertest.cc", "../browser/browsing_data/navigation_entry_remover_browsertest.cc", "../browser/browsing_data/third_party_data_remover_browsertest.cc", "../browser/capability_delegation_browsertest.cc",
diff --git a/chrome/test/data/page_load_metrics/use_counter_features_in_iframe.html b/chrome/test/data/page_load_metrics/use_counter_features_in_iframe.html index 8bafbe22..57a0f7bd 100644 --- a/chrome/test/data/page_load_metrics/use_counter_features_in_iframe.html +++ b/chrome/test/data/page_load_metrics/use_counter_features_in_iframe.html
@@ -1,4 +1,4 @@ <html><head><title>iframe test</title></head> <body> -<iframe src="use_counter_features.html"></iframe> +<iframe allow="fullscreen 'none'" src="use_counter_features.html"></iframe> </body></html>
diff --git a/chrome/test/data/page_load_metrics/use_counter_features_in_iframes.html b/chrome/test/data/page_load_metrics/use_counter_features_in_iframes.html index 07ee61f..f863030e9 100644 --- a/chrome/test/data/page_load_metrics/use_counter_features_in_iframes.html +++ b/chrome/test/data/page_load_metrics/use_counter_features_in_iframes.html
@@ -1,5 +1,5 @@ <html><head><title>iframe test</title></head> <body> -<iframe id="f0" src="use_counter_features.html"></iframe> -<iframe id="f1" src="http://localhost:8000/use_counter_features.html"></iframe> +<iframe id="f0" allow="fullscreen 'none'" src="use_counter_features.html"></iframe> +<iframe id="f1" allow="fullscreen 'none'" src="http://localhost:8000/use_counter_features.html"></iframe> </body></html>
diff --git a/chrome/test/data/webui/chromeos/scanning/scanning_app_test.js b/chrome/test/data/webui/chromeos/scanning/scanning_app_test.js index 45dedb2..07e248b 100644 --- a/chrome/test/data/webui/chromeos/scanning/scanning_app_test.js +++ b/chrome/test/data/webui/chromeos/scanning/scanning_app_test.js
@@ -245,6 +245,8 @@ }); } + startMultiPageScan() {} + cancelScan() { this.methodCalled('cancelScan'); }
diff --git a/chrome/updater/mac/setup/setup.mm b/chrome/updater/mac/setup/setup.mm index 7c7ba41..543fd9e 100644 --- a/chrome/updater/mac/setup/setup.mm +++ b/chrome/updater/mac/setup/setup.mm
@@ -84,7 +84,7 @@ } #pragma mark Setup -bool CopyBundle(const base::FilePath& dest_path) { +bool CopyBundle(const base::FilePath& dest_path, UpdaterScope scope) { if (!base::PathExists(dest_path)) { base::File::Error error; if (!base::CreateDirectoryAndGetError(dest_path, &error)) { @@ -94,6 +94,26 @@ } } + // For system installs, set file permissions to be drwxr-xr-x + if (scope == UpdaterScope::kSystem) { + constexpr int kPermissionsMask = base::FILE_PERMISSION_USER_MASK | + base::FILE_PERMISSION_READ_BY_GROUP | + base::FILE_PERMISSION_EXECUTE_BY_GROUP | + base::FILE_PERMISSION_READ_BY_OTHERS | + base::FILE_PERMISSION_EXECUTE_BY_OTHERS; + if (!base::SetPosixFilePermissions( + GetLibraryFolderPath(scope)->Append(COMPANY_SHORTNAME_STRING), + kPermissionsMask) || + !base::SetPosixFilePermissions(*GetUpdaterFolderPath(scope), + kPermissionsMask) || + !base::SetPosixFilePermissions(*GetVersionedUpdaterFolderPath(scope), + kPermissionsMask)) { + LOG(ERROR) << "Failed to set permissions to drwxr-xr-x at " + << dest_path.value().c_str(); + return false; + } + } + if (!base::CopyDirectory(base::mac::OuterBundlePath(), dest_path, true)) { LOG(ERROR) << "Copying app to '" << dest_path.value().c_str() << "' failed"; return false; @@ -339,7 +359,7 @@ if (!dest_path) return setup_exit_codes::kFailedToGetVersionedUpdaterFolderPath; - if (!CopyBundle(*dest_path)) + if (!CopyBundle(*dest_path, scope)) return setup_exit_codes::kFailedToCopyBundle; const base::FilePath updater_executable_path =
diff --git a/chromecast/device/bluetooth/le/gatt_client_manager_impl.cc b/chromecast/device/bluetooth/le/gatt_client_manager_impl.cc index 7ba57b22..d4194f0 100644 --- a/chromecast/device/bluetooth/le/gatt_client_manager_impl.cc +++ b/chromecast/device/bluetooth/le/gatt_client_manager_impl.cc
@@ -17,6 +17,7 @@ #include "chromecast/device/bluetooth/le/remote_descriptor_impl.h" #include "chromecast/device/bluetooth/le/remote_device_impl.h" #include "chromecast/device/bluetooth/le/remote_service_impl.h" +#include "chromecast/public/bluetooth/gatt.h" namespace chromecast { namespace bluetooth { @@ -151,9 +152,10 @@ void GattClientManagerImpl::EnqueueConnectRequest( const bluetooth_v2_shlib::Addr& addr, - bool is_connect) { + bool is_connect, + bluetooth_v2_shlib::Gatt::Client::Transport transport) { DCHECK(io_task_runner_->BelongsToCurrentThread()); - pending_connect_requests_.push_back(std::make_pair(addr, is_connect)); + pending_connect_requests_.emplace_back(addr, is_connect, transport); // Run the request if this is the only request in the queue. Otherwise, it // will be run when all previous requests complete. @@ -269,14 +271,16 @@ it->second->SetConnected(false); connected_devices_.erase(addr); if (!pending_connect_requests_.empty() && - addr == pending_connect_requests_.front().first) { + addr == pending_connect_requests_.front().addr) { pending_connect_requests_.pop_front(); connect_timeout_timer_.Stop(); disconnect_timeout_timer_.Stop(); RunQueuedConnectRequest(); } else { - base::Erase(pending_connect_requests_, std::make_pair(addr, true)); - base::Erase(pending_connect_requests_, std::make_pair(addr, false)); + base::EraseIf(pending_connect_requests_, + [addr](const PendingRequest& request) { + return request.addr == addr; + }); } base::Erase(pending_read_remote_rssi_requests_, addr); @@ -425,8 +429,8 @@ it->second->GetServicesSync()); if (pending_connect_requests_.empty() || - addr != pending_connect_requests_.front().first || - !pending_connect_requests_.front().second) { + addr != pending_connect_requests_.front().addr || + !pending_connect_requests_.front().is_connect) { NOTREACHED() << "Unexpected call to " << __func__; return; } @@ -465,11 +469,12 @@ DCHECK(io_task_runner_->BelongsToCurrentThread()); while (!pending_connect_requests_.empty()) { - auto addr = pending_connect_requests_.front().first; - bool is_connect = pending_connect_requests_.front().second; + const PendingRequest& pending_request = pending_connect_requests_.front(); + const bluetooth_v2_shlib::Addr& addr = pending_request.addr; + const bool is_connect = pending_request.is_connect; if (is_connect) { if (gatt_client_connectable_) { - if (gatt_client_->Connect(addr)) { + if (gatt_client_->Connect(addr, pending_request.transport)) { connect_timeout_timer_.Start( FROM_HERE, kConnectTimeout, base::BindOnce(&GattClientManagerImpl::OnConnectTimeout, @@ -610,5 +615,13 @@ gatt_client_->SetDelegate(nullptr); } +GattClientManagerImpl::PendingRequest::PendingRequest( + const bluetooth_v2_shlib::Addr& addr, + bool is_connect, + bluetooth_v2_shlib::Gatt::Client::Transport transport) + : addr(addr), is_connect(is_connect), transport(transport) {} + +GattClientManagerImpl::PendingRequest::~PendingRequest() = default; + } // namespace bluetooth } // namespace chromecast
diff --git a/chromecast/device/bluetooth/le/gatt_client_manager_impl.h b/chromecast/device/bluetooth/le/gatt_client_manager_impl.h index 1ec075f..4a366154 100644 --- a/chromecast/device/bluetooth/le/gatt_client_manager_impl.h +++ b/chromecast/device/bluetooth/le/gatt_client_manager_impl.h
@@ -17,6 +17,7 @@ #include "chromecast/device/bluetooth/le/ble_notification_logger.h" #include "chromecast/device/bluetooth/le/gatt_client_manager.h" #include "chromecast/device/bluetooth/shlib/gatt_client.h" +#include "chromecast/public/bluetooth/gatt.h" namespace chromecast { namespace bluetooth { @@ -67,9 +68,12 @@ // Add a Connect or Disconnect request to the queue. |is_connect| is true for // Connect request and false for Disconnect request. They can only be executed - // serially. - void EnqueueConnectRequest(const bluetooth_v2_shlib::Addr& addr, - bool is_connect); + // serially. |transport| need only be set if is_connect == true and you wish + // to force a BT Classic or LE connection. + void EnqueueConnectRequest( + const bluetooth_v2_shlib::Addr& addr, + bool is_connect, + bluetooth_v2_shlib::Gatt::Client::Transport transport = bluetooth_v2_shlib::Gatt::Client::Transport::kAuto); // Add a ReadRemoteRssi request to the queue. They can only be executed // serially. @@ -160,8 +164,17 @@ // Queue for concurrent Connect/Disconnect requests. Each request is // represented using a <addr, is_connect> pair. |is_connect| is true for // Connect requests and false for Disconnect requests. - std::deque<std::pair<bluetooth_v2_shlib::Addr, bool>> - pending_connect_requests_; + struct PendingRequest { + PendingRequest(const bluetooth_v2_shlib::Addr& addr, + bool is_connect, + bluetooth_v2_shlib::Gatt::Client::Transport transport); + ~PendingRequest(); + + bluetooth_v2_shlib::Addr addr; + bool is_connect; + bluetooth_v2_shlib::Gatt::Client::Transport transport; + }; + std::deque<PendingRequest> pending_connect_requests_; bool disconnect_all_pending_ = false;
diff --git a/chromecast/device/bluetooth/le/gatt_client_manager_impl_test.cc b/chromecast/device/bluetooth/le/gatt_client_manager_impl_test.cc index fb76fb1..f7bd527 100644 --- a/chromecast/device/bluetooth/le/gatt_client_manager_impl_test.cc +++ b/chromecast/device/bluetooth/le/gatt_client_manager_impl_test.cc
@@ -218,7 +218,9 @@ } void Connect(const bluetooth_v2_shlib::Addr& addr) { - EXPECT_CALL(*gatt_client_, Connect(addr)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(addr, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); scoped_refptr<RemoteDevice> device = GetDevice(addr); EXPECT_CALL(connect_cb_, Run(RemoteDevice::ConnectStatus::kSuccess)); device->Connect(connect_cb_.Get()); @@ -272,7 +274,9 @@ device->ConnectionParameterUpdate(10, 10, 50, 100, cb_.Get()); // First connect request fails right away. - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(false)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(false)); EXPECT_CALL(*gatt_client_, ClearPendingConnect(kTestAddr1)) .WillOnce(Return(true)); EXPECT_CALL(connect_cb_, Run(RemoteDevice::ConnectStatus::kFailure)); @@ -280,7 +284,9 @@ EXPECT_FALSE(device->IsConnected()); // Second connect request succeeds. - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); EXPECT_CALL(connect_cb_, Run(RemoteDevice::ConnectStatus::kSuccess)); device->Connect(connect_cb_.Get()); EXPECT_CALL(*gatt_client_, GetServices(kTestAddr1)).WillOnce(Return(true)); @@ -423,7 +429,9 @@ // Only the 1st Connect request will be executed immediately. The rest will be // queued. - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); device1->Connect(cb1.Get()); device2->Connect(cb2.Get()); device3->Connect(cb3.Get()); @@ -437,15 +445,21 @@ // Queued Connect requests will not be called until we receive OnGetServices // of the current Connect request if it is successful. EXPECT_CALL(cb1, Run(RemoteDevice::ConnectStatus::kSuccess)); - EXPECT_CALL(*gatt_client_, Connect(kTestAddr2)).WillOnce(Return(false)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr2, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(false)); EXPECT_CALL(cb2, Run(RemoteDevice::ConnectStatus::kFailure)); // If the Connect request fails in the initial request (not in the callback), // the next queued request will be executed immediately. - EXPECT_CALL(*gatt_client_, Connect(kTestAddr3)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr3, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); delegate->OnGetServices(kTestAddr1, {}); EXPECT_CALL(cb3, Run(RemoteDevice::ConnectStatus::kFailure)); - EXPECT_CALL(*gatt_client_, Connect(kTestAddr4)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr4, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); delegate->OnConnectChanged(kTestAddr3, true /* status */, false /* connected */); @@ -479,7 +493,9 @@ scoped_refptr<RemoteDevice> device = GetDevice(kTestAddr1); // Issue a Connect request - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); device->Connect(connect_cb_.Get()); // Let Connect request timeout @@ -498,7 +514,9 @@ scoped_refptr<RemoteDevice> device = GetDevice(kTestAddr1); // Issue a Connect request and let Connect succeed - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); device->Connect(connect_cb_.Get()); EXPECT_CALL(*gatt_client_, GetServices(kTestAddr1)).WillOnce(Return(true)); delegate->OnConnectChanged(kTestAddr1, true /* status */, @@ -643,7 +661,9 @@ EXPECT_TRUE(gatt_client_manager_->gatt_client_connectable()); // Start a connection. - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); device->Connect(connect_cb_.Get()); // Disable GATT client connectability while connection is pending. @@ -661,7 +681,7 @@ ASSERT_FALSE(device->IsConnected()); // Connect should fail when GATT client connectability is already disabled. - EXPECT_CALL(*gatt_client_, Connect(_)).Times(0); + EXPECT_CALL(*gatt_client_, Connect).Times(0); EXPECT_CALL(connect_cb_, Run(RemoteDevice::ConnectStatus::kFailure)); device->Connect(connect_cb_.Get()); ASSERT_FALSE(device->IsConnected()); @@ -1199,7 +1219,9 @@ TEST_F(GattClientManagerTest, GetServicesFailOnConnect) { scoped_refptr<RemoteDevice> device = GetDevice(kTestAddr1); - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); device->Connect(connect_cb_.Get()); bluetooth_v2_shlib::Gatt::Client::Delegate* delegate = gatt_client_->delegate(); @@ -1231,7 +1253,9 @@ EXPECT_EQ(expected_services->size(), services.size()); }, this, &kServices, &cb_called); - EXPECT_CALL(*gatt_client_, Connect(kTestAddr1)).WillOnce(Return(true)); + EXPECT_CALL(*gatt_client_, + Connect(kTestAddr1, bluetooth_v2_shlib::Gatt::Client::Transport::kAuto)) + .WillOnce(Return(true)); device->Connect(std::move(cb)); bluetooth_v2_shlib::Gatt::Client::Delegate* delegate =
diff --git a/chromecast/device/bluetooth/le/mock_remote_device.h b/chromecast/device/bluetooth/le/mock_remote_device.h index a7845f7..8e5d21a 100644 --- a/chromecast/device/bluetooth/le/mock_remote_device.h +++ b/chromecast/device/bluetooth/le/mock_remote_device.h
@@ -19,7 +19,10 @@ explicit MockRemoteDevice(const bluetooth_v2_shlib::Addr& addr); MOCK_METHOD0(Connect, ConnectStatus()); - void Connect(ConnectCallback cb) override { std::move(cb).Run(Connect()); } + void Connect(ConnectCallback cb, + bluetooth_v2_shlib::Gatt::Client::Transport /* transport */) override { + std::move(cb).Run(Connect()); + } MOCK_METHOD0(Disconnect, bool()); void Disconnect(StatusCallback cb) override {
diff --git a/chromecast/device/bluetooth/le/remote_device.h b/chromecast/device/bluetooth/le/remote_device.h index b7dda0f6..bdbc9a92 100644 --- a/chromecast/device/bluetooth/le/remote_device.h +++ b/chromecast/device/bluetooth/le/remote_device.h
@@ -38,7 +38,9 @@ // Initiate a connection to this device. Callback will return |true| if // connected successfully, otherwise false. Only one pending call is allowed // at a time. - virtual void Connect(ConnectCallback cb) = 0; + virtual void Connect( + ConnectCallback cb, + bluetooth_v2_shlib::Gatt::Client::Transport transport = bluetooth_v2_shlib::Gatt::Client::Transport::kAuto) = 0; // Disconnect from this device. Callback will return |true| if disconnected // successfully, otherwise false. Only one pending call is allowed at a time.
diff --git a/chromecast/device/bluetooth/le/remote_device_impl.cc b/chromecast/device/bluetooth/le/remote_device_impl.cc index e8397d3..46632327 100644 --- a/chromecast/device/bluetooth/le/remote_device_impl.cc +++ b/chromecast/device/bluetooth/le/remote_device_impl.cc
@@ -13,6 +13,7 @@ #include "chromecast/device/bluetooth/le/remote_characteristic_impl.h" #include "chromecast/device/bluetooth/le/remote_descriptor_impl.h" #include "chromecast/device/bluetooth/le/remote_service_impl.h" +#include "chromecast/public/bluetooth/gatt.h" namespace chromecast { namespace bluetooth { @@ -69,8 +70,9 @@ RemoteDeviceImpl::~RemoteDeviceImpl() = default; -void RemoteDeviceImpl::Connect(ConnectCallback cb) { - MAKE_SURE_IO_THREAD(Connect, BindToCurrentSequence(std::move(cb))); +void RemoteDeviceImpl::Connect(ConnectCallback cb, + bluetooth_v2_shlib::Gatt::Client::Transport transport) { + MAKE_SURE_IO_THREAD(Connect, BindToCurrentSequence(std::move(cb)), transport); LOG(INFO) << "Connect(" << util::AddrLastByteString(addr_) << ")"; if (!gatt_client_manager_) { @@ -85,7 +87,7 @@ gatt_client_manager_->NotifyConnect(addr_); connect_cb_ = std::move(cb); - gatt_client_manager_->EnqueueConnectRequest(addr_, true); + gatt_client_manager_->EnqueueConnectRequest(addr_, true, transport); } void RemoteDeviceImpl::Disconnect(StatusCallback cb) {
diff --git a/chromecast/device/bluetooth/le/remote_device_impl.h b/chromecast/device/bluetooth/le/remote_device_impl.h index e848915c..c84531d 100644 --- a/chromecast/device/bluetooth/le/remote_device_impl.h +++ b/chromecast/device/bluetooth/le/remote_device_impl.h
@@ -20,6 +20,7 @@ #include "chromecast/device/bluetooth/le/remote_characteristic.h" #include "chromecast/device/bluetooth/le/remote_descriptor.h" #include "chromecast/device/bluetooth/le/remote_device.h" +#include "chromecast/public/bluetooth/gatt.h" namespace chromecast { namespace bluetooth { @@ -38,7 +39,7 @@ base::TimeDelta::FromSeconds(30); // RemoteDevice implementation - void Connect(ConnectCallback cb) override; + void Connect(ConnectCallback cb, bluetooth_v2_shlib::Gatt::Client::Transport transport) override; void Disconnect(StatusCallback cb) override; void CreateBond(StatusCallback cb) override; void RemoveBond(StatusCallback cb) override;
diff --git a/chromecast/device/bluetooth/shlib/gatt_client.h b/chromecast/device/bluetooth/shlib/gatt_client.h index 4c708ad..2e8dbf9f 100644 --- a/chromecast/device/bluetooth/shlib/gatt_client.h +++ b/chromecast/device/bluetooth/shlib/gatt_client.h
@@ -17,7 +17,7 @@ virtual ~GattClient() = default; virtual bool IsSupported() = 0; virtual void SetDelegate(Gatt::Client::Delegate* delegate) = 0; - virtual bool Connect(const Addr& addr) = 0; + virtual bool Connect(const Addr& addr, Gatt::Client::Transport transport) = 0; virtual bool Disconnect(const Addr& addr) = 0; virtual bool CreateBond(const Addr& addr) = 0; virtual bool RemoveBond(const Addr& addr) = 0;
diff --git a/chromecast/device/bluetooth/shlib/mock_gatt_client.h b/chromecast/device/bluetooth/shlib/mock_gatt_client.h index 09fcf74..220e5a7 100644 --- a/chromecast/device/bluetooth/shlib/mock_gatt_client.h +++ b/chromecast/device/bluetooth/shlib/mock_gatt_client.h
@@ -18,7 +18,7 @@ MockGattClient(); ~MockGattClient() override; MOCK_METHOD0(IsSupported, bool()); - MOCK_METHOD1(Connect, bool(const Addr&)); + MOCK_METHOD2(Connect, bool(const Addr&, Gatt::Client::Transport transport)); MOCK_METHOD1(SetDelegate, void(Gatt::Client::Delegate*)); MOCK_METHOD0(Enable, bool()); MOCK_METHOD0(Disable, bool());
diff --git a/chromecast/public/bluetooth/gatt.h b/chromecast/public/bluetooth/gatt.h index d1f10f2..6eee61577 100644 --- a/chromecast/public/bluetooth/gatt.h +++ b/chromecast/public/bluetooth/gatt.h
@@ -123,6 +123,12 @@ AUTH_REQ_MAX = AUTH_REQ_MITM, }; + enum class Transport { + kAuto, + kBrEdr, + kLe, + }; + // These callbacks may be on any thead. class Delegate { public: @@ -193,8 +199,8 @@ static bool IsSupported(); static void SetDelegate(Delegate* delegate); - // Create a connection to remote device |addr|. - static bool Connect(const Addr& addr); + // Create a connection to remote device |addr| using |transport|. + static bool Connect(const Addr& addr, Transport transport); // Remove connection to remote device |addr|. static bool Disconnect(const Addr& addr); @@ -261,8 +267,7 @@ static bool GetServices(const Addr& addr); // Clear pending connect request of remote device with |addr|. - static bool ClearPendingConnect(const Addr& addr) - __attribute__((__weak__)); + static bool ClearPendingConnect(const Addr& addr) __attribute__((__weak__)); // Clear pending disconnect request of remote device with |addr|. static bool ClearPendingDisconnect(const Addr& addr)
diff --git a/chromeos/components/personalization_app/resources/common/icons.js b/chromeos/components/personalization_app/resources/common/icons.js index eed2e15..e71d164 100644 --- a/chromeos/components/personalization_app/resources/common/icons.js +++ b/chromeos/components/personalization_app/resources/common/icons.js
@@ -35,7 +35,7 @@ <g id="change-daily"> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">> - <rect width="20" height="20" fill="white"/> + <rect width="20" height="20" fill="none"/> <path d="M17.4989 4.16672H19.1656V15.8334H17.4989V4.16672ZM14.1656 4.16672H15.8322V15.8334H14.1656V4.16672ZM11.6656 4.16672H1.66558C1.20724 4.16672 0.832245 4.54172 0.832245 @@ -54,7 +54,7 @@ <g id="refresh"> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> - <rect width="20" height="20" fill="white"/> + <rect width="20" height="20" fill="none"/> <path d="M10 3C6.136 3 3 6.136 3 10C3 13.864 6.136 17 10 17C12.1865 17 14.1399 15.9959 15.4239 14.4239L13.9984 12.9984C13.0852 14.2129 11.6325 15 10 15C7.24375 15 5 12.7563 5 10C5 7.24375 7.24375 5 10 @@ -69,7 +69,7 @@ <g id="layout_fill"> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> - <rect width="20" height="20" fill="white"/> + <rect width="20" height="20" fill="none"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 13.125H16.25V6.875L3.75 6.78571V13.125ZM2.5 14.375H17.5V5.625H2.5V14.375ZM12.5 4.375H14.375V2.5H12.5V4.375ZM12.5 @@ -89,7 +89,7 @@ <g id="layout_center"> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> - <rect width="20" height="20" fill="white"/> + <rect width="20" height="20" fill="none"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 12.5H12.5V7.5H7.5V12.5ZM6.25 13.75H13.75V6.25H6.25V13.75ZM12.5 4.375H14.375V2.5H12.5V4.375ZM11.875
diff --git a/components/browser_ui/site_settings/DEPS b/components/browser_ui/site_settings/DEPS index 62df9f8..91dc26e 100644 --- a/components/browser_ui/site_settings/DEPS +++ b/components/browser_ui/site_settings/DEPS
@@ -16,6 +16,7 @@ "+services/device/public", "+services/network/public", "+storage/browser", + "+third_party/blink/public/common", "+third_party/blink/public/mojom", "+ui/android", ]
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java index 869801f..0cda031 100644 --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
@@ -1115,17 +1115,19 @@ @Override public boolean onPreferenceClick(Preference preference) { - int titleResId = mHideNonPermissionPreferences ? R.string.page_info_permissions_reset - : R.string.website_reset; - int confirmationResId = mHideNonPermissionPreferences - ? R.string.page_info_permissions_reset_confirmation - : R.string.website_reset_confirmation; + int titleResId = mHideNonPermissionPreferences + ? R.string.page_info_permissions_reset_dialog_title + : R.string.website_reset; + String confirmationText = mHideNonPermissionPreferences + ? getString(R.string.page_info_permissions_reset_confirmation, + mSite.getAddress().getHost()) + : getString(R.string.website_reset_confirmation); int buttonResId = mHideNonPermissionPreferences ? R.string.reset : titleResId; // Handle the Clear & Reset preference click by showing a confirmation. mConfirmationDialog = new AlertDialog.Builder(getContext(), R.style.Theme_Chromium_AlertDialog) .setTitle(titleResId) - .setMessage(confirmationResId) + .setMessage(confirmationText) .setPositiveButton(buttonResId, (dialog, which) -> { if (mHideNonPermissionPreferences) {
diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc index 2c8b920..d84d38da 100644 --- a/components/browser_ui/site_settings/android/website_preference_bridge.cc +++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc
@@ -43,6 +43,7 @@ #include "content/public/browser/storage_partition.h" #include "services/network/public/mojom/cookie_manager.mojom.h" #include "storage/browser/quota/quota_manager.h" +#include "third_party/blink/public/common/storage_key/storage_key.h" #include "third_party/blink/public/mojom/quota/quota_types.mojom.h" #include "url/origin.h" #include "url/url_constants.h" @@ -644,11 +645,11 @@ BrowserContext* browser_context = unwrap(jbrowser_context_handle); auto local_storage_helper = base::MakeRefCounted<browsing_data::LocalStorageHelper>(browser_context); - auto origin = - url::Origin::Create(GURL(ConvertJavaStringToUTF8(env, jorigin))); - local_storage_helper->DeleteOrigin( - origin, base::BindOnce(&OnLocalStorageCleared, - ScopedJavaGlobalRef<jobject>(java_callback))); + auto storage_key = blink::StorageKey( + url::Origin::Create(GURL(ConvertJavaStringToUTF8(env, jorigin)))); + local_storage_helper->DeleteStorageKey( + storage_key, base::BindOnce(&OnLocalStorageCleared, + ScopedJavaGlobalRef<jobject>(java_callback))); } static void JNI_WebsitePreferenceBridge_ClearStorageData(
diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd index 0df2d76b..ffa4d21d 100644 --- a/components/browser_ui/strings/android/browser_ui_strings.grd +++ b/components/browser_ui/strings/android/browser_ui_strings.grd
@@ -474,8 +474,11 @@ <message name="IDS_PAGE_INFO_PERMISSIONS_RESET" desc="The label for the button allowing users to reset the permissions for a website."> Reset permissions </message> + <message name="IDS_PAGE_INFO_PERMISSIONS_RESET_DIALOG_TITLE" desc="The title for the dialog asking if the user is sure about resetting the permissions for a site."> + Reset permissions? + </message> <message name="IDS_PAGE_INFO_PERMISSIONS_RESET_CONFIRMATION" desc="The confirmation text asking if the user is sure about resetting the permissions for a site."> - Are you sure you want to reset all permissions for this website? + This choice will reset permissions for <ph name="WEBSITE">%1$s<ex>example.com</ex></ph> </message> <message name="IDS_PAGE_INFO_PERMISSIONS_OS_WARNING" desc="Text to show an OS-level permission warning."> <ph name="PERMISSION">%1$s<ex>Location</ex></ph> - <ph name="WARNING_MESSAGE">%2$s<ex>Turned off for this device</ex></ph>
diff --git a/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_PERMISSIONS_RESET_CONFIRMATION.png.sha1 b/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_PERMISSIONS_RESET_CONFIRMATION.png.sha1 index 09b2e87..b92c0a2 100644 --- a/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_PERMISSIONS_RESET_CONFIRMATION.png.sha1 +++ b/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_PERMISSIONS_RESET_CONFIRMATION.png.sha1
@@ -1 +1 @@ -e9650311b2b884ee0afa9688b2d485204529a06d \ No newline at end of file +422c3e0fdd780eb210310719dcbd3ee33a08b7da \ No newline at end of file
diff --git a/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_PERMISSIONS_RESET_DIALOG_TITLE.png.sha1 b/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_PERMISSIONS_RESET_DIALOG_TITLE.png.sha1 new file mode 100644 index 0000000..b92c0a2 --- /dev/null +++ b/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_PERMISSIONS_RESET_DIALOG_TITLE.png.sha1
@@ -0,0 +1 @@ +422c3e0fdd780eb210310719dcbd3ee33a08b7da \ No newline at end of file
diff --git a/components/browsing_data/content/cookie_helper_unittest.cc b/components/browsing_data/content/cookie_helper_unittest.cc index 7ff55e8..87dba4e7 100644 --- a/components/browsing_data/content/cookie_helper_unittest.cc +++ b/components/browsing_data/content/cookie_helper_unittest.cc
@@ -116,11 +116,13 @@ void CreateCookiesForTest() { absl::optional<base::Time> server_time = absl::nullopt; GURL cookie1_source("https://www.google.com"); - auto cookie1 = net::CanonicalCookie::Create(cookie1_source, "A=1", - base::Time::Now(), server_time); + auto cookie1 = net::CanonicalCookie::Create( + cookie1_source, "A=1", base::Time::Now(), server_time, + absl::nullopt /* cookie_partition_key */); GURL cookie2_source("https://www.gmail.google.com"); - auto cookie2 = net::CanonicalCookie::Create(cookie2_source, "B=1", - base::Time::Now(), server_time); + auto cookie2 = net::CanonicalCookie::Create( + cookie2_source, "B=1", base::Time::Now(), server_time, + absl::nullopt /* cookie_partition_key */); network::mojom::CookieManager* cookie_manager = storage_partition()->GetCookieManagerForBrowserProcess(); @@ -135,11 +137,12 @@ void CreateCookiesForDomainCookieTest() { absl::optional<base::Time> server_time = absl::nullopt; GURL cookie_source("https://www.google.com"); - auto cookie1 = net::CanonicalCookie::Create(cookie_source, "A=1", - base::Time::Now(), server_time); - auto cookie2 = net::CanonicalCookie::Create(cookie_source, - "A=2; Domain=.www.google.com ", - base::Time::Now(), server_time); + auto cookie1 = net::CanonicalCookie::Create( + cookie_source, "A=1", base::Time::Now(), server_time, + absl::nullopt /* cookie_partition_key */); + auto cookie2 = net::CanonicalCookie::Create( + cookie_source, "A=2; Domain=.www.google.com ", base::Time::Now(), + server_time, absl::nullopt /* cookie_partition_key */); network::mojom::CookieManager* cookie_manager = storage_partition()->GetCookieManagerForBrowserProcess(); @@ -301,7 +304,8 @@ const GURL origin1("http://www.google.com"); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - origin1, "A=1", base::Time::Now(), absl::nullopt /* server_time */)); + origin1, "A=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin1, @@ -309,7 +313,8 @@ {*cookie1}}); const GURL origin2("http://www.gmail.google.com"); std::unique_ptr<net::CanonicalCookie> cookie2(net::CanonicalCookie::Create( - origin2, "B=1", base::Time::Now(), absl::nullopt /* server_time */)); + origin2, "B=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie2); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin2, @@ -339,7 +344,8 @@ ASSERT_TRUE(helper->empty()); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - origin, "A=1", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -347,7 +353,8 @@ {*cookie1}}); std::unique_ptr<net::CanonicalCookie> cookie2(net::CanonicalCookie::Create( origin, "A=1; Domain=.www.google.com", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie2); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -375,7 +382,8 @@ ASSERT_TRUE(helper->empty()); std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( - origin, "A=1", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie); helper->AddCookies( {content::CookieAccessDetails::Type::kChange, origin, origin, {*cookie}}); @@ -404,14 +412,16 @@ ASSERT_TRUE(helper->empty()); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - origin, "A=1", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, origin, {*cookie1}}); std::unique_ptr<net::CanonicalCookie> cookie2(net::CanonicalCookie::Create( - origin, "A=2", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=2", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie2); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -419,7 +429,8 @@ {*cookie2}}); std::unique_ptr<net::CanonicalCookie> cookie3(net::CanonicalCookie::Create( origin, "A=3; Path=/example/0", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie3); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -427,7 +438,8 @@ {*cookie3}}); std::unique_ptr<net::CanonicalCookie> cookie4(net::CanonicalCookie::Create( origin, "A=4; Path=/example/0", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie4); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -435,7 +447,8 @@ {*cookie4}}); std::unique_ptr<net::CanonicalCookie> cookie5(net::CanonicalCookie::Create( origin, "A=5; Domain=google.com", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie5); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -443,7 +456,8 @@ {*cookie5}}); std::unique_ptr<net::CanonicalCookie> cookie6(net::CanonicalCookie::Create( origin, "A=6; Domain=google.com", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie6); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -451,7 +465,8 @@ {*cookie6}}); std::unique_ptr<net::CanonicalCookie> cookie7(net::CanonicalCookie::Create( origin, "A=7; Domain=google.com; Path=/example/1", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie7); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -459,7 +474,8 @@ {*cookie7}}); std::unique_ptr<net::CanonicalCookie> cookie8(net::CanonicalCookie::Create( origin, "A=8; Domain=google.com; Path=/example/1", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie8); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -468,7 +484,8 @@ std::unique_ptr<net::CanonicalCookie> cookie9(net::CanonicalCookie::Create( origin, "A=9; Domain=www.google.com", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie9); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -476,7 +493,8 @@ {*cookie9}}); std::unique_ptr<net::CanonicalCookie> cookie10(net::CanonicalCookie::Create( origin, "A=10; Domain=www.google.com", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie10); helper->AddCookies({content::CookieAccessDetails::Type::kChange, origin, @@ -507,7 +525,8 @@ ASSERT_TRUE(helper->empty()); std::unique_ptr<net::CanonicalCookie> changed_cookie( net::CanonicalCookie::Create(url_google, "a=1", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(changed_cookie); helper->AddCookies({content::CookieAccessDetails::Type::kChange, url_google, @@ -519,7 +538,8 @@ net::CookieList cookies; std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( - url_google, "a=1", base::Time::Now(), absl::nullopt /* server_time */)); + url_google, "a=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie); cookies.push_back(*cookie); @@ -540,21 +560,24 @@ ASSERT_TRUE(helper->empty()); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - request_url, "a=1", base::Time::Now(), absl::nullopt /* server_time */)); + request_url, "a=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame1_url, request_url, {*cookie1}}); std::unique_ptr<net::CanonicalCookie> cookie2(net::CanonicalCookie::Create( - request_url, "b=1", base::Time::Now(), absl::nullopt /* server_time */)); + request_url, "b=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie2); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame1_url, request_url, {*cookie2}}); std::unique_ptr<net::CanonicalCookie> cookie3(net::CanonicalCookie::Create( - request_url, "c=1", base::Time::Now(), absl::nullopt /* server_time */)); + request_url, "c=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie3); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame1_url, @@ -587,7 +610,8 @@ // cookies. EXPECT_EQ(0U, helper->GetCookieCount()); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - frame1_url, "A=1", base::Time::Now(), absl::nullopt /* server_time */)); + frame1_url, "A=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame1_url, @@ -595,7 +619,8 @@ {*cookie1}}); EXPECT_EQ(1U, helper->GetCookieCount()); std::unique_ptr<net::CanonicalCookie> cookie2(net::CanonicalCookie::Create( - frame1_url, "B=1", base::Time::Now(), absl::nullopt /* server_time */)); + frame1_url, "B=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie2); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame1_url, @@ -609,7 +634,8 @@ // request to |frame1_url| is updated. // The cookie-name of |cookie3| must match the cookie-name of |cookie1|. std::unique_ptr<net::CanonicalCookie> cookie3(net::CanonicalCookie::Create( - frame1_url, "A=2", base::Time::Now(), absl::nullopt /* server_time */)); + frame1_url, "A=2", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie3); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame2_url, @@ -621,7 +647,8 @@ // below have a differnt path-value since the request URLs have different // paths. std::unique_ptr<net::CanonicalCookie> cookie4(net::CanonicalCookie::Create( - request1_url, "A=2", base::Time::Now(), absl::nullopt /* server_time */)); + request1_url, "A=2", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie4); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame2_url, @@ -629,7 +656,8 @@ {*cookie4}}); EXPECT_EQ(3U, helper->GetCookieCount()); std::unique_ptr<net::CanonicalCookie> cookie5(net::CanonicalCookie::Create( - request2_url, "A=2", base::Time::Now(), absl::nullopt /* server_time */)); + request2_url, "A=2", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie5); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame2_url, @@ -645,7 +673,8 @@ // Add a domain cookie and check if it increases the cookie count. std::unique_ptr<net::CanonicalCookie> cookie6(net::CanonicalCookie::Create( frame1_url, "A=3; Domain=.www.google.com", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie6); helper->AddCookies({content::CookieAccessDetails::Type::kChange, frame2_url,
diff --git a/components/browsing_data/content/local_shared_objects_container.cc b/components/browsing_data/content/local_shared_objects_container.cc index b6577269..e1f259a2 100644 --- a/components/browsing_data/content/local_shared_objects_container.cc +++ b/components/browsing_data/content/local_shared_objects_container.cc
@@ -104,15 +104,17 @@ ++count; } - // Count local storages for the domain of the given |origin|. - for (const auto& storage_origin : local_storages()->GetOrigins()) { - if (SameDomainOrHost(origin, storage_origin.GetURL())) + // Count local storages for the domain of the given `storage_key`. + for (const auto& storage_key : local_storages()->GetStorageKeys()) { + // TODO(https://crbug.com/1199077): Use the real StorageKey once migrated. + if (SameDomainOrHost(origin, storage_key.origin().GetURL())) ++count; } - // Count session storages for the domain of the given |origin|. - for (const auto& storage_origin : session_storages()->GetOrigins()) { - if (SameDomainOrHost(origin, storage_origin.GetURL())) + // Count session storages for the domain of the given `storage_key`. + for (const auto& storage_key : session_storages()->GetStorageKeys()) { + // TODO(https://crbug.com/1199077): Use the real StorageKey once migrated. + if (SameDomainOrHost(origin, storage_key.origin().GetURL())) ++count; } @@ -172,11 +174,15 @@ hosts.insert(cookie.Domain()); } - for (const auto& origin : local_storages()->GetOrigins()) - hosts.insert(origin.host()); + for (const auto& storage_key : local_storages()->GetStorageKeys()) { + // TODO(https://crbug.com/1199077): Use the real StorageKey once migrated. + hosts.insert(storage_key.origin().host()); + } - for (const auto& origin : session_storages()->GetOrigins()) - hosts.insert(origin.host()); + for (const auto& storage_key : session_storages()->GetStorageKeys()) { + // TODO(https://crbug.com/1199077): Use the real StorageKey once migrated. + hosts.insert(storage_key.origin().host()); + } for (const auto& storage_key : indexed_dbs()->GetStorageKeys()) { // TODO(https://crbug.com/1199077): Use the real StorageKey once migrated.
diff --git a/components/browsing_data/content/local_storage_helper.cc b/components/browsing_data/content/local_storage_helper.cc index 3b6114d..116500a9 100644 --- a/components/browsing_data/content/local_storage_helper.cc +++ b/components/browsing_data/content/local_storage_helper.cc
@@ -29,8 +29,8 @@ namespace { // Only websafe state is considered browsing data. -bool HasStorageScheme(const GURL& origin_url) { - return base::Contains(url::GetWebStorageSchemes(), origin_url.scheme()); +bool HasStorageScheme(const url::Origin& origin) { + return base::Contains(url::GetWebStorageSchemes(), origin.scheme()); } void GetUsageInfoCallback(LocalStorageHelper::FetchCallback callback, @@ -40,7 +40,7 @@ std::list<content::StorageUsageInfo> result; for (const content::StorageUsageInfo& info : infos) { - if (HasStorageScheme(info.origin.GetURL())) + if (HasStorageScheme(info.origin)) result.push_back(info); } @@ -65,12 +65,10 @@ base::BindOnce(&GetUsageInfoCallback, std::move(callback))); } -void LocalStorageHelper::DeleteOrigin(const url::Origin& origin, - base::OnceClosure callback) { +void LocalStorageHelper::DeleteStorageKey(const blink::StorageKey& storage_key, + base::OnceClosure callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - dom_storage_context_->DeleteLocalStorage( - // TODO(https://crbug.com/1212808): Use storage_key instead of origin. - blink::StorageKey(origin), std::move(callback)); + dom_storage_context_->DeleteLocalStorage(storage_key, std::move(callback)); } //--------------------------------------------------------- @@ -78,26 +76,27 @@ CannedLocalStorageHelper::CannedLocalStorageHelper(BrowserContext* context) : LocalStorageHelper(context) {} -void CannedLocalStorageHelper::Add(const url::Origin& origin) { - if (!HasStorageScheme(origin.GetURL())) +void CannedLocalStorageHelper::Add(const blink::StorageKey& storage_key) { + if (!HasStorageScheme(storage_key.origin())) return; - pending_origins_.insert(origin); + pending_storage_keys_.insert(storage_key); } void CannedLocalStorageHelper::Reset() { - pending_origins_.clear(); + pending_storage_keys_.clear(); } bool CannedLocalStorageHelper::empty() const { - return pending_origins_.empty(); + return pending_storage_keys_.empty(); } size_t CannedLocalStorageHelper::GetCount() const { - return pending_origins_.size(); + return pending_storage_keys_.size(); } -const std::set<url::Origin>& CannedLocalStorageHelper::GetOrigins() const { - return pending_origins_; +const std::set<blink::StorageKey>& CannedLocalStorageHelper::GetStorageKeys() + const { + return pending_storage_keys_; } void CannedLocalStorageHelper::StartFetching(FetchCallback callback) { @@ -105,17 +104,21 @@ DCHECK(!callback.is_null()); std::list<content::StorageUsageInfo> result; - for (const auto& origin : pending_origins_) - result.emplace_back(origin, 0, base::Time()); + for (const auto& storage_key : pending_storage_keys_) + result.emplace_back( + // TODO(https://crbug.com/1199077): Pass the real StorageKey when + // StorageUsageInfo is converted. + storage_key.origin(), 0, base::Time()); content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, base::BindOnce(std::move(callback), result)); } -void CannedLocalStorageHelper::DeleteOrigin(const url::Origin& origin, - base::OnceClosure callback) { - pending_origins_.erase(origin); - LocalStorageHelper::DeleteOrigin(origin, std::move(callback)); +void CannedLocalStorageHelper::DeleteStorageKey( + const blink::StorageKey& storage_key, + base::OnceClosure callback) { + pending_storage_keys_.erase(storage_key); + LocalStorageHelper::DeleteStorageKey(storage_key, std::move(callback)); } CannedLocalStorageHelper::~CannedLocalStorageHelper() = default;
diff --git a/components/browsing_data/content/local_storage_helper.h b/components/browsing_data/content/local_storage_helper.h index 35e296d..c0d8d4e 100644 --- a/components/browsing_data/content/local_storage_helper.h +++ b/components/browsing_data/content/local_storage_helper.h
@@ -17,16 +17,19 @@ #include "base/memory/ref_counted.h" #include "content/public/browser/dom_storage_context.h" #include "content/public/browser/storage_usage_info.h" -#include "url/origin.h" + +namespace blink { +class StorageKey; +} // namespace blink namespace content { class BrowserContext; -} +} // namespace content namespace browsing_data { // This class fetches local storage information and provides a -// means to delete the data associated with an origin. +// means to delete the data associated with an StorageKey. class LocalStorageHelper : public base::RefCounted<LocalStorageHelper> { public: using FetchCallback = @@ -38,11 +41,11 @@ // callback. This must be called only in the UI thread. virtual void StartFetching(FetchCallback callback); - // Deletes the local storage for the |origin|. |callback| is called when - // the deletion is sent to the database and |StartFetching()| doesn't return - // entries for |origin_url| anymore. - virtual void DeleteOrigin(const url::Origin& origin, - base::OnceClosure callback); + // Deletes the local storage for the `storage_key`. `callback` is called when + // the deletion is sent to the database and `StartFetching()` doesn't return + // entries for `storage_key` anymore. + virtual void DeleteStorageKey(const blink::StorageKey& storage_key, + base::OnceClosure callback); protected: friend class base::RefCounted<LocalStorageHelper>; @@ -54,16 +57,16 @@ DISALLOW_COPY_AND_ASSIGN(LocalStorageHelper); }; -// This class is a thin wrapper around LocalStorageHelper that does -// not fetch its information from the local storage context, but gets them -// passed by a call when accessed. +// This class is a thin wrapper around LocalStorageHelper that does not fetch +// its information from the local storage context, but gets them passed by a +// call when accessed. class CannedLocalStorageHelper : public LocalStorageHelper { public: explicit CannedLocalStorageHelper(content::BrowserContext* context); // Add a local storage to the set of canned local storages that is returned // by this helper. - void Add(const url::Origin& origin_url); + void Add(const blink::StorageKey& storage_key); // Clear the list of canned local storages. void Reset(); @@ -74,18 +77,18 @@ // Returns the number of local storages currently stored. size_t GetCount() const; - // Returns the set of origins that use local storage. - const std::set<url::Origin>& GetOrigins() const; + // Returns the set of StorageKeys that use local storage. + const std::set<blink::StorageKey>& GetStorageKeys() const; // LocalStorageHelper implementation. void StartFetching(FetchCallback callback) override; - void DeleteOrigin(const url::Origin& origin, - base::OnceClosure callback) override; + void DeleteStorageKey(const blink::StorageKey& storage_key, + base::OnceClosure callback) override; private: ~CannedLocalStorageHelper() override; - std::set<url::Origin> pending_origins_; + std::set<blink::StorageKey> pending_storage_keys_; DISALLOW_COPY_AND_ASSIGN(CannedLocalStorageHelper); };
diff --git a/components/browsing_data/content/local_storage_helper_browsertest.cc b/components/browsing_data/content/local_storage_helper_browsertest.cc index 9afda3d0..e117453c7 100644 --- a/components/browsing_data/content/local_storage_helper_browsertest.cc +++ b/components/browsing_data/content/local_storage_helper_browsertest.cc
@@ -138,8 +138,9 @@ new LocalStorageHelper(shell()->web_contents()->GetBrowserContext())); CreateLocalStorageDataForTest(); base::RunLoop delete_run_loop; - local_storage_helper->DeleteOrigin(url::Origin::Create(GURL(kOrigin1)), - delete_run_loop.QuitClosure()); + local_storage_helper->DeleteStorageKey( + blink::StorageKey::CreateFromStringForTesting(kOrigin1), + delete_run_loop.QuitClosure()); delete_run_loop.Run(); // Ensure the origin has been deleted, but other origins are intact. @@ -171,13 +172,15 @@ } IN_PROC_BROWSER_TEST_F(LocalStorageHelperTest, CannedAddLocalStorage) { - const GURL origin1("http://host1:1/"); - const GURL origin2("http://host2:1/"); + const blink::StorageKey storage_key1 = + blink::StorageKey::CreateFromStringForTesting("http://host1:1/"); + const blink::StorageKey storage_key2 = + blink::StorageKey::CreateFromStringForTesting("http://host2:1/"); scoped_refptr<CannedLocalStorageHelper> helper(new CannedLocalStorageHelper( shell()->web_contents()->GetBrowserContext())); - helper->Add(url::Origin::Create(origin1)); - helper->Add(url::Origin::Create(origin2)); + helper->Add(storage_key1); + helper->Add(storage_key2); TestCompletionCallback callback; helper->StartFetching(base::BindOnce(&TestCompletionCallback::callback, @@ -187,18 +190,19 @@ ASSERT_EQ(2u, result.size()); auto info = result.begin(); - EXPECT_EQ(origin1, info->origin.GetURL()); + EXPECT_EQ(storage_key1.origin(), info->origin); info++; - EXPECT_EQ(origin2, info->origin.GetURL()); + EXPECT_EQ(storage_key2.origin(), info->origin); } IN_PROC_BROWSER_TEST_F(LocalStorageHelperTest, CannedUnique) { - const GURL origin("http://host1:1/"); + const blink::StorageKey storage_key = + blink::StorageKey::CreateFromStringForTesting("http://host1:1/"); scoped_refptr<CannedLocalStorageHelper> helper(new CannedLocalStorageHelper( shell()->web_contents()->GetBrowserContext())); - helper->Add(url::Origin::Create(origin)); - helper->Add(url::Origin::Create(origin)); + helper->Add(storage_key); + helper->Add(storage_key); TestCompletionCallback callback; helper->StartFetching(base::BindOnce(&TestCompletionCallback::callback, @@ -207,7 +211,7 @@ std::list<content::StorageUsageInfo> result = callback.result(); ASSERT_EQ(1u, result.size()); - EXPECT_EQ(origin, result.begin()->origin.GetURL()); + EXPECT_EQ(storage_key.origin(), result.begin()->origin); } } // namespace
diff --git a/components/browsing_data/content/local_storage_helper_unittest.cc b/components/browsing_data/content/local_storage_helper_unittest.cc index 0f14d98..8919e5504 100644 --- a/components/browsing_data/content/local_storage_helper_unittest.cc +++ b/components/browsing_data/content/local_storage_helper_unittest.cc
@@ -8,7 +8,7 @@ #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_browser_context.h" #include "testing/gtest/include/gtest/gtest.h" -#include "url/gurl.h" +#include "third_party/blink/public/common/storage_key/storage_key.h" namespace browsing_data { @@ -21,13 +21,14 @@ TEST_F(CannedLocalStorageTest, Empty) { content::TestBrowserContext context; - const GURL origin("http://host1:1/"); + const blink::StorageKey storage_key = + blink::StorageKey::CreateFromStringForTesting("http://host1:1/"); scoped_refptr<CannedLocalStorageHelper> helper( new CannedLocalStorageHelper(&context)); ASSERT_TRUE(helper->empty()); - helper->Add(url::Origin::Create(origin)); + helper->Add(storage_key); ASSERT_FALSE(helper->empty()); helper->Reset(); ASSERT_TRUE(helper->empty()); @@ -36,37 +37,44 @@ TEST_F(CannedLocalStorageTest, Delete) { content::TestBrowserContext context; - const GURL origin1("http://host1:9000"); - const GURL origin2("http://example.com"); - const GURL origin3("http://foo.example.com"); + const blink::StorageKey storage_key1 = + blink::StorageKey::CreateFromStringForTesting("http://host1:9000"); + const blink::StorageKey storage_key2 = + blink::StorageKey::CreateFromStringForTesting("http://example.com"); + const blink::StorageKey storage_key3 = + blink::StorageKey::CreateFromStringForTesting("http://foo.example.com"); scoped_refptr<CannedLocalStorageHelper> helper( new CannedLocalStorageHelper(&context)); EXPECT_TRUE(helper->empty()); - helper->Add(url::Origin::Create(origin1)); - helper->Add(url::Origin::Create(origin2)); - helper->Add(url::Origin::Create(origin3)); + helper->Add(storage_key1); + helper->Add(storage_key2); + helper->Add(storage_key3); EXPECT_EQ(3u, helper->GetCount()); - helper->DeleteOrigin(url::Origin::Create(origin2), base::DoNothing()); + helper->DeleteStorageKey(storage_key2, base::DoNothing()); EXPECT_EQ(2u, helper->GetCount()); - helper->DeleteOrigin(url::Origin::Create(origin1), base::DoNothing()); + helper->DeleteStorageKey(storage_key1, base::DoNothing()); EXPECT_EQ(1u, helper->GetCount()); } TEST_F(CannedLocalStorageTest, IgnoreExtensionsAndDevTools) { content::TestBrowserContext context; - const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/"); - const GURL origin2("devtools://abcdefghijklmnopqrstuvwxyz/"); + const blink::StorageKey storage_key1 = + blink::StorageKey::CreateFromStringForTesting( + "chrome-extension://abcdefghijklmnopqrstuvwxyz/"); + const blink::StorageKey storage_key2 = + blink::StorageKey::CreateFromStringForTesting( + "devtools://abcdefghijklmnopqrstuvwxyz/"); scoped_refptr<CannedLocalStorageHelper> helper( new CannedLocalStorageHelper(&context)); ASSERT_TRUE(helper->empty()); - helper->Add(url::Origin::Create(origin1)); + helper->Add(storage_key1); ASSERT_TRUE(helper->empty()); - helper->Add(url::Origin::Create(origin2)); + helper->Add(storage_key2); ASSERT_TRUE(helper->empty()); }
diff --git a/components/browsing_data/content/mock_cookie_helper.cc b/components/browsing_data/content/mock_cookie_helper.cc index c4cd385..59657cc 100644 --- a/components/browsing_data/content/mock_cookie_helper.cc +++ b/components/browsing_data/content/mock_cookie_helper.cc
@@ -37,7 +37,8 @@ void MockCookieHelper::AddCookieSamples(const GURL& url, const std::string& cookie_line) { std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create( - url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */)); + url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); if (cc.get()) { for (const auto& cookie : cookie_list_) {
diff --git a/components/browsing_data/content/mock_local_storage_helper.cc b/components/browsing_data/content/mock_local_storage_helper.cc index 366b8fd..f693671 100644 --- a/components/browsing_data/content/mock_local_storage_helper.cc +++ b/components/browsing_data/content/mock_local_storage_helper.cc
@@ -9,7 +9,6 @@ #include "base/callback.h" #include "base/containers/contains.h" #include "testing/gtest/include/gtest/gtest.h" -#include "url/gurl.h" namespace browsing_data { @@ -24,25 +23,29 @@ callback_ = std::move(callback); } -void MockLocalStorageHelper::DeleteOrigin(const url::Origin& origin, - base::OnceClosure callback) { - ASSERT_TRUE(base::Contains(origins_, origin)); - last_deleted_origin_ = origin; - origins_[origin] = false; +void MockLocalStorageHelper::DeleteStorageKey( + const blink::StorageKey& storage_key, + base::OnceClosure callback) { + ASSERT_TRUE(base::Contains(storage_keys_, storage_key)); + last_deleted_storage_key_ = storage_key; + storage_keys_[storage_key] = false; std::move(callback).Run(); } void MockLocalStorageHelper::AddLocalStorageSamples() { - const GURL kOrigin1("http://host1:1/"); - const GURL kOrigin2("http://host2:2/"); - AddLocalStorageForOrigin(url::Origin::Create(kOrigin1), 1); - AddLocalStorageForOrigin(url::Origin::Create(kOrigin2), 2); + const blink::StorageKey kStorageKey1 = + blink::StorageKey::CreateFromStringForTesting("http://host1:1/"); + const blink::StorageKey kStorageKey2 = + blink::StorageKey::CreateFromStringForTesting("http://host2:2/"); + AddLocalStorageForStorageKey(kStorageKey1, 1); + AddLocalStorageForStorageKey(kStorageKey2, 2); } -void MockLocalStorageHelper::AddLocalStorageForOrigin(const url::Origin& origin, - int64_t size) { - response_.emplace_back(origin, size, base::Time()); - origins_[origin] = true; +void MockLocalStorageHelper::AddLocalStorageForStorageKey( + const blink::StorageKey& storage_key, + int64_t size) { + response_.emplace_back(storage_key.origin(), size, base::Time()); + storage_keys_[storage_key] = true; } void MockLocalStorageHelper::Notify() { @@ -50,12 +53,12 @@ } void MockLocalStorageHelper::Reset() { - for (auto& pair : origins_) + for (auto& pair : storage_keys_) pair.second = true; } bool MockLocalStorageHelper::AllDeleted() { - for (const auto& pair : origins_) { + for (const auto& pair : storage_keys_) { if (pair.second) return false; }
diff --git a/components/browsing_data/content/mock_local_storage_helper.h b/components/browsing_data/content/mock_local_storage_helper.h index c0b69aca..5b6516a 100644 --- a/components/browsing_data/content/mock_local_storage_helper.h +++ b/components/browsing_data/content/mock_local_storage_helper.h
@@ -11,6 +11,7 @@ #include "base/callback.h" #include "base/macros.h" #include "components/browsing_data/content/local_storage_helper.h" +#include "third_party/blink/public/common/storage_key/storage_key.h" namespace browsing_data { @@ -23,14 +24,15 @@ // browsing_data::LocalStorageHelper implementation. void StartFetching(FetchCallback callback) override; - void DeleteOrigin(const url::Origin& origin, - base::OnceClosure callback) override; + void DeleteStorageKey(const blink::StorageKey& storage_key, + base::OnceClosure callback) override; // Adds some LocalStorageInfo samples. void AddLocalStorageSamples(); - // Add a LocalStorageInfo entry for a single origin. - void AddLocalStorageForOrigin(const url::Origin& origin, int64_t size); + // Add a LocalStorageInfo entry for a single `storage_key`. + void AddLocalStorageForStorageKey(const blink::StorageKey& storage_key, + int64_t size); // Notifies the callback. void Notify(); @@ -42,14 +44,14 @@ // invocation. bool AllDeleted(); - url::Origin last_deleted_origin_; + blink::StorageKey last_deleted_storage_key_; private: ~MockLocalStorageHelper() override; FetchCallback callback_; - std::map<const url::Origin, bool> origins_; + std::map<const blink::StorageKey, bool> storage_keys_; std::list<content::StorageUsageInfo> response_;
diff --git a/components/captive_portal/content/captive_portal_login_detector.cc b/components/captive_portal/content/captive_portal_login_detector.cc index 54f7e2f..922dfd4 100644 --- a/components/captive_portal/content/captive_portal_login_detector.cc +++ b/components/captive_portal/content/captive_portal_login_detector.cc
@@ -24,8 +24,7 @@ return; } - captive_portal_service_->DetectCaptivePortal( - CaptivePortalProbeReason::kLoginTabLoad); + captive_portal_service_->DetectCaptivePortal(); } void CaptivePortalLoginDetector::OnCaptivePortalResults(
diff --git a/components/captive_portal/content/captive_portal_service.cc b/components/captive_portal/content/captive_portal_service.cc index 967bbbe..ea9da89 100644 --- a/components/captive_portal/content/captive_portal_service.cc +++ b/components/captive_portal/content/captive_portal_service.cc
@@ -13,7 +13,6 @@ #include "base/notreached.h" #include "base/time/tick_clock.h" #include "build/build_config.h" -#include "components/captive_portal/core/captive_portal_metrics.h" #include "components/captive_portal/core/captive_portal_types.h" #include "components/embedder_support/pref_names.h" #include "components/prefs/pref_service.h" @@ -154,8 +153,7 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); } -void CaptivePortalService::DetectCaptivePortal( - CaptivePortalProbeReason probe_reason) { +void CaptivePortalService::DetectCaptivePortal() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // Detection should be disabled only in tests. @@ -173,11 +171,10 @@ check_captive_portal_timer_.Start( FROM_HERE, time_until_next_check, base::BindOnce(&CaptivePortalService::DetectCaptivePortalInternal, - base::Unretained(this), probe_reason)); + base::Unretained(this))); } -void CaptivePortalService::DetectCaptivePortalInternal( - CaptivePortalProbeReason probe_reason) { +void CaptivePortalService::DetectCaptivePortalInternal() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK(state_ == STATE_TIMER_RUNNING || state_ == STATE_IDLE); DCHECK(!TimerRunning()); @@ -222,8 +219,6 @@ } })"); - captive_portal::CaptivePortalMetrics::LogCaptivePortalProbeReason( - probe_reason); captive_portal_detector_->DetectCaptivePortal( test_url_, base::BindOnce(&CaptivePortalService::OnPortalDetectionCompleted, @@ -323,7 +318,7 @@ // Since a captive portal request was queued or running, something may be // expecting to receive a captive portal result. - DetectCaptivePortal(CaptivePortalProbeReason::kUnspecified); + DetectCaptivePortal(); } }
diff --git a/components/captive_portal/content/captive_portal_service.h b/components/captive_portal/content/captive_portal_service.h index b03db3f..da0dba5 100644 --- a/components/captive_portal/content/captive_portal_service.h +++ b/components/captive_portal/content/captive_portal_service.h
@@ -13,6 +13,7 @@ #include "base/time/time.h" #include "base/timer/timer.h" #include "components/captive_portal/core/captive_portal_detector.h" +#include "components/captive_portal/core/captive_portal_types.h" #include "components/keyed_service/core/keyed_service.h" #include "components/prefs/pref_member.h" #include "net/base/backoff_entry.h" @@ -71,7 +72,7 @@ // Triggers a check for a captive portal. If there's already a check in // progress, does nothing. Throttles the rate at which requests are sent. // Always sends the result notification asynchronously. - void DetectCaptivePortal(CaptivePortalProbeReason probe_reason); + void DetectCaptivePortal(); base::CallbackListSubscription RegisterCallback( const base::RepeatingCallback<void(const Results&)>& cb) { @@ -131,7 +132,7 @@ // Initiates a captive portal check, without any throttling. If the service // is disabled, just acts like there's an Internet connection. - void DetectCaptivePortalInternal(CaptivePortalProbeReason probe_reason); + void DetectCaptivePortalInternal(); // Called by CaptivePortalDetector when detection completes. void OnPortalDetectionCompleted(
diff --git a/components/captive_portal/content/captive_portal_service_unittest.cc b/components/captive_portal/content/captive_portal_service_unittest.cc index 2778e31..608f41a 100644 --- a/components/captive_portal/content/captive_portal_service_unittest.cc +++ b/components/captive_portal/content/captive_portal_service_unittest.cc
@@ -14,6 +14,7 @@ #include "base/test/test_timeouts.h" #include "components/captive_portal/content/captive_portal_service.h" #include "components/captive_portal/core/captive_portal_testing_utils.h" +#include "components/captive_portal/core/captive_portal_types.h" #include "components/embedder_support/pref_names.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/testing_pref_service.h" @@ -150,7 +151,7 @@ ASSERT_EQ(base::TimeDelta(), GetTimeUntilNextRequest()); CaptivePortalObserver observer(service()); - service()->DetectCaptivePortal(CaptivePortalProbeReason::kCertificateError); + service()->DetectCaptivePortal(); EXPECT_EQ(CaptivePortalService::STATE_TIMER_RUNNING, service()->state()); EXPECT_FALSE(FetchingURL()); @@ -182,7 +183,7 @@ ASSERT_EQ(base::TimeDelta(), GetTimeUntilNextRequest()); CaptivePortalObserver observer(service()); - service()->DetectCaptivePortal(CaptivePortalProbeReason::kCertificateError); + service()->DetectCaptivePortal(); EXPECT_EQ(CaptivePortalService::STATE_TIMER_RUNNING, service()->state()); EXPECT_FALSE(FetchingURL()); @@ -366,7 +367,7 @@ CaptivePortalObserver observer(service()); // Needed to create the URLFetcher, even if it never returns any results. - service()->DetectCaptivePortal(CaptivePortalProbeReason::kCertificateError); + service()->DetectCaptivePortal(); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(FetchingURL()); @@ -393,7 +394,7 @@ set_initial_backoff_no_portal(base::TimeDelta::FromDays(1)); CaptivePortalObserver observer(service()); - service()->DetectCaptivePortal(CaptivePortalProbeReason::kCertificateError); + service()->DetectCaptivePortal(); EXPECT_FALSE(FetchingURL()); EXPECT_TRUE(TimerRunning()); @@ -420,7 +421,7 @@ RunDisabledTest(0); CaptivePortalObserver observer(service()); - service()->DetectCaptivePortal(CaptivePortalProbeReason::kCertificateError); + service()->DetectCaptivePortal(); EXPECT_FALSE(FetchingURL()); EXPECT_TRUE(TimerRunning());
diff --git a/components/captive_portal/content/captive_portal_tab_reloader.cc b/components/captive_portal/content/captive_portal_tab_reloader.cc index 955d9e6..1bd28d3 100644 --- a/components/captive_portal/content/captive_portal_tab_reloader.cc +++ b/components/captive_portal/content/captive_portal_tab_reloader.cc
@@ -9,6 +9,7 @@ #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" +#include "components/captive_portal/core/captive_portal_types.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" @@ -22,24 +23,23 @@ // portal check. const int kDefaultSlowSSLTimeSeconds = 30; -// Returns the appropriate CaptivePortalProbeReason if |error| may indicate a -// captive portal, otherwise returns nullopt. -absl::optional<CaptivePortalProbeReason> SslNetErrorMayImplyCaptivePortal( - int error) { +// Returns true if |error| may indicate a captive portal, otherwise returns +// false. +bool SslNetErrorMayImplyCaptivePortal(int error) { // May be returned when a captive portal silently blocks an SSL request. if (error == net::ERR_CONNECTION_TIMED_OUT) - return CaptivePortalProbeReason::kTimeout; + return true; // May be returned when a captive portal lets SSL requests connect, but // disconnects Chrome after Chrome starts SSL negotiation, or sends an // HTTP response. if (error == net::ERR_SSL_PROTOCOL_ERROR) - return CaptivePortalProbeReason::kSslProtocolError; + return true; if (net::IsCertificateError(error)) - return CaptivePortalProbeReason::kCertificateError; + return true; - return absl::nullopt; + return false; } } // namespace @@ -90,9 +90,7 @@ // If |net_error| is not an error code that could indicate there's a captive // portal, reset the state. - absl::optional<CaptivePortalProbeReason> probe_reason = - SslNetErrorMayImplyCaptivePortal(net_error); - if (!probe_reason.has_value()) { + if (!SslNetErrorMayImplyCaptivePortal(net_error)) { // TODO(mmenke): If the new URL is the same as the old broken URL, and the // request succeeds, should probably trigger another // captive portal check. @@ -103,7 +101,7 @@ // The page returned an error out before the timer triggered. Go ahead and // try to detect a portal now, rather than waiting for the timer. if (state_ == STATE_TIMER_RUNNING) { - OnSlowSSLConnect(probe_reason.value()); + OnSlowSSLConnect(); return; } @@ -187,19 +185,16 @@ // ERR_CERT_COMMON_NAME_INVALID and ERR_CERT_AUTHORITY_INVALID. It's unclear // if captive portals cause any others. if (state_ == STATE_TIMER_RUNNING) - SetState(STATE_MAYBE_BROKEN_BY_PORTAL, - CaptivePortalProbeReason::kCertificateError); + SetState(STATE_MAYBE_BROKEN_BY_PORTAL); } -void CaptivePortalTabReloader::OnSlowSSLConnect( - CaptivePortalProbeReason probe_reason) { - SetState(STATE_MAYBE_BROKEN_BY_PORTAL, probe_reason); +void CaptivePortalTabReloader::OnSlowSSLConnect() { + SetState(STATE_MAYBE_BROKEN_BY_PORTAL); } void CaptivePortalTabReloader::OnSecureDnsNetworkError() { if (state_ == STATE_NONE || state_ == STATE_TIMER_RUNNING) { - SetState(STATE_MAYBE_BROKEN_BY_PORTAL, - CaptivePortalProbeReason::kSecureDnsError); + SetState(STATE_MAYBE_BROKEN_BY_PORTAL); return; } @@ -210,9 +205,7 @@ } } -void CaptivePortalTabReloader::SetState( - State new_state, - absl::optional<CaptivePortalProbeReason> probe_reason) { +void CaptivePortalTabReloader::SetState(State new_state) { // Stop the timer even when old and new states are the same. if (state_ == STATE_TIMER_RUNNING) { slow_ssl_load_timer_.Stop(); @@ -252,15 +245,12 @@ case STATE_TIMER_RUNNING: slow_ssl_load_timer_.Start( FROM_HERE, slow_ssl_load_time_, - base::BindOnce( - &CaptivePortalTabReloader::OnSlowSSLConnect, - weak_factory_.GetWeakPtr(), - CaptivePortalProbeReason::kTimeout /* probe_reason */)); + base::BindOnce(&CaptivePortalTabReloader::OnSlowSSLConnect, + weak_factory_.GetWeakPtr())); break; case STATE_MAYBE_BROKEN_BY_PORTAL: - DCHECK(probe_reason.has_value()); - CheckForCaptivePortal(probe_reason.value()); + CheckForCaptivePortal(); break; case STATE_NEEDS_RELOAD: @@ -299,10 +289,9 @@ open_login_tab_callback_.Run(); } -void CaptivePortalTabReloader::CheckForCaptivePortal( - CaptivePortalProbeReason probe_reason) { +void CaptivePortalTabReloader::CheckForCaptivePortal() { if (captive_portal_service_) - captive_portal_service_->DetectCaptivePortal(probe_reason); + captive_portal_service_->DetectCaptivePortal(); } } // namespace captive_portal
diff --git a/components/captive_portal/content/captive_portal_tab_reloader.h b/components/captive_portal/content/captive_portal_tab_reloader.h index dbd2278..f02fa09b 100644 --- a/components/captive_portal/content/captive_portal_tab_reloader.h +++ b/components/captive_portal/content/captive_portal_tab_reloader.h
@@ -12,8 +12,8 @@ #include "base/time/time.h" #include "base/timer/timer.h" #include "components/captive_portal/content/captive_portal_service.h" +#include "components/captive_portal/core/captive_portal_types.h" #include "net/dns/public/resolve_error_info.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace content { class WebContents; @@ -138,13 +138,11 @@ // Sets |state_| and takes any action associated with the new state. Also // stops the timer, if needed. If |new_state| is STATE_MAYBE_BROKEN_BY_PORTAL, // |probe_trigger| should be specified. - void SetState( - State new_state, - absl::optional<CaptivePortalProbeReason> probe_reason = absl::nullopt); + void SetState(State new_state); // Called by a timer when an SSL main frame provisional load is taking a // while to commit. - void OnSlowSSLConnect(CaptivePortalProbeReason probe_reason); + void OnSlowSSLConnect(); // Called when a main frame loads with a secure DNS network error. void OnSecureDnsNetworkError(); @@ -165,7 +163,7 @@ virtual void MaybeOpenCaptivePortalLoginTab(); // Has |captive_portal_service_| (if present) start a captive portal check. - virtual void CheckForCaptivePortal(CaptivePortalProbeReason probe_reason); + virtual void CheckForCaptivePortal(); CaptivePortalService* captive_portal_service_; content::WebContents* web_contents_;
diff --git a/components/captive_portal/content/captive_portal_tab_reloader_unittest.cc b/components/captive_portal/content/captive_portal_tab_reloader_unittest.cc index c9c50b4..9766c8a 100644 --- a/components/captive_portal/content/captive_portal_tab_reloader_unittest.cc +++ b/components/captive_portal/content/captive_portal_tab_reloader_unittest.cc
@@ -46,8 +46,7 @@ // CaptivePortalTabReloader: MOCK_METHOD0(ReloadTab, void()); MOCK_METHOD0(MaybeOpenCaptivePortalLoginTab, void()); - MOCK_METHOD1(CheckForCaptivePortal, - void(CaptivePortalProbeReason probe_reason)); + MOCK_METHOD0(CheckForCaptivePortal, void()); private: DISALLOW_COPY_AND_ASSIGN(TestCaptivePortalTabReloader); @@ -87,9 +86,7 @@ tab_reloader().state()); EXPECT_TRUE(tab_reloader().TimerRunning()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -116,9 +113,7 @@ tab_reloader().state()); EXPECT_TRUE(tab_reloader().TimerRunning()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); tab_reloader().OnLoadCommitted(net::ERR_CONNECTION_TIMED_OUT, net::ResolveErrorInfo(net::OK)); EXPECT_FALSE(tab_reloader().TimerRunning()); @@ -140,9 +135,7 @@ tab_reloader().state()); EXPECT_TRUE(tab_reloader().TimerRunning()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -184,9 +177,7 @@ TEST_F(CaptivePortalTabReloaderTest, Login) { tab_reloader().OnLoadStart(true); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -223,9 +214,7 @@ TEST_F(CaptivePortalTabReloaderTest, LoginLate) { tab_reloader().OnLoadStart(true); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -259,9 +248,7 @@ // The error page commits, which should trigger a captive portal check, // since the timer's still running. - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); tab_reloader().OnLoadCommitted(net::ERR_CONNECTION_TIMED_OUT, net::ResolveErrorInfo(net::OK)); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -294,9 +281,7 @@ // The page encounters a secure DNS network error. The error page commits, // which should trigger a captive portal check, even for HTTP pages. - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kSecureDnsError)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); tab_reloader().OnLoadCommitted( net::ERR_NAME_NOT_RESOLVED, net::ResolveErrorInfo(net::ERR_CERT_COMMON_NAME_INVALID, @@ -325,9 +310,7 @@ // The page encounters a secure DNS network error. The error page commits, // which should trigger a captive portal check. The SSL timer should be // cancelled. - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kSecureDnsError)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); tab_reloader().OnLoadCommitted( net::ERR_NAME_NOT_RESOLVED, net::ResolveErrorInfo(net::ERR_CERT_COMMON_NAME_INVALID, @@ -354,9 +337,7 @@ tab_reloader().state()); EXPECT_TRUE(tab_reloader().TimerRunning()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -390,12 +371,7 @@ tab_reloader().state()); EXPECT_TRUE(tab_reloader().TimerRunning()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kSecureDnsError)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(2); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -429,9 +405,7 @@ tab_reloader().state()); EXPECT_TRUE(tab_reloader().TimerRunning()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -489,9 +463,7 @@ // The error page commits, which should trigger a captive portal check, // since the timer's still running. - EXPECT_CALL(tab_reloader(), CheckForCaptivePortal( - CaptivePortalProbeReason::kSslProtocolError)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); tab_reloader().OnLoadCommitted(net::ERR_SSL_PROTOCOL_ERROR, net::ResolveErrorInfo(net::OK)); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -521,9 +493,7 @@ // The error page commits, which should trigger a captive portal check, // since the timer's still running. - EXPECT_CALL(tab_reloader(), CheckForCaptivePortal( - CaptivePortalProbeReason::kSslProtocolError)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); tab_reloader().OnLoadCommitted(net::ERR_SSL_PROTOCOL_ERROR, net::ResolveErrorInfo(net::OK)); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -562,9 +532,7 @@ TEST_F(CaptivePortalTabReloaderTest, AlreadyLoggedIn) { tab_reloader().OnLoadStart(true); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -655,9 +623,7 @@ tab_reloader().state()); // The rest proceeds as normal. - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, tab_reloader().state()); @@ -721,9 +687,7 @@ tab_reloader().state()); EXPECT_TRUE(tab_reloader().TimerRunning()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL, @@ -751,9 +715,7 @@ EXPECT_EQ(CaptivePortalTabReloader::STATE_TIMER_RUNNING, tab_reloader().state()); - EXPECT_CALL(tab_reloader(), - CheckForCaptivePortal(CaptivePortalProbeReason::kTimeout)) - .Times(1); + EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(tab_reloader().TimerRunning()); EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
diff --git a/components/captive_portal/core/captive_portal_metrics.cc b/components/captive_portal/core/captive_portal_metrics.cc index f45bc114..e156dbc1 100644 --- a/components/captive_portal/core/captive_portal_metrics.cc +++ b/components/captive_portal/core/captive_portal_metrics.cc
@@ -8,11 +8,6 @@ namespace captive_portal { -void CaptivePortalMetrics::LogCaptivePortalProbeReason( - CaptivePortalProbeReason probe_reason) { - UMA_HISTOGRAM_ENUMERATION("CaptivePortal.ProbeReason", probe_reason); -} - void CaptivePortalMetrics::LogCaptivePortalBlockingPageEvent( CaptivePortalBlockingPageEvent event) { UMA_HISTOGRAM_ENUMERATION("interstitial.captive_portal", event,
diff --git a/components/captive_portal/core/captive_portal_metrics.h b/components/captive_portal/core/captive_portal_metrics.h index c9185de..f9f66c8 100644 --- a/components/captive_portal/core/captive_portal_metrics.h +++ b/components/captive_portal/core/captive_portal_metrics.h
@@ -7,7 +7,6 @@ #include "base/macros.h" #include "components/captive_portal/core/captive_portal_export.h" -#include "components/captive_portal/core/captive_portal_types.h" namespace captive_portal { @@ -22,9 +21,6 @@ CAPTIVE_PORTAL_BLOCKING_PAGE_EVENT_COUNT }; - static void LogCaptivePortalProbeReason( - CaptivePortalProbeReason probe_reason); - // Logs a user action when the user is shown a captive portal error page. static void LogCaptivePortalBlockingPageEvent( CaptivePortalBlockingPageEvent event);
diff --git a/components/captive_portal/core/captive_portal_types.h b/components/captive_portal/core/captive_portal_types.h index bb806535..68b1c5f 100644 --- a/components/captive_portal/core/captive_portal_types.h +++ b/components/captive_portal/core/captive_portal_types.h
@@ -23,25 +23,6 @@ RESULT_COUNT }; -// Possible causes of a captive portal probe. These values are persisted to -// logs. Entries should not be renumbered and numeric values should never be -// reused. Please keep in sync with "CaptivePortalProbeReason" in -// src/tools/metrics/histograms/enums.xml. -enum class CaptivePortalProbeReason { - kUnspecified = 0, - // Timeout - kTimeout = 1, - // Certificate error - kCertificateError = 2, - // SSL protocol error - kSslProtocolError = 3, - // First load of login tab - kLoginTabLoad = 4, - // Secure DNS error - kSecureDnsError = 5, - kMaxValue = kSecureDnsError, -}; - CAPTIVE_PORTAL_EXPORT extern std::string CaptivePortalResultToString( CaptivePortalResult result);
diff --git a/components/commerce/DIR_METADATA b/components/commerce/DIR_METADATA new file mode 100644 index 0000000..676fe2a --- /dev/null +++ b/components/commerce/DIR_METADATA
@@ -0,0 +1,4 @@ +monorail { + component: "UI>Browser>Shopping" +} +team_email: "chrome-shopping@google.com"
diff --git a/components/commerce/OWNERS b/components/commerce/OWNERS new file mode 100644 index 0000000..a991d86 --- /dev/null +++ b/components/commerce/OWNERS
@@ -0,0 +1,3 @@ +ayman@chromium.org +davidjm@chromium.org +wychen@chromium.org
diff --git a/components/commerce/README b/components/commerce/README new file mode 100644 index 0000000..7ad75b7a --- /dev/null +++ b/components/commerce/README
@@ -0,0 +1,5 @@ +This component contains all of the cross-platform logic and protos for commerce +and shopping related projects. + +Commerce is structured as a layered component. See: +http://www.chromium.org/developers/design-documents/layered-components-design
diff --git a/components/commerce/core/BUILD.gn b/components/commerce/core/BUILD.gn new file mode 100644 index 0000000..30943be1 --- /dev/null +++ b/components/commerce/core/BUILD.gn
@@ -0,0 +1,17 @@ +# Copyright 2021 The Chromium Authors.All rights reserved. +# Use of this source code is governed by a BSD - style license that can be +# found in the LICENSE file. + +import("//build/config/android/rules.gni") +import("//third_party/protobuf/proto_library.gni") + +proto_library("proto") { + sources = [ "proto/price_tracking.proto" ] +} + +if (is_android) { + proto_java_library("proto_java") { + proto_path = "." + sources = [ "proto/price_tracking.proto" ] + } +}
diff --git a/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/state/proto/price_tracking.proto b/components/commerce/core/proto/price_tracking.proto similarity index 92% rename from chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/state/proto/price_tracking.proto rename to components/commerce/core/proto/price_tracking.proto index fca23f84..d43ae98 100644 --- a/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/state/proto/price_tracking.proto +++ b/components/commerce/core/proto/price_tracking.proto
@@ -4,9 +4,9 @@ syntax = "proto2"; -package org.chromium.chrome.browser.tab.proto; +package org.chromium.components.commerce; -option java_package = "org.chromium.chrome.browser.tab.proto"; +option java_package = "org.chromium.components.commerce"; message PriceTrackingData { // metadata relating to the product
diff --git a/components/content_settings/browser/page_specific_content_settings.cc b/components/content_settings/browser/page_specific_content_settings.cc index 83d32f65e..2f60f40 100644 --- a/components/content_settings/browser/page_specific_content_settings.cc +++ b/components/content_settings/browser/page_specific_content_settings.cc
@@ -553,7 +553,10 @@ : allowed_local_shared_objects_; browsing_data::CannedLocalStorageHelper* helper = local ? container.local_storages() : container.session_storages(); - helper->Add(url::Origin::Create(url)); + helper->Add( + // TODO(https://crbug.com/1199077): Pass the real StorageKey into this + // function directly. + blink::StorageKey(url::Origin::Create(url))); if (blocked_by_policy) { OnContentBlocked(ContentSettingsType::COOKIES);
diff --git a/components/content_settings/browser/page_specific_content_settings_unittest.cc b/components/content_settings/browser/page_specific_content_settings_unittest.cc index 3342b41..fd559fb 100644 --- a/components/content_settings/browser/page_specific_content_settings_unittest.cc +++ b/components/content_settings/browser/page_specific_content_settings_unittest.cc
@@ -124,7 +124,8 @@ // popup. GURL origin("http://google.com"); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kChange, @@ -171,7 +172,8 @@ // Block a cookie. std::unique_ptr<net::CanonicalCookie> cookie2(net::CanonicalCookie::Create( - origin, "C=D", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "C=D", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie2); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kChange, @@ -258,7 +260,8 @@ // Record a cookie. GURL origin("http://google.com"); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kChange, @@ -272,7 +275,8 @@ // Record a blocked cookie. std::unique_ptr<net::CanonicalCookie> cookie2(net::CanonicalCookie::Create( - origin, "C=D", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "C=D", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie2); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kChange, @@ -313,7 +317,8 @@ bool blocked_by_policy = false; GURL origin("http://google.com"); std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( - origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kChange, @@ -326,7 +331,8 @@ std::unique_ptr<net::CanonicalCookie> other_cookie( net::CanonicalCookie::Create(GURL("http://google.com"), "CookieName=CookieValue", base::Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(other_cookie); cookie_list.push_back(*other_cookie); @@ -349,9 +355,10 @@ PageSpecificContentSettings* content_settings = PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame()); bool blocked_by_policy = false; - auto cookie = net::CanonicalCookie::Create(GURL("http://google.com"), "k=v", - base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie = net::CanonicalCookie::Create( + GURL("http://google.com"), "k=v", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kRead, GURL("http://google.com"), @@ -387,18 +394,22 @@ PageSpecificContentSettings* content_settings = PageSpecificContentSettings::GetForFrame(web_contents()->GetMainFrame()); bool blocked_by_policy = false; - auto cookie1 = net::CanonicalCookie::Create(GURL("http://google.com"), "k1=v", - base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie1 = net::CanonicalCookie::Create( + GURL("http://google.com"), "k1=v", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); auto cookie2 = net::CanonicalCookie::Create( GURL("http://www.google.com"), "k2=v; Domain=google.com", - base::Time::Now(), absl::nullopt /* server_time */); + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); auto cookie3 = net::CanonicalCookie::Create( GURL("http://www.google.com"), "k3=v; Domain=.google.com", - base::Time::Now(), absl::nullopt /* server_time */); + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); auto cookie4 = net::CanonicalCookie::Create( GURL("http://www.google.com"), "k4=v; Domain=.www.google.com", - base::Time::Now(), absl::nullopt /* server_time */); + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kRead, GURL("http://www.google.com"), @@ -406,9 +417,10 @@ {*cookie1, *cookie2, *cookie3, *cookie4}, blocked_by_policy}); - auto cookie5 = net::CanonicalCookie::Create(GURL("https://www.google.com"), - "k5=v", base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie5 = net::CanonicalCookie::Create( + GURL("https://www.google.com"), "k5=v", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); GetHandle()->OnCookiesAccessed(web_contents()->GetMainFrame(), {content::CookieAccessDetails::Type::kRead, GURL("https://www.google.com"), @@ -520,7 +532,8 @@ // a popup. GURL origin("http://google.com"); std::unique_ptr<net::CanonicalCookie> cookie1(net::CanonicalCookie::Create( - origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */)); + origin, "A=B", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookie1); pscs->OnCookiesAccessed({content::CookieAccessDetails::Type::kChange, origin, @@ -559,8 +572,9 @@ const bool blocked_by_policy = false; const GURL url = GURL("http://google.com"); const url::Origin origin = url::Origin::Create(url); - auto cookie = net::CanonicalCookie::Create(url, "k=v", base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie = net::CanonicalCookie::Create( + url, "k=v", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); pscs->OnCookiesAccessed({content::CookieAccessDetails::Type::kRead, url, url,
diff --git a/components/embedder_support/android/metrics/java/src/org/chromium/components/metrics/AndroidMetricsServiceClient.java b/components/embedder_support/android/metrics/java/src/org/chromium/components/metrics/AndroidMetricsServiceClient.java index 2fb56c7..8a2c604 100644 --- a/components/embedder_support/android/metrics/java/src/org/chromium/components/metrics/AndroidMetricsServiceClient.java +++ b/components/embedder_support/android/metrics/java/src/org/chromium/components/metrics/AndroidMetricsServiceClient.java
@@ -32,6 +32,9 @@ // Only record if it's a system app or it was installed from Play Store. Context ctx = ContextUtils.getApplicationContext(); String packageName = ctx.getPackageName(); + if (packageName == null) { + return false; + } String installerPackageName = ctx.getPackageManager().getInstallerPackageName(packageName); return (ctx.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0 || (PLAY_STORE_PACKAGE_NAME.equals(installerPackageName));
diff --git a/components/metrics/expired_histogram_util.cc b/components/metrics/expired_histogram_util.cc index b1ffb44..5b17a588 100644 --- a/components/metrics/expired_histogram_util.cc +++ b/components/metrics/expired_histogram_util.cc
@@ -15,10 +15,6 @@ const base::Feature kExpiredHistogramLogicFeature{ "ExpiredHistogramLogic", base::FEATURE_DISABLED_BY_DEFAULT}; -// TODO(jwd): Remove when the study config is updated with the new param. -const base::FeatureParam<std::string> kWhitelistParam{ - &kExpiredHistogramLogicFeature, "whitelist", ""}; - const base::FeatureParam<std::string> kAllowlistParam{ &kExpiredHistogramLogicFeature, "allowlist", ""}; @@ -29,9 +25,6 @@ DCHECK(base::FeatureList::GetInstance()); if (base::FeatureList::IsEnabled(kExpiredHistogramLogicFeature)) { std::string allowlist = kAllowlistParam.Get(); - // TODO(jwd): Remove when the study config is updated with the new param. - if (allowlist.empty()) - allowlist = kWhitelistParam.Get(); base::StatisticsRecorder::SetRecordChecker( std::make_unique<ExpiredHistogramsChecker>( expired_histograms_hashes, num_expired_histograms, allowlist));
diff --git a/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.cc b/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.cc index 70a7f85..7fbcc3f5 100644 --- a/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.cc +++ b/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.cc
@@ -74,6 +74,8 @@ DCHECK_EQ(css_properties_recorded_.count(), 0ul); DCHECK_EQ(animated_css_properties_recorded_.count(), 0ul); DCHECK_EQ(violated_permissions_policy_features_recorded_.count(), 0ul); + DCHECK_EQ(iframe_permissions_policy_features_recorded_, 0ul); + DCHECK_EQ(header_permissions_policy_features_recorded_, 0ul); content::RenderFrameHost* rfh = navigation_handle->GetRenderFrameHost(); @@ -194,6 +196,23 @@ UMA_HISTOGRAM_ENUMERATION( internal::kPermissionsPolicyViolationHistogramName, static_cast<PermissionsPolicyFeature>(feature.value())); + break; + case FeatureType::kPermissionsPolicyHeader: + if (TestAndSet(header_permissions_policy_features_recorded_, + feature.value())) + return; + UMA_HISTOGRAM_ENUMERATION( + internal::kPermissionsPolicyHeaderHistogramName, + static_cast<PermissionsPolicyFeature>(feature.value())); + break; + case FeatureType::kPermissionsPolicyIframeAttribute: + if (TestAndSet(iframe_permissions_policy_features_recorded_, + feature.value())) + return; + UMA_HISTOGRAM_ENUMERATION( + internal::kPermissionsPolicyIframeAttributeHistogramName, + static_cast<PermissionsPolicyFeature>(feature.value())); + break; } }
diff --git a/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.h b/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.h index 4b543028..a01c3129 100644 --- a/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.h +++ b/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer.h
@@ -24,6 +24,10 @@ "Blink.UseCounter.AnimatedCSSProperties"; const char kPermissionsPolicyViolationHistogramName[] = "Blink.UseCounter.PermissionsPolicy.Violation.Enforce"; +const char kPermissionsPolicyHeaderHistogramName[] = + "Blink.UseCounter.PermissionsPolicy.Allow"; +const char kPermissionsPolicyIframeAttributeHistogramName[] = + "Blink.UseCounter.PermissionsPolicy.Header"; } // namespace internal @@ -86,6 +90,14 @@ blink::mojom::PermissionsPolicyFeature::kMaxValue) + 1> violated_permissions_policy_features_recorded_; + std::bitset<static_cast<size_t>( + blink::mojom::PermissionsPolicyFeature::kMaxValue) + + 1> + iframe_permissions_policy_features_recorded_; + std::bitset<static_cast<size_t>( + blink::mojom::PermissionsPolicyFeature::kMaxValue) + + 1> + header_permissions_policy_features_recorded_; DISALLOW_COPY_AND_ASSIGN(UseCounterPageLoadMetricsObserver); };
diff --git a/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer_unittest.cc b/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer_unittest.cc index 6991ad9..d7efff89 100644 --- a/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer_unittest.cc +++ b/components/page_load_metrics/browser/observers/use_counter_page_load_metrics_observer_unittest.cc
@@ -33,6 +33,10 @@ return internal::kAnimatedCssPropertiesHistogramName; case FeatureType::kPermissionsPolicyViolationEnforce: return internal::kPermissionsPolicyViolationHistogramName; + case FeatureType::kPermissionsPolicyHeader: + return internal::kPermissionsPolicyHeaderHistogramName; + case FeatureType::kPermissionsPolicyIframeAttribute: + return internal::kPermissionsPolicyIframeAttributeHistogramName; } }
diff --git a/components/password_manager/core/browser/password_save_manager_impl.cc b/components/password_manager/core/browser/password_save_manager_impl.cc index cc226e2..b3bdd79 100644 --- a/components/password_manager/core/browser/password_save_manager_impl.cc +++ b/components/password_manager/core/browser/password_save_manager_impl.cc
@@ -111,15 +111,15 @@ std::unique_ptr<PasswordSaveManagerImpl> PasswordSaveManagerImpl::CreatePasswordSaveManagerImpl( const PasswordManagerClient* client) { - auto profile_form_saver = - std::make_unique<FormSaverImpl>(client->GetProfilePasswordStore()); + auto profile_form_saver = std::make_unique<FormSaverImpl>( + client->GetProfilePasswordStoreInterface()); return base::FeatureList::IsEnabled( password_manager::features::kEnablePasswordsAccountStorage) ? std::make_unique<MultiStorePasswordSaveManager>( std::move(profile_form_saver), std::make_unique<FormSaverImpl>( - client->GetAccountPasswordStore())) + client->GetAccountPasswordStoreInterface())) : std::make_unique<PasswordSaveManagerImpl>( std::move(profile_form_saver)); }
diff --git a/components/permissions/permission_uma_util.cc b/components/permissions/permission_uma_util.cc index 28679d8..04dc41a 100644 --- a/components/permissions/permission_uma_util.cc +++ b/components/permissions/permission_uma_util.cc
@@ -320,6 +320,39 @@ return short_version; } +AutoDSEPermissionRevertTransition GetAutoDSEPermissionRevertedTransition( + ContentSetting backed_up_setting, + ContentSetting effective_setting, + ContentSetting end_state_setting) { + if (backed_up_setting == CONTENT_SETTING_ASK && + effective_setting == CONTENT_SETTING_ALLOW && + end_state_setting == CONTENT_SETTING_ASK) { + return AutoDSEPermissionRevertTransition::NO_DECISION_ASK; + } else if (backed_up_setting == CONTENT_SETTING_ALLOW && + effective_setting == CONTENT_SETTING_ALLOW && + end_state_setting == CONTENT_SETTING_ALLOW) { + return AutoDSEPermissionRevertTransition::PRESERVE_ALLOW; + } else if (backed_up_setting == CONTENT_SETTING_BLOCK && + effective_setting == CONTENT_SETTING_ALLOW && + end_state_setting == CONTENT_SETTING_ASK) { + return AutoDSEPermissionRevertTransition::CONFLICT_ASK; + } else if (backed_up_setting == CONTENT_SETTING_ASK && + effective_setting == CONTENT_SETTING_BLOCK && + end_state_setting == CONTENT_SETTING_BLOCK) { + return AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_ASK; + } else if (backed_up_setting == CONTENT_SETTING_ALLOW && + effective_setting == CONTENT_SETTING_BLOCK && + end_state_setting == CONTENT_SETTING_BLOCK) { + return AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_ALLOW; + } else if (backed_up_setting == CONTENT_SETTING_BLOCK && + effective_setting == CONTENT_SETTING_BLOCK && + end_state_setting == CONTENT_SETTING_BLOCK) { + return AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_BLOCK; + } else { + return AutoDSEPermissionRevertTransition::INVALID_END_STATE; + } +} + } // anonymous namespace // PermissionUmaUtil ---------------------------------------------------------- @@ -815,6 +848,33 @@ delta.InSeconds(), 1, base::TimeDelta::FromDays(365).InSeconds(), 100); } +// static +void PermissionUmaUtil::RecordAutoDSEPermissionReverted( + ContentSettingsType permission_type, + ContentSetting backed_up_setting, + ContentSetting effective_setting, + ContentSetting end_state_setting) { + std::string permission_string = + GetPermissionRequestString(GetUmaValueForRequestType( + ContentSettingsTypeToRequestType(permission_type))); + base::UmaHistogramEnumeration( + "Permissions.DSE.AutoPermissionRevertTransition." + permission_string, + GetAutoDSEPermissionRevertedTransition( + backed_up_setting, effective_setting, end_state_setting)); +} + +// static +void PermissionUmaUtil::RecordDSEEffectiveSetting( + ContentSettingsType permission_type, + ContentSetting setting) { + std::string permission_string = + GetPermissionRequestString(GetUmaValueForRequestType( + ContentSettingsTypeToRequestType(permission_type))); + base::UmaHistogramEnumeration( + "Permissions.DSE.EffectiveSetting." + permission_string, setting, + CONTENT_SETTING_NUM_SETTINGS); +} + std::string PermissionUmaUtil::GetPermissionActionString( PermissionAction permission_action) { switch (permission_action) {
diff --git a/components/permissions/permission_uma_util.h b/components/permissions/permission_uma_util.h index 82d9a5f..fd42419 100644 --- a/components/permissions/permission_uma_util.h +++ b/components/permissions/permission_uma_util.h
@@ -10,6 +10,7 @@ #include "base/macros.h" #include "base/time/time.h" #include "base/version.h" +#include "components/content_settings/core/common/content_settings_types.h" #include "components/permissions/permission_request.h" #include "components/permissions/permission_result.h" #include "components/permissions/permission_util.h" @@ -196,6 +197,37 @@ PREVIOUSLY_AUTO_REVOKED = 0x01, }; +// This enum backs up the `AutoDSEPermissionRevertTransition` histogram enum. +// Never reuse values and mirror any updates to it. +// Describes the transition that has occured for the setting of a DSE origin +// when DSE autogrant becomes disabled. +enum class AutoDSEPermissionRevertTransition { + // The user has not previously made any decision so it results in an `ASK` end + // state. + NO_DECISION_ASK = 0, + // The user has decided to `ALLOW` the origin before it was the DSE origin and + // has not reverted this decision. + PRESERVE_ALLOW = 1, + // The user has previously `BLOCKED` the origin but has allowed it after it + // became the DSE origin. Resolve the conflict by setting it to `ASK` so the + // user will make a decision again. + CONFLICT_ASK = 2, + // The user has blocked the DSE origin and has not made a previous decision + // before the origin became the DSE origin. + PRESERVE_BLOCK_ASK = 3, + // The user has blocked the DSE origin and has `ALLOWED` it before it became + // the DSE origin, preserve the latest decision. + PRESERVE_BLOCK_ALLOW = 4, + // The user has blocked the DSE origin and has `BLOCKED` it before it became + // the DSE origin as well. + PRESERVE_BLOCK_BLOCK = 5, + // There has been an invalid transition. + INVALID_END_STATE = 6, + + // Always keep at the end. + kMaxValue = INVALID_END_STATE, +}; + // Provides a convenient way of logging UMA for permission related operations. class PermissionUmaUtil { public: @@ -283,6 +315,15 @@ static void RecordTimeElapsedBetweenGrantAndRevoke(ContentSettingsType type, base::TimeDelta delta); + static void RecordAutoDSEPermissionReverted( + ContentSettingsType permission_type, + ContentSetting backed_up_setting, + ContentSetting effective_setting, + ContentSetting end_state_setting); + + static void RecordDSEEffectiveSetting(ContentSettingsType permission_type, + ContentSetting setting); + static std::string GetPermissionActionString( PermissionAction permission_action);
diff --git a/components/permissions/permission_uma_util_unittest.cc b/components/permissions/permission_uma_util_unittest.cc index dac90a5..f8ed456 100644 --- a/components/permissions/permission_uma_util_unittest.cc +++ b/components/permissions/permission_uma_util_unittest.cc
@@ -137,4 +137,70 @@ "Permissions.CrowdDeny.PreloadData.VersionAtAbuseCheckTime", 1, 1); } +// Test that the appropriate UMA metrics have been recorded when the DSE is +// disabled. +TEST_F(PermissionUmaUtilTest, MetricsAreRecordedWhenAutoDSEPermissionReverted) { + constexpr char kNotificationsHistogram[] = + "Permissions.DSE.AutoPermissionRevertTransition.Notifications"; + constexpr char kGeolocationHistogram[] = + "Permissions.DSE.AutoPermissionRevertTransition.Geolocation"; + + constexpr struct { + ContentSetting backed_up_setting; + ContentSetting effective_setting; + ContentSetting end_state_setting; + permissions::AutoDSEPermissionRevertTransition expected_transition; + } kTests[] = { + // Expected valid combinations. + {CONTENT_SETTING_ASK, CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK, + permissions::AutoDSEPermissionRevertTransition::NO_DECISION_ASK}, + {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_ALLOW}, + {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK, + permissions::AutoDSEPermissionRevertTransition::CONFLICT_ASK}, + {CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK, CONTENT_SETTING_BLOCK, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_ASK}, + {CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, CONTENT_SETTING_BLOCK, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_ALLOW}, + {CONTENT_SETTING_BLOCK, CONTENT_SETTING_BLOCK, CONTENT_SETTING_BLOCK, + permissions::AutoDSEPermissionRevertTransition::PRESERVE_BLOCK_BLOCK}, + + // Invalid combinations. + {CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK, CONTENT_SETTING_ASK, + permissions::AutoDSEPermissionRevertTransition::INVALID_END_STATE}, + {CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW, + permissions::AutoDSEPermissionRevertTransition::INVALID_END_STATE}, + {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, + permissions::AutoDSEPermissionRevertTransition::INVALID_END_STATE}, + {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW, + permissions::AutoDSEPermissionRevertTransition::INVALID_END_STATE}, + }; + + // We test every combination of test case for notifications and geolocation to + // basically test the entire possible transition space. + for (const auto& test : kTests) { + for (const auto type : {ContentSettingsType::NOTIFICATIONS, + ContentSettingsType::GEOLOCATION}) { + base::HistogramTester histograms; + PermissionUmaUtil::RecordAutoDSEPermissionReverted( + type, test.backed_up_setting, test.effective_setting, + test.end_state_setting); + + // Test that the expected samples are recorded in histograms. + for (auto sample = static_cast<int>( + permissions::AutoDSEPermissionRevertTransition::NO_DECISION_ASK); + sample < + static_cast<int>( + permissions::AutoDSEPermissionRevertTransition::kMaxValue); + ++sample) { + histograms.ExpectBucketCount( + type == ContentSettingsType::NOTIFICATIONS ? kNotificationsHistogram + : kGeolocationHistogram, + sample, + static_cast<int>(test.expected_transition) == sample ? 1 : 0); + } + } + } +} + } // namespace permissions
diff --git a/components/reading_list/features/reading_list_switches.cc b/components/reading_list/features/reading_list_switches.cc index e3724b4b..fa44390 100644 --- a/components/reading_list/features/reading_list_switches.cc +++ b/components/reading_list/features/reading_list_switches.cc
@@ -38,6 +38,9 @@ #endif } +const base::Feature kReadLaterBackendMigration{ + "ReadLaterBackendMigration", base::FEATURE_DISABLED_BY_DEFAULT}; + #ifdef OS_ANDROID // Feature flag used for enabling read later reminder notification. const base::Feature kReadLaterReminderNotification{
diff --git a/components/reading_list/features/reading_list_switches.h b/components/reading_list/features/reading_list_switches.h index 23179257..1192f25 100644 --- a/components/reading_list/features/reading_list_switches.h +++ b/components/reading_list/features/reading_list_switches.h
@@ -30,6 +30,15 @@ // true if `kSidePanel` is enabled as it assumes a reading list. bool IsReadingListEnabled(); +// Feature flag used for enabling the reading list backend migration. +// When enabled, reading list data will also be stored in the Bookmarks backend. +// This allows each platform to migrate their reading list front end to point at +// the new reading list data stored in the bookmarks backend without +// interruption to cross device sync if some syncing devices are on versions +// with the migration behavior while others aren't. See crbug/1234426 for more +// details. +extern const base::Feature kReadLaterBackendMigration; + #ifdef OS_ANDROID // Feature flag used for enabling read later reminder notification. extern const base::Feature kReadLaterReminderNotification;
diff --git a/components/security_interstitials/content/ssl_error_handler.cc b/components/security_interstitials/content/ssl_error_handler.cc index 9431c316..06873a9 100644 --- a/components/security_interstitials/content/ssl_error_handler.cc +++ b/components/security_interstitials/content/ssl_error_handler.cc
@@ -21,7 +21,6 @@ #include "base/time/clock.h" #include "base/time/time.h" #include "build/build_config.h" -#include "components/captive_portal/core/captive_portal_types.h" #include "components/network_time/network_time_tracker.h" #include "components/prefs/pref_service.h" #include "components/security_interstitials/content/bad_clock_blocking_page.h" @@ -424,8 +423,7 @@ void SSLErrorHandlerDelegateImpl::CheckForCaptivePortal() { #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) - captive_portal_service_->DetectCaptivePortal( - captive_portal::CaptivePortalProbeReason::kCertificateError); + captive_portal_service_->DetectCaptivePortal(); #else NOTREACHED(); #endif
diff --git a/components/signin/internal/identity_manager/gaia_cookie_manager_service.cc b/components/signin/internal/identity_manager/gaia_cookie_manager_service.cc index 8ccd9c4..181fe06 100644 --- a/components/signin/internal/identity_manager/gaia_cookie_manager_service.cc +++ b/components/signin/internal/identity_manager/gaia_cookie_manager_service.cc
@@ -619,7 +619,7 @@ "." + google_url.host(), "/", base::Time(), base::Time(), base::Time(), true /* secure */, false /* httponly */, net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_DEFAULT, - false /* same_party */, absl::nullopt /* partition_key */); + false /* same_party */, absl::nullopt /* cookie_partition_key */); OnCookieChange( net::CookieChangeInfo(*cookie, net::CookieAccessResult(), net::CookieChangeCause::UNKNOWN_DELETION));
diff --git a/components/sync_bookmarks/bookmark_remote_updates_handler.cc b/components/sync_bookmarks/bookmark_remote_updates_handler.cc index f63df6e..fd40903 100644 --- a/components/sync_bookmarks/bookmark_remote_updates_handler.cc +++ b/components/sync_bookmarks/bookmark_remote_updates_handler.cc
@@ -268,15 +268,29 @@ // Ignore updates that have already been seen according to the version. if (tracked_entity && tracked_entity->metadata()->server_version() >= update->response_version) { - // Seen this update before. This update may be a reflection and may have - // missing the GUID in specifics. Next reupload will populate GUID in - // specifics and this codepath will not repeat indefinitely. This logic is - // needed for the case when there is only one device and hence the GUID - // will not be set by other devices. - ReuploadEntityIfNeeded(update_entity, tracked_entity); + if (update_entity.id == tracked_entity->metadata()->server_id()) { + // Seen this update before. This update may be a reflection and may have + // missing the GUID in specifics. Next reupload will populate GUID in + // specifics and this codepath will not repeat indefinitely. This logic + // is needed for the case when there is only one device and hence the + // GUID will not be set by other devices. + ReuploadEntityIfNeeded(update_entity, tracked_entity); + } continue; } + // The server ID has changed for a tracked entity (matched via client tag). + // This can happen if a commit succeeds, but the response does not come back + // fast enough(e.g. before shutdown or crash), then the |bookmark_tracker_| + // might assume that it was never committed. The server will track the + // client that sent up the original commit and return this in a get updates + // response. This also may happen due to duplicate GUIDs. In this case it's + // better to update to the latest server ID. + if (tracked_entity) { + bookmark_tracker_->UpdateSyncIdIfNeeded(tracked_entity, + /*sync_id=*/update_entity.id); + } + if (tracked_entity && tracked_entity->IsUnsynced()) { ProcessConflict(*update, tracked_entity); // |tracked_entity| might be deleted during processing conflict. @@ -503,14 +517,6 @@ DCHECK(tracked_entity_by_client_tag); DCHECK(!tracked_entity_by_sync_id); - // The server ID has changed for a tracked entity (matched via client tag). - // This can happen if a commit succeeds, but the response does not come back - // fast enough(e.g. before shutdown or crash), then the |bookmark_tracker_| - // might assume that it was never committed. The server will track the client - // that sent up the original commit and return this in a get updates response. - bookmark_tracker_->UpdateSyncIdForLocalCreationIfNeeded( - tracked_entity_by_client_tag, - /*sync_id=*/update_entity.id); return tracked_entity_by_client_tag; }
diff --git a/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc b/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc index 68169be..e44ad8a 100644 --- a/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc +++ b/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc
@@ -1062,8 +1062,8 @@ // |originator_client_item_id| is used a temp sync id and mark the entity that // it needs to be committed.. const SyncedBookmarkTracker::Entity* entity = - tracker()->Add(&node, /*sync_id=*/kOriginatorClientItemId, kServerVersion, - kModificationTime, specifics); + tracker()->Add(&node, /*sync_id=*/kOriginatorClientItemId, + /*server_version=*/0, kModificationTime, specifics); tracker()->IncrementSequenceNumber(entity); ASSERT_THAT(tracker()->GetEntityForSyncId(kOriginatorClientItemId), @@ -1084,7 +1084,7 @@ syncer::UpdateResponseData response_data; response_data.entity = std::move(data); // Similar to what's done in the loopback_server. - response_data.response_version = 0; + response_data.response_version = kServerVersion; updates.push_back(std::move(response_data)); updates_handler()->Process(updates, @@ -1129,7 +1129,7 @@ // |originator_client_item_id| is used a temp sync id and mark the entity that // it needs to be committed.. const SyncedBookmarkTracker::Entity* entity = - tracker()->Add(&node, /*sync_id=*/kBookmarkGuid, kServerVersion, + tracker()->Add(&node, /*sync_id=*/kBookmarkGuid, /*server_version=*/0, kModificationTime, specifics); tracker()->IncrementSequenceNumber(entity); @@ -1151,7 +1151,7 @@ syncer::UpdateResponseData response_data; response_data.entity = std::move(data); // Similar to what's done in the loopback_server. - response_data.response_version = 0; + response_data.response_version = kServerVersion; updates.push_back(std::move(response_data)); updates_handler()->Process(updates, @@ -1921,6 +1921,56 @@ EXPECT_TRUE(entity->IsUnsynced()); } +TEST_F(BookmarkRemoteUpdatesHandlerWithInitialMergeTest, + ShouldProcessDifferentEntitiesWithSameGuid) { + const std::string kServerId1 = "server_id_1"; + const std::string kServerId2 = "server_id_2"; + + const std::string kTitle = "Title"; + const base::GUID kGuid = base::GUID::GenerateRandomV4(); + + // Initialize the model with one node. + syncer::UpdateResponseDataList updates; + updates.push_back(CreateUpdateResponseData( + /*server_id=*/kServerId1, + /*parent_id=*/kBookmarkBarId, + /*guid=*/kGuid, + /*is_deletion=*/false, + /*version=*/0)); + updates_handler()->Process(updates, + /*got_new_encryption_requirements=*/false); + ASSERT_THAT(tracker()->TrackedEntitiesCountForTest(), Eq(4U)); + ASSERT_THAT(tracker()->GetEntityForSyncId(kServerId1), NotNull()); + updates.clear(); + + // Create two updates having the same GUID, one is a tombstone for the old + // |server_id|, another with a new one. The tombstone is processed after the + // update and should be ignored due to its server version. + updates.push_back(CreateUpdateResponseData( + /*server_id=*/kServerId2, + /*parent_id=*/kBookmarkBarId, + /*guid=*/kGuid, + /*is_deletion=*/false, + /*version=*/2)); + updates.push_back(CreateUpdateResponseData( + /*server_id=*/kServerId1, + /*parent_id=*/kBookmarkBarId, + /*guid=*/kGuid, + /*is_deletion=*/true, + /*version=*/1)); + + updates_handler()->Process(updates, + /*got_new_encryption_requirements=*/false); + + EXPECT_THAT(tracker()->TrackedEntitiesCountForTest(), Eq(4U)); + EXPECT_THAT(tracker()->GetEntityForSyncId(kServerId1), IsNull()); + const SyncedBookmarkTracker::Entity* entity = + tracker()->GetEntityForSyncId(kServerId2); + EXPECT_THAT(entity, NotNull()); + EXPECT_THAT(entity->bookmark_node(), NotNull()); + EXPECT_THAT(entity->bookmark_node()->guid(), Eq(kGuid)); +} + TEST(BookmarkRemoteUpdatesHandlerTest, ShouldComputeRightChildNodeIndexForEmptyParent) { const std::string suffix = syncer::UniquePosition::RandomSuffix();
diff --git a/components/sync_bookmarks/synced_bookmark_tracker.cc b/components/sync_bookmarks/synced_bookmark_tracker.cc index 7bd9c1d4..eafd3f5 100644 --- a/components/sync_bookmarks/synced_bookmark_tracker.cc +++ b/components/sync_bookmarks/synced_bookmark_tracker.cc
@@ -727,12 +727,11 @@ return; } - UpdateSyncIdForLocalCreationIfNeeded(mutable_entity, sync_id); + UpdateSyncIdIfNeeded(mutable_entity, sync_id); } -void SyncedBookmarkTracker::UpdateSyncIdForLocalCreationIfNeeded( - const Entity* entity, - const std::string& sync_id) { +void SyncedBookmarkTracker::UpdateSyncIdIfNeeded(const Entity* entity, + const std::string& sync_id) { DCHECK(entity); const std::string old_id = entity->metadata()->server_id();
diff --git a/components/sync_bookmarks/synced_bookmark_tracker.h b/components/sync_bookmarks/synced_bookmark_tracker.h index 504f5395..510b084 100644 --- a/components/sync_bookmarks/synced_bookmark_tracker.h +++ b/components/sync_bookmarks/synced_bookmark_tracker.h
@@ -230,8 +230,7 @@ // Informs the tracker that the sync ID for |entity| has changed. It updates // the internal state of the tracker accordingly. |entity| must be owned by // this tracker. - void UpdateSyncIdForLocalCreationIfNeeded(const Entity* entity, - const std::string& sync_id); + void UpdateSyncIdIfNeeded(const Entity* entity, const std::string& sync_id); // Used to start tracking an entity that overwrites a previous local tombstone // (e.g. user-initiated bookmark deletion undo). |entity| must be owned by
diff --git a/components/sync_bookmarks/synced_bookmark_tracker_unittest.cc b/components/sync_bookmarks/synced_bookmark_tracker_unittest.cc index ba0bcee..7ecef78 100644 --- a/components/sync_bookmarks/synced_bookmark_tracker_unittest.cc +++ b/components/sync_bookmarks/synced_bookmark_tracker_unittest.cc
@@ -329,7 +329,7 @@ ASSERT_THAT(entity, NotNull()); // Update the sync id. - tracker->UpdateSyncIdForLocalCreationIfNeeded(entity, kNewSyncId); + tracker->UpdateSyncIdIfNeeded(entity, kNewSyncId); // Old id shouldn't be there, but the new one should. EXPECT_THAT(tracker->GetEntityForSyncId(kSyncId), IsNull());
diff --git a/components/variations/metrics.cc b/components/variations/metrics.cc index 3f9b0cf..fe9d125 100644 --- a/components/variations/metrics.cc +++ b/components/variations/metrics.cc
@@ -30,4 +30,8 @@ StoreSeedResult::ENUM_SIZE); } +void ReportUnsupportedSeedFormatError() { + RecordStoreSeedResult(StoreSeedResult::FAILED_UNSUPPORTED_SEED_FORMAT); +} + } // namespace variations
diff --git a/components/variations/metrics.h b/components/variations/metrics.h index fdf5447d..069cde3 100644 --- a/components/variations/metrics.h +++ b/components/variations/metrics.h
@@ -109,6 +109,10 @@ // server. COMPONENT_EXPORT(VARIATIONS) void RecordStoreSeedResult(StoreSeedResult result); + +// Reports to UMA that the seed format specified by the server is unsupported. +COMPONENT_EXPORT(VARIATIONS) void ReportUnsupportedSeedFormatError(); + } // namespace variations #endif // COMPONENTS_VARIATIONS_METRICS_H_
diff --git a/components/variations/service/variations_service.cc b/components/variations/service/variations_service.cc index 02c707bb5..5d9083f 100644 --- a/components/variations/service/variations_service.cc +++ b/components/variations/service/variations_service.cc
@@ -891,7 +891,7 @@ &is_gzip_compressed)) { // The header does not specify supported instance manipulations, unable to // process data. Details of errors were logged by GetInstanceManipulations. - field_trial_creator_.seed_store()->ReportUnsupportedSeedFormatError(); + ReportUnsupportedSeedFormatError(); return; }
diff --git a/components/variations/variations_seed_store.cc b/components/variations/variations_seed_store.cc index 5f0a27e..5356ec9 100644 --- a/components/variations/variations_seed_store.cc +++ b/components/variations/variations_seed_store.cc
@@ -647,8 +647,4 @@ return true; } -void VariationsSeedStore::ReportUnsupportedSeedFormatError() { - RecordStoreSeedResult(StoreSeedResult::FAILED_UNSUPPORTED_SEED_FORMAT); -} - } // namespace variations
diff --git a/components/variations/variations_seed_store.h b/components/variations/variations_seed_store.h index 7ea27d3..aceb11b 100644 --- a/components/variations/variations_seed_store.h +++ b/components/variations/variations_seed_store.h
@@ -114,9 +114,6 @@ // different day. void UpdateSeedDateAndLogDayChange(const base::Time& server_date_fetched); - // Reports to UMA that the seed format specified by the server is unsupported. - void ReportUnsupportedSeedFormatError(); - // Returns the serial number of the most recently received seed, or an empty // string if there is no seed (or if it could not be read). // Side-effect: If there is a failure while attempting to read the latest seed
diff --git a/components/viz/service/gl/gpu_service_impl.cc b/components/viz/service/gl/gpu_service_impl.cc index 3d3e414..c2a92df 100644 --- a/components/viz/service/gl/gpu_service_impl.cc +++ b/components/viz/service/gl/gpu_service_impl.cc
@@ -1161,8 +1161,13 @@ void GpuServiceImpl::OnBackgroundedOnMainThread() { gpu_channel_manager_->OnApplicationBackgrounded(); - if (visibility_changed_callback_) + if (visibility_changed_callback_) { visibility_changed_callback_.Run(false); + if (gpu_preferences_.enable_gpu_benchmarking_extension) { + ++gpu_info_.visibility_callback_call_count; + UpdateGPUInfoGL(); + } + } } void GpuServiceImpl::OnForegrounded() { @@ -1178,8 +1183,13 @@ } void GpuServiceImpl::OnForegroundedOnMainThread() { - if (visibility_changed_callback_) + if (visibility_changed_callback_) { visibility_changed_callback_.Run(true); + if (gpu_preferences_.enable_gpu_benchmarking_extension) { + ++gpu_info_.visibility_callback_call_count; + UpdateGPUInfoGL(); + } + } } #if !defined(OS_ANDROID)
diff --git a/content/browser/browsing_data/browsing_data_filter_builder_impl_unittest.cc b/content/browser/browsing_data/browsing_data_filter_builder_impl_unittest.cc index 5db95e0..ad29c56 100644 --- a/content/browser/browsing_data/browsing_data_filter_builder_impl_unittest.cc +++ b/content/browser/browsing_data/browsing_data_filter_builder_impl_unittest.cc
@@ -62,9 +62,9 @@ std::string cookie_line = "A=2"; GURL test_url(test_case.url); EXPECT_TRUE(test_url.is_valid()) << test_case.url; - std::unique_ptr<net::CanonicalCookie> cookie = - net::CanonicalCookie::Create(test_url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */); + std::unique_ptr<net::CanonicalCookie> cookie = net::CanonicalCookie::Create( + test_url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie) << cookie_line << " from " << test_case.url << " is not a valid cookie"; if (cookie) { @@ -78,9 +78,9 @@ } cookie_line = std::string("A=2;domain=") + test_url.host(); - cookie = - net::CanonicalCookie::Create(test_url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */); + cookie = net::CanonicalCookie::Create( + test_url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); if (cookie) { EXPECT_EQ(test_case.should_match, delete_info.Matches( @@ -92,9 +92,9 @@ } cookie_line = std::string("A=2; HttpOnly;") + test_url.host(); - cookie = - net::CanonicalCookie::Create(test_url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */); + cookie = net::CanonicalCookie::Create( + test_url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); if (cookie) { EXPECT_EQ(test_case.should_match, delete_info.Matches( @@ -106,9 +106,9 @@ } cookie_line = std::string("A=2; HttpOnly; Secure;") + test_url.host(); - cookie = - net::CanonicalCookie::Create(test_url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */); + cookie = net::CanonicalCookie::Create( + test_url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); if (cookie) { EXPECT_EQ(test_case.should_match, delete_info.Matches(
diff --git a/content/browser/browsing_data/clear_site_data_handler_browsertest.cc b/content/browser/browsing_data/clear_site_data_handler_browsertest.cc index 63f13cc..42f68bfa 100644 --- a/content/browser/browsing_data/clear_site_data_handler_browsertest.cc +++ b/content/browser/browsing_data/clear_site_data_handler_browsertest.cc
@@ -169,7 +169,8 @@ storage_partition()->GetCookieManagerForBrowserProcess(); std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( - url, "A=1", base::Time::Now(), absl::nullopt /* server_time */)); + url, "A=1", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); base::RunLoop run_loop; cookie_manager->SetCanonicalCookie(
diff --git a/content/browser/devtools/devtools_url_loader_interceptor.cc b/content/browser/devtools/devtools_url_loader_interceptor.cc index 1fd27ce..05b86710 100644 --- a/content/browser/devtools/devtools_url_loader_interceptor.cc +++ b/content/browser/devtools/devtools_url_loader_interceptor.cc
@@ -1123,7 +1123,8 @@ size_t iter = 0; while (headers.EnumerateHeader(&iter, name, &cookie_line)) { std::unique_ptr<net::CanonicalCookie> cookie = net::CanonicalCookie::Create( - create_loader_params_->request.url, cookie_line, now, server_time); + create_loader_params_->request.url, cookie_line, now, server_time, + net::CookiePartitionKey::Todo()); if (cookie) cookies.emplace_back(std::move(cookie)); }
diff --git a/content/browser/devtools/protocol/system_info_handler.cc b/content/browser/devtools/protocol/system_info_handler.cc index 4216ecfc..56c94c8e 100644 --- a/content/browser/devtools/protocol/system_info_handler.cc +++ b/content/browser/devtools/protocol/system_info_handler.cc
@@ -230,6 +230,8 @@ gpu_info.EnumerateFields(&enumerator); enumerator.BeginAuxAttributes(); enumerator.AddInt("processCrashCount", GpuProcessHost::GetGpuCrashCount()); + enumerator.AddInt("visibilityCallbackCallCount", + gpu_info.visibility_callback_call_count); enumerator.EndAuxAttributes(); std::unique_ptr<base::DictionaryValue> base_feature_status =
diff --git a/content/browser/native_io/native_io_file_host.cc b/content/browser/native_io/native_io_file_host.cc index 8199624..3e890b1 100644 --- a/content/browser/native_io/native_io_file_host.cc +++ b/content/browser/native_io/native_io_file_host.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/sequence_checker.h" +#include "base/types/pass_key.h" #include "build/build_config.h" #include "content/browser/native_io/native_io_host.h" #include "content/browser/native_io/native_io_manager.h" @@ -36,19 +37,24 @@ &NativeIOFileHost::OnReceiverDisconnect, base::Unretained(this))); } -NativeIOFileHost::~NativeIOFileHost() = default; +NativeIOFileHost::~NativeIOFileHost() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +} void NativeIOFileHost::Close(CloseCallback callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); std::move(callback).Run(); - origin_host_->OnFileClose(this); // Deletes |this|. + + // May delete `this`. + origin_host_->OnFileClose(this, base::PassKey<NativeIOFileHost>()); } void NativeIOFileHost::OnReceiverDisconnect() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - origin_host_->OnFileClose(this); // Deletes |this|. + // May delete `this`. + origin_host_->OnFileClose(this, base::PassKey<NativeIOFileHost>()); } } // namespace content
diff --git a/content/browser/native_io/native_io_host.cc b/content/browser/native_io/native_io_host.cc index 58cdc86..6f5c4304 100644 --- a/content/browser/native_io/native_io_host.cc +++ b/content/browser/native_io/native_io_host.cc
@@ -21,6 +21,7 @@ #include "base/task/task_traits.h" #include "base/task/thread_pool.h" #include "base/task_runner.h" +#include "base/types/pass_key.h" #include "build/build_config.h" #include "content/browser/native_io/native_io_file_host.h" #include "content/browser/native_io/native_io_manager.h" @@ -495,7 +496,8 @@ std::move(callback).Run(capacity_delta); } -void NativeIOHost::OnFileClose(NativeIOFileHost* file_host) { +void NativeIOHost::OnFileClose(NativeIOFileHost* file_host, + base::PassKey<NativeIOFileHost>) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(open_file_hosts_.count(file_host->file_name()) > 0); DCHECK_EQ(open_file_hosts_[file_host->file_name()].get(), file_host); @@ -525,7 +527,8 @@ void NativeIOHost::OnReceiverDisconnect() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - manager_->OnHostReceiverDisconnect(this); + // May delete `this`. + manager_->OnHostReceiverDisconnect(this, base::PassKey<NativeIOHost>()); } void NativeIOHost::DidOpenFile(
diff --git a/content/browser/native_io/native_io_host.h b/content/browser/native_io/native_io_host.h index d6f4974..87591b3 100644 --- a/content/browser/native_io/native_io_host.h +++ b/content/browser/native_io/native_io_host.h
@@ -16,6 +16,7 @@ #include "base/sequence_checker.h" #include "base/thread_annotations.h" #include "base/threading/thread_checker.h" +#include "base/types/pass_key.h" #include "build/build_config.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver_set.h" @@ -106,9 +107,10 @@ // Called when one of the open files for this storage key closes. // - // |file_host| must be owned by this storage key host. This method should only - // be called by NativeIOFileHost. - void OnFileClose(NativeIOFileHost* file_host); + // `file_host` must be owned by this storage key host. `file_host` may be + // deleted. + void OnFileClose(NativeIOFileHost* file_host, + base::PassKey<NativeIOFileHost>); private: // Called when a receiver in the receiver set is disconnected.
diff --git a/content/browser/native_io/native_io_manager.cc b/content/browser/native_io/native_io_manager.cc index a0dafd6b..d5a39d5c 100644 --- a/content/browser/native_io/native_io_manager.cc +++ b/content/browser/native_io/native_io_manager.cc
@@ -14,6 +14,7 @@ #include "base/task/task_traits.h" #include "base/task/thread_pool.h" #include "base/threading/thread_checker.h" +#include "base/types/pass_key.h" #include "build/build_config.h" #include "components/services/storage/public/mojom/quota_client.mojom.h" #include "content/browser/native_io/native_io_host.h" @@ -165,7 +166,8 @@ it->second->BindReceiver(std::move(receiver)); } -void NativeIOManager::OnHostReceiverDisconnect(NativeIOHost* host) { +void NativeIOManager::OnHostReceiverDisconnect(NativeIOHost* host, + base::PassKey<NativeIOHost>) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); MaybeDeleteHost(host); }
diff --git a/content/browser/native_io/native_io_manager.h b/content/browser/native_io/native_io_manager.h index 8a6cc6c1..3b33861 100644 --- a/content/browser/native_io/native_io_manager.h +++ b/content/browser/native_io/native_io_manager.h
@@ -15,6 +15,7 @@ #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "base/thread_annotations.h" +#include "base/types/pass_key.h" #include "build/build_config.h" #include "components/services/storage/public/mojom/quota_client.mojom-forward.h" #include "content/browser/native_io/native_io_quota_client.h" @@ -119,9 +120,9 @@ // Called when a receiver is disconnected from a NativeIOHost. // - // `host` must be owned by this manager. This method should only be called by - // NativeIOHost. - void OnHostReceiverDisconnect(NativeIOHost* host); + // `host` must be owned by this manager. `host` may be deleted. + void OnHostReceiverDisconnect(NativeIOHost* host, + base::PassKey<NativeIOHost>); // Callback function when DeleteStorageKeyData has completed. //
diff --git a/content/browser/renderer_host/cookie_browsertest.cc b/content/browser/renderer_host/cookie_browsertest.cc index f155009..12f41e3 100644 --- a/content/browser/renderer_host/cookie_browsertest.cc +++ b/content/browser/renderer_host/cookie_browsertest.cc
@@ -64,7 +64,8 @@ net::CookieOptions::SameSiteCookieContext::MakeInclusive()); auto cookie_obj = net::CanonicalCookie::Create( - url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */); + url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); base::RunLoop run_loop; tab->GetBrowserContext()
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 93d2c89..07e5a42b 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -2247,7 +2247,9 @@ RenderFrameHostImpl* frame = host()->frame_tree()->GetMainFrame(); if (!frame) return; - frame->NotifyVirtualKeyboardOverlayRect(keyboard_rect); + if (ShouldVirtualKeyboardOverlayContent()) { + frame->NotifyVirtualKeyboardOverlayRect(keyboard_rect); + } } bool RenderWidgetHostViewAura::FocusedFrameHasStickyActivation() const {
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 092c07e1..03b5d09 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -118,6 +118,8 @@ TouchSelectionControllerClientManager* GetTouchSelectionControllerClientManager() override; bool ShouldVirtualKeyboardOverlayContent() override; + void NotifyVirtualKeyboardOverlayRect( + const gfx::Rect& keyboard_rect) override; // Overridden from RenderWidgetHostViewBase: void InitAsPopup(RenderWidgetHostView* parent_host_view, @@ -360,7 +362,6 @@ void SetTooltipsEnabled(bool enable) override; void Shutdown() override; - void NotifyVirtualKeyboardOverlayRect(const gfx::Rect& keyboard_rect); bool FocusedFrameHasStickyActivation() const; RenderWidgetHostViewEventHandler* event_handler() {
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 c31a2b5..00f5be9c 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc
@@ -521,8 +521,24 @@ } void RenderWidgetHostViewBase::UpdateScreenInfo(gfx::NativeView view) { - if (host() && host()->delegate()) - host()->delegate()->SendScreenRects(); + bool force_sync_visual_properties = false; + // Delegate, which is usually WebContentsImpl, do not send rect updates for + // popups as they are not registered as FrameTreeNodes. Instead, send screen + // rects directly to host and force synchronization of visual properties so + // that blink knows host changed bounds. This only happens if the change was + // instantiated by system server/compositor (for example, Wayland, which + // may reposition a popup if part of it is going to be shown outside a + // display's work area. Note that Wayland clients cannot know where their + // windows are located and cannot adjust bounds). + if (widget_type_ == WidgetType::kPopup) { + if (host()) { + force_sync_visual_properties = true; + host()->SendScreenRects(); + } + } else { + if (host() && host()->delegate()) + host()->delegate()->SendScreenRects(); + } const display::DisplayList new_display_list = display::Screen::GetScreen()->GetDisplayListNearestViewWithFallbacks(
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 17803f4..a02e23d5 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h
@@ -138,6 +138,8 @@ bool show_reason_unoccluded, bool show_reason_bfcache_restore) final; bool ShouldVirtualKeyboardOverlayContent() override; + void NotifyVirtualKeyboardOverlayRect( + const gfx::Rect& keyboard_rect) override {} // This only needs to be overridden by RenderWidgetHostViewBase subclasses // that handle content embedded within other RenderWidgetHostViews.
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index a95e76a..218fe63 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc
@@ -256,7 +256,6 @@ tick_clock_(base::DefaultTickClock::GetInstance()), clock_(base::DefaultClock::GetInstance()), ping_controller_(this), - validator_(std::make_unique<blink::TrialTokenValidator>()), remote_reference_(std::move(remote_reference)), ukm_source_id_(ukm::ConvertToSourceId(ukm::AssignNewSourceId(), ukm::SourceIdType::WORKER_ID)), @@ -1077,7 +1076,7 @@ void ServiceWorkerVersion::SetValidOriginTrialTokens( const blink::TrialTokenValidator::FeatureToTokensMap& tokens) { - origin_trial_tokens_ = validator_->GetValidTokens( + origin_trial_tokens_ = validator_.GetValidTokens( url::Origin::Create(scope()), tokens, clock_->Now()); } @@ -1130,7 +1129,7 @@ // was written by old version Chrome (< M56), so |origin_trial_tokens| // wasn't set in the entry. if (!origin_trial_tokens_) { - origin_trial_tokens_ = validator_->GetValidTokensFromHeaders( + origin_trial_tokens_ = validator_.GetValidTokensFromHeaders( url::Origin::Create(scope()), main_script_response_->headers.get(), clock_->Now()); }
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h index 27c633b1..33da2093 100644 --- a/content/browser/service_worker/service_worker_version.h +++ b/content/browser/service_worker/service_worker_version.h
@@ -1104,7 +1104,7 @@ // version completed, or used during the lifetime of |this|. std::set<blink::mojom::WebFeature> used_features_; - std::unique_ptr<blink::TrialTokenValidator> const validator_; + blink::TrialTokenValidator const validator_; // Stores the result of byte-to-byte update check for each script. std::map<GURL, ServiceWorkerUpdateChecker::ComparedScriptInfo>
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc index 7d2ef7b..5c34baa5 100644 --- a/content/browser/storage_partition_impl_unittest.cc +++ b/content/browser/storage_partition_impl_unittest.cc
@@ -169,9 +169,10 @@ void AddCookie(const url::Origin& origin) { net::CookieInclusionStatus status; - std::unique_ptr<net::CanonicalCookie> cc( - net::CanonicalCookie::Create(origin.GetURL(), "A=1", base::Time::Now(), - absl::nullopt /* server_time */, &status)); + std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create( + origin.GetURL(), "A=1", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */, &status)); storage_partition_->GetCookieManagerForBrowserProcess()->SetCanonicalCookie( *cc, origin.GetURL(), net::CookieOptions::MakeAllInclusive(), base::BindOnce(&RemoveCookieTester::SetCookieCallback, @@ -1855,20 +1856,21 @@ base::Time now = base::Time::Now(); std::vector<std::unique_ptr<CanonicalCookie>> valid_cookies; - valid_cookies.push_back( - CanonicalCookie::Create(url, "A=B", now, server_time)); - valid_cookies.push_back( - CanonicalCookie::Create(url, "C=F", now, server_time)); + valid_cookies.push_back(CanonicalCookie::Create( + url, "A=B", now, server_time, absl::nullopt /* cookie_partition_key */)); + valid_cookies.push_back(CanonicalCookie::Create( + url, "C=F", now, server_time, absl::nullopt /* cookie_partition_key */)); // We should match a different scheme with the same host. - valid_cookies.push_back( - CanonicalCookie::Create(url2, "A=B", now, server_time)); + valid_cookies.push_back(CanonicalCookie::Create( + url2, "A=B", now, server_time, absl::nullopt /* cookie_partition_key */)); std::vector<std::unique_ptr<CanonicalCookie>> invalid_cookies; // We don't match domain cookies. - invalid_cookies.push_back(CanonicalCookie::Create( - url2, "A=B;domain=.example.com", now, server_time)); invalid_cookies.push_back( - CanonicalCookie::Create(url3, "A=B", now, server_time)); + CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, server_time, + absl::nullopt /* cookie_partition_key */)); + invalid_cookies.push_back(CanonicalCookie::Create( + url3, "A=B", now, server_time, absl::nullopt /* cookie_partition_key */)); for (const auto& cookie : valid_cookies) { EXPECT_TRUE(FilterMatchesCookie(deletion_filter, *cookie))
diff --git a/content/browser/worker_host/worker_browsertest.cc b/content/browser/worker_host/worker_browsertest.cc index a5e4df0..cdf23fa1 100644 --- a/content/browser/worker_host/worker_browsertest.cc +++ b/content/browser/worker_host/worker_browsertest.cc
@@ -201,7 +201,8 @@ GURL cookie_url = ssl_server_.GetURL(host, "/"); std::unique_ptr<net::CanonicalCookie> cookie = net::CanonicalCookie::Create( cookie_url, std::string(kSameSiteCookie) + "; SameSite=Lax; Secure", - base::Time::Now(), absl::nullopt /* server_time */); + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); base::RunLoop run_loop; cookie_manager->SetCanonicalCookie( *cookie, cookie_url, options,
diff --git a/content/public/browser/render_widget_host_view.h b/content/public/browser/render_widget_host_view.h index 2486758..7a8ceb19 100644 --- a/content/public/browser/render_widget_host_view.h +++ b/content/public/browser/render_widget_host_view.h
@@ -312,6 +312,11 @@ // resize the visual/layout viewports in response to keyboard visibility // changes. virtual bool ShouldVirtualKeyboardOverlayContent() = 0; + + // Create a geometrychange event and forward it to the JS with the + // keyboard coordinates. + virtual void NotifyVirtualKeyboardOverlayRect( + const gfx::Rect& keyboard_rect) = 0; }; } // namespace content
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index ff14d80..d4c06de 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc
@@ -1986,7 +1986,8 @@ ->GetNetworkContext() ->GetCookieManager(cookie_manager.BindNewPipeAndPassReceiver()); std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create( - url, value, base::Time::Now(), absl::nullopt /* server_time */)); + url, value, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); DCHECK(cc.get()); net::CookieOptions options;
diff --git a/content/test/gpu/gpu_tests/gpu_process_integration_test.py b/content/test/gpu/gpu_tests/gpu_process_integration_test.py index 121b8aa0..cc75b24 100644 --- a/content/test/gpu/gpu_tests/gpu_process_integration_test.py +++ b/content/test/gpu/gpu_tests/gpu_process_integration_test.py
@@ -126,7 +126,8 @@ ('GpuProcess_webgl_disabled_extension', 'gpu/functional_webgl_disabled_extension.html'), ('GpuProcess_webgpu_iframe_removed', - 'gpu/webgpu-iframe-removed.html')) + 'gpu/webgpu-iframe-removed.html'), ('GpuProcess_visibility', + 'about:blank')) for t in tests: yield (t[0], t[1], ('_' + t[0])) @@ -382,6 +383,49 @@ if not has_gpu_process: self.fail('GPU process not detected') + def _GpuProcess_visibility(self, test_path): + os_name = self.browser.platform.GetOSName() + os_version = self.browser.platform.GetOSVersionName() + if os_name != 'android' or os_version == 'M': + logging.info('Skipping test because not running on Android M+') + return + + has_gpu_process = self.tab.EvaluateJavaScript( + 'chrome.gpuBenchmarking.hasGpuProcess()') + if not has_gpu_process: + logging.info('Skipping test because no out-of-process GPU service') + return + + self.RestartBrowserIfNecessaryWithArgs([]) + self._Navigate(test_path) + system_info = self.browser.GetSystemInfo() + callback_count = system_info.gpu.aux_attributes[ + 'visibility_callback_call_count'] + # initial callback count should be 1 since the app became visible + if callback_count != 1: + self.fail('Visibility callback call count expected 1, got %d' % + callback_count) + + self.browser.platform.android_action_runner.TurnScreenOff() + self.tab.WaitForJavaScriptCondition('document.visibilityState == "hidden"', + timeout=_GPU_PAGE_TIMEOUT) + system_info = self.browser.GetSystemInfo() + callback_count = system_info.gpu.aux_attributes[ + 'visibility_callback_call_count'] + if callback_count != 2: + self.fail('Visibility callback call count expected 2, got %d' % + callback_count) + + self.browser.platform.android_action_runner.TurnScreenOn() + self.tab.WaitForJavaScriptCondition('document.visibilityState == "visible"', + timeout=_GPU_PAGE_TIMEOUT) + system_info = self.browser.GetSystemInfo() + callback_count = system_info.gpu.aux_attributes[ + 'visibility_callback_call_count'] + if callback_count != 3: + self.fail('Visibility callback call count expected 3, got %d' % + callback_count) + def _GpuProcess_disable_gpu_and_swiftshader(self, test_path): # Disable SwiftShader, GPU process should launch for display compositing. self.RestartBrowserIfNecessaryWithArgs(
diff --git a/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt b/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt index 197738a..0db1277 100644 --- a/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt +++ b/content/test/gpu/gpu_tests/test_expectations/webgl_conformance_expectations.txt
@@ -450,6 +450,7 @@ crbug.com/1203167 [ mac amd angle-metal ] conformance/extensions/oes-texture-float-with-video.html [ RetryOnFailure ] crbug.com/1230781 [ mac amd-0x6821 ] conformance/canvas/to-data-url-test.html [ Failure ] crbug.com/1230781 [ mac amd-0x679e ] conformance/canvas/to-data-url-test.html [ Failure ] +crbug.com/1236072 [ mac amd-0x679e angle-opengl ] conformance/renderbuffers/stencil-renderbuffer-initialization.html [ RetryOnFailure ] # TODO(kbr): uncomment the following expectation after test has # been made more robust.
diff --git a/docs/branch_sheriff.md b/docs/branch_sheriff.md index a7234fb..512bc0fc 100644 --- a/docs/branch_sheriff.md +++ b/docs/branch_sheriff.md
@@ -1,145 +1,18 @@ # Chromium Branch Sheriffing -This document describes how to be a Chromium *branch* sheriff and how sheriffing -on a branch differs from sheriffing on trunk. For trunk sheriffing guidance, see -[//docs/sheriff.md][sheriff-md]. - -[TOC] - -## Philosophy +The Chrome release branch sheriff provides coverage for release branches +(stable and beta) under Pacific timezone shifts. The goals of a branch sheriff are quite similar to those of a trunk sheriff. Branch sheriffs need to ensure that: -1. **Compile failures get fixed**, because compile failures on branches block -all tests (both automated and manual) and consequently reduce our confidence -in the quality of what we're shipping, possibly to the point of blocking -releases. -2. **Consistent test failures get repaired**, because they similarly reduce -our confidence in the quality of our code. +1. **Compile failures get fixed**, because compile failures on branches block + all tests (both automated and manual) and consequently reduce our confidence + in the quality of what we're shipping, possibly to the point of blocking + releases. +2. **Consistent test failures get repaired**, because they similarly reduce our + confidence in the quality of our code. -**Communication** is important for sheriffs in general, but it's particularly -important for branch sheriffs. Over the course of your shift, you may need to -coordinate with trunk sheriffs, troopers, release TPMs, and others -- don't -hesitate to do so, particularly if you have questions. - -Points of contact (i.e. platform-specific sheriffs) can be found -[here](http://goto.google.com/chrome-branch-sheriffing#points-of-contact). - -## Processes - -In general, you'll want to follow the same processes outlined in -[//docs/sheriff.md][sheriff-md]. There are some differences, though. - -### Checkout - -You'll need to ensure that your checkout is configured to check out the branch -heads. You can do so by running - -``` - src $ gclient sync --with_branch_heads -``` - -> This only needs to be done once, though running it more than once won't hurt. - -You may also need to run: - -``` - src $ git fetch -``` - -Once you've done that, you'll be able to check out branches: - -``` - src $ git checkout branch-heads/$BRANCH_NUMBER # e.g. branch-heads/4044 for M81 - src $ gclient sync -``` - -To determine the appropriate branch number, you can either use -[chromiumdash](#chromiumdash) or check [milestone.json][milestone-json] -directly. - -### Findit - -As FindIt is not available on branches, one way to try to find culprits is using -`git bisect` locally and upload changes to a gerrit CL and run the needed -trybots to check. This is especially useful when the errors are not reproducible -on your local builds or you don't have the required hardware to build the failed -tests. - -### Flaky tests - -Flaky tests that are disabled on trunk should also be disabled on any branches -with frequent failures of that test. If a trunk CL lands with no change other -than to disable one or more tests ([example](https://crrev.com/c/2507299)) and -it has an associated bug and the release manager is cc'd on the bug, you can and -should cherrypick it to the affected branch without requesting merge approval. - -On the other hand, if you believe that a flake was introduced by a cherry-pick -to the branch in question and is not flaky on trunk, you will need to create a -new CL to disable it only on the branch and go through the usual merge request -process. - -Note: there is little value in merging changes to the stable release -branch when the next milestone's stable release is less than a week away -(since there are usually no planned stable respins at that point). -You can find release dates on [chromiumdash][chromiumdash-schedule]. - -### Landing changes - -When you need to land a change to a branch, you'll need to go through [the same -merge approval process](./process/merge_request.md) as other cherry-picks (see -exception for flaky tests above). You should feel free to ping the relevant -release TPM as listed on [chromiumdash][chromiumdash-schedule]. - -## Tools - -### Sheriff-o-Matic - -Use the [branch SoM console][sheriff-o-matic] rather than the main chromium -console. - -### Consoles - -Use the [beta][main-beta] and [stable][main-stable] branch consoles rather than -the main console. A new console is created for each milestone. They are named -"Chromium M## Console" and can be found under the -[Chromium Project](https://ci.chromium.org/p/chromium). - -### Monorail issues (crbug) - -Refer and use the -[Sheriff-Chrome-Release label](https://bugs.chromium.org/p/chromium/issues/list?q=label%3ASheriff-Chrome-Release) -to find and tag issues that are of importance to Branch sheriffs. - -### Chromiumdash - -[chromiumdash][chromiumdash] can help you determine the branch number for a -particular milestone or channel, along with a host of other useful information: - - * [Branches][chromiumdash-branches] lists the branches for each milestone. - * [Releases][chromiumdash-releases] lists the builds currently shipping to - each channel, which can help map from channel to milestone or to branch. - * [Schedule][chromiumdash-schedule] lists the relevant dates for each - milestone and includes the release TPMs responsible for each milestone by - platform. - -### Rotation - -The current branch sheriff is listed [here][rotation-home]. The configuration -and source of truth for the schedule lives [here][rotation-config]. To swap, -simply send a CL changing schedule at the bottom of the file. -You can also use [Oncall Swapper](https://oncallswapper.corp.google.com/) -to find the swap and submit the CL for you. - -[chromiumdash]: https://chromiumdash.appspot.com -[chromiumdash-branches]: https://chromiumdash.appspot.com/branches -[chromiumdash-releases]: https://chromiumdash.appspot.com/releases -[chromiumdash-schedule]: https://chromiumdash.appspot.com/schedule -[main-beta]: https://ci.chromium.org/p/chromium/g/main-m81/console -[main-stable]: https://ci.chromium.org/p/chromium/g/main-m80/console -[milestone-json]: https://goto.google.com/chrome-milestone-json -[rotation-home]: https://goto.google.com/chrome-branch-sheriff-amer-west -[rotation-config]: https://goto.google.com/chrome-branch-sheriff-amer-west-config -[sheriff-md]: /docs/sheriff.md -[sheriff-o-matic]: https://sheriff-o-matic.appspot.com/chrome_browser_release +For more information on Chromium Branch Sheriffs, including How Tos, Swapping +Shifts and rotation updates, please see [Chromium +Branch Sheriffing](http://goto.google.com/chrome-branch-sheriffing)
diff --git a/docs/network_traffic_annotations.md b/docs/network_traffic_annotations.md index d7bc89b..6a66463 100644 --- a/docs/network_traffic_annotations.md +++ b/docs/network_traffic_annotations.md
@@ -292,16 +292,14 @@ ### Presubmit tests -To perform tests prior to submit, one can use the `traffic_annotation_auditor` -binary. It runs over the whole repository and using a python script, extracts -all the annotations and then checks if all above items are correct. The latest -executable for supported platforms can be found in -`tools/traffic_annotation/bin/[platform]`. +To perform tests prior to submit, one can use the `auditor.py` +script. It runs over the whole repository, extracts +all the annotations from C++ code, and then checks them for correctness. -Running the `traffic_annotation_auditor` requires having a build directory and -can be done with the following syntax: -`tools/traffic_annotation/bin/[linux64/win32]/traffic_annotation_auditor - --build-path=[out/Default]` +Running the `auditor.py` script requires a build directory in which you just +built the `chrome` target. You can invoke it like this: +`vpython3 tools/traffic_annotation/scripts/auditor/auditor.py + --build-path=out/Default` ### Waterfall tests Two commit queue trybots test traffic annotations on changed files using the @@ -320,7 +318,7 @@ enforced through keeping a summary of annotations in `tools/traffic_annotation/summary/annotations.xml`. Once a new annotation is added, one is updated, or deleted, this file should also be updated. To update the -`annotations.xml` file automatically, one can run `traffic_annotation_auditor` +`annotations.xml` file automatically, one can run `auditor.py` as specified in presubmit tests. But if it is not possible to do so (e.g., if you are changing the code from an unsupported platform or you don’t have a compiled build directory), the code can be submitted to the trybot and the test @@ -434,11 +432,12 @@ value. In these cases, `net::MutableNetworkTrafficAnnotationTag` and `net::MutablePartialNetworkTrafficAnnotationTag` can be used which do not have this limitation. + Mutable annotations have a run time check before being converted into normal annotations to ensure their content is valid. Therefore it is suggested that they would be used only if there is no other way around it. Use cases are -checked with the `traffic_annotation_auditor` to ensure proper initialization -values for the mutable annotations. +checked with `auditor.py` to ensure proper initialization values for the +mutable annotations. ## Mojo Interfaces (Advanced)
diff --git a/docs/sheriff.md b/docs/sheriff.md index 44d1a902..1a97d514 100644 --- a/docs/sheriff.md +++ b/docs/sheriff.md
@@ -1,9 +1,5 @@ # Chromium Sheriffing -Author: ellyjones@ - -## Sheriffing Philosophy - Sheriffs have one overarching role: to ensure that the Chromium build infrastructure is doing its job of helping developers deliver good software. Every other sheriff responsibility flows from that one. In priority order, @@ -29,6 +25,9 @@ TBRs were removed in Q1 2021. +For more information on Chromium Trunk Sheriffs, including How Tos, Swapping +Shifts and rotation updates, please see [Chromium Trunk Sheriffing](http://goto.google.com/chrome-trunk-sheriffing) + ## How to be a Sheriff To be a sheriff, you must be both a Chromium committer and a Google employee.
diff --git a/docs/speed/bot_health_sheriffing/how_to_access_test_logs.md b/docs/speed/bot_health_sheriffing/how_to_access_test_logs.md index 89ee025..bdbb38c 100644 --- a/docs/speed/bot_health_sheriffing/how_to_access_test_logs.md +++ b/docs/speed/bot_health_sheriffing/how_to_access_test_logs.md
@@ -1,5 +1,7 @@ # How to access and navigate test logs +**Important**: When making changes to this document, also update duplicate files under the [internal docs](http://goto.google.com/perf-bot-health-sheriffs). + When trying to understand a failure, it can be useful to inspect the test logs where the failure occurred. [TOC]
diff --git a/docs/speed/bot_health_sheriffing/how_to_address_duplicate_alerts.md b/docs/speed/bot_health_sheriffing/how_to_address_duplicate_alerts.md index 7ee4990..695f5478f 100644 --- a/docs/speed/bot_health_sheriffing/how_to_address_duplicate_alerts.md +++ b/docs/speed/bot_health_sheriffing/how_to_address_duplicate_alerts.md
@@ -1,5 +1,7 @@ # How to address a new alert with the same root cause as an existing alert +**Important**: When making changes to this document, also update duplicate files under the [internal docs](http://goto.google.com/perf-bot-health-sheriffs). + It's common when large problems arise for multiple alerts to fire due to the same underlying problem. Sheriff-o-matic does its best to automatically group these problems into a single alert, but sometimes it's unable to and we have to group the alerts together manually. This is important because it helps future sheriffs see at a glance the number of distinct problems. Unfortunately, there's no way to distinguish these duplicate alerts from new alerts without knowing the contents of those other alerts. If you're unsure about two particular alerts, don't hesitate to ask for help [on chat](https://hangouts.google.com/group/2GmiXjz55R2ixTXi1).
diff --git a/docs/speed/bot_health_sheriffing/how_to_disable_a_story.md b/docs/speed/bot_health_sheriffing/how_to_disable_a_story.md index df549ef..6c98eb09 100644 --- a/docs/speed/bot_health_sheriffing/how_to_disable_a_story.md +++ b/docs/speed/bot_health_sheriffing/how_to_disable_a_story.md
@@ -1,5 +1,7 @@ # How to disable a failing test/story on the perf waterfall +**Important**: When making changes to this document, also update duplicate files under the [internal docs](http://goto.google.com/perf-bot-health-sheriffs). + To disable a failing test/story, the first step is to figure out if the failing thing is gtest or Telemetry, then you can follow the below directions to disable the failing test/story.
diff --git a/docs/speed/bot_health_sheriffing/how_to_follow_up_on_an_alert.md b/docs/speed/bot_health_sheriffing/how_to_follow_up_on_an_alert.md index d74b5b8..1c36082 100644 --- a/docs/speed/bot_health_sheriffing/how_to_follow_up_on_an_alert.md +++ b/docs/speed/bot_health_sheriffing/how_to_follow_up_on_an_alert.md
@@ -1,5 +1,7 @@ # How to follow up on an alert +**Important**: When making changes to this document, also update duplicate files under the [internal docs](http://goto.google.com/perf-bot-health-sheriffs). + [TOC] Skim the bug to understand where the last sheriff left things and where you should pick up.
diff --git a/docs/speed/bot_health_sheriffing/how_to_handle_a_new_problem.md b/docs/speed/bot_health_sheriffing/how_to_handle_a_new_problem.md index 1916347..a6df2cc 100644 --- a/docs/speed/bot_health_sheriffing/how_to_handle_a_new_problem.md +++ b/docs/speed/bot_health_sheriffing/how_to_handle_a_new_problem.md
@@ -1,5 +1,7 @@ # How to handle an alert for a new problem +**Important**: When making changes to this document, also update duplicate files under the [internal docs](http://goto.google.com/perf-bot-health-sheriffs). + **Warning: this is the hardest part of being a sheriff.** Each bug may take 10 minutes to an hour to address, but there are usually a manageable number of new bugs per shift (5 on a good shift, 15 on a bad one).
diff --git a/docs/speed/bot_health_sheriffing/how_to_launch_a_functional_bisect.md b/docs/speed/bot_health_sheriffing/how_to_launch_a_functional_bisect.md index 92cfb04..8f0c6b78 100644 --- a/docs/speed/bot_health_sheriffing/how_to_launch_a_functional_bisect.md +++ b/docs/speed/bot_health_sheriffing/how_to_launch_a_functional_bisect.md
@@ -1,5 +1,7 @@ # How to launch a functional bisect and interpret its results +**Important**: When making changes to this document, also update duplicate files under the [internal docs](http://goto.google.com/perf-bot-health-sheriffs). + A functional bisect determines the revision at which a particular benchmark or story started failing more often. It does this by doing a binary search between a known good and known bad revision, running the test multiple times at each potential revision until it narrows down the culprit to a single revision. [TOC]
diff --git a/docs/speed/bot_health_sheriffing/how_to_snooze_an_alert.md b/docs/speed/bot_health_sheriffing/how_to_snooze_an_alert.md index 458d337..7161caa 100644 --- a/docs/speed/bot_health_sheriffing/how_to_snooze_an_alert.md +++ b/docs/speed/bot_health_sheriffing/how_to_snooze_an_alert.md Binary files differ
diff --git a/docs/speed/bot_health_sheriffing/main.md b/docs/speed/bot_health_sheriffing/main.md index d9e8c98..611b0a33 100644 --- a/docs/speed/bot_health_sheriffing/main.md +++ b/docs/speed/bot_health_sheriffing/main.md
@@ -1,18 +1,14 @@ -# Perf bot health sheriff rotation +# Perf Bot Health Sheriff -## Warning +The goal of the perf bot health sheriff rotation is to ensure that the benchmarks running on our perf waterfall continue to produce data and catch regressions quickly. This is also known as "keeping the bots green" and is primarily achieved by triaging incoming alerts. Note that a different rotation [Perf Regressions Sheriffs](../perf_regression_sheriffing.md) is focused on performance. -**Note that Sheriff-O-Matic currently doesn't work for the perf waterfall -[crbug.com/984159](https://crbug.com/984159). -Please use [Milo chrome.perf -console](https://ci.chromium.org/p/chrome/g/chrome.perf/console) instead.** - -## Goal - -The goal of the perf bot health sheriff rotation is to ensure that the benchmarks running on our perf waterfall continue to produce data and catch regressions quickly. This is also known as "keeping the bots green" and is primarily achieved by triaging incoming alerts. +For more information on Perf Bot Health Sheriffing, who's on rotation, how to handle specific +tasks, and swap shifts, please see [Perf Bot Health +Sheriffs](http://goto.google.com/perf-bot-health-sheriffs) ## Quick links +* [Perf Bot Health Sheriffing Overview and How-To](http://goto.google.com/perf-bot-health-sheriffs) * [How to determine what story is failing](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/what_test_is_failing.md) * [How to disable a story](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_disable_a_story.md) * [How to launch a functional bisect](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_launch_a_functional_bisect.md) @@ -21,102 +17,3 @@ * [How to handle a new problem](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_handle_a_new_problem.md) * [How to follow up on an alert](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_follow_up_on_an_alert.md) * [How to address duplicate alerts](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_address_duplicate_alerts.md) -* [Glossary](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/glossary.md) - -[TOC] - -## Vocabulary - -Definitions of various bot health related vocabulary can be found in our [glossary](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/glossary.md). - -## High-level responsibilities - -The sheriff's role is to work through the list of failures, fixing the easiest ones and routing the rest to the correct owners. This mostly requires filing bugs, disabling benchmarks and stories, launching bisects, and reverting any CLs that are obviously responsible for breakages. - -Additionally, the sheriff should watch the [catapult -roll](https://autoroll.skia.org/r/catapult-autoroll), which should -automatically TBR the sheriff. If the catapult roll fails, the sheriff should -investigate and revert suspect changelists. - -Near the end of their shift, sheriffs should also inspect[this dashboard](https://dashboards.corp.google.com/_e3cbeb60_d250_4e67_8795_56cd9af8a303) for the time covered during their shift, and do a first-pass analysis of any anomalies (e.g. jobs taking 6 hours when they normally take 1.5). - -The sheriff should *not* feel responsible for investigating hard problems. The volume of incoming alerts makes this infeasible. Instead, they should delegate deep investigations to the right owners. As a rule of thumb, a trained sheriff should expect to spend 10-20 minutes per alert and should never be spending more than an hour per alert. - -## Workflow - -~~Incoming failures are shown in [Sheriff-o-matic](https://sheriff-o-matic.appspot.com/chromium.perf), which acts as a task management system for bot health sheriffs. Failures are divided into three groups on the dashboard:~~ - -* ~~**Infra failures** show general infrastructure problems that are affecting benchmarks. Besides surfacing in Sheriff-o-matic, we also need to check for down bots in the lame duck pool. Please file a ticket for any bots you see in [this list](https://chrome-swarming.appspot.com/botlist?c=id&c=os&c=task&c=status&c=os&c=task&c=status&c=pool&f=status%3Adead&f=pool%3Achrome.tests.perf&l=100&q=pool%3Achrome.tests.perf&s=id%3Aasc) or [this list for webview](https://chrome-swarming.appspot.com/botlist?c=id&c=os&c=task&c=status&c=os&c=task&c=status&c=pool&f=status%3Adead&f=pool%3Achrome.tests.perf-webview&l=100&q=pool%3Achrome.tests.perf&s=id%3Aasc) as they will not show up in Sheriff-o-matic.~~ - -* ~~**Consistent failures** show benchmarks that have been failing for a while.~~ - -* ~~**New failures** show benchmarks that benchmarks that have recently started failing.~~ - -~~Of these three groups, the sheriff should only be concerned with **infra failures** and **consistent failures.** New failures are too likely to be one-off flakes to warrant investigation.~~ - -~~The high-level workflow is to start at the top of the list of the list of failures and address one alert at a time. The alerts are ordered roughly in order of their impact.~~ - -~~As the sheriff addresses alerts, the number of alerts will generally decrease as problems with the same cause get grouped together and failures get fixed. Addressed alerts will also move to the bottom of the list. Ideally, Sheriff-o-matic should reflect the work you've done so that a new sheriff could potentially take over at any time and pick up at the top of the list.~~ - -**Note that Sheriff-O-Matic currently doesn't work for the perf waterfall -[crbug.com/984159](https://crbug.com/984159). -Please use [Milo chrome.perf -console](https://ci.chromium.org/p/chrome/g/chrome.perf/console) instead.** - -## How to address each alert - -Alerts can be addressed by answering the following questions: - -### Has a previous sheriff already addressed this alert? - -This category of alert should have a bug already linked with it. This link can be found next to the alert. - - - -Instructions can be found [here](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_follow_up_on_an_alert.md) on how to follow up with an existing alert. - -### Is this a new alert caused by the same root cause as an already-triaged alert? - -This category of alert won't have a bug linked with it yet. However, a bug *does* exist for the issue: it may be linked to another alert, but can otherwise be found [here](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=label:Performance-Sheriff-BotHealth&sort=pri&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified) under the Performance-Sheriff-BotHealth label in monorail. For example: - - - -and - - - -are both in the list of current of alerts but represent the same failure. - -It can sometimes be tricky to differentiate between these alerts and ones caused by completely new problems, but sheriffs can always treat an alert as new and merge it with another later. - -Instructions can be found [here](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_address_duplicate_alerts.md) on how to handle a duplicate alert. - -### Is this a new alert caused by a new problem? - -This category of alert doesn't yet have a bug associated with it. It's the most common category and requires the most expertise to handle. - -Instructions can be found [here](https://chromium.googlesource.com/chromium/src/+/main/docs/speed/bot_health_sheriffing/how_to_handle_a_new_problem.md) on how to handle an alert for a new problem. - -## After your shift is over - -Your only responsibility after your shift concludes is to follow up with any bugs that would no longer appear on the dashboard (i.e. the failure has stopped) but still need correct routing. - -For example, if you disabled a story and snoozed an alert during your shift, you should ensure that the bug is assigned to the benchmark's owner before relinquishing responsibility for the bug. - -## Frequently asked questions - -### Why do the benchmarks break so often? - -The bots runs Chrome benchmarks that are complicated integration tests of Chrome. Developers frequently submit code that breaks some part of Chrome and one of our integration tests (hopefully) tests that bit of code, resulting in a broken benchmark. In some sense, frequent breakages indicate that the benchmarks are working. - -Many breakages probably *aren't* good signs, though. If you have ideas on how to reduce the number of breakages or the work required to handle a breakage, submit your idea to the Chrome benchmarking group! - -### Do I have to use Sheriff-o-matic? - -Yes! Sheriff-o-matic allows us to smoothly hand off responsibility between sheriffs and allows us to standardize sheriffing. - -If you find a problem with Sheriff-o-matic or have a feature request, file a bug [here](https://bugs.chromium.org/p/chromium/issues/entry?template=Build%20Infrastructure&components=Infra%3ESheriffing%3ESheriffOMatic&labels=Pri-2,Infra-DX&cc=seanmccullough@chromium.org,martiniss@chromium.org,zhangtiff@chromium.org&comment=Problem+with+Sheriff-o-Matic). The team is usually very responsive and, because of their work, the tool is getting better every day. - -### How can I tell if I've done a good job? - -It can be hard to tell. Generally, a good goal is to try and have fewer alerts when your shift ends than when it began. Sometimes that isn't possible, though.
diff --git a/docs/speed/bot_health_sheriffing/what_test_is_failing.md b/docs/speed/bot_health_sheriffing/what_test_is_failing.md index 6c65d1ff..aee53ef4 100644 --- a/docs/speed/bot_health_sheriffing/what_test_is_failing.md +++ b/docs/speed/bot_health_sheriffing/what_test_is_failing.md
@@ -1,5 +1,7 @@ # How to determine what story is failing +**Important**: When making changes to this document, also update duplicate files under the [internal docs](http://goto.google.com/perf-bot-health-sheriffs). + The first step in addressing a test failure is to identify what stories are failing. The easiest way to identify these is to use the [Flakiness dashboard](https://test-results.appspot.com/dashboards/flakiness_dashboard.html#testType=blink_perf.layout), which is a high-level dashboard showing test passes and failures. (Sheriff-o-matic tries to automatically identify the failing stories, but is often incorrect and therefore can't be trusted.) Open up the flakiness dashboard and select the benchmark and platform in question (pulled from the SOM alert) from the "Test type" and "Builder" dropdowns. You should see a view like this:
diff --git a/docs/speed/perf_regression_sheriffing.md b/docs/speed/perf_regression_sheriffing.md index a4cdf79..a06fbda 100644 --- a/docs/speed/perf_regression_sheriffing.md +++ b/docs/speed/perf_regression_sheriffing.md
@@ -1,4 +1,4 @@ -# Perf Regression Sheriffing (go/perfregression-sheriff) +# Perf Regression Sheriffing The perf regression sheriff tracks performance regressions in Chrome's continuous integration tests. Note that a [different @@ -6,95 +6,12 @@ tests stay green, so the perf regression sheriff role is now entirely focused on performance. -**[Rotation calendar](https://calendar.google.com/calendar/embed?src=google.com_2fpmo740pd1unrui9d7cgpbg2k%40group.calendar.google.com)** +Key responsibilities include: -## Key Responsibilities + * Addressing bugs that need attention + * Follow up on Performance Regressions + * Give Feedback on our Infrastructure -* [Address bugs needing attention](#Address-bugs-needing-attention) - -* [Follow up on Performance Regressions](#Follow-up-on-Performance-Regressions) - -* [Give Feedback on our Infrastructure](#Give-Feedback-on-our-Infrastructure) - -## Address bugs needing attention - -NOTE: Ensure that you're signed into Monorail. - -Use [this Monorail query](https://bugs.chromium.org/p/chromium/issues/list?sort=modified&q=label%3AChromeperf-Sheriff-NeedsAttention%2CChromeperf-Auto-NeedsAttention%20-has%3Aowner&can=2) -to find automatically triaged issues which need attention. - -NOTE: If the list of issues that need attention is empty, please jump ahead to -[Follow up on Performance Regressions](#Follow-up-on-Performance-Regressions). - -Issues in the list will include automatically filed and bisected regressions -that are supported by the Chromium Perf Sheriff rotation. For each of the -issues: - -1. Determine the cause of the failure: - - * If it's Pinpoint failing to find a culprit, consider re-running the - failing Pinpoint job. - - * If it's the Chromeperf Dashboard failing to start a Pinpoint bisection, - consider running a bisection from the grouped alerts. The issue - description should have a link to the group of anomalies associated with - the issue. - - * If this was a manual escalation (e.g. a suspected culprit author put the - `Chromeperf-Sheriff-NeedsAttention` label to seek help) use the tools at - your disposal, like: - - * Retry the most recent Pinpoint job, potentially changing the parameters. - - * Inspect the results of the Pinpoint job associated with the issues and - decide that this could be noise. - - * In cases where it's unclear what next should be done, escalate the issue - to the Chrome Speed Tooling team by adding the `Speed>Bisection` component - and leaving the issue `Untriaged` or `Unconfirmed`. - -2. Remove the `Chromeperf-Sheriff-NeedsAttention` or - `Chromeperf-Auto-NeedsAttention` label once you've acted on an issue. - -**For alerts related to `resource_sizes`:** Refer to - [apk_size_regressions.md](apk_size_regressions.md). - -## Follow up on Performance Regressions - -Please spend any spare time driving down bugs from the [regression -backlog](https://bugs.chromium.org/p/chromium/issues/list?can=2&q=Performance%3DSheriff+Type%3ABug+modified-before%3Atoday-6&sort=-modified). -Treat these bugs as you would your own -- investigate the regressions, find out -what the next step should be, and then move the bug along. Some possible next steps -and questions to answer are: - -* Should the bug be closed? -* Are there questions that need to be answered? -* Are there people that should be added to the CC list? -* Is the correct owner assigned? - -When a bug does need to be pinged, rather than adding a generic "ping", it's -much much more effective to include the username and action item. - -You should aim to end your shift with an empty backlog, but it's important to -still advance each bug in a meaningful way. - -After your shift, please try to follow up on the bugs you filed weekly. Kick off -new bisects if the previous ones failed, and if the bisect picks a likely -culprit follow up to ensure the CL author addresses the problem. If you are -certain that a specific CL caused a performance regression, and the author does -not have an immediate plan to address the problem, please revert the CL. - -## Give Feedback on our Infrastructure - -Perf regression sheriffs have their eyes on the perf dashboard and bisects -more than anyone else, and their feedback is invaluable for making sure these -tools are accurate and improving them. Please file bugs and feature requests -as you see them: - -* **Perf Dashboard**: Please use the red "Report Issue" link in the navbar. -* **Pinpoint**: If Pinpoint is identifying the wrong CL as culprit - or missing a clear culprit, or not reproducing what appears to be a clear - regression, please file an issue in crbug with the `Speed>Bisection` - component. -* **Noisy Tests**: Please file a bug in crbug with component `Speed>Benchmarks` - and [cc the owner](http://go/perf-owners). +For more information on how these responsibilities, how to swap shifts and more, +please see [Perf Regression +Sheriffs](http://goto.google.com/chrome-perf-regression-sheriffing)
diff --git a/extensions/renderer/gc_callback.cc b/extensions/renderer/gc_callback.cc index 98d8a15..0eaea31 100644 --- a/extensions/renderer/gc_callback.cc +++ b/extensions/renderer/gc_callback.cc
@@ -8,7 +8,6 @@ #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" -#include "extensions/renderer/bindings/api_binding_util.h" #include "extensions/renderer/script_context.h" #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/web/web_local_frame.h" @@ -50,6 +49,18 @@ object_.SetWeak(this, OnObjectGC, v8::WeakCallbackType::kParameter); context->AddInvalidationObserver(base::BindOnce( &GCCallback::OnContextInvalidated, weak_ptr_factory_.GetWeakPtr())); + blink::WebLocalFrame* frame = context_->web_frame(); + if (frame) { + // We cache the task runner here instead of fetching it right before we use + // it to avoid a potential crash that can happen if the object is GC'd + // *during* the script context invalidation process (e.g. before the + // extension system has marked the context invalid but after the frame has + // already had it's schedueler disconnected). See crbug.com/1216541 + task_runner_ = frame->GetTaskRunner(blink::TaskType::kInternalDefault); + } else { + // |frame| can be null on tests. + task_runner_ = base::ThreadTaskRunnerHandle::Get(); + } } GCCallback::~GCCallback() {} @@ -64,32 +75,9 @@ GCCallback* self = data.GetParameter(); self->object_.Reset(); - // If it looks like the context is already invalidated, bail early to avoid a - // potential crash from trying to get a task runner that no longer exists. - // This can happen if the object is GC'd *during* the script context - // invalidation process (e.g., before OnContextInvalidated() is called for the - // script context). Since binding::IsContextValid() is one of the first - // signals, we check that as well. If the context is invalidated, - // OnContextInvalidated() will be called almost immediately, and finish - // calling `fallback_` and deleting the GCCallback. - // See crbug.com/1216541 - { - v8::HandleScope handle_scope(self->context_->isolate()); - if (!binding::IsContextValid(self->context_->v8_context())) - return; - } - - blink::WebLocalFrame* frame = self->context_->web_frame(); - scoped_refptr<base::SingleThreadTaskRunner> task_runner; - if (frame) { - task_runner = frame->GetTaskRunner(blink::TaskType::kInternalDefault); - } else { - // |frame| can be null on tests. - task_runner = base::ThreadTaskRunnerHandle::Get(); - } - task_runner->PostTask(FROM_HERE, - base::BindOnce(&GCCallback::RunCallback, - self->weak_ptr_factory_.GetWeakPtr())); + self->task_runner_->PostTask( + FROM_HERE, base::BindOnce(&GCCallback::RunCallback, + self->weak_ptr_factory_.GetWeakPtr())); } void GCCallback::RunCallback() {
diff --git a/extensions/renderer/gc_callback.h b/extensions/renderer/gc_callback.h index eee1b31a..1d6bd55 100644 --- a/extensions/renderer/gc_callback.h +++ b/extensions/renderer/gc_callback.h
@@ -7,7 +7,9 @@ #include "base/callback.h" #include "base/macros.h" +#include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/single_thread_task_runner.h" #include "v8/include/v8.h" namespace extensions { @@ -46,6 +48,9 @@ // The context which owns |object_|. ScriptContext* context_; + // A task runner associated with the frame for the context. + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; + // The object this GCCallback is bound to. v8::Global<v8::Object> object_;
diff --git a/gpu/command_buffer/service/wrapped_sk_image.cc b/gpu/command_buffer/service/wrapped_sk_image.cc index d419bc1..a2be231 100644 --- a/gpu/command_buffer/service/wrapped_sk_image.cc +++ b/gpu/command_buffer/service/wrapped_sk_image.cc
@@ -501,7 +501,7 @@ // raster and/or display. return (usage & kWrappedSkImageUsage) && !(usage & ~kWrappedSkImageUsage); } else { - // For d SkiaRenderer/GL only use WrappedSkImages for OOP-R because + // For SkiaRenderer/GL only use WrappedSkImages for OOP-R because // CopySubTexture() doesn't use Skia. https://crbug.com/984045 return (usage == kWrappedSkImageUsage) || (usage == SHARED_IMAGE_USAGE_DISPLAY);
diff --git a/gpu/config/gpu_info.cc b/gpu/config/gpu_info.cc index 3692a28..441fe09 100644 --- a/gpu/config/gpu_info.cc +++ b/gpu/config/gpu_info.cc
@@ -318,6 +318,7 @@ bool oop_rasterization_supported; bool subpixel_font_rendering; + uint32_t visibility_callback_call_count; #if BUILDFLAG(ENABLE_VULKAN) absl::optional<VulkanInfo> vulkan_info; @@ -395,6 +396,8 @@ EnumerateImageDecodeAcceleratorSupportedProfile(profile, enumerator); enumerator->AddBool("oopRasterizationSupported", oop_rasterization_supported); enumerator->AddBool("subpixelFontRendering", subpixel_font_rendering); + enumerator->AddInt("visibilityCallbackCallCount", + visibility_callback_call_count); #if BUILDFLAG(ENABLE_VULKAN) if (vulkan_info) { auto blob = vulkan_info->Serialize();
diff --git a/gpu/config/gpu_info.h b/gpu/config/gpu_info.h index ee53e043..e3d96411 100644 --- a/gpu/config/gpu_info.h +++ b/gpu/config/gpu_info.h
@@ -413,6 +413,8 @@ bool subpixel_font_rendering; + uint32_t visibility_callback_call_count = 0; + #if BUILDFLAG(ENABLE_VULKAN) absl::optional<VulkanInfo> vulkan_info; #endif
diff --git a/gpu/ipc/common/gpu_info.mojom b/gpu/ipc/common/gpu_info.mojom index 8b54e59..abce48f 100644 --- a/gpu/ipc/common/gpu_info.mojom +++ b/gpu/ipc/common/gpu_info.mojom
@@ -181,6 +181,7 @@ bool oop_rasterization_supported; bool subpixel_font_rendering; + uint32 visibility_callback_call_count; [EnableIf=supports_vulkan] VulkanInfo? vulkan_info;
diff --git a/gpu/ipc/common/gpu_info_mojom_traits.cc b/gpu/ipc/common/gpu_info_mojom_traits.cc index ef0c67df..c00fa81 100644 --- a/gpu/ipc/common/gpu_info_mojom_traits.cc +++ b/gpu/ipc/common/gpu_info_mojom_traits.cc
@@ -396,6 +396,7 @@ out->oop_rasterization_supported = data.oop_rasterization_supported(); out->subpixel_font_rendering = data.subpixel_font_rendering(); + out->visibility_callback_call_count = data.visibility_callback_call_count(); #if defined(OS_WIN) out->d3d12_feature_level = data.d3d12_feature_level();
diff --git a/gpu/ipc/common/gpu_info_mojom_traits.h b/gpu/ipc/common/gpu_info_mojom_traits.h index b351439..03627b3 100644 --- a/gpu/ipc/common/gpu_info_mojom_traits.h +++ b/gpu/ipc/common/gpu_info_mojom_traits.h
@@ -414,6 +414,10 @@ return input.subpixel_font_rendering; } + static uint32_t visibility_callback_call_count(const gpu::GPUInfo& input) { + return input.visibility_callback_call_count; + } + #if BUILDFLAG(ENABLE_VULKAN) static const absl::optional<gpu::VulkanInfo> vulkan_info( const gpu::GPUInfo& input) {
diff --git a/ios/chrome/app/spotlight/spotlight_manager_unittest.mm b/ios/chrome/app/spotlight/spotlight_manager_unittest.mm index 2eeda63b..d82210f 100644 --- a/ios/chrome/app/spotlight/spotlight_manager_unittest.mm +++ b/ios/chrome/app/spotlight/spotlight_manager_unittest.mm
@@ -184,53 +184,3 @@ ->GetAdditionalKeywords()]; EXPECT_TRUE([hardCodedKeywordsSet isSubsetOfSet:spotlightManagerKeywords]); } - -// The iOS MD5 APIs were marked as deprecated in iOS 13 and cannot be called if -// the min_deployment_target is 13.0 or higher. -#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0 - -namespace { - -// Returns the original implementation of |hashForURL:| which used -// OS-provided MD5 functions. -int64_t OriginalHash(const GURL& url, NSString* title) { - NSString* key = [NSString - stringWithFormat:@"%@ %@", base::SysUTF8ToNSString(url.spec()), title]; - unsigned char hash[CC_MD5_DIGEST_LENGTH]; - const std::string clipboard = base::SysNSStringToUTF8(key); - const char* c_string = clipboard.c_str(); - CC_MD5(c_string, strlen(c_string), hash); - uint64_t md5 = *(reinterpret_cast<uint64_t*>(hash)); - return md5; -} - -} // namespace - -// The implementation of |getHashForlURL:| was rewritten to use base/hash/md5.h -// instead of OS-provided MD5 functions. Test that the two implementations hash -// to the same values, since the result is used as a Spotlight ID. -TEST_F(SpotlightManagerTest, TestMD5HashesMatch) { - { - GURL url("https://www.google.com"); - NSString* title = @"Google"; - - NSString* original_hash = - [NSString stringWithFormat:@"%016llx", OriginalHash(url, title)]; - NSString* spotlight_id = - [bookmarksSpotlightManager_ spotlightIDForURL:url title:title]; - EXPECT_TRUE([spotlight_id containsString:original_hash]); - } - { - GURL url("http://www.example.com/path/to/resource"); - NSString* title = @"Example - Title"; - - NSString* original_hash = - [NSString stringWithFormat:@"%016llx", OriginalHash(url, title)]; - NSString* spotlight_id = - [bookmarksSpotlightManager_ spotlightIDForURL:url title:title]; - EXPECT_TRUE([spotlight_id containsString:original_hash]); - } -} - -#endif // !defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MIN_REQUIRED < - // __IPHONE_13_0
diff --git a/ios/chrome/browser/credential_provider/archivable_credential+password_form.h b/ios/chrome/browser/credential_provider/archivable_credential+password_form.h index 2dadfd2c..1d092c7 100644 --- a/ios/chrome/browser/credential_provider/archivable_credential+password_form.h +++ b/ios/chrome/browser/credential_provider/archivable_credential+password_form.h
@@ -11,6 +11,10 @@ struct PasswordForm; } // namespace password_manager +// Connivence method to create a PasswordForm from a Credential. +password_manager::PasswordForm PasswordFormFromCredential( + id<Credential> credential); + // Category for adding convenience logic related to PasswordForms. @interface ArchivableCredential (PasswordForm)
diff --git a/ios/chrome/browser/credential_provider/archivable_credential+password_form.mm b/ios/chrome/browser/credential_provider/archivable_credential+password_form.mm index 1fd2a49..7a8b5fa 100644 --- a/ios/chrome/browser/credential_provider/archivable_credential+password_form.mm +++ b/ios/chrome/browser/credential_provider/archivable_credential+password_form.mm
@@ -18,11 +18,40 @@ namespace { +using base::SysNSStringToUTF8; +using base::SysNSStringToUTF16; using base::SysUTF8ToNSString; using base::SysUTF16ToNSString; +// Helper function that strips any authentication data, as well as query and +// ref portions of URL. +GURL StripAuthAndParams(const GURL& gurl) { + GURL::Replacements rep; + rep.ClearUsername(); + rep.ClearPassword(); + rep.ClearQuery(); + rep.ClearRef(); + return gurl.ReplaceComponents(rep); +} + } // namespace +password_manager::PasswordForm PasswordFormFromCredential( + id<Credential> credential) { + password_manager::PasswordForm form; + + GURL url(SysNSStringToUTF8(credential.serviceIdentifier)); + DCHECK(url.is_valid()); + + form.url = StripAuthAndParams(url); + form.signon_realm = form.url.GetOrigin().spec(); + form.username_value = SysNSStringToUTF16(credential.user); + form.encrypted_password = SysNSStringToUTF8(credential.keychainIdentifier); + form.times_used = credential.rank; + + return form; +} + @implementation ArchivableCredential (PasswordForm) - (instancetype)initWithPasswordForm:
diff --git a/ios/chrome/browser/credential_provider/archivable_credential+password_form_unittest.mm b/ios/chrome/browser/credential_provider/archivable_credential+password_form_unittest.mm index e857ba89..cff7e70 100644 --- a/ios/chrome/browser/credential_provider/archivable_credential+password_form_unittest.mm +++ b/ios/chrome/browser/credential_provider/archivable_credential+password_form_unittest.mm
@@ -109,4 +109,31 @@ EXPECT_FALSE(credential); } +// Tests the creation of a PasswordForm from a Credential. +TEST_F(ArchivableCredentialPasswordFormTest, PasswordFormFromCredential) { + NSString* username = @"username_value"; + NSString* keychainIdentifier = @"keychain_identifier_value"; + NSString* url = @"http://www.alpha.example.com/path/and?args=8"; + NSString* recordIdentifier = @"recordIdentifier"; + + id<Credential> credential = + [[ArchivableCredential alloc] initWithFavicon:nil + keychainIdentifier:keychainIdentifier + rank:1 + recordIdentifier:recordIdentifier + serviceIdentifier:url + serviceName:nil + user:username + validationIdentifier:nil]; + EXPECT_TRUE(credential); + + PasswordForm passwordForm = PasswordFormFromCredential(credential); + EXPECT_EQ(passwordForm.times_used, credential.rank); + EXPECT_EQ(passwordForm.username_value, base::SysNSStringToUTF16(username)); + EXPECT_EQ(passwordForm.encrypted_password, + base::SysNSStringToUTF8(keychainIdentifier)); + EXPECT_EQ(passwordForm.url, GURL("http://www.alpha.example.com/path/and")); + EXPECT_EQ(passwordForm.signon_realm, "http://www.alpha.example.com/"); +} + } // namespace
diff --git a/ios/chrome/browser/main/browser.h b/ios/chrome/browser/main/browser.h index 8e5c9ec..b58d8be 100644 --- a/ios/chrome/browser/main/browser.h +++ b/ios/chrome/browser/main/browser.h
@@ -13,7 +13,6 @@ class BrowserObserver; class ChromeBrowserState; @class CommandDispatcher; -@class TabModel; class WebStateList; // Browser is the model for a window containing multiple tabs. Instances @@ -31,10 +30,6 @@ // Accessor for the owning ChromeBrowserState. virtual ChromeBrowserState* GetBrowserState() const = 0; - // Accessor for the TabModel. DEPRECATED: prefer GetWebStateList() whenever - // possible. - virtual TabModel* GetTabModel() const = 0; - // Accessor for the WebStateList. virtual WebStateList* GetWebStateList() const = 0;
diff --git a/ios/chrome/browser/main/browser_impl.h b/ios/chrome/browser/main/browser_impl.h index a8a37d7b..9ecf608 100644 --- a/ios/chrome/browser/main/browser_impl.h +++ b/ios/chrome/browser/main/browser_impl.h
@@ -14,7 +14,6 @@ class ChromeBrowserState; @class SceneState; -@class TabModel; class WebStateList; class WebStateListDelegate; @@ -35,7 +34,6 @@ // Browser. ChromeBrowserState* GetBrowserState() const override; - TabModel* GetTabModel() const override; WebStateList* GetWebStateList() const override; CommandDispatcher* GetCommandDispatcher() const override; void AddObserver(BrowserObserver* observer) override; @@ -48,7 +46,6 @@ std::unique_ptr<WebStateList> web_state_list); ChromeBrowserState* browser_state_; - __strong TabModel* tab_model_ = nil; std::unique_ptr<WebStateListDelegate> web_state_list_delegate_; std::unique_ptr<WebStateList> web_state_list_; __strong CommandDispatcher* command_dispatcher_;
diff --git a/ios/chrome/browser/main/browser_impl.mm b/ios/chrome/browser/main/browser_impl.mm index cd38991..246785ee7 100644 --- a/ios/chrome/browser/main/browser_impl.mm +++ b/ios/chrome/browser/main/browser_impl.mm
@@ -11,7 +11,6 @@ #import "ios/chrome/browser/main/browser_observer.h" #import "ios/chrome/browser/main/browser_web_state_list_delegate.h" #import "ios/chrome/browser/sessions/session_service_ios.h" -#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list_delegate.h" @@ -30,10 +29,6 @@ std::make_unique<WebStateList>(web_state_list_delegate_.get()); } -void BrowserImpl::CreateTabModel() { - tab_model_ = [[TabModel alloc] initWithBrowser:this]; -} - BrowserImpl::BrowserImpl(ChromeBrowserState* browser_state, std::unique_ptr<WebStateList> web_state_list) : browser_state_(browser_state), @@ -51,10 +46,6 @@ return browser_state_; } -TabModel* BrowserImpl::GetTabModel() const { - return tab_model_; -} - WebStateList* BrowserImpl::GetWebStateList() const { return web_state_list_.get(); } @@ -76,6 +67,5 @@ std::unique_ptr<BrowserImpl> browser = std::make_unique<BrowserImpl>(browser_state); AttachBrowserAgents(browser.get()); - browser->CreateTabModel(); return browser; }
diff --git a/ios/chrome/browser/main/browser_impl_unittest.mm b/ios/chrome/browser/main/browser_impl_unittest.mm index 3e1f9d5a..bc2d79f 100644 --- a/ios/chrome/browser/main/browser_impl_unittest.mm +++ b/ios/chrome/browser/main/browser_impl_unittest.mm
@@ -6,7 +6,6 @@ #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #import "ios/chrome/browser/main/fake_browser_observer.h" -#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" #include "ios/chrome/browser/web_state_list/web_state_list.h" #include "ios/web/public/test/web_task_environment.h" @@ -48,11 +47,6 @@ std::unique_ptr<Browser> browser = std::make_unique<BrowserImpl>(chrome_browser_state_.get()); FakeBrowserObserver observer(browser.get()); - // Simulate shut down order from BrowserViewWrangler, where the TabModel's - // |-browserStateDestroyed| is expected to be executed before the - // TabModelList's destructor. - // TODO(crbug.com/783777): Remove when TabModel is no longer used. - [browser->GetTabModel() disconnect]; browser = nullptr; EXPECT_TRUE(observer.browser_destroyed()); }
diff --git a/ios/chrome/browser/main/test_browser.h b/ios/chrome/browser/main/test_browser.h index 8e9ee24..6cf2296 100644 --- a/ios/chrome/browser/main/test_browser.h +++ b/ios/chrome/browser/main/test_browser.h
@@ -32,7 +32,6 @@ // Browser. ChromeBrowserState* GetBrowserState() const override; - TabModel* GetTabModel() const override; WebStateList* GetWebStateList() const override; CommandDispatcher* GetCommandDispatcher() const override; void AddObserver(BrowserObserver* observer) override; @@ -47,7 +46,6 @@ // Used in all cases. __strong CommandDispatcher* command_dispatcher_ = nil; ChromeBrowserState* browser_state_ = nullptr; - TabModel* tab_model_ = nil; WebStateList* web_state_list_ = nullptr; base::ObserverList<BrowserObserver, /* check_empty= */ true> observers_;
diff --git a/ios/chrome/browser/main/test_browser.mm b/ios/chrome/browser/main/test_browser.mm index c67057b..9affd01 100644 --- a/ios/chrome/browser/main/test_browser.mm +++ b/ios/chrome/browser/main/test_browser.mm
@@ -53,10 +53,6 @@ return browser_state_; } -TabModel* TestBrowser::GetTabModel() const { - return tab_model_; -} - WebStateList* TestBrowser::GetWebStateList() const { return web_state_list_; }
diff --git a/ios/chrome/browser/net/cookie_util_unittest.mm b/ios/chrome/browser/net/cookie_util_unittest.mm index 246ecde..6500362 100644 --- a/ios/chrome/browser/net/cookie_util_unittest.mm +++ b/ios/chrome/browser/net/cookie_util_unittest.mm
@@ -95,9 +95,9 @@ options.set_include_httponly(); std::string cookie_line = base::SysNSStringToUTF8(cookie_name) + "=" + base::SysNSStringToUTF8(cookie_value); - auto canonical_cookie = - net::CanonicalCookie::Create(test_url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */); + auto canonical_cookie = net::CanonicalCookie::Create( + test_url, cookie_line, base::Time::Now(), /*server_time=*/absl::nullopt, + /*cookie_partition_key=*/absl::nullopt); cookie_store->SetCanonicalCookieAsync(std::move(canonical_cookie), test_url, options, net::CookieStore::SetCookiesCallback());
diff --git a/ios/chrome/browser/providers/BUILD.gn b/ios/chrome/browser/providers/BUILD.gn index a83a743..7e7d7b1 100644 --- a/ios/chrome/browser/providers/BUILD.gn +++ b/ios/chrome/browser/providers/BUILD.gn
@@ -50,6 +50,7 @@ ":chromium_provider_factory", # The individual API implementations. + "//ios/chrome/browser/providers/app_distribution:chromium_app_distribution", "//ios/chrome/browser/providers/branded_images:chromium_branded_images", "//ios/chrome/browser/providers/lens:chromium_lens", "//ios/chrome/browser/providers/modals:chromium_modals",
diff --git a/ios/chrome/browser/providers/app_distribution/BUILD.gn b/ios/chrome/browser/providers/app_distribution/BUILD.gn new file mode 100644 index 0000000..50f7952 --- /dev/null +++ b/ios/chrome/browser/providers/app_distribution/BUILD.gn
@@ -0,0 +1,9 @@ +# Copyright 2021 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("chromium_app_distribution") { + configs += [ "//build/config/compiler:enable_arc" ] + sources = [ "chromium_app_distribution.cc" ] + deps = [ "//ios/public/provider/chrome/browser/app_distribution:app_distribution_api" ] +}
diff --git a/ios/chrome/browser/providers/app_distribution/chromium_app_distribution.cc b/ios/chrome/browser/providers/app_distribution/chromium_app_distribution.cc new file mode 100644 index 0000000..e4ea9fe --- /dev/null +++ b/ios/chrome/browser/providers/app_distribution/chromium_app_distribution.cc
@@ -0,0 +1,30 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ios/public/provider/chrome/browser/app_distribution/app_distribution_api.h" + +namespace ios { +namespace provider { + +std::string GetBrandCode() { + // Chromium has no brand code. + return std::string(); +} + +void ScheduleAppDistributionNotifications( + const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory, + bool is_first_run) { + // Nothing to do for Chromium. +} + +void CancelAppDistributionNotifications() { + // Nothing to do for Chromium. +} + +void InitializeFirebase(base::Time install_date, bool is_first_run) { + // Nothing to do for Chromium. +} + +} // namespace provider +} // namespace ios
diff --git a/ios/chrome/browser/sessions/BUILD.gn b/ios/chrome/browser/sessions/BUILD.gn index 806ec05..7c767dc 100644 --- a/ios/chrome/browser/sessions/BUILD.gn +++ b/ios/chrome/browser/sessions/BUILD.gn
@@ -128,6 +128,24 @@ configs += [ "//build/config/compiler:enable_arc" ] } +source_set("session_saving") { + sources = [ + "session_saving_scene_agent.h", + "session_saving_scene_agent.mm", + ] + deps = [ + ":restoration_agent", + "//ios/chrome/browser/browser_state", + "//ios/chrome/browser/main:public", + "//ios/chrome/browser/snapshots", + "//ios/chrome/browser/ui/main:browser_interface_provider", + "//ios/chrome/browser/ui/main:observing_scene_agent", + "//ios/chrome/browser/web_state_list", + "//ios/chrome/browser/web_state_list/web_usage_enabler", + ] + configs += [ "//build/config/compiler:enable_arc" ] +} + source_set("test_support") { configs += [ "//build/config/compiler:enable_arc" ] testonly = true
diff --git a/ios/chrome/browser/sessions/README.md b/ios/chrome/browser/sessions/README.md new file mode 100644 index 0000000..ee5ebb68 --- /dev/null +++ b/ios/chrome/browser/sessions/README.md
@@ -0,0 +1,75 @@ +## Session saving and restoration. + +A *Session* is the data Chrome saves to an iOS device's storage that preserves +the state of open tabs in a given Browser. On a device that only supports a +single Chrome window, there will be one saved session for the regular tabs, +and one saved session for the Incognito tabs. On devices that support multiple +windows, there will be one or two (two if there are Incognito tabs) saved +sessions for each window. + +Sessions are the mechanism by which a user's open tabs are restored when they +laucnh Chrome. Given that iOS can terminate Chrome in the background at any +time -- and can disconnect individual scenes when there are multiple windows -- +it's critical that sessions are saved and restored in a way that is quick and +lossless for the user. + +(Don't confuse this Chrome-specific sense of *session* with the UIKit concept +of a *scene session*, implemented in the `UISceneSession` class. While both are +concerned with persisting application state data, they are not interchangeable, +and Chrome's sessions are not implemented using UISceneSessions for storage.) + +### Session saving + +The design intent is that sessions are saved before Chrome enters a state where +it might be suddenly terminated. + +Saving a session is done by means of the `SessionRestorationBrowserAgent` for +the browser being saved, using the `SaveSession()` method. Calling this saves +the session for the browser the agent is attached to. + +<!-- Add details on how sessions are saved; this depends on if the iOS15 APIs +for saving WKWebView interactionState are being used or not. Also describe +how per-window session saving is done. --> + +`SaveSession()` is called in the following circumstances: +1. Whenever a sene moves to the background, `SaveSession()` is called on its + browsers. +2. When the UI for a scene is destroyed (when the scene's `SceneController` is + shutting down), `SaveSession()` is called if it hasn't been called aready. +3. When a tab is inserted, removed, activated, replaced, re-ordered, or + completes a navigation, `SaveSession()` on the Browser that owns its + WebStateList. +4. When a prerendered tab is loaded, replacing an existing webState, + `SaveSession()` on the browser whose WebStateList contains the new tab. + +Case (1) is handled by `SessionSavingSceneAgent`, which watches for scene state +changes and tracks if the current scene has been foregrounded since the last +time it was saved. Such scenes are marked as needing to have their sessions +saved the next time they background. + +Case (2) is handled by `SceneController` itself when it shuts down; it in turn +asks its `SessionSavingSceneAgent` to save its sessions if needed. + +Case (3) is handled by `SessionRestorationBrowserAgent` via WebState and +WebStateList observation. + +Case (4) is handled by the `PrerenderService`; it directly calls +`SaveSession()`, regardless of whether the session is in the background. + +Cases (3) and (4) save after a short delay, and repeated session saves within +that delay are ignored. Cases (1) and (2) save immediately (canceling any +pending delayed saves). `SessionServiceIOS` handles this. + +### Session Restoration + +TODO: Describe when sessions are restored. + +### Session Recovery + +TODO: Describe the logic for post-crash session recovery and how sessions are +set aside and (possibly) discarded. + +### Incognito Sessions + +TODO: Describe how Incognito sessions are stored, and how it differs from how +regular session are.
diff --git a/ios/chrome/browser/sessions/session_saving_scene_agent.h b/ios/chrome/browser/sessions/session_saving_scene_agent.h new file mode 100644 index 0000000..6a7a49f1 --- /dev/null +++ b/ios/chrome/browser/sessions/session_saving_scene_agent.h
@@ -0,0 +1,20 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_SESSIONS_SESSION_SAVING_SCENE_AGENT_H_ +#define IOS_CHROME_BROWSER_SESSIONS_SESSION_SAVING_SCENE_AGENT_H_ + +#import <Foundation/Foundation.h> + +#import "ios/chrome/browser/ui/main/observing_scene_state_agent.h" + +@interface SessionSavingSceneAgent : ObservingSceneAgent + +// Saves the scene's sessions if they haven't been saved since the last time +// the scene was foregrounded. +- (void)saveSessionsIfNeeded; + +@end + +#endif // IOS_CHROME_BROWSER_SESSIONS_SESSION_SAVING_SCENE_AGENT_H_
diff --git a/ios/chrome/browser/sessions/session_saving_scene_agent.mm b/ios/chrome/browser/sessions/session_saving_scene_agent.mm new file mode 100644 index 0000000..9d7d8d6 --- /dev/null +++ b/ios/chrome/browser/sessions/session_saving_scene_agent.mm
@@ -0,0 +1,137 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "ios/chrome/browser/sessions/session_saving_scene_agent.h" + +#import "ios/chrome/browser/browser_state/chrome_browser_state.h" +#import "ios/chrome/browser/main/browser.h" +#import "ios/chrome/browser/sessions/session_restoration_browser_agent.h" +#import "ios/chrome/browser/snapshots/snapshot_tab_helper.h" +#import "ios/chrome/browser/ui/main/browser_interface_provider.h" +#import "ios/chrome/browser/web_state_list/web_state_list.h" +#import "ios/chrome/browser/web_state_list/web_usage_enabler/web_usage_enabler_browser_agent.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +@implementation SessionSavingSceneAgent { + // YES when sessions need saving -- specifically after the scene has + // foregrounded. Initially NO, so session saving isn't triggered as the + // scene initially launches. + BOOL _sessionsNeedSaving; +} + +#pragma mark - SceneStateObserver + +- (void)sceneState:(SceneState*)sceneState + transitionedToActivationLevel:(SceneActivationLevel)level { + switch (level) { + case SceneActivationLevelUnattached: + // no-op. + break; + case SceneActivationLevelBackground: + [self saveSessionsIfNeeded]; + break; + case SceneActivationLevelForegroundInactive: + [self prepareSessionsForBackgrounding]; + break; + case SceneActivationLevelForegroundActive: + _sessionsNeedSaving = YES; + break; + } +} + +#pragma mark - Public + +- (void)saveSessionsIfNeeded { + // No need to do this if the session is already saved. + if (!_sessionsNeedSaving) + return; + + id<BrowserInterfaceProvider> interfaceProvider = + self.sceneState.interfaceProvider; + if (!interfaceProvider) + return; + + // Since the app is about to be backgrounded or terminated, save the sessions + // immediately. + Browser* mainBrowser = interfaceProvider.mainInterface.browser; + SessionRestorationBrowserAgent::FromBrowser(mainBrowser) + ->SaveSession(/*immediately=*/true); + if (interfaceProvider.hasIncognitoInterface) { + Browser* incognitoBrowser = interfaceProvider.incognitoInterface.browser; + SessionRestorationBrowserAgent::FromBrowser(incognitoBrowser) + ->SaveSession(/*immediately=*/true); + } + + // Save a grey version of the active webstates. + SnapshotTabHelper* mainSnapshotHelper = + [self snapshotHelperForActiveWebStateInMainBrowser]; + if (mainSnapshotHelper) { + mainSnapshotHelper->SaveGreyInBackground(); + } + + SnapshotTabHelper* incognitoSnapshotHelper = + [self snapshotHelperForActiveWebStateInIncognitoBrowser]; + if (incognitoSnapshotHelper) { + incognitoSnapshotHelper->SaveGreyInBackground(); + } + + _sessionsNeedSaving = NO; +} + +#pragma mark - Private + +- (void)prepareSessionsForBackgrounding { + SnapshotTabHelper* mainSnapshotHelper = + [self snapshotHelperForActiveWebStateInMainBrowser]; + if (mainSnapshotHelper) { + mainSnapshotHelper->WillBeSavedGreyWhenBackgrounding(); + } + + SnapshotTabHelper* incognitoSnapshotHelper = + [self snapshotHelperForActiveWebStateInIncognitoBrowser]; + if (incognitoSnapshotHelper) { + incognitoSnapshotHelper->WillBeSavedGreyWhenBackgrounding(); + } +} + +#pragma mark - Utility + +- (SnapshotTabHelper*)snapshotHelperForActiveWebStateInMainBrowser { + id<BrowserInterfaceProvider> interfaceProvider = + self.sceneState.interfaceProvider; + if (!interfaceProvider) + return nullptr; + + return [self + snapshotHelperForActiveWebStateInBrowser:interfaceProvider.mainInterface + .browser]; +} + +- (SnapshotTabHelper*)snapshotHelperForActiveWebStateInIncognitoBrowser { + id<BrowserInterfaceProvider> interfaceProvider = + self.sceneState.interfaceProvider; + if (!interfaceProvider.hasIncognitoInterface) + return nullptr; + + return [self + snapshotHelperForActiveWebStateInBrowser:interfaceProvider + .incognitoInterface.browser]; +} + +- (SnapshotTabHelper*)snapshotHelperForActiveWebStateInBrowser: + (Browser*)browser { + WebUsageEnablerBrowserAgent* webEnabler = + WebUsageEnablerBrowserAgent::FromBrowser(browser); + web::WebState* webState = browser->GetWebStateList()->GetActiveWebState(); + if (webEnabler->IsWebUsageEnabled() && webState != nullptr) { + return SnapshotTabHelper::FromWebState(webState); + } + + return nullptr; +} + +@end
diff --git a/ios/chrome/browser/tabs/BUILD.gn b/ios/chrome/browser/tabs/BUILD.gn index 7e7821f..7f8361e 100644 --- a/ios/chrome/browser/tabs/BUILD.gn +++ b/ios/chrome/browser/tabs/BUILD.gn
@@ -9,7 +9,6 @@ "synced_window_delegate_browser_agent.h", "tab_helper_delegate_installer.h", "tab_helper_util.h", - "tab_model.h", "tab_parenting_browser_agent.h", "tab_parenting_browser_agent.mm", "tab_parenting_global_observer.cc", @@ -36,7 +35,6 @@ "ios_synced_window_delegate_getter.mm", "synced_window_delegate_browser_agent.mm", "tab_helper_util.mm", - "tab_model.mm", "tab_title_util.h", "tab_title_util.mm", ] @@ -109,6 +107,7 @@ "//ios/components/security_interstitials/legacy_tls", "//ios/components/security_interstitials/lookalikes", "//ios/public/provider/chrome/browser", + "//ios/public/provider/chrome/browser/text_zoom:text_zoom_api", "//ios/web/common:features", "//ios/web/public/security", "//ios/web/public/session", @@ -125,7 +124,6 @@ testonly = true sources = [ "tab_helper_delegate_installer_unittest.mm", - "tab_model_unittest.mm", "tab_title_util_unittest.mm", ] deps = [
diff --git a/ios/chrome/browser/tabs/tab_helper_util.mm b/ios/chrome/browser/tabs/tab_helper_util.mm index 704f807d..2f582e6 100644 --- a/ios/chrome/browser/tabs/tab_helper_util.mm +++ b/ios/chrome/browser/tabs/tab_helper_util.mm
@@ -67,8 +67,6 @@ #import "ios/chrome/browser/voice/voice_search_navigations_tab_helper.h" #import "ios/chrome/browser/web/blocked_popup_tab_helper.h" #include "ios/chrome/browser/web/error_page_controller_bridge.h" -#import "ios/chrome/browser/web/features.h" -#include "ios/chrome/browser/web/features.h" #import "ios/chrome/browser/web/font_size/font_size_tab_helper.h" #import "ios/chrome/browser/web/image_fetch/image_fetch_tab_helper.h" #import "ios/chrome/browser/web/invalid_url_tab_helper.h" @@ -85,6 +83,7 @@ #import "ios/components/security_interstitials/lookalikes/lookalike_url_tab_allow_list.h" #import "ios/components/security_interstitials/lookalikes/lookalike_url_tab_helper.h" #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" +#import "ios/public/provider/chrome/browser/text_zoom/text_zoom_api.h" #include "ios/web/common/features.h" #import "ios/web/public/web_state.h" @@ -129,7 +128,7 @@ TranslateOverlayTabHelper::CreateForWebState(web_state); } - if (base::FeatureList::IsEnabled(web::kWebPageTextAccessibility)) { + if (ios::provider::IsTextZoomEnabled()) { FontSizeTabHelper::CreateForWebState(web_state); }
diff --git a/ios/chrome/browser/tabs/tab_model.h b/ios/chrome/browser/tabs/tab_model.h deleted file mode 100644 index 7fa440b7..0000000 --- a/ios/chrome/browser/tabs/tab_model.h +++ /dev/null
@@ -1,31 +0,0 @@ -// Copyright 2012 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 IOS_CHROME_BROWSER_TABS_TAB_MODEL_H_ -#define IOS_CHROME_BROWSER_TABS_TAB_MODEL_H_ - -#import <Foundation/Foundation.h> -#import <UIKit/UIKit.h> - -class Browser; - -// A legacy class that encapsulates some lifecycle business logic for tabs in -// a WebStateList. This class is moribund (see crbug.com/783777). -@interface TabModel : NSObject -// Initializes a TabModel from a browser. -- (instancetype)initWithBrowser:(Browser*)browser; - -- (instancetype)init NS_UNAVAILABLE; - -// Tells the receiver to disconnect from the model object it depends on. This -// should be called before destroying the browser that the receiver was -// initialized with. -// It is safe to call this method multiple times. -// At this point the tab model will no longer ever be active, and will likely be -// deallocated soon. -- (void)disconnect; - -@end - -#endif // IOS_CHROME_BROWSER_TABS_TAB_MODEL_H_
diff --git a/ios/chrome/browser/tabs/tab_model.mm b/ios/chrome/browser/tabs/tab_model.mm deleted file mode 100644 index 2c9890e..0000000 --- a/ios/chrome/browser/tabs/tab_model.mm +++ /dev/null
@@ -1,157 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import "ios/chrome/browser/tabs/tab_model.h" - -#include "ios/chrome/browser/browser_state/chrome_browser_state.h" -#import "ios/chrome/browser/sessions/session_restoration_browser_agent.h" -#import "ios/chrome/browser/snapshots/snapshot_tab_helper.h" -#import "ios/chrome/browser/web_state_list/web_state_list.h" -#import "ios/chrome/browser/web_state_list/web_usage_enabler/web_usage_enabler_browser_agent.h" - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - - -@interface TabModel () { - // Weak reference to the underlying shared model implementation. - WebStateList* _webStateList; - - // Enabler for |_webStateList| - WebUsageEnablerBrowserAgent* _webEnabler; - - // Weak reference to the session restoration agent. - SessionRestorationBrowserAgent* _sessionRestorationBrowserAgent; - - ChromeBrowserState* _browserState; -} - -@end - -@implementation TabModel { - BOOL _savedSessionDuringBackgrounding; -} - -#pragma mark - Overriden - -- (void)dealloc { - // -disconnect should always have been called before destruction. - DCHECK(!_browserState); -} - -#pragma mark - Public methods - -- (instancetype)initWithBrowser:(Browser*)browser { - if ((self = [super init])) { - _webStateList = browser->GetWebStateList(); - _browserState = browser->GetBrowserState(); - DCHECK(_browserState); - - _sessionRestorationBrowserAgent = - SessionRestorationBrowserAgent::FromBrowser(browser); - _webEnabler = WebUsageEnablerBrowserAgent::FromBrowser(browser); - - _savedSessionDuringBackgrounding = NO; - - // Register for resign active notification. - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(applicationWillResignActive:) - name:UIApplicationWillResignActiveNotification - object:nil]; - // Register for background notification. - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(applicationDidEnterBackground:) - name:UIApplicationDidEnterBackgroundNotification - object:nil]; - // Register for foregrounding notification. - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(applicationWillEnterForeground:) - name:UIApplicationWillEnterForegroundNotification - object:nil]; - } - return self; -} - -// NOTE: This can be called multiple times, so must be robust against that. -- (void)disconnect { - if (!_browserState) - return; - - if (!_savedSessionDuringBackgrounding) { - [self saveSessionOnBackgroundingOrTermination]; - _savedSessionDuringBackgrounding = YES; - } - - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - _sessionRestorationBrowserAgent = nullptr; - _browserState = nullptr; - - // Close all tabs. Do this in an @autoreleasepool as WebStateList observers - // will be notified (they are unregistered later). As some of them may be - // implemented in Objective-C and unregister themselves in their -dealloc - // method, ensure they -autorelease introduced by ARC are processed before - // the WebStateList destructor is called. - @autoreleasepool { - _webStateList->CloseAllWebStates(WebStateList::CLOSE_NO_FLAGS); - } - - _webStateList = nullptr; -} - -#pragma mark - Notification Handlers - -// Called when UIApplicationWillResignActiveNotification is received. -// TODO(crbug.com/1115611): Move to SceneController. -- (void)applicationWillResignActive:(NSNotification*)notify { - if (_webEnabler->IsWebUsageEnabled() && _webStateList->GetActiveWebState()) { - SnapshotTabHelper::FromWebState(_webStateList->GetActiveWebState()) - ->WillBeSavedGreyWhenBackgrounding(); - } -} - -// Called when UIApplicationDidEnterBackgroundNotification is received. -// TODO(crbug.com/1115611): Move to SceneController. -- (void)applicationDidEnterBackground:(NSNotification*)notify { - // When using the Scene API (which requires iOS 13.0 or later and a recent - // enough device), UIApplicationDidEnterBackgroundNotification is not sent - // to the application if it is terminated by swipe gesture while it is in - // the foreground. The notification is send if Scene API is not used. In - // order to avoid saving twice the session on app termination, use a flag - // to record that the session was saved. - [self saveSessionOnBackgroundingOrTermination]; - _savedSessionDuringBackgrounding = YES; -} - -// Called when UIApplicationWillEnterForegroundNotification is received. -// TODO(crbug.com/1115611): Move to SceneController. -- (void)applicationWillEnterForeground:(NSNotification*)notify { - // Reset the boolean to allow saving the session state the next time the - // application is backgrounded or terminated. - _savedSessionDuringBackgrounding = NO; -} - -#pragma mark - Saving session on backgrounding or termination - -- (void)saveSessionOnBackgroundingOrTermination { - if (!_browserState) - return; - - // Normally, the session is saved after some timer expires but since the app - // is about to be backgrounded or terminated send true to save the session - // immediately. - _sessionRestorationBrowserAgent->SaveSession(/*immediately=*/true); - - // Write out a grey version of the current website to disk. - if (_webEnabler->IsWebUsageEnabled() && _webStateList->GetActiveWebState()) { - SnapshotTabHelper::FromWebState(_webStateList->GetActiveWebState()) - ->SaveGreyInBackground(); - } -} - -@end
diff --git a/ios/chrome/browser/tabs/tab_model_unittest.mm b/ios/chrome/browser/tabs/tab_model_unittest.mm deleted file mode 100644 index 867fb60b..0000000 --- a/ios/chrome/browser/tabs/tab_model_unittest.mm +++ /dev/null
@@ -1,136 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import "ios/chrome/browser/tabs/tab_model.h" - -#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" -#include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" -#import "ios/chrome/browser/main/browser_web_state_list_delegate.h" -#import "ios/chrome/browser/main/test_browser.h" -#include "ios/chrome/browser/sessions/session_restoration_browser_agent.h" -#import "ios/chrome/browser/sessions/session_window_ios.h" -#import "ios/chrome/browser/sessions/test_session_service.h" -#import "ios/chrome/browser/web_state_list/tab_insertion_browser_agent.h" -#import "ios/chrome/browser/web_state_list/web_state_list.h" -#import "ios/chrome/browser/web_state_list/web_usage_enabler/web_usage_enabler_browser_agent.h" -#include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.h" -#include "ios/web/public/test/web_task_environment.h" -#include "ios/web/public/thread/web_thread.h" -#include "testing/platform_test.h" - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -namespace { - -const char kURL1[] = "https://www.some.url.com"; - -class TabModelTest : public PlatformTest { - public: - TabModelTest() - : scoped_browser_state_manager_( - std::make_unique<TestChromeBrowserStateManager>(base::FilePath())), - web_state_list_delegate_( - std::make_unique<BrowserWebStateListDelegate>()), - web_state_list_( - std::make_unique<WebStateList>(web_state_list_delegate_.get())) { - DCHECK_CURRENTLY_ON(web::WebThread::UI); - - TestChromeBrowserState::Builder test_cbs_builder; - chrome_browser_state_ = test_cbs_builder.Build(); - - browser_ = std::make_unique<TestBrowser>(chrome_browser_state_.get(), - web_state_list_.get()); - // Web usage is disabled during these tests. - WebUsageEnablerBrowserAgent::CreateForBrowser(browser_.get()); - web_usage_enabler_ = - WebUsageEnablerBrowserAgent::FromBrowser(browser_.get()); - web_usage_enabler_->SetWebUsageEnabled(false); - - session_window_ = [[SessionWindowIOS alloc] init]; - - TabInsertionBrowserAgent::CreateForBrowser(browser_.get()); - - agent_ = TabInsertionBrowserAgent::FromBrowser(browser_.get()); - session_service_ = [[TestSessionService alloc] init]; - // Create session restoration agent with just a dummy session - // service so the async state saving doesn't trigger unless actually - // wanted. - SessionRestorationBrowserAgent::CreateForBrowser(browser_.get(), - session_service_); - SessionRestorationBrowserAgent::FromBrowser(browser_.get()) - ->SetSessionID([[NSUUID UUID] UUIDString]); - SetTabModel(CreateTabModel(nil)); - } - - ~TabModelTest() override = default; - - void TearDown() override { - SetTabModel(nil); - PlatformTest::TearDown(); - } - - void SetTabModel(TabModel* tab_model) { - if (tab_model_) { - @autoreleasepool { - [tab_model_ disconnect]; - tab_model_ = nil; - } - } - - tab_model_ = tab_model; - } - - TabModel* CreateTabModel(SessionWindowIOS* session_window) { - TabModel* tab_model([[TabModel alloc] initWithBrowser:browser_.get()]); - return tab_model; - } - - const web::NavigationManager::WebLoadParams Params(GURL url) { - return Params(url, ui::PAGE_TRANSITION_TYPED); - } - - const web::NavigationManager::WebLoadParams Params( - GURL url, - ui::PageTransition transition) { - web::NavigationManager::WebLoadParams loadParams(url); - loadParams.referrer = web::Referrer(); - loadParams.transition_type = transition; - return loadParams; - } - - protected: - web::WebTaskEnvironment task_environment_; - IOSChromeScopedTestingChromeBrowserStateManager scoped_browser_state_manager_; - std::unique_ptr<WebStateListDelegate> web_state_list_delegate_; - std::unique_ptr<WebStateList> web_state_list_; - std::unique_ptr<Browser> browser_; - SessionWindowIOS* session_window_; - std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; - TabInsertionBrowserAgent* agent_; - TestSessionService* session_service_; - WebUsageEnablerBrowserAgent* web_usage_enabler_; - TabModel* tab_model_; -}; - -TEST_F(TabModelTest, InsertWithSessionController) { - EXPECT_EQ(web_state_list_->count(), 0); - - web::WebState* new_web_state = - agent_->InsertWebState(Params(GURL(kURL1)), - /*parent=*/nil, - /*opened_by_dom=*/false, - /*index=*/web_state_list_->count(), - /*in_background=*/false, - /*inherit_opener=*/false); - - EXPECT_EQ(web_state_list_->count(), 1); - EXPECT_EQ(new_web_state, web_state_list_->GetWebStateAt(0)); - web_state_list_->ActivateWebStateAt(0); - web::WebState* current_web_state = web_state_list_->GetActiveWebState(); - EXPECT_TRUE(current_web_state); -} - -} // anonymous namespace
diff --git a/ios/chrome/browser/ui/authentication/signin/consistency_promo_signin/consistency_promo_signin_coordinator.mm b/ios/chrome/browser/ui/authentication/signin/consistency_promo_signin/consistency_promo_signin_coordinator.mm index cd077fa5..a1a1f24 100644 --- a/ios/chrome/browser/ui/authentication/signin/consistency_promo_signin/consistency_promo_signin_coordinator.mm +++ b/ios/chrome/browser/ui/authentication/signin/consistency_promo_signin/consistency_promo_signin_coordinator.mm
@@ -372,6 +372,10 @@ - (void)signinWithIdentity:(ChromeIdentity*)identity { DCHECK([self.selectedIdentity isEqual:identity]); + // Reset dismissal count if the user wants to sign-in. + ChromeBrowserState* browserState = self.browser->GetBrowserState(); + PrefService* userPrefService = browserState->GetPrefs(); + userPrefService->SetInteger(prefs::kSigninWebSignDismissalCount, 0); [self.defaultAccountCoordinator startSigninSpinner]; self.authenticationService->SignIn(self.selectedIdentity); DCHECK(self.authenticationService->HasPrimaryIdentity(
diff --git a/ios/chrome/browser/ui/browser_view/BUILD.gn b/ios/chrome/browser/ui/browser_view/BUILD.gn index 7983d22..5d20329a 100644 --- a/ios/chrome/browser/ui/browser_view/BUILD.gn +++ b/ios/chrome/browser/ui/browser_view/BUILD.gn
@@ -194,6 +194,7 @@ "//ios/components/webui:url_constants", "//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser/signin", + "//ios/public/provider/chrome/browser/text_zoom:text_zoom_api", "//ios/public/provider/chrome/browser/ui", "//ios/public/provider/chrome/browser/voice", "//ios/third_party/material_components_ios",
diff --git a/ios/chrome/browser/ui/browser_view/browser_coordinator.mm b/ios/chrome/browser/ui/browser_view/browser_coordinator.mm index d7a1097f..4371803f 100644 --- a/ios/chrome/browser/ui/browser_view/browser_coordinator.mm +++ b/ios/chrome/browser/ui/browser_view/browser_coordinator.mm
@@ -81,7 +81,6 @@ #include "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/url_loading/url_loading_browser_agent.h" #import "ios/chrome/browser/url_loading/url_loading_params.h" -#import "ios/chrome/browser/web/features.h" #import "ios/chrome/browser/web/font_size/font_size_tab_helper.h" #import "ios/chrome/browser/web/print/print_tab_helper.h" #import "ios/chrome/browser/web/repost_form_tab_helper.h" @@ -89,6 +88,7 @@ #import "ios/chrome/browser/web/web_navigation_browser_agent.h" #include "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h" +#import "ios/public/provider/chrome/browser/text_zoom/text_zoom_api.h" #include "ui/base/l10n/l10n_util_mac.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -876,7 +876,7 @@ } - (void)closeTextZoom { - if (!base::FeatureList::IsEnabled(web::kWebPageTextAccessibility)) { + if (!ios::provider::IsTextZoomEnabled()) { return; }
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_mediator.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_mediator.mm index 36c7c40..0775550 100644 --- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_mediator.mm +++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_mediator.mm
@@ -52,7 +52,6 @@ #import "ios/chrome/browser/web_state_list/web_state_list.h" #include "ios/chrome/common/app_group/app_group_constants.h" #include "ios/chrome/grit/ios_strings.h" -#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" #import "ios/public/provider/chrome/browser/discover_feed/discover_feed_observer_bridge.h" #include "ios/public/provider/chrome/browser/images/branded_image_provider.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -409,9 +408,7 @@ if (_notificationPromo->CanShow()) { ContentSuggestionsWhatsNewItem* item = [[ContentSuggestionsWhatsNewItem alloc] initWithType:0]; - item.icon = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetWhatsNewIconImage(_notificationPromo->icon()); + item.icon = _notificationPromo->GetIcon(); item.text = base::SysUTF8ToNSString(_notificationPromo->promo_text()); [convertedSuggestions addObject:item]; }
diff --git a/ios/chrome/browser/ui/default_promo/BUILD.gn b/ios/chrome/browser/ui/default_promo/BUILD.gn index 1d0e29ef..0e15944 100644 --- a/ios/chrome/browser/ui/default_promo/BUILD.gn +++ b/ios/chrome/browser/ui/default_promo/BUILD.gn
@@ -55,8 +55,7 @@ "//ios/chrome/browser/web_state_list", "//ios/chrome/common/ui/confirmation_alert", "//ios/chrome/common/ui/elements:popover_label_view_controller", - "//ios/public/provider/chrome/browser", - "//ios/public/provider/chrome/browser/images", + "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ios/web/public", "//ui/base", ] @@ -80,8 +79,7 @@ "//ios/chrome/browser/ui/infobars/coordinators", "//ios/chrome/browser/ui/main:default_browser_scene_agent", "//ios/chrome/browser/ui/main:scene_state_header", - "//ios/public/provider/chrome/browser", - "//ios/public/provider/chrome/browser/images", + "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ui/base", ] }
diff --git a/ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_coordinator.mm b/ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_coordinator.mm index f9217e6c..2a5c76f 100644 --- a/ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_coordinator.mm +++ b/ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_coordinator.mm
@@ -4,6 +4,7 @@ #import "ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_coordinator.h" +#include "base/notreached.h" #import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_commands.h" @@ -15,8 +16,7 @@ #import "ios/chrome/browser/ui/main/scene_state_browser_agent.h" #include "ios/chrome/grit/ios_google_chrome_strings.h" #include "ios/chrome/grit/ios_strings.h" -#import "ios/public/provider/chrome/browser/chrome_browser_provider.h" -#import "ios/public/provider/chrome/browser/images/branded_image_provider.h" +#import "ios/public/provider/chrome/browser/branded_images/branded_images_api.h" #include "ui/base/l10n/l10n_util_mac.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -65,9 +65,8 @@ [self.bannerViewController setButtonText:l10n_util::GetNSString( IDS_IOS_DEFAULT_NON_MODAL_PRIMARY_BUTTON_TEXT)]; - UIImage* image = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetNonModalPromoImage(); + UIImage* image = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kNonModalDefaultBrowserPromo); [self.bannerViewController setIconImage:image]; [self.bannerViewController setUseIconBackgroundTint:NO]; [self.bannerViewController setPresentsModal:NO];
diff --git a/ios/chrome/browser/ui/default_promo/tailored_promo_util.mm b/ios/chrome/browser/ui/default_promo/tailored_promo_util.mm index 1565bf1..0f9ac63 100644 --- a/ios/chrome/browser/ui/default_promo/tailored_promo_util.mm +++ b/ios/chrome/browser/ui/default_promo/tailored_promo_util.mm
@@ -7,8 +7,7 @@ #include "base/notreached.h" #include "ios/chrome/grit/ios_google_chrome_strings.h" #include "ios/chrome/grit/ios_strings.h" -#import "ios/public/provider/chrome/browser/chrome_browser_provider.h" -#import "ios/public/provider/chrome/browser/images/branded_image_provider.h" +#import "ios/public/provider/chrome/browser/branded_images/branded_images_api.h" #include "ui/base/device_form_factor.h" #include "ui/base/l10n/l10n_util_mac.h" @@ -38,23 +37,20 @@ title = GetNSString(IDS_IOS_DEFAULT_BROWSER_TAILORED_STAY_SAFE_TITLE); subtitle = GetNSString(IDS_IOS_DEFAULT_BROWSER_TAILORED_STAY_SAFE_DESCRIPTION); - image = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetStaySafePromoImage(); + image = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kStaySafePromo); break; case DefaultPromoTypeMadeForIOS: if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET) { title = GetNSString( IDS_IOS_DEFAULT_BROWSER_TAILORED_BUILT_FOR_IPADOS_TITLE); - image = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetMadeForIPadOSPromoImage(); + image = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kMadeForIPadOSPromo); } else { title = GetNSString(IDS_IOS_DEFAULT_BROWSER_TAILORED_BUILT_FOR_IOS_TITLE); - image = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetMadeForIOSPromoImage(); + image = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kMadeForIOSPromo); } subtitle = GetNSString( IDS_IOS_DEFAULT_BROWSER_TAILORED_BUILT_FOR_IOS_DESCRIPTION);
diff --git a/ios/chrome/browser/ui/download/BUILD.gn b/ios/chrome/browser/ui/download/BUILD.gn index 571624e..2610486 100644 --- a/ios/chrome/browser/ui/download/BUILD.gn +++ b/ios/chrome/browser/ui/download/BUILD.gn
@@ -55,8 +55,7 @@ "//ios/chrome/browser/web_state_list:web_state_list", "//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/util", - "//ios/public/provider/chrome/browser", - "//ios/public/provider/chrome/browser/images", + "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ios/third_party/material_components_ios", "//ios/web", "//ios/web:core",
diff --git a/ios/chrome/browser/ui/download/download_manager_view_controller.mm b/ios/chrome/browser/ui/download/download_manager_view_controller.mm index 016a231d..88712c0 100644 --- a/ios/chrome/browser/ui/download/download_manager_view_controller.mm +++ b/ios/chrome/browser/ui/download/download_manager_view_controller.mm
@@ -18,8 +18,7 @@ #import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/util/constraints_ui_util.h" #include "ios/chrome/grit/ios_strings.h" -#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" -#import "ios/public/provider/chrome/browser/images/branded_image_provider.h" +#import "ios/public/provider/chrome/browser/branded_images/branded_images_api.h" #include "ui/base/l10n/l10n_util_mac.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -505,9 +504,8 @@ if (!_installDriveIcon) { _installDriveIcon = [[UIImageView alloc] initWithFrame:CGRectZero]; _installDriveIcon.translatesAutoresizingMaskIntoConstraints = NO; - _installDriveIcon.image = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetDownloadGoogleDriveImage(); + _installDriveIcon.image = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kDownloadGoogleDrive); } return _installDriveIcon; }
diff --git a/ios/chrome/browser/ui/main/BUILD.gn b/ios/chrome/browser/ui/main/BUILD.gn index 6853f581..09649c6 100644 --- a/ios/chrome/browser/ui/main/BUILD.gn +++ b/ios/chrome/browser/ui/main/BUILD.gn
@@ -151,6 +151,7 @@ "//ios/chrome/browser/policy:policy_util", "//ios/chrome/browser/screenshot", "//ios/chrome/browser/sessions:scene_util", + "//ios/chrome/browser/sessions:session_saving", "//ios/chrome/browser/signin", "//ios/chrome/browser/snapshots", "//ios/chrome/browser/ui:feature_flags",
diff --git a/ios/chrome/browser/ui/main/browser_view_wrangler.mm b/ios/chrome/browser/ui/main/browser_view_wrangler.mm index 393a8e65..e7a60e61 100644 --- a/ios/chrome/browser/ui/main/browser_view_wrangler.mm +++ b/ios/chrome/browser/ui/main/browser_view_wrangler.mm
@@ -19,7 +19,6 @@ #import "ios/chrome/browser/sessions/scene_util.h" #import "ios/chrome/browser/sessions/session_restoration_browser_agent.h" #import "ios/chrome/browser/snapshots/snapshot_browser_agent.h" -#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/ui/browser_view/browser_coordinator.h" #import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" #import "ios/chrome/browser/ui/browser_view/browser_view_controller_dependency_factory.h" @@ -240,7 +239,14 @@ WebStateList* webStateList = self.mainBrowser->GetWebStateList(); breakpad::StopMonitoringTabStateForWebStateList(webStateList); breakpad::StopMonitoringURLsForWebStateList(webStateList); - [self.mainBrowser->GetTabModel() disconnect]; + // Close all webstates in |webStateList|. Do this in an @autoreleasepool as + // WebStateList observers will be notified (they are unregistered later). As + // some of them may be implemented in Objective-C and unregister themselves + // in their -dealloc method, ensure they -autorelease introduced by ARC are + // processed before the WebStateList destructor is called. + @autoreleasepool { + webStateList->CloseAllWebStates(WebStateList::CLOSE_NO_FLAGS); + } } _mainBrowser = nullptr; @@ -250,7 +256,14 @@ if (_otrBrowser.get()) { WebStateList* webStateList = self.otrBrowser->GetWebStateList(); breakpad::StopMonitoringTabStateForWebStateList(webStateList); - [self.otrBrowser->GetTabModel() disconnect]; + // Close all webstates in |webStateList|. Do this in an @autoreleasepool as + // WebStateList observers will be notified (they are unregistered later). As + // some of them may be implemented in Objective-C and unregister themselves + // in their -dealloc method, ensure they -autorelease introduced by ARC are + // processed before the WebStateList destructor is called. + @autoreleasepool { + webStateList->CloseAllWebStates(WebStateList::CLOSE_NO_FLAGS); + } } _otrBrowser = std::move(otrBrowser);
diff --git a/ios/chrome/browser/ui/main/browser_view_wrangler_unittest.mm b/ios/chrome/browser/ui/main/browser_view_wrangler_unittest.mm index 18acc17..d2dbbf2 100644 --- a/ios/chrome/browser/ui/main/browser_view_wrangler_unittest.mm +++ b/ios/chrome/browser/ui/main/browser_view_wrangler_unittest.mm
@@ -19,7 +19,6 @@ #include "ios/chrome/browser/sessions/session_restoration_browser_agent.h" #import "ios/chrome/browser/sessions/test_session_service.h" #import "ios/chrome/browser/sync/send_tab_to_self_sync_service_factory.h" -#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" #import "ios/chrome/browser/ui/main/scene_state.h" #import "ios/chrome/browser/ui/main/scene_state_browser_agent.h"
diff --git a/ios/chrome/browser/ui/main/scene_controller.mm b/ios/chrome/browser/ui/main/scene_controller.mm index 7f9cf25..aae2bbc 100644 --- a/ios/chrome/browser/ui/main/scene_controller.mm +++ b/ios/chrome/browser/ui/main/scene_controller.mm
@@ -66,6 +66,7 @@ #include "ios/chrome/browser/policy/policy_watcher_browser_agent.h" #import "ios/chrome/browser/policy/policy_watcher_browser_agent_observer_bridge.h" #include "ios/chrome/browser/screenshot/screenshot_delegate.h" +#import "ios/chrome/browser/sessions/session_saving_scene_agent.h" #import "ios/chrome/browser/signin/authentication_service.h" #import "ios/chrome/browser/signin/authentication_service_factory.h" #import "ios/chrome/browser/signin/chrome_account_manager_service.h" @@ -299,6 +300,7 @@ [_sceneState addAgent:[[StartSurfaceSceneAgent alloc] init]]; [_sceneState addAgent:[[ReadingListBackgroundSessionSceneAgent alloc] init]]; + [_sceneState addAgent:[[SessionSavingSceneAgent alloc] init]]; } return self; } @@ -1135,6 +1137,8 @@ // agent). self.sceneState.UIEnabled = NO; + [[SessionSavingSceneAgent agentFromScene:self.sceneState] + saveSessionsIfNeeded]; [self.browserViewWrangler shutdown]; self.browserViewWrangler = nil;
diff --git a/ios/chrome/browser/ui/menu/resources/select.imageset/Contents.json b/ios/chrome/browser/ui/menu/resources/select.imageset/Contents.json index 82359c6..03b5d6c 100644 --- a/ios/chrome/browser/ui/menu/resources/select.imageset/Contents.json +++ b/ios/chrome/browser/ui/menu/resources/select.imageset/Contents.json
@@ -14,5 +14,8 @@ "info": { "version": 1, "author": "xcode" + }, + "properties": { + "template-rendering-intent": "template" } }
diff --git a/ios/chrome/browser/ui/ntp/BUILD.gn b/ios/chrome/browser/ui/ntp/BUILD.gn index 6d6cebf..63af1a5 100644 --- a/ios/chrome/browser/ui/ntp/BUILD.gn +++ b/ios/chrome/browser/ui/ntp/BUILD.gn
@@ -131,6 +131,7 @@ "//components/prefs", "//components/strings", "//ios/chrome/app/strings", + "//ios/chrome/app/theme", "//ios/chrome/browser", "//ios/chrome/browser/browser_state", "//ios/chrome/browser/drag_and_drop", @@ -165,7 +166,7 @@ "//ios/chrome/common/ui/favicon", "//ios/chrome/common/ui/util", "//ios/public/provider/chrome/browser", - "//ios/public/provider/chrome/browser/images", + "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ios/public/provider/chrome/browser/ui", "//ios/public/provider/chrome/browser/voice", "//ios/third_party/material_components_ios",
diff --git a/ios/chrome/browser/ui/ntp/notification_promo_whats_new.h b/ios/chrome/browser/ui/ntp/notification_promo_whats_new.h index 85ebbb1..be57d7f 100644 --- a/ios/chrome/browser/ui/ntp/notification_promo_whats_new.h +++ b/ios/chrome/browser/ui/ntp/notification_promo_whats_new.h
@@ -8,9 +8,10 @@ #include <string> #include <vector> +#import <UIKit/UIKit.h> + #include "base/macros.h" #include "ios/chrome/browser/notification_promo.h" -#include "ios/public/provider/chrome/browser/images/branded_image_icon_types.h" #include "url/gurl.h" namespace base { @@ -27,6 +28,12 @@ // Helper class for NotificationPromo that deals with mobile_ntp promos. class NotificationPromoWhatsNew { public: + enum IconType { + kIconTypeInfo, + kIconTypeLogo, + kIconTypeLogoRoundedRectangle, + }; + explicit NotificationPromoWhatsNew(PrefService* local_state); ~NotificationPromoWhatsNew(); @@ -49,7 +56,8 @@ bool valid() const { return valid_; } const std::string& promo_type() { return promo_type_; } const std::string& promo_text() { return promo_text_; } - WhatsNewIcon icon() { return icon_; } + UIImage* GetIcon() const; + IconType icon_type() const { return icon_type_; } bool IsURLPromo() const; const GURL& url() { return url_; } bool IsChromeCommandPromo() const; @@ -73,10 +81,10 @@ const std::string& icon); // Prefs service for promos. - PrefService* local_state_; + PrefService* local_state_ = nullptr; // True if InitFromPrefs/JSON was called and all mandatory fields were found. - bool valid_; + bool valid_ = false; // Text of promo. std::string promo_text_; @@ -85,15 +93,15 @@ std::string promo_type_; // Icon of promo. - WhatsNewIcon icon_; + IconType icon_type_ = kIconTypeInfo; // The minimum number of seconds from installation before promo can be valid. // E.g. Don't show the promo if installation was within N days. - int seconds_since_install_; + int seconds_since_install_ = 0; // The duration after installation that the promo can be valid. // E.g. Don't show the promo if installation was more than N days ago. - int max_seconds_since_install_; + int max_seconds_since_install_ = 0; // If promo type is 'url'. GURL url_; @@ -107,9 +115,6 @@ // The lower-level notification promo. ios::NotificationPromo notification_promo_; - // Convert an icon name string to WhatsNewIcon. - WhatsNewIcon ParseIconName(const std::string& icon_name); - DISALLOW_COPY_AND_ASSIGN(NotificationPromoWhatsNew); };
diff --git a/ios/chrome/browser/ui/ntp/notification_promo_whats_new.mm b/ios/chrome/browser/ui/ntp/notification_promo_whats_new.mm index 830651f..b1dd9a4f 100644 --- a/ios/chrome/browser/ui/ntp/notification_promo_whats_new.mm +++ b/ios/chrome/browser/ui/ntp/notification_promo_whats_new.mm
@@ -9,12 +9,14 @@ #include <memory> #include <vector> +#include "base/check.h" #include "base/cxx17_backports.h" #include "base/ios/ios_util.h" #include "base/json/json_reader.h" #include "base/metrics/field_trial.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" +#include "base/notreached.h" #include "base/strings/string_util.h" #include "base/time/time.h" #include "base/values.h" @@ -25,7 +27,10 @@ #include "ios/chrome/browser/system_flags.h" #include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_strings.h" +#include "ios/chrome/grit/ios_theme_resources.h" +#import "ios/public/provider/chrome/browser/branded_images/branded_images_api.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -62,6 +67,43 @@ return std::string(); } +// Convert an icon name string to an IconType. +NotificationPromoWhatsNew::IconType IconNameToIconType( + const std::string& icon_name) { + if (icon_name == "logo") { + return NotificationPromoWhatsNew::kIconTypeLogo; + } + + if (icon_name == "logoWithRoundedRectangle") { + return NotificationPromoWhatsNew::kIconTypeLogoRoundedRectangle; + } + + return NotificationPromoWhatsNew::kIconTypeInfo; +} + +// Convert an icon type to an UIImage*. +UIImage* IconTypeToUIImage(NotificationPromoWhatsNew::IconType icon_type) { + switch (icon_type) { + case NotificationPromoWhatsNew::kIconTypeInfo: { + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + return rb.GetNativeImageNamed(IDR_IOS_PROMO_INFO).ToUIImage(); + } + + case NotificationPromoWhatsNew::kIconTypeLogo: { + return ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kWhatsNewLogo); + } + + case NotificationPromoWhatsNew::kIconTypeLogoRoundedRectangle: { + return ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kWhatsNewLogoRoundedRectangle); + } + } + + NOTREACHED(); + return nil; +} + } // namespace // The What's New promo command for testing. @@ -72,9 +114,9 @@ const char kSetDefaultBrowserCommand[] = "openSettings"; NotificationPromoWhatsNew::NotificationPromoWhatsNew(PrefService* local_state) - : local_state_(local_state), - valid_(false), - notification_promo_(local_state_) {} + : local_state_(local_state), notification_promo_(local_state_) { + DCHECK(local_state_); +} NotificationPromoWhatsNew::~NotificationPromoWhatsNew() {} @@ -185,6 +227,10 @@ notification_promo_.HandleClosed(); } +UIImage* NotificationPromoWhatsNew::GetIcon() const { + return IconTypeToUIImage(icon_type_); +} + bool NotificationPromoWhatsNew::IsURLPromo() const { return promo_type_ == "url"; } @@ -193,16 +239,6 @@ return promo_type_ == "chrome_command"; } -WhatsNewIcon NotificationPromoWhatsNew::ParseIconName( - const std::string& icon_name) { - if (icon_name == "logo") { - return WHATS_NEW_LOGO; - } else if (icon_name == "logoWithRoundedRectangle") { - return WHATS_NEW_LOGO_ROUNDED_RECTANGLE; - } - return WHATS_NEW_INFO; -} - bool NotificationPromoWhatsNew::InitFromNotificationPromo() { valid_ = false; @@ -250,7 +286,7 @@ // Optional values don't need validation. const std::string* icon_name = notification_promo_.promo_payload().FindStringKey("icon"); - icon_ = ParseIconName(icon_name ? *icon_name : std::string()); + icon_type_ = IconNameToIconType(icon_name ? *icon_name : std::string()); seconds_since_install_ = notification_promo_.promo_payload() .FindIntKey("seconds_since_install")
diff --git a/ios/chrome/browser/ui/ntp/notification_promo_whats_new_unittest.mm b/ios/chrome/browser/ui/ntp/notification_promo_whats_new_unittest.mm index 379f977..7fee66d 100644 --- a/ios/chrome/browser/ui/ntp/notification_promo_whats_new_unittest.mm +++ b/ios/chrome/browser/ui/ntp/notification_promo_whats_new_unittest.mm
@@ -17,7 +17,6 @@ #include "components/variations/variations_associated_data.h" #include "ios/chrome/browser/notification_promo.h" #include "ios/chrome/grit/ios_chromium_strings.h" -#include "ios/public/provider/chrome/browser/images/branded_image_icon_types.h" #include "testing/platform_test.h" #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" @@ -93,7 +92,7 @@ const std::string& promo_type, const std::string& url, const std::string& command, - WhatsNewIcon icon, + NotificationPromoWhatsNew::IconType icon_type, bool valid) { EXPECT_EQ(promo_text, promo_.promo_text()); EXPECT_EQ(promo_type, promo_.promo_type()); @@ -103,9 +102,9 @@ EXPECT_EQ(command, promo_.command()); EXPECT_EQ(valid, promo_.CanShow()); - // |icon()| is set only if the promo is valid. + // |icon_type()| is set only if the promo is valid. if (valid) - EXPECT_EQ(icon, promo_.icon()); + EXPECT_EQ(icon_type, promo_.icon_type()); } void OnUserAction(const std::string& user_action, @@ -130,7 +129,8 @@ "testWhatsNewCommand", "0", "chrome_command", "", kTestWhatsNewCommand, "TestWhatsNewMetric", "logo", "0", "0"); RunTests(std::string(kTestWhatsNewMessage), "chrome_command", "", - kTestWhatsNewCommand, WHATS_NEW_LOGO, true); + kTestWhatsNewCommand, NotificationPromoWhatsNew::kIconTypeLogo, + true); } // Test that a url-based, valid promo is shown with the correct text and icon. @@ -138,7 +138,8 @@ Init("3 Aug 1999 9:26:06 GMT", "3 Aug 2199 9:26:06 GMT", "moveToDockTip", "0", "url", "http://blog.chromium.org", "", "TestURLPromo", "", "0", "0"); RunTests(l10n_util::GetStringUTF8(IDS_IOS_MOVE_TO_DOCK_TIP), "url", - "http://blog.chromium.org/", "", WHATS_NEW_INFO, true); + "http://blog.chromium.org/", "", + NotificationPromoWhatsNew::kIconTypeInfo, true); } // Test that a promo without a valid promo type is not shown.
diff --git a/ios/chrome/browser/ui/omnibox/BUILD.gn b/ios/chrome/browser/ui/omnibox/BUILD.gn index 0d62e6a..ede0009 100644 --- a/ios/chrome/browser/ui/omnibox/BUILD.gn +++ b/ios/chrome/browser/ui/omnibox/BUILD.gn
@@ -167,7 +167,7 @@ "//ios/chrome/common/ui/util", "//ios/chrome/common/ui/util:dynamic_type_util", "//ios/public/provider/chrome/browser", - "//ios/public/provider/chrome/browser/images", + "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ios/web", "//net", "//skia",
diff --git a/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm b/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm index b4da48c5..3ba087f 100644 --- a/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm +++ b/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm
@@ -14,8 +14,7 @@ #include "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/common/ui/favicon/favicon_attributes.h" -#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" -#include "ios/public/provider/chrome/browser/images/branded_image_provider.h" +#import "ios/public/provider/chrome/browser/branded_images/branded_images_api.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -189,9 +188,8 @@ if (defaultProvider && defaultProvider->GetEngineType( self.templateURLService->search_terms_data()) == SEARCH_ENGINE_GOOGLE) { - UIImage* bundledLogo = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetOmniboxAnswerIcon(); + UIImage* bundledLogo = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kOmniboxAnswer); if (bundledLogo) { self.currentDefaultSearchEngineFavicon = bundledLogo;
diff --git a/ios/chrome/browser/ui/omnibox/popup/BUILD.gn b/ios/chrome/browser/ui/omnibox/popup/BUILD.gn index af3ff979..8f0e1484 100644 --- a/ios/chrome/browser/ui/omnibox/popup/BUILD.gn +++ b/ios/chrome/browser/ui/omnibox/popup/BUILD.gn
@@ -102,7 +102,7 @@ "//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/util", "//ios/public/provider/chrome/browser", - "//ios/public/provider/chrome/browser/images", + "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ui/base", "//url", ]
diff --git a/ios/chrome/browser/ui/omnibox/popup/simple_omnibox_icon.mm b/ios/chrome/browser/ui/omnibox/popup/simple_omnibox_icon.mm index fff3483d..4c7d52d 100644 --- a/ios/chrome/browser/ui/omnibox/popup/simple_omnibox_icon.mm +++ b/ios/chrome/browser/ui/omnibox/popup/simple_omnibox_icon.mm
@@ -8,8 +8,7 @@ #import "ios/chrome/browser/ui/omnibox/omnibox_suggestion_icon_util.h" #import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" -#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" -#include "ios/public/provider/chrome/browser/images/branded_image_provider.h" +#import "ios/public/provider/chrome/browser/branded_images/branded_images_api.h" #import "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -89,9 +88,8 @@ } - (UIImage*)fallbackAnswerBrandedIcon { - return ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetOmniboxAnswerIcon(); + return ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kOmniboxAnswer); } - (UIColor*)iconImageTintColor {
diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm index 73f5ece..29655c7b 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm
@@ -53,7 +53,6 @@ #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h" #import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" -#import "ios/chrome/browser/web/features.h" #import "ios/chrome/browser/web/font_size/font_size_tab_helper.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h"
diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_mediator_unittest.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_mediator_unittest.mm index 72a1538..4b8ac55 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_mediator_unittest.mm +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_mediator_unittest.mm
@@ -38,7 +38,6 @@ #include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/web/chrome_web_client.h" #import "ios/chrome/browser/web/chrome_web_test.h" -#include "ios/chrome/browser/web/features.h" #import "ios/chrome/browser/web/font_size/font_size_tab_helper.h" #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" #include "ios/chrome/browser/web_state_list/web_state_list.h"
diff --git a/ios/chrome/browser/ui/recent_tabs/synced_sessions_bridge.mm b/ios/chrome/browser/ui/recent_tabs/synced_sessions_bridge.mm index 5539fbc..ba9f01df 100644 --- a/ios/chrome/browser/ui/recent_tabs/synced_sessions_bridge.mm +++ b/ios/chrome/browser/ui/recent_tabs/synced_sessions_bridge.mm
@@ -43,11 +43,12 @@ void SyncedSessionsObserverBridge::OnPrimaryAccountChanged( const signin::PrimaryAccountChangeEvent& event) { switch (event.GetEventTypeFor(signin::ConsentLevel::kSync)) { - case signin::PrimaryAccountChangeEvent::Type::kSet: case signin::PrimaryAccountChangeEvent::Type::kNone: // Ignored. break; + case signin::PrimaryAccountChangeEvent::Type::kSet: case signin::PrimaryAccountChangeEvent::Type::kCleared: + // Update the session Sync state if consent is given or removed. [owner_ reloadSessions]; break; }
diff --git a/ios/chrome/browser/ui/settings/clear_browsing_data/BUILD.gn b/ios/chrome/browser/ui/settings/clear_browsing_data/BUILD.gn index 9a701d2..2ae2e84 100644 --- a/ios/chrome/browser/ui/settings/clear_browsing_data/BUILD.gn +++ b/ios/chrome/browser/ui/settings/clear_browsing_data/BUILD.gn
@@ -59,8 +59,7 @@ "//ios/chrome/browser/ui/table_view/cells:cells_constants", "//ios/chrome/common", "//ios/chrome/common/ui/colors", - "//ios/public/provider/chrome/browser", - "//ios/public/provider/chrome/browser/images", + "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ui/base", ] }
diff --git a/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm b/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm index ed95b11..39d9f20 100644 --- a/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm +++ b/ios/chrome/browser/ui/settings/clear_browsing_data/clear_browsing_data_manager.mm
@@ -63,8 +63,7 @@ #import "ios/chrome/common/ui/colors/semantic_color_names.h" #include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_strings.h" -#import "ios/public/provider/chrome/browser/chrome_browser_provider.h" -#import "ios/public/provider/chrome/browser/images/branded_image_provider.h" +#import "ios/public/provider/chrome/browser/branded_images/branded_images_api.h" #include "ui/base/l10n/l10n_util_mac.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -546,9 +545,9 @@ } - (TableViewLinkHeaderFooterItem*)footerGoogleAccountAndMyActivityItem { - UIImage* image = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetClearBrowsingDataAccountActivityImage(); + UIImage* image = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kClearBrowsingDataAccountActivity); + return [self footerItemWithType:ItemTypeFooterGoogleAccountAndMyActivity titleID:IDS_IOS_CLEAR_BROWSING_DATA_FOOTER_ACCOUNT_AND_HISTORY @@ -557,9 +556,9 @@ } - (TableViewLinkHeaderFooterItem*)footerSavedSiteDataItem { - UIImage* image = ios::GetChromeBrowserProvider() - .GetBrandedImageProvider() - ->GetClearBrowsingDataSiteDataImage(); + UIImage* image = ios::provider::GetBrandedImage( + ios::provider::BrandedImage::kClearBrowsingDataSiteData); + return [self footerItemWithType:ItemTypeFooterSavedSiteData titleID:IDS_IOS_CLEAR_BROWSING_DATA_FOOTER_SAVED_SITE_DATA
diff --git a/ios/chrome/browser/web/font_size/font_size_tab_helper.mm b/ios/chrome/browser/web/font_size/font_size_tab_helper.mm index 865ce90..62e6367 100644 --- a/ios/chrome/browser/web/font_size/font_size_tab_helper.mm +++ b/ios/chrome/browser/web/font_size/font_size_tab_helper.mm
@@ -112,6 +112,7 @@ FontSizeTabHelper::FontSizeTabHelper(web::WebState* web_state) : web_state_(web_state) { + DCHECK(ios::provider::IsTextZoomEnabled()); web_state->AddObserver(this); content_size_did_change_observer_ = [NSNotificationCenter.defaultCenter addObserverForName:UIContentSizeCategoryDidChangeNotification @@ -138,7 +139,6 @@ } tab_helper_has_zoomed_ = true; - DCHECK(ios::provider::IsTextZoomEnabled()); ios::provider::SetTextZoomForWebState(web_state_, size); }
diff --git a/ios/chrome/test/app/chrome_test_util.h b/ios/chrome/test/app/chrome_test_util.h index 033d9a98..e2310dd7 100644 --- a/ios/chrome/test/app/chrome_test_util.h +++ b/ios/chrome/test/app/chrome_test_util.h
@@ -66,6 +66,11 @@ const char* pref_name, bool value); +// Sets the value of an integer user pref in the given browser state. +void SetIntegerUserPref(ChromeBrowserState* browser_state, + const char* pref_name, + int value); + // Sets the state of using cellular network. void SetWWANStateTo(bool value);
diff --git a/ios/chrome/test/app/chrome_test_util.mm b/ios/chrome/test/app/chrome_test_util.mm index 7e417d03..1d6e8dfd 100644 --- a/ios/chrome/test/app/chrome_test_util.mm +++ b/ios/chrome/test/app/chrome_test_util.mm
@@ -191,6 +191,16 @@ pref.SetValue(value); } +void SetIntegerUserPref(ChromeBrowserState* browser_state, + const char* pref_name, + int value) { + DCHECK(browser_state); + DCHECK(browser_state->GetPrefs()); + IntegerPrefMember pref; + pref.Init(pref_name, browser_state->GetPrefs()); + pref.SetValue(value); +} + void SetWWANStateTo(bool value) { MainController* mainController = chrome_test_util::GetMainController(); net::NetworkChangeNotifier::ConnectionType connectionType =
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey.h b/ios/chrome/test/earl_grey/chrome_earl_grey.h index a9679a4..f2c935d 100644 --- a/ios/chrome/test/earl_grey/chrome_earl_grey.h +++ b/ios/chrome/test/earl_grey/chrome_earl_grey.h
@@ -682,8 +682,9 @@ - (int)userIntegerPref:(const std::string&)prefName; - (std::string)userStringPref:(const std::string&)prefName; -// Sets the value of a boolean user pref in the original browser state. +// Sets the value of a user pref in the original browser state. - (void)setBoolValue:(BOOL)value forUserPref:(const std::string&)UTF8PrefName; +- (void)setIntegerValue:(int)value forUserPref:(const std::string&)UTF8PrefName; // Resets the BrowsingDataPrefs, which defines if its selected or not when // clearing Browsing data.
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey.mm b/ios/chrome/test/earl_grey/chrome_earl_grey.mm index ae5ea19..901a9f28 100644 --- a/ios/chrome/test/earl_grey/chrome_earl_grey.mm +++ b/ios/chrome/test/earl_grey/chrome_earl_grey.mm
@@ -1306,6 +1306,13 @@ return [ChromeEarlGreyAppInterface setBoolValue:value forUserPref:prefName]; } +- (void)setIntegerValue:(int)value + forUserPref:(const std::string&)UTF8PrefName { + NSString* prefName = base::SysUTF8ToNSString(UTF8PrefName); + return [ChromeEarlGreyAppInterface setIntegerValue:value + forUserPref:prefName]; +} + - (void)resetBrowsingDataPrefs { return [ChromeEarlGreyAppInterface resetBrowsingDataPrefs]; }
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h b/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h index 78c5835..7530a2fe 100644 --- a/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h +++ b/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h
@@ -542,6 +542,9 @@ // Sets the value of a boolean user pref in the original browser state. + (void)setBoolValue:(BOOL)value forUserPref:(NSString*)prefName; +// Sets the value of a integer user pref in the original browser state. ++ (void)setIntegerValue:(int)value forUserPref:(NSString*)prefName; + // Resets the BrowsingDataPrefs, which defines if its selected or not when // clearing Browsing data. + (void)resetBrowsingDataPrefs;
diff --git a/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.mm b/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.mm index 1786da16..55fee6a 100644 --- a/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.mm +++ b/ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.mm
@@ -1075,6 +1075,12 @@ base::SysNSStringToUTF8(prefName).c_str(), value); } ++ (void)setIntegerValue:(int)value forUserPref:(NSString*)prefName { + chrome_test_util::SetIntegerUserPref( + chrome_test_util::GetOriginalBrowserState(), + base::SysNSStringToUTF8(prefName).c_str(), value); +} + + (void)resetBrowsingDataPrefs { PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory);
diff --git a/ios/net/cookies/cookie_store_ios_test_util.mm b/ios/net/cookies/cookie_store_ios_test_util.mm index ddcb28f..907e080 100644 --- a/ios/net/cookies/cookie_store_ios_test_util.mm +++ b/ios/net/cookies/cookie_store_ios_test_util.mm
@@ -38,9 +38,9 @@ void TestPersistentCookieStore::RunLoadedCallback() { std::vector<std::unique_ptr<net::CanonicalCookie>> cookies; - std::unique_ptr<net::CanonicalCookie> cookie( - net::CanonicalCookie::Create(kTestCookieURL, "a=b", base::Time::Now(), - absl::nullopt /* server_time */)); + std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( + kTestCookieURL, "a=b", base::Time::Now(), /*server_time=*/absl::nullopt, + /*cookie_partition_key=*/absl::nullopt)); cookies.push_back(std::move(cookie)); std::unique_ptr<net::CanonicalCookie> bad_canonical_cookie = @@ -135,7 +135,8 @@ net::CookieOptions options; options.set_include_httponly(); auto canonical_cookie = net::CanonicalCookie::Create( - url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */); + url, cookie_line, base::Time::Now(), /*server_time=*/absl::nullopt, + /*cookie_partition_key=*/absl::nullopt); ASSERT_TRUE(canonical_cookie); store->SetCanonicalCookieAsync(std::move(canonical_cookie), url, options, base::DoNothing());
diff --git a/ios/net/cookies/cookie_store_ios_unittest.mm b/ios/net/cookies/cookie_store_ios_unittest.mm index 276eaf32..411b09f 100644 --- a/ios/net/cookies/cookie_store_ios_unittest.mm +++ b/ios/net/cookies/cookie_store_ios_unittest.mm
@@ -245,9 +245,9 @@ // Semantics for CookieMonster::DeleteCanonicalCookieAsync don't match deletes // for same key if cookie value changed. Document CookieStoreIOS compat. - std::unique_ptr<CanonicalCookie> non_equiv_cookie = - CanonicalCookie::Create(kTestCookieURLFooBar, "abc=wfg", not_now, - absl::nullopt /* server_time */); + std::unique_ptr<CanonicalCookie> non_equiv_cookie = CanonicalCookie::Create( + kTestCookieURLFooBar, "abc=wfg", not_now, /*server_time=*/absl::nullopt, + /*cookie_partition_key=*/absl::nullopt); base::RunLoop run_loop; store_->DeleteCanonicalCookieAsync( *non_equiv_cookie, base::BindLambdaForTesting([&](uint32_t deleted) { @@ -269,9 +269,9 @@ run_loop2.Run(); // Now delete equivalent one with non-matching ctime. - std::unique_ptr<CanonicalCookie> equiv_cookie = - CanonicalCookie::Create(kTestCookieURLFooBar, "abc=def", not_now, - absl::nullopt /* server_time */); + std::unique_ptr<CanonicalCookie> equiv_cookie = CanonicalCookie::Create( + kTestCookieURLFooBar, "abc=def", not_now, /*server_time=*/absl::nullopt, + /*cookie_partition_key=*/absl::nullopt); base::RunLoop run_loop3; store_->DeleteCanonicalCookieAsync( @@ -337,7 +337,7 @@ // Add a cookie. auto canonical_cookie = net::CanonicalCookie::Create( kTestCookieURLFooBar, "a=b", base::Time::Now(), - absl::nullopt /* server_time */); + /*server_time=*/absl::nullopt, /*cookie_partition_key=*/absl::nullopt); cookie_store->SetCanonicalCookieAsync(std::move(canonical_cookie), kTestCookieURLFooBar, net::CookieOptions::MakeAllInclusive(),
diff --git a/ios/public/provider/chrome/browser/BUILD.gn b/ios/public/provider/chrome/browser/BUILD.gn index a736c77e..6023f51 100644 --- a/ios/public/provider/chrome/browser/BUILD.gn +++ b/ios/public/provider/chrome/browser/BUILD.gn
@@ -43,6 +43,7 @@ group("provider_api") { deps = [ # The individual APIs. + "//ios/public/provider/chrome/browser/app_distribution:app_distribution_api", "//ios/public/provider/chrome/browser/branded_images:branded_images_api", "//ios/public/provider/chrome/browser/lens:lens_api", "//ios/public/provider/chrome/browser/modals:modals_api", @@ -94,6 +95,7 @@ ":test_provider_factory", # The individual API implementations. + "//ios/public/provider/chrome/browser/app_distribution:test_app_distribution", "//ios/public/provider/chrome/browser/branded_images:test_branded_images", "//ios/public/provider/chrome/browser/lens:test_lens", "//ios/public/provider/chrome/browser/modals:test_modals",
diff --git a/ios/public/provider/chrome/browser/app_distribution/BUILD.gn b/ios/public/provider/chrome/browser/app_distribution/BUILD.gn new file mode 100644 index 0000000..9d18eb0 --- /dev/null +++ b/ios/public/provider/chrome/browser/app_distribution/BUILD.gn
@@ -0,0 +1,15 @@ +# Copyright 2021 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("app_distribution_api") { + configs += [ "//build/config/compiler:enable_arc" ] + sources = [ "app_distribution_api.h" ] + deps = [ "//base" ] +} + +source_set("test_app_distribution") { + configs += [ "//build/config/compiler:enable_arc" ] + sources = [ "test_app_distribution.cc" ] + deps = [ ":app_distribution_api" ] +}
diff --git a/ios/public/provider/chrome/browser/app_distribution/app_distribution_api.h b/ios/public/provider/chrome/browser/app_distribution/app_distribution_api.h new file mode 100644 index 0000000..e774bc3 --- /dev/null +++ b/ios/public/provider/chrome/browser/app_distribution/app_distribution_api.h
@@ -0,0 +1,39 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_APP_DISTRIBUTION_APP_DISTRIBUTION_API_H_ +#define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_APP_DISTRIBUTION_APP_DISTRIBUTION_API_H_ + +#include <string> + +#include "base/memory/scoped_refptr.h" +#include "base/time/time.h" + +namespace network { +class SharedURLLoaderFactory; +} // namespace network + +namespace ios { +namespace provider { + +// Returns the app distribution brand code. +std::string GetBrandCode(); + +// Schedules app distribution notifications to be sent using |context|. +void ScheduleAppDistributionNotifications( + const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory, + bool is_first_run); + +// Cancels any pending app distribution notifications. +void CancelAppDistributionNotifications(); + +// Initializes Firebase for installation attribution purpose. |install_date| +// is used to detect "legacy" users that installed Chrome before Firebase was +// integrated and thus should not have Firebase enabled. +void InitializeFirebase(base::Time install_date, bool is_first_run); + +} // namespace provider +} // namespace ios + +#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_APP_DISTRIBUTION_APP_DISTRIBUTION_API_H_
diff --git a/ios/public/provider/chrome/browser/app_distribution/test_app_distribution.cc b/ios/public/provider/chrome/browser/app_distribution/test_app_distribution.cc new file mode 100644 index 0000000..6852bd4 --- /dev/null +++ b/ios/public/provider/chrome/browser/app_distribution/test_app_distribution.cc
@@ -0,0 +1,30 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ios/public/provider/chrome/browser/app_distribution/app_distribution_api.h" + +namespace ios { +namespace provider { + +std::string GetBrandCode() { + // Test has no brand code. + return std::string(); +} + +void ScheduleAppDistributionNotifications( + const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory, + bool is_first_run) { + // Nothing to do for tests. +} + +void CancelAppDistributionNotifications() { + // Nothing to do for tests. +} + +void InitializeFirebase(base::Time install_date, bool is_first_run) { + // Nothing to do for tests. +} + +} // namespace provider +} // namespace ios
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 452c8d5..9731ad2 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc
@@ -1312,6 +1312,22 @@ return release_sync_token_; } +gpu::SyncToken VideoFrame::UpdateMailboxHolderSyncToken( + size_t plane, + SyncTokenClient* client) { + DCHECK(HasOneRef()); + DCHECK(HasTextures()); + DCHECK(!wrapped_frame_); + DCHECK_LT(plane, kMaxPlanes); + + // No lock is required due to the HasOneRef() check. + auto& token = mailbox_holders_[plane].sync_token; + if (token.HasData()) + client->WaitSyncToken(token); + client->GenerateSyncToken(&token); + return token; +} + std::string VideoFrame::AsHumanReadableString() const { if (metadata().end_of_stream) return "end of stream";
diff --git a/media/base/video_frame.h b/media/base/video_frame.h index 82dc8ca..81c9ac7 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h
@@ -600,6 +600,12 @@ // This method is thread safe. Both blink and compositor threads can call it. gpu::SyncToken UpdateReleaseSyncToken(SyncTokenClient* client); + // Similar to UpdateReleaseSyncToken() but operates on the gpu::SyncToken for + // each plane. This should only be called when a VideoFrame has a single + // owner. I.e., before it has been vended after creation. + gpu::SyncToken UpdateMailboxHolderSyncToken(size_t plane, + SyncTokenClient* client); + // Returns a human-readable string describing |*this|. std::string AsHumanReadableString() const;
diff --git a/media/renderers/video_frame_rgba_to_yuva_converter.cc b/media/renderers/video_frame_rgba_to_yuva_converter.cc index 1fac1ced..0d94aa8 100644 --- a/media/renderers/video_frame_rgba_to_yuva_converter.cc +++ b/media/renderers/video_frame_rgba_to_yuva_converter.cc
@@ -114,6 +114,8 @@ const gpu::MailboxHolder& src_mailbox_holder, VideoFrame* dst_video_frame, gpu::SyncToken& completion_sync_token) { + DCHECK_EQ(dst_video_frame->format(), PIXEL_FORMAT_NV12); + auto* ri = provider->RasterInterface(); DCHECK(ri); @@ -136,10 +138,13 @@ return false; } - // Make GrContext wait for `dst_video_frame`. + // Make GrContext wait for `dst_video_frame`. Waiting on the mailbox tokens + // here ensures that all writes are completed in cases where the underlying + // GpuMemoryBuffer and SharedImage resources have been reused. ri->Flush(); WaitAndReplaceSyncTokenClient client(ri); - dst_video_frame->UpdateReleaseSyncToken(&client); + for (size_t plane = 0; plane < 2; ++plane) + dst_video_frame->UpdateMailboxHolderSyncToken(plane, &client); // Do the blit. skia::BlitRGBAToYUVA( @@ -151,10 +156,14 @@ ri->Flush(); // Set `completion_sync_token` to mark the completion of the copy. - ri->GenUnverifiedSyncTokenCHROMIUM(completion_sync_token.GetData()); + ri->GenSyncTokenCHROMIUM(completion_sync_token.GetData()); - // Make `dst_video_frame` wait on the token. + // Make access to the `dst_video_frame` wait on copy completion. We also + // update the ReleaseSyncToken here since it's used when the underlying + // GpuMemoryBuffer and SharedImage resources are returned to the pool. SimpleSyncTokenClient simple_client(completion_sync_token); + for (size_t plane = 0; plane < 2; ++plane) + dst_video_frame->UpdateMailboxHolderSyncToken(plane, &simple_client); dst_video_frame->UpdateReleaseSyncToken(&simple_client); return true; }
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc index eeca896..e9d0122 100644 --- a/net/cookies/canonical_cookie.cc +++ b/net/cookies/canonical_cookie.cc
@@ -459,6 +459,7 @@ const std::string& cookie_line, const base::Time& creation_time, absl::optional<base::Time> server_time, + absl::optional<CookiePartitionKey> cookie_partition_key, CookieInclusionStatus* status) { // Put a pointer on the stack so the rest of the function can assign to it if // the default nullptr is passed in. @@ -529,6 +530,8 @@ if (parsed_cookie.IsPartitioned()) { base::UmaHistogramBoolean("Cookie.IsPartitionedValid", is_partitioned_valid); + } else { + cookie_partition_key = absl::nullopt; } if (!status->IsInclude()) @@ -549,7 +552,8 @@ parsed_cookie.Name(), parsed_cookie.Value(), cookie_domain, cookie_path, creation_time, cookie_expires, creation_time, parsed_cookie.IsSecure(), parsed_cookie.IsHttpOnly(), samesite, parsed_cookie.Priority(), - parsed_cookie.IsSameParty(), absl::nullopt, source_scheme, source_port)); + parsed_cookie.IsSameParty(), cookie_partition_key, source_scheme, + source_port)); // TODO(chlily): Log metrics. if (!cc->IsCanonical()) {
diff --git a/net/cookies/canonical_cookie.h b/net/cookies/canonical_cookie.h index 3d1add3..4391cec 100644 --- a/net/cookies/canonical_cookie.h +++ b/net/cookies/canonical_cookie.h
@@ -80,12 +80,22 @@ // HttpOnly related parameters should be checked when setting the cookie in // the CookieStore. // + // The partition_key argument only needs to be present if the cookie line + // contains the Partitioned attribute. If the cookie line will never contain + // that attribute, you should use absl::nullopt to indicate you intend to + // always create an unpartitioned cookie. If partition_key has a value but the + // cookie line does not contain the Partitioned attribute, the resulting + // cookie will be unpartitioned. If the partition_key is null, then the cookie + // will be unpartitioned even when the cookie line has the Partitioned + // attribute. + // // If a cookie is returned, |cookie->IsCanonical()| will be true. static std::unique_ptr<CanonicalCookie> Create( const GURL& url, const std::string& cookie_line, const base::Time& creation_time, absl::optional<base::Time> server_time, + absl::optional<CookiePartitionKey> cookie_partition_key, CookieInclusionStatus* status = nullptr); // Create a canonical cookie based on sanitizing the passed inputs in the
diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc index 50a3f67..baf579e 100644 --- a/net/cookies/canonical_cookie_unittest.cc +++ b/net/cookies/canonical_cookie_unittest.cc
@@ -137,26 +137,28 @@ // Space in name. cookie = CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), - "A C=2", creation_time, server_time); + "A C=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_EQ("A C", cookie->Name()); // Semicolon in path. cookie = CanonicalCookie::Create(GURL("http://fool/;/"), "*", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); // Control characters in name or value. CookieInclusionStatus status; - cookie = - CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), - "\b=foo", creation_time, server_time, &status); + cookie = CanonicalCookie::Create( + GURL("http://www.example.com/test/foo.html"), "\b=foo", creation_time, + server_time, absl::nullopt /* cookie_partition_key */, &status); EXPECT_FALSE(cookie.get()); EXPECT_TRUE(status.HasExclusionReason( CookieInclusionStatus::ExclusionReason::EXCLUDE_FAILURE_TO_STORE)); - cookie = - CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), - "bar=\b", creation_time, server_time, &status); + cookie = CanonicalCookie::Create( + GURL("http://www.example.com/test/foo.html"), "bar=\b", creation_time, + server_time, absl::nullopt /* cookie_partition_key */, &status); EXPECT_FALSE(cookie.get()); EXPECT_TRUE(status.HasExclusionReason( CookieInclusionStatus::ExclusionReason::EXCLUDE_FAILURE_TO_STORE)); @@ -170,7 +172,8 @@ absl::optional<base::Time> server_time = absl::nullopt; std::unique_ptr<CanonicalCookie> cookie( - CanonicalCookie::Create(url, "A=2", creation_time, server_time)); + CanonicalCookie::Create(url, "A=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); EXPECT_EQ("A", cookie->Name()); EXPECT_EQ("2", cookie->Value()); EXPECT_EQ("www.example.com", cookie->Domain()); @@ -180,7 +183,8 @@ EXPECT_EQ(cookie->SourcePort(), 80); GURL url2("http://www.foo.com"); - cookie = CanonicalCookie::Create(url2, "B=1", creation_time, server_time); + cookie = CanonicalCookie::Create(url2, "B=1", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ("B", cookie->Name()); EXPECT_EQ("1", cookie->Value()); EXPECT_EQ("www.foo.com", cookie->Domain()); @@ -192,103 +196,126 @@ // Test creating secure cookies. Secure scheme is not checked upon creation, // so a URL of any scheme can create a Secure cookie. cookie = - CanonicalCookie::Create(url, "A=2; Secure", creation_time, server_time); + CanonicalCookie::Create(url, "A=2; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsSecure()); cookie = CanonicalCookie::Create(https_url, "A=2; Secure", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsSecure()); GURL url3("https://www.foo.com"); cookie = - CanonicalCookie::Create(url3, "A=2; Secure", creation_time, server_time); + CanonicalCookie::Create(url3, "A=2; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsSecure()); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kSecure); - cookie = CanonicalCookie::Create(url3, "A=2", creation_time, server_time); + cookie = CanonicalCookie::Create(url3, "A=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_FALSE(cookie->IsSecure()); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kSecure); // Test creating cookie from localhost URL. cookie = CanonicalCookie::Create(GURL("http://localhost/path"), "A=2", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kNonSecure); cookie = CanonicalCookie::Create(GURL("http://127.0.0.1/path"), "A=2", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kNonSecure); cookie = CanonicalCookie::Create(GURL("http://[::1]/path"), "A=2", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kNonSecure); cookie = CanonicalCookie::Create(GURL("https://localhost/path"), "A=2", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kSecure); cookie = CanonicalCookie::Create(GURL("https://127.0.0.1/path"), "A=2", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kSecure); cookie = CanonicalCookie::Create(GURL("https://[::1]/path"), "A=2", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourceScheme(), CookieSourceScheme::kSecure); // Test creating http only cookies. HttpOnly is not checked upon creation. cookie = - CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, server_time); + CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsHttpOnly()); cookie = - CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, server_time); + CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsHttpOnly()); // Test creating SameSite cookies. SameSite is not checked upon creation. cookie = CanonicalCookie::Create(url, "A=2; SameSite=Strict", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie.get()); EXPECT_EQ(CookieSameSite::STRICT_MODE, cookie->SameSite()); cookie = CanonicalCookie::Create(url, "A=2; SameSite=Lax", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie.get()); EXPECT_EQ(CookieSameSite::LAX_MODE, cookie->SameSite()); cookie = CanonicalCookie::Create(url, "A=2; SameSite=Extended", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie.get()); EXPECT_EQ(CookieSameSite::UNSPECIFIED, cookie->SameSite()); cookie = CanonicalCookie::Create(url, "A=2; SameSite=None", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie.get()); EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie->SameSite()); - cookie = CanonicalCookie::Create(url, "A=2", creation_time, server_time); + cookie = CanonicalCookie::Create(url, "A=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie.get()); EXPECT_EQ(CookieSameSite::UNSPECIFIED, cookie->SameSite()); // Test creating cookies with different ports. cookie = CanonicalCookie::Create(GURL("http://www.foo.com"), "B=1", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourcePort(), 80); cookie = CanonicalCookie::Create(GURL("http://www.foo.com:81"), "B=1", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourcePort(), 81); cookie = CanonicalCookie::Create(GURL("https://www.foo.com"), "B=1", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourcePort(), 443); cookie = CanonicalCookie::Create(GURL("https://www.foo.com:1234"), "B=1", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourcePort(), 1234); cookie = CanonicalCookie::Create(GURL("http://www.foo.com:443"), "B=1", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourcePort(), 443); // GURL's port parsing will handle any invalid ports, but let's still make // sure we get the expected result anyway. cookie = CanonicalCookie::Create(GURL("http://www.foo.com:70000"), "B=1", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(cookie->SourcePort(), url::PORT_INVALID); } @@ -300,12 +327,14 @@ // Non-standard value for the SameSite attribute. cookie = CanonicalCookie::Create(url, "A=2; SameSite=NonStandard", now, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_EQ(CookieSameSite::UNSPECIFIED, cookie->SameSite()); // Omit value for the SameSite attribute. - cookie = CanonicalCookie::Create(url, "A=2; SameSite", now, server_time); + cookie = CanonicalCookie::Create(url, "A=2; SameSite", now, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_EQ(CookieSameSite::UNSPECIFIED, cookie->SameSite()); } @@ -320,13 +349,17 @@ // value (it is upon setting the cookie that the SameSiteContext comes into // effect). cookie = - CanonicalCookie::Create(url, "A=2; SameSite=Strict", now, server_time); + CanonicalCookie::Create(url, "A=2; SameSite=Strict", now, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); - cookie = CanonicalCookie::Create(url, "A=2; SameSite=Lax", now, server_time); + cookie = CanonicalCookie::Create(url, "A=2; SameSite=Lax", now, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); - cookie = CanonicalCookie::Create(url, "A=2; SameSite=None", now, server_time); + cookie = CanonicalCookie::Create(url, "A=2; SameSite=None", now, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); - cookie = CanonicalCookie::Create(url, "A=2;", now, server_time); + cookie = CanonicalCookie::Create(url, "A=2;", now, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); } @@ -337,8 +370,9 @@ CookieInclusionStatus status; // An HttpOnly cookie can be created. - std::unique_ptr<CanonicalCookie> cookie = - CanonicalCookie::Create(url, "A=2; HttpOnly", now, server_time, &status); + std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( + url, "A=2; HttpOnly", now, server_time, + absl::nullopt /* cookie_partition_key */, &status); EXPECT_TRUE(cookie->IsHttpOnly()); EXPECT_TRUE(status.IsInclude()); } @@ -350,7 +384,8 @@ CookieInclusionStatus status; std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( - url, "A=2; Domain=wrongdomain.com", now, server_time, &status); + url, "A=2; Domain=wrongdomain.com", now, server_time, + absl::nullopt /* cookie_partition_key */, &status); EXPECT_EQ(nullptr, cookie.get()); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_DOMAIN})); @@ -364,23 +399,26 @@ CookieInclusionStatus status; std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( - url, "A=2; SameParty; Secure", creation_time, server_time, &status); + url, "A=2; SameParty; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status); ASSERT_TRUE(cookie.get()); EXPECT_TRUE(status.IsInclude()); EXPECT_TRUE(cookie->IsSecure()); EXPECT_TRUE(cookie->IsSameParty()); EXPECT_EQ(CookieSameSite::UNSPECIFIED, cookie->SameSite()); - cookie = CanonicalCookie::Create(url, "A=2; SameParty; SameSite=None; Secure", - creation_time, server_time, &status); + cookie = CanonicalCookie::Create( + url, "A=2; SameParty; SameSite=None; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status); ASSERT_TRUE(cookie.get()); EXPECT_TRUE(status.IsInclude()); EXPECT_TRUE(cookie->IsSecure()); EXPECT_TRUE(cookie->IsSameParty()); EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie->SameSite()); - cookie = CanonicalCookie::Create(url, "A=2; SameParty; SameSite=Lax; Secure", - creation_time, server_time, &status); + cookie = CanonicalCookie::Create( + url, "A=2; SameParty; SameSite=Lax; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status); ASSERT_TRUE(cookie.get()); EXPECT_TRUE(status.IsInclude()); EXPECT_TRUE(cookie->IsSecure()); @@ -388,16 +426,17 @@ EXPECT_EQ(CookieSameSite::LAX_MODE, cookie->SameSite()); // SameParty cookie with SameSite=Strict is invalid. - cookie = - CanonicalCookie::Create(url, "A=2; SameParty; SameSite=Strict; Secure", - creation_time, server_time, &status); + cookie = CanonicalCookie::Create( + url, "A=2; SameParty; SameSite=Strict; Secure", creation_time, + server_time, absl::nullopt /* cookie_partition_key */, &status); EXPECT_FALSE(cookie.get()); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_SAMEPARTY})); // SameParty cookie without Secure is invalid. - cookie = CanonicalCookie::Create(url, "A=2; SameParty; SameSite=Lax", - creation_time, server_time, &status); + cookie = CanonicalCookie::Create( + url, "A=2; SameParty; SameSite=Lax", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status); EXPECT_FALSE(cookie.get()); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_SAMEPARTY})); @@ -407,23 +446,37 @@ GURL url("https://www.example.com/test/foo.html"); base::Time creation_time = base::Time::Now(); absl::optional<base::Time> server_time = absl::nullopt; + auto partition_key = absl::make_optional( + CookiePartitionKey::FromURLForTesting(GURL("https://toplevelsite.com"))); CookieInclusionStatus status; // Valid Partitioned attribute - std::unique_ptr<CanonicalCookie> cookie = - CanonicalCookie::Create(url, "__Host-A=2; Partitioned; Path=/; Secure", - creation_time, server_time, &status); + std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( + url, "__Host-A=2; Partitioned; Path=/; Secure", creation_time, + server_time, partition_key, &status); ASSERT_TRUE(cookie.get()); EXPECT_TRUE(status.IsInclude()); EXPECT_TRUE(cookie->IsSecure()); - // TODO(crbug.com/1225444) Uncomment line below. - // EXPECT_TRUE(cookie->IsPartitioned()); + EXPECT_TRUE(cookie->IsPartitioned()); + EXPECT_EQ(partition_key, cookie->PartitionKey()); EXPECT_EQ(CookieSameSite::UNSPECIFIED, cookie->SameSite()); + // Create() without Partitioned in the cookie line should not result in a + // partitioned cookie. + status = CookieInclusionStatus(); + cookie = + CanonicalCookie::Create(url, "__Host-A=2; Path=/; Secure", creation_time, + server_time, partition_key, &status); + ASSERT_TRUE(cookie.get()); + EXPECT_TRUE(status.IsInclude()); + EXPECT_FALSE(cookie->IsPartitioned()); + EXPECT_FALSE(cookie->PartitionKey()); + // Invalid Partitioned attribute: no __Host- prefix. status = CookieInclusionStatus(); cookie = CanonicalCookie::Create(url, "A=2; Partitioned; Path=/; Secure", - creation_time, server_time, &status); + creation_time, server_time, partition_key, + &status); EXPECT_FALSE(cookie.get()); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PARTITIONED})); @@ -432,7 +485,7 @@ status = CookieInclusionStatus(); cookie = CanonicalCookie::Create( url, "A=2; Partitioned; Path=/; Secure; SameParty", creation_time, - server_time, &status); + server_time, partition_key, &status); EXPECT_FALSE(cookie.get()); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PARTITIONED})); @@ -445,7 +498,8 @@ // Max-age with positive integer. std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( - url, "A=1; max-age=60", creation_time, server_time); + url, "A=1; max-age=60", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -455,7 +509,7 @@ // Max-age with expires (max-age should take precedence). cookie = CanonicalCookie::Create( url, "A=1; expires=01-Jan-1970, 00:00:00 GMT; max-age=60", creation_time, - server_time); + server_time, absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -464,8 +518,9 @@ // Max-age=0 should create an expired cookie with expiry equal to the earliest // representable time. - cookie = CanonicalCookie::Create(url, "A=1; max-age=0", creation_time, - server_time); + cookie = + CanonicalCookie::Create(url, "A=1; max-age=0", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsPersistent()); EXPECT_TRUE(cookie->IsExpired(creation_time)); @@ -474,7 +529,8 @@ // Negative max-age should create an expired cookie with expiry equal to the // earliest representable time. cookie = CanonicalCookie::Create(url, "A=1; max-age=-1", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsPersistent()); EXPECT_TRUE(cookie->IsExpired(creation_time)); @@ -482,7 +538,8 @@ // Max-age with whitespace (should be trimmed out). cookie = CanonicalCookie::Create(url, "A=1; max-age = 60 ; Secure", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -491,7 +548,8 @@ // Max-age with non-integer should be ignored. cookie = CanonicalCookie::Create(url, "A=1; max-age=abcd", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_FALSE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -502,7 +560,8 @@ "max-age=" "9999999999999999999999999999999999999999999" "999999999999999999999999999999999999999999", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -514,7 +573,8 @@ "max-age=-" "9999999999999999999999999999999999999999999" "999999999999999999999999999999999999999999", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_TRUE(cookie->IsPersistent()); EXPECT_TRUE(cookie->IsExpired(creation_time)); @@ -529,7 +589,8 @@ std::string cookie_line = "ACSTM=20130308043820420042; path=/; domain=ipdl.inpit.go.jp; Expires="; std::unique_ptr<CanonicalCookie> cookie( - CanonicalCookie::Create(url, cookie_line, creation_time, server_time)); + CanonicalCookie::Create(url, cookie_line, creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); EXPECT_TRUE(cookie.get()); EXPECT_FALSE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -537,8 +598,8 @@ // With a stale server time server_time = creation_time - base::TimeDelta::FromHours(1); - cookie = - CanonicalCookie::Create(url, cookie_line, creation_time, server_time); + cookie = CanonicalCookie::Create(url, cookie_line, creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_FALSE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -546,8 +607,8 @@ // With a future server time server_time = creation_time + base::TimeDelta::FromHours(1); - cookie = - CanonicalCookie::Create(url, cookie_line, creation_time, server_time); + cookie = CanonicalCookie::Create(url, cookie_line, creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie.get()); EXPECT_FALSE(cookie->IsPersistent()); EXPECT_FALSE(cookie->IsExpired(creation_time)); @@ -746,7 +807,8 @@ absl::optional<base::Time> server_time = absl::nullopt; std::unique_ptr<CanonicalCookie> cookie( - CanonicalCookie::Create(url, "A=2", creation_time, server_time)); + CanonicalCookie::Create(url, "A=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); EXPECT_TRUE(cookie->IsHostCookie()); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); @@ -755,7 +817,8 @@ EXPECT_FALSE(cookie->IsDomainMatch("example.com")); cookie = CanonicalCookie::Create(url, "A=2; Domain=www.example.com", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsDomainCookie()); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); @@ -764,7 +827,8 @@ EXPECT_FALSE(cookie->IsDomainMatch("example.com")); cookie = CanonicalCookie::Create(url, "A=2; Domain=.www.example.com", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); EXPECT_TRUE(cookie->IsDomainMatch("www.example.com")); EXPECT_TRUE(cookie->IsDomainMatch("foo.www.example.com")); @@ -777,7 +841,8 @@ absl::optional<base::Time> server_time = absl::nullopt; std::unique_ptr<CanonicalCookie> cookie(CanonicalCookie::Create( - GURL("http://www.example.com"), "A=2", creation_time, server_time)); + GURL("http://www.example.com"), "A=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); EXPECT_TRUE(cookie->IsOnPath("/")); EXPECT_TRUE(cookie->IsOnPath("/test")); EXPECT_TRUE(cookie->IsOnPath("/test/bar.html")); @@ -786,7 +851,8 @@ EXPECT_FALSE(cookie->IsOnPath(std::string())); cookie = CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), - "A=2", creation_time, server_time); + "A=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_FALSE(cookie->IsOnPath("/")); EXPECT_TRUE(cookie->IsOnPath("/test")); EXPECT_TRUE(cookie->IsOnPath("/test/bar.html")); @@ -882,7 +948,8 @@ absl::optional<base::Time> server_time = absl::nullopt; std::unique_ptr<CanonicalCookie> cookie( - CanonicalCookie::Create(url, "A=2", creation_time, server_time)); + CanonicalCookie::Create(url, "A=2", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); EXPECT_TRUE(cookie ->IncludeForRequestURL( url, options, @@ -929,7 +996,8 @@ // Test that cookie with a cookie path that does not match the url path are // not included. cookie = CanonicalCookie::Create(url, "A=2; Path=/foo/bar", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie ->IncludeForRequestURL( url, options, @@ -952,7 +1020,8 @@ // Test that a secure cookie is not included for a non secure URL. GURL secure_url("https://www.example.com"); cookie = CanonicalCookie::Create(secure_url, "A=2; Secure", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsSecure()); EXPECT_TRUE(cookie ->IncludeForRequestURL( @@ -975,7 +1044,8 @@ // Test that a delegate can make an exception, however, and ask for a // non-secure URL to be treated as trustworthy... with a warning. cookie = - CanonicalCookie::Create(url, "A=2; Secure", creation_time, server_time); + CanonicalCookie::Create(url, "A=2; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie); EXPECT_TRUE(cookie->IsSecure()); CookieAccessResult result = cookie->IncludeForRequestURL( @@ -990,7 +1060,8 @@ // The same happens for localhost even w/o delegate intervention. GURL localhost_url("http://localhost/"); cookie = CanonicalCookie::Create(localhost_url, "A=2; Secure", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie); EXPECT_TRUE(cookie->IsSecure()); result = cookie->IncludeForRequestURL( @@ -1004,7 +1075,8 @@ // An unneeded exception doesn't add a warning, however. cookie = CanonicalCookie::Create(secure_url, "A=2; Secure", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie); EXPECT_TRUE(cookie->IsSecure()); result = cookie->IncludeForRequestURL( @@ -1021,7 +1093,8 @@ // is set on the cookie options. options.set_include_httponly(); cookie = - CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, server_time); + CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(cookie->IsHttpOnly()); EXPECT_TRUE(cookie ->IncludeForRequestURL( @@ -1060,7 +1133,8 @@ for (const auto& test : test_cases) { base::Time creation_time = base::Time::Now() - test.creation_time_delta; std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( - url, test.cookie_line, creation_time, absl::nullopt /* server_time */); + url, test.cookie_line, creation_time, absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); EXPECT_EQ(test.expected_samesite, cookie->SameSite()); CookieOptions request_options; @@ -1445,7 +1519,8 @@ // Make a SameSite=None, *not* Secure cookie. std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( - url, "A=2; SameSite=None", creation_time, server_time); + url, "A=2; SameSite=None", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie.get()); EXPECT_FALSE(cookie->IsSecure()); EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie->SameSite()); @@ -1494,7 +1569,8 @@ // SameSite is not specified. std::unique_ptr<CanonicalCookie> cookie_samesite_unspecified = CanonicalCookie::Create(url, "A=2; SameParty; Secure", creation_time, - server_time); + server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie_samesite_unspecified.get()); EXPECT_TRUE(cookie_samesite_unspecified->IsSecure()); EXPECT_EQ(CookieSameSite::UNSPECIFIED, @@ -1506,7 +1582,8 @@ // SameSite=None. std::unique_ptr<CanonicalCookie> cookie_samesite_none = CanonicalCookie::Create(url, "A=2; SameSite=None; SameParty; Secure", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie_samesite_none.get()); EXPECT_TRUE(cookie_samesite_none->IsSecure()); EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie_samesite_none->SameSite()); @@ -1517,7 +1594,8 @@ // SameSite=Lax. std::unique_ptr<CanonicalCookie> cookie_samesite_lax = CanonicalCookie::Create(url, "A=2; SameSite=Lax; SameParty; Secure", - creation_time, server_time); + creation_time, server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie_samesite_lax.get()); EXPECT_TRUE(cookie_samesite_lax->IsSecure()); EXPECT_EQ(CookieSameSite::LAX_MODE, cookie_samesite_lax->SameSite()); @@ -1885,7 +1963,8 @@ CookieInclusionStatus create_status; auto cookie2 = CanonicalCookie::Create( url, "__Secure-notactuallysecure=value;Domain=some-other-domain.com", - creation_time, server_time, &create_status); + creation_time, server_time, absl::nullopt /* cookie_partition_key */, + &create_status); ASSERT_FALSE(cookie2); EXPECT_TRUE(create_status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX, @@ -1893,7 +1972,8 @@ // Test IsSetPermittedInContext() auto cookie3 = CanonicalCookie::Create( - url, "name=value;HttpOnly;SameSite=Lax", creation_time, server_time); + url, "name=value;HttpOnly;SameSite=Lax", creation_time, server_time, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie3); EXPECT_THAT( cookie3->IsSetPermittedInContext( @@ -1914,12 +1994,14 @@ base::Time creation_time = base::Time::Now(); absl::optional<base::Time> server_time = absl::nullopt; std::unique_ptr<CanonicalCookie> cookie( - CanonicalCookie::Create(url, "a=b", creation_time, server_time)); + CanonicalCookie::Create(url, "a=b", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); std::unique_ptr<CanonicalCookie> cookie_different_path( - CanonicalCookie::Create(url, "a=b; path=/foo", creation_time, - server_time)); + CanonicalCookie::Create(url, "a=b; path=/foo", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); std::unique_ptr<CanonicalCookie> cookie_different_value( - CanonicalCookie::Create(url, "a=c", creation_time, server_time)); + CanonicalCookie::Create(url, "a=c", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); // Cookie is equivalent to itself. EXPECT_FALSE(cookie->PartialCompare(*cookie)); @@ -1945,29 +2027,36 @@ CookieInclusionStatus status; // A __Secure- cookie must be Secure. - EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Secure-A=B", creation_time, - server_time, &status)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Secure-A=B", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); - EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Secure-A=B; httponly", - creation_time, server_time, &status)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Secure-A=B; httponly", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status)); // (EXCLUDE_HTTP_ONLY would be fine, too) EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); // A typoed prefix does not have to be Secure. - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__secure-A=B; Secure", - creation_time, server_time)); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__secure-A=C;", creation_time, - server_time)); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=B; Secure", - creation_time, server_time)); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=C;", creation_time, - server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__secure-A=B; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__secure-A=C;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__SecureA=B; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__SecureA=C;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); // A __Secure- cookie can't be set on a non-secure origin. - EXPECT_FALSE(CanonicalCookie::Create(http_url, "__Secure-A=B; Secure", - creation_time, server_time, &status)); + EXPECT_FALSE(CanonicalCookie::Create( + http_url, "__Secure-A=B; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); } @@ -1981,71 +2070,79 @@ CookieInclusionStatus status; // A __Host- cookie must be Secure. - EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B;", creation_time, - server_time, &status)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); EXPECT_FALSE(CanonicalCookie::Create( https_url, "__Host-A=B; Domain=" + domain + "; Path=/;", creation_time, - server_time, &status)); + server_time, absl::nullopt /* cookie_partition_key */, &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Path=/; Secure;", - creation_time, server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__Host-A=B; Path=/; Secure;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); // A __Host- cookie must be set from a secure scheme. EXPECT_FALSE(CanonicalCookie::Create( http_url, "__Host-A=B; Domain=" + domain + "; Path=/; Secure;", - creation_time, server_time, &status)); + creation_time, server_time, absl::nullopt /* cookie_partition_key */, + &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Path=/; Secure;", - creation_time, server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__Host-A=B; Path=/; Secure;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); // A __Host- cookie can't have a Domain. EXPECT_FALSE(CanonicalCookie::Create( https_url, "__Host-A=B; Domain=" + domain + "; Path=/; Secure;", - creation_time, server_time, &status)); + creation_time, server_time, absl::nullopt /* cookie_partition_key */, + &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); EXPECT_FALSE(CanonicalCookie::Create( https_url, "__Host-A=B; Domain=" + domain + "; Secure;", creation_time, - server_time, &status)); + server_time, absl::nullopt /* cookie_partition_key */, &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); // A __Host- cookie may have a domain if it's an IP address that matches the // URL. - EXPECT_TRUE( - CanonicalCookie::Create(GURL("https://127.0.0.1"), - "__Host-A=B; Domain=127.0.0.1; Path=/; Secure;", - creation_time, server_time, &status)); + EXPECT_TRUE(CanonicalCookie::Create( + GURL("https://127.0.0.1"), + "__Host-A=B; Domain=127.0.0.1; Path=/; Secure;", creation_time, + server_time, absl::nullopt /* cookie_partition_key */, &status)); // A __Host- cookie with an IP address domain does not need the domain // attribute specified explicitly (just like a normal domain). - EXPECT_TRUE(CanonicalCookie::Create(GURL("https://127.0.0.1"), - "__Host-A=B; Domain=; Path=/; Secure;", - creation_time, server_time, &status)); + EXPECT_TRUE(CanonicalCookie::Create( + GURL("https://127.0.0.1"), "__Host-A=B; Domain=; Path=/; Secure;", + creation_time, server_time, absl::nullopt /* cookie_partition_key */, + &status)); // A __Host- cookie must have a Path of "/". - EXPECT_FALSE(CanonicalCookie::Create(https_url, - "__Host-A=B; Path=/foo; Secure;", - creation_time, server_time, &status)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B; Path=/foo; Secure;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); - EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B; Secure;", - creation_time, server_time, &status)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B; Secure;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */, &status)); EXPECT_TRUE(status.HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_INVALID_PREFIX})); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Secure; Path=/;", - creation_time, server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__Host-A=B; Secure; Path=/;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); // Rules don't apply for a typoed prefix. EXPECT_TRUE(CanonicalCookie::Create( http_url, "__host-A=B; Domain=" + domain + "; Path=/;", creation_time, - server_time)); + server_time, absl::nullopt /* cookie_partition_key */)); EXPECT_TRUE(CanonicalCookie::Create( https_url, "__HostA=B; Domain=" + domain + "; Secure;", creation_time, - server_time)); + server_time, absl::nullopt /* cookie_partition_key */)); } TEST(CanonicalCookieTest, CanCreateSecureCookiesFromAnyScheme) { @@ -2055,13 +2152,17 @@ absl::optional<base::Time> server_time = absl::nullopt; std::unique_ptr<CanonicalCookie> http_cookie_no_secure( - CanonicalCookie::Create(http_url, "a=b", creation_time, server_time)); + CanonicalCookie::Create(http_url, "a=b", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); std::unique_ptr<CanonicalCookie> http_cookie_secure(CanonicalCookie::Create( - http_url, "a=b; Secure", creation_time, server_time)); + http_url, "a=b; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); std::unique_ptr<CanonicalCookie> https_cookie_no_secure( - CanonicalCookie::Create(https_url, "a=b", creation_time, server_time)); + CanonicalCookie::Create(https_url, "a=b", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); std::unique_ptr<CanonicalCookie> https_cookie_secure(CanonicalCookie::Create( - https_url, "a=b; Secure", creation_time, server_time)); + https_url, "a=b; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); EXPECT_TRUE(http_cookie_no_secure.get()); EXPECT_TRUE(http_cookie_secure.get()); @@ -2391,42 +2492,48 @@ base::Time creation_time = base::Time::Now(); absl::optional<base::Time> server_time = absl::nullopt; - EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B;", creation_time, - server_time)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Host-A=B;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Host-A=B; Path=/; Secure", - creation_time, server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__Host-A=B; Path=/; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__HostA=B; Path=/; Secure", - creation_time, server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__HostA=B; Path=/; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_HOST, 1); - EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Secure-A=B;", - creation_time, server_time)); + EXPECT_FALSE(CanonicalCookie::Create( + https_url, "__Secure-A=B;", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 1); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 1); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__Secure-A=B; Path=/; Secure", - creation_time, server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__Secure-A=B; Path=/; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 1); - EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=B; Path=/; Secure", - creation_time, server_time)); + EXPECT_TRUE(CanonicalCookie::Create( + https_url, "__SecureA=B; Path=/; Secure", creation_time, server_time, + absl::nullopt /* cookie_partition_key */)); histograms.ExpectBucketCount(kCookiePrefixHistogram, CanonicalCookie::COOKIE_PREFIX_SECURE, 2); histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, @@ -2440,21 +2547,26 @@ absl::optional<base::Time> server_time = absl::nullopt; MatchCookieLineToVector("", cookies); - cookies.push_back(CanonicalCookie::Create(url, "A=B", now, server_time)); + cookies.push_back(CanonicalCookie::Create( + url, "A=B", now, server_time, absl::nullopt /* cookie_partition_key */)); MatchCookieLineToVector("A=B", cookies); // Nameless cookies are sent back without a prefixed '='. - cookies.push_back(CanonicalCookie::Create(url, "C", now, server_time)); + cookies.push_back(CanonicalCookie::Create( + url, "C", now, server_time, absl::nullopt /* cookie_partition_key */)); MatchCookieLineToVector("A=B; C", cookies); // Cookies separated by ';'. - cookies.push_back(CanonicalCookie::Create(url, "D=E", now, server_time)); + cookies.push_back(CanonicalCookie::Create( + url, "D=E", now, server_time, absl::nullopt /* cookie_partition_key */)); MatchCookieLineToVector("A=B; C; D=E", cookies); // BuildCookieLine doesn't reorder the list, it relies on the caller to do so. cookies.push_back(CanonicalCookie::Create( - url, "F=G", now - base::TimeDelta::FromSeconds(1), server_time)); + url, "F=G", now - base::TimeDelta::FromSeconds(1), server_time, + absl::nullopt /* cookie_partition_key */)); MatchCookieLineToVector("A=B; C; D=E; F=G", cookies); // BuildCookieLine doesn't deduplicate. cookies.push_back(CanonicalCookie::Create( - url, "D=E", now - base::TimeDelta::FromSeconds(2), server_time)); + url, "D=E", now - base::TimeDelta::FromSeconds(2), server_time, + absl::nullopt /* cookie_partition_key */)); MatchCookieLineToVector("A=B; C; D=E; F=G; D=E", cookies); }
diff --git a/net/cookies/cookie_deletion_info_unittest.cc b/net/cookies/cookie_deletion_info_unittest.cc index 462f6954..d408ceeec 100644 --- a/net/cookies/cookie_deletion_info_unittest.cc +++ b/net/cookies/cookie_deletion_info_unittest.cc
@@ -507,27 +507,28 @@ // the IncludeForRequestURL call uses CookieOptions::MakeAllInclusive). TEST(CookieDeletionInfoTest, MatchesWithCookieAccessSemantics) { // Cookie with unspecified SameSite. - auto cookie = - CanonicalCookie::Create(GURL("https://www.example.com"), "cookie=1", - base::Time::Now(), absl::nullopt); + auto cookie = CanonicalCookie::Create( + GURL("https://www.example.com"), "cookie=1", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); - CookieDeletionInfo delete_info; - delete_info.url = GURL("https://www.example.com/path"); - EXPECT_TRUE(delete_info.Matches( - *cookie, - CookieAccessParams{CookieAccessSemantics::UNKNOWN, - /*delegate_treats_url_as_trustworthy=*/false, - CookieSamePartyStatus::kNoSamePartyEnforcement})); - EXPECT_TRUE(delete_info.Matches( - *cookie, - CookieAccessParams{CookieAccessSemantics::LEGACY, - /*delegate_treats_url_as_trustworthy=*/false, - CookieSamePartyStatus::kNoSamePartyEnforcement})); - EXPECT_TRUE(delete_info.Matches( - *cookie, - CookieAccessParams{CookieAccessSemantics::NONLEGACY, - /*delegate_treats_url_as_trustworthy=*/false, - CookieSamePartyStatus::kNoSamePartyEnforcement})); + CookieDeletionInfo delete_info; + delete_info.url = GURL("https://www.example.com/path"); + EXPECT_TRUE(delete_info.Matches( + *cookie, + CookieAccessParams{CookieAccessSemantics::UNKNOWN, + /*delegate_treats_url_as_trustworthy=*/false, + CookieSamePartyStatus::kNoSamePartyEnforcement})); + EXPECT_TRUE(delete_info.Matches( + *cookie, + CookieAccessParams{CookieAccessSemantics::LEGACY, + /*delegate_treats_url_as_trustworthy=*/false, + CookieSamePartyStatus::kNoSamePartyEnforcement})); + EXPECT_TRUE(delete_info.Matches( + *cookie, + CookieAccessParams{CookieAccessSemantics::NONLEGACY, + /*delegate_treats_url_as_trustworthy=*/false, + CookieSamePartyStatus::kNoSamePartyEnforcement})); } } // namespace net
diff --git a/net/cookies/cookie_monster_perftest.cc b/net/cookies/cookie_monster_perftest.cc index c8ff8b5..61bb68f 100644 --- a/net/cookies/cookie_monster_perftest.cc +++ b/net/cookies/cookie_monster_perftest.cc
@@ -95,8 +95,9 @@ void SetCookie(CookieMonster* cm, const GURL& gurl, const std::string& cookie_line) { - auto cookie = CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie = CanonicalCookie::Create( + gurl, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cm->SetCanonicalCookieAsync( std::move(cookie), gurl, options_, base::BindOnce(&SetCookieCallback::Run, base::Unretained(this)));
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc index 883d777..23c3f2e7 100644 --- a/net/cookies/cookie_monster_unittest.cc +++ b/net/cookies/cookie_monster_unittest.cc
@@ -171,7 +171,8 @@ ResultSavingCookieCallback<CookieAccessResult> callback; cm->SetCanonicalCookieAsync( CanonicalCookie::Create(url, cookie_line, creation_time, - absl::nullopt /* server_time */), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */), url, CookieOptions::MakeAllInclusive(), callback.MakeCallback()); callback.WaitUntilDone(); return callback.result().status.IsInclude(); @@ -1036,7 +1037,8 @@ ResultSavingCookieCallback<CookieAccessResult> call1; cookie_monster_->SetCanonicalCookieAsync( CanonicalCookie::Create(http_www_foo_.url(), "A=B", base::Time::Now(), - absl::nullopt /* server_time */), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */), http_www_foo_.url(), CookieOptions::MakeAllInclusive(), call1.MakeCallback()); base::RunLoop().RunUntilIdle(); @@ -1050,7 +1052,8 @@ ResultSavingCookieCallback<CookieAccessResult> call2; cookie_monster_->SetCanonicalCookieAsync( CanonicalCookie::Create(http_www_foo_.url(), "X=Y", base::Time::Now(), - absl::nullopt /* server_time */), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */), http_www_foo_.url(), CookieOptions::MakeAllInclusive(), call2.MakeCallback()); ASSERT_TRUE(call2.was_run()); @@ -1335,7 +1338,8 @@ cookie_monster_->SetCanonicalCookieAsync( CanonicalCookie::Create(http_www_foo_.url(), "A=B", base::Time::Now(), - absl::nullopt /* server_time */), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */), http_www_foo_.url(), CookieOptions::MakeAllInclusive(), set_cookies_callback.MakeCallback()); @@ -1621,39 +1625,47 @@ absl::optional<base::Time> server_time = absl::nullopt; EXPECT_TRUE( CreateAndSetCookieReturnStatus(cm.get(), http_url, "x=1").IsInclude()); - EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( - cm.get(), - CanonicalCookie::Create(http_url, "y=1", now, server_time), - http_url, false /*modify_httponly*/) - .status.IsInclude()); + EXPECT_TRUE( + SetCanonicalCookieReturnAccessResult( + cm.get(), + CanonicalCookie::Create(http_url, "y=1", now, server_time, + absl::nullopt /* cookie_partition_key */), + http_url, false /*modify_httponly*/) + .status.IsInclude()); EXPECT_TRUE(CreateAndSetCookieReturnStatus(cm.get(), foo_url, "x=1") .HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME})); - EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( - cm.get(), - CanonicalCookie::Create(foo_url, "y=1", now, server_time), - foo_url, false /*modify_httponly*/) - .status.HasExactlyExclusionReasonsForTesting( - {CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME})); + EXPECT_TRUE( + SetCanonicalCookieReturnAccessResult( + cm.get(), + CanonicalCookie::Create(foo_url, "y=1", now, server_time, + absl::nullopt /* cookie_partition_key */), + foo_url, false /*modify_httponly*/) + .status.HasExactlyExclusionReasonsForTesting( + {CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME})); EXPECT_TRUE( CreateAndSetCookieReturnStatus(cm_foo.get(), foo_url, "x=1").IsInclude()); - EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( - cm_foo.get(), - CanonicalCookie::Create(foo_url, "y=1", now, server_time), - foo_url, false /*modify_httponly*/) - .status.IsInclude()); + EXPECT_TRUE( + SetCanonicalCookieReturnAccessResult( + cm_foo.get(), + CanonicalCookie::Create(foo_url, "y=1", now, server_time, + absl::nullopt /* cookie_partition_key */), + foo_url, false /*modify_httponly*/) + .status.IsInclude()); EXPECT_TRUE(CreateAndSetCookieReturnStatus(cm_foo.get(), http_url, "x=1") .HasExactlyExclusionReasonsForTesting( {CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME})); - EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( - cm_foo.get(), - CanonicalCookie::Create(http_url, "y=1", now, server_time), - http_url, false /*modify_httponly*/) - .status.HasExactlyExclusionReasonsForTesting( - {CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME})); + EXPECT_TRUE( + SetCanonicalCookieReturnAccessResult( + cm_foo.get(), + CanonicalCookie::Create(http_url, "y=1", now, server_time, + absl::nullopt /* cookie_partition_key */), + http_url, false /*modify_httponly*/) + .status.HasExactlyExclusionReasonsForTesting( + {CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME})); } TEST_F(CookieMonsterTest, GetAllCookiesForURL) { @@ -2364,8 +2376,9 @@ store->set_store_load_commands(true); std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), &net_log_)); - auto cookie = CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie = CanonicalCookie::Create( + kUrl, "a=b", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); ResultSavingCookieCallback<CookieAccessResult> set_cookie_callback; cm->SetCanonicalCookieAsync(std::move(cookie), kUrl, CookieOptions::MakeAllInclusive(), @@ -2426,8 +2439,9 @@ std::vector<std::unique_ptr<CanonicalCookie>> cookies; // When passed to the CookieMonster, it takes ownership of the pointed to // cookies. - cookies.push_back(CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - absl::nullopt /* server_time */)); + cookies.push_back(CanonicalCookie::Create( + kUrl, "a=b", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_TRUE(cookies[0]); store->TakeCallbackAt(0).Run(std::move(cookies)); @@ -2452,8 +2466,9 @@ GetAllCookiesCallback get_cookies_callback1; cm->GetAllCookiesAsync(get_cookies_callback1.MakeCallback()); - auto cookie = CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie = CanonicalCookie::Create( + kUrl, "a=b", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); ResultSavingCookieCallback<CookieAccessResult> set_cookie_callback; cm->SetCanonicalCookieAsync(std::move(cookie), kUrl, CookieOptions::MakeAllInclusive(), @@ -2499,8 +2514,9 @@ std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), &net_log_)); // Get all cookies task that queues a task to set a cookie when executed. - auto cookie = CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie = CanonicalCookie::Create( + kUrl, "a=b", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); ResultSavingCookieCallback<CookieAccessResult> set_cookie_callback; cm->GetAllCookiesAsync(base::BindOnce( &RunClosureOnAllCookiesReceived, @@ -2713,7 +2729,8 @@ std::string(kValidCookieLine) + "; expires=Blarg arg arg"; std::unique_ptr<CanonicalCookie> cookie( CanonicalCookie::Create(http_www_foo_.url(), cookie_line, Time::Now(), - absl::nullopt /* server_time */)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); ASSERT_FALSE(cookie->IsPersistent()); } @@ -2916,16 +2933,25 @@ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore); std::vector<std::unique_ptr<CanonicalCookie>> initial_cookies; initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain1.test"), "A=1", base::Time::Now(), absl::nullopt)); + GURL("http://domain1.test"), "A=1", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain2.test"), "A=1", base::Time::Now(), absl::nullopt)); - initial_cookies.push_back( - CanonicalCookie::Create(GURL("http://sub.domain2.test"), "A=1", - base::Time::Now(), absl::nullopt)); + GURL("http://domain2.test"), "A=1", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain3.test"), "A=1", base::Time::Now(), absl::nullopt)); + GURL("http://sub.domain2.test"), "A=1", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain3.test"), "B=1", base::Time::Now(), absl::nullopt)); + GURL("http://domain3.test"), "A=1", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); + initial_cookies.push_back(CanonicalCookie::Create( + GURL("http://domain3.test"), "B=1", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); store->SetLoadExpectation(true /* return_value */, std::move(initial_cookies)); auto cm = std::make_unique<CookieMonster>(store.get(), &net_log_); @@ -3007,9 +3033,10 @@ // Insecure localhost can set secure cookie, and warning is attached to // status. { - auto cookie = CanonicalCookie::Create(insecure_localhost, - "from_insecure_localhost=1; Secure", - base::Time::Now(), absl::nullopt); + auto cookie = CanonicalCookie::Create( + insecure_localhost, "from_insecure_localhost=1; Secure", + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie); CookieInclusionStatus status = SetCanonicalCookieReturnAccessResult(cm.get(), std::move(cookie), @@ -3023,9 +3050,10 @@ // Secure localhost can set secure cookie, and warning is not attached to // status. { - auto cookie = CanonicalCookie::Create(insecure_localhost, - "from_secure_localhost=1; Secure", - base::Time::Now(), absl::nullopt); + auto cookie = CanonicalCookie::Create( + insecure_localhost, "from_secure_localhost=1; Secure", + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); ASSERT_TRUE(cookie); CookieInclusionStatus status = SetCanonicalCookieReturnAccessResult(cm.get(), std::move(cookie), @@ -3076,7 +3104,8 @@ // Set a secure, httponly cookie from a secure origin auto preexisting_cookie = CanonicalCookie::Create( https_www_foo_.url(), "A=B;Secure;HttpOnly", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); CookieAccessResult access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(preexisting_cookie), https_www_foo_.url(), true /* can_modify_httponly */); @@ -3094,7 +3123,8 @@ // equivalent to the pre-existing Secure cookie. auto bad_cookie = CanonicalCookie::Create(http_www_foo_.url(), "A=D", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Allow modifying HttpOnly, so that we don't skip preexisting cookies for // being HttpOnly. access_result = SetCanonicalCookieReturnAccessResult( @@ -3125,7 +3155,8 @@ // trying to shadow a secure cookie. bad_cookie = CanonicalCookie::Create( http_www_foo_.url(), "A=E; path=/some/path", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Allow modifying HttpOnly, so that we don't skip preexisting cookies for // being HttpOnly. access_result = SetCanonicalCookieReturnAccessResult( @@ -3153,9 +3184,10 @@ net_log_.Clear(); // Test skipping equivalent cookie for HttpOnly only. - bad_cookie = CanonicalCookie::Create(https_www_foo_.url(), "A=E; Secure", - base::Time::Now(), - absl::nullopt /* server_time */); + bad_cookie = CanonicalCookie::Create( + https_www_foo_.url(), "A=E; Secure", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(bad_cookie), https_www_foo_.url(), false /* can_modify_httponly */); @@ -3179,7 +3211,8 @@ // Set a secure, httponly cookie from a secure origin auto preexisting_cookie = CanonicalCookie::Create( https_www_foo_.url(), "A=B;Secure;HttpOnly", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); CookieAccessResult access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(preexisting_cookie), https_www_foo_.url(), true /* can_modify_httponly */); @@ -3189,7 +3222,8 @@ // Httponly from an insecure scheme. auto cookie = CanonicalCookie::Create(http_www_foo_.url(), "A=B", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(cookie), http_www_foo_.url(), false /* can_modify_httponly */); @@ -3214,7 +3248,8 @@ auto preexisting_cookie = CanonicalCookie::Create( http_www_foo_.url(), "cookie=foo", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); CookieAccessResult access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(preexisting_cookie), http_www_foo_.url(), false /* can_modify_httponly */); @@ -3222,7 +3257,8 @@ auto bad_cookie = CanonicalCookie::Create( http_www_foo_.url(), "cookie=bar;secure", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); CookieAccessResult access_result2 = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(bad_cookie), http_www_foo_.url(), false /* can_modify_httponly */); @@ -3889,7 +3925,8 @@ GURL cookie_url("http://a.com/"); cm.SetCanonicalCookieAsync( CanonicalCookie::Create(cookie_url, "A=B", base::Time::Now(), - absl::nullopt /* server_time */), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */), cookie_url, CookieOptions::MakeAllInclusive(), callback_set.MakeCallback()); @@ -3967,17 +4004,20 @@ std::string cookie_line = "foo=bar"; CookieOptions options = CookieOptions::MakeAllInclusive(); absl::optional<base::Time> server_time = absl::nullopt; + absl::optional<CookiePartitionKey> partition_key = absl::nullopt; CookieMonster cm(nullptr, nullptr); // Write a cookie created at |t1|. - auto cookie = CanonicalCookie::Create(url, cookie_line, t1, server_time); + auto cookie = + CanonicalCookie::Create(url, cookie_line, t1, server_time, partition_key); ResultSavingCookieCallback<CookieAccessResult> set_callback_1; cm.SetCanonicalCookieAsync(std::move(cookie), url, options, set_callback_1.MakeCallback()); set_callback_1.WaitUntilDone(); // Overwrite the cookie at |t2|. - cookie = CanonicalCookie::Create(url, cookie_line, t2, server_time); + cookie = + CanonicalCookie::Create(url, cookie_line, t2, server_time, partition_key); ResultSavingCookieCallback<CookieAccessResult> set_callback_2; cm.SetCanonicalCookieAsync(std::move(cookie), url, options, set_callback_2.MakeCallback()); @@ -3985,7 +4025,8 @@ // The second cookie overwrites the first one but it will inherit the creation // timestamp |t1|. Test that deleting the new cookie still works. - cookie = CanonicalCookie::Create(url, cookie_line, t2, server_time); + cookie = + CanonicalCookie::Create(url, cookie_line, t2, server_time, partition_key); ResultSavingCookieCallback<unsigned int> delete_callback; cm.DeleteCanonicalCookieAsync(*cookie, delete_callback.MakeCallback()); delete_callback.WaitUntilDone(); @@ -4004,9 +4045,9 @@ CookieInclusionStatus status; // Cookie can be created successfully; SameSite is not checked on Creation. - auto cookie = - CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */, &status); + auto cookie = CanonicalCookie::Create( + url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */, &status); ASSERT_TRUE(cookie != nullptr); ASSERT_TRUE(status.IsInclude()); @@ -4027,9 +4068,9 @@ CookieInclusionStatus status; // Cookie can be created successfully from an any url. Secure is not checked // on Create. - auto cookie = - CanonicalCookie::Create(http_url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */, &status); + auto cookie = CanonicalCookie::Create( + http_url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */, &status); ASSERT_TRUE(cookie != nullptr); ASSERT_TRUE(status.IsInclude()); @@ -4051,9 +4092,9 @@ CookieMonster cm(nullptr, nullptr); CookieInclusionStatus status; // Cookie can be created successfully; HttpOnly is not checked on Create. - auto cookie = - CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */, &status); + auto cookie = CanonicalCookie::Create( + url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */, &status); ASSERT_TRUE(cookie != nullptr); ASSERT_TRUE(status.IsInclude()); @@ -4135,8 +4176,9 @@ GURL url = test.is_url_secure ? secure_url : insecure_url; base::Time creation_time = base::Time::Now() - test.creation_time_delta; - auto cookie = CanonicalCookie::Create(url, test.cookie_line, creation_time, - absl::nullopt /* server_time */); + auto cookie = CanonicalCookie::Create( + url, test.cookie_line, creation_time, absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Make a copy so we can delete it after the test. CanonicalCookie cookie_copy = *cookie; CookieAccessResult result = SetCanonicalCookieReturnAccessResult( @@ -4209,12 +4251,15 @@ std::vector<std::unique_ptr<CanonicalCookie>> initial_cookies; GURL url("http://www.foo.com"); initial_cookies.push_back(CanonicalCookie::Create( - url, "X=1; path=/", base::Time::Now(), absl::nullopt)); + url, "X=1; path=/", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); initial_cookies.push_back(CanonicalCookie::Create( - url, "Y=1; path=/", base::Time::Now(), absl::nullopt)); + url, "Y=1; path=/", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); initial_cookies.push_back(CanonicalCookie::Create( url, "Y=2; path=/", base::Time::Now() + base::TimeDelta::FromDays(1), - absl::nullopt)); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); // Execute the load store->TakeCallbackAt(0).Run(std::move(initial_cookies)); @@ -4583,7 +4628,8 @@ auto unspecified_cookie = CanonicalCookie::Create( GURL("https://www.foo.com/withoutport"), "C=D; Path=/withoutport", - base::Time::Now(), absl::nullopt); + base::Time::Now(), /* server_time */ absl::nullopt, + /* cookie_partition_key */ absl::nullopt); // Force to be unspecified. unspecified_cookie->SetSourcePort(url::PORT_UNSPECIFIED); EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( @@ -4594,7 +4640,8 @@ auto invalid_cookie = CanonicalCookie::Create( GURL("https://www.foo.com/invalidport"), "E=F; Path=/invalidport", - base::Time::Now(), absl::nullopt); + base::Time::Now(), /* server_time */ absl::nullopt, + /* cookie_partition_key */ absl::nullopt); // Force to be invalid. invalid_cookie->SetSourcePort(99999); EXPECT_TRUE(SetCanonicalCookieReturnAccessResult(
diff --git a/net/cookies/cookie_partition_key.h b/net/cookies/cookie_partition_key.h index a78de05..cc1102b9 100644 --- a/net/cookies/cookie_partition_key.h +++ b/net/cookies/cookie_partition_key.h
@@ -63,6 +63,10 @@ return CookiePartitionKey(url); } + // Temporary method, used to mark the places where we need to supply the + // cookie partition key to CanonicalCookie::Create. + static absl::optional<CookiePartitionKey> Todo() { return absl::nullopt; } + private: explicit CookiePartitionKey(const GURL& url);
diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h index 9bf27e6..1631f16 100644 --- a/net/cookies/cookie_store_unittest.h +++ b/net/cookies/cookie_store_unittest.h
@@ -200,7 +200,8 @@ absl::optional<base::Time> server_time = absl::nullopt, absl::optional<base::Time> system_time = absl::nullopt) { auto cookie = CanonicalCookie::Create( - url, cookie_line, system_time.value_or(base::Time::Now()), server_time); + url, cookie_line, system_time.value_or(base::Time::Now()), server_time, + absl::nullopt /* cookie_partition_key */); if (!cookie) return false; @@ -271,9 +272,9 @@ const GURL& url, const std::string& cookie_line) { CookieInclusionStatus create_status; - auto cookie = CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */, - &create_status); + auto cookie = CanonicalCookie::Create( + url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */, &create_status); if (!cookie) return create_status; @@ -601,7 +602,8 @@ CookieInclusionStatus status; auto cookie = CanonicalCookie::Create( this->http_www_foo_.url(), "foo=1; Secure", base::Time::Now(), - absl::nullopt /* server_time */, &status); + absl::nullopt /* server_time */, absl::nullopt /* cookie_partition_key */, + &status); EXPECT_TRUE(cookie->IsSecure()); EXPECT_TRUE(status.IsInclude()); EXPECT_TRUE(this->SetCanonicalCookieReturnAccessResult( @@ -650,7 +652,8 @@ CookieInclusionStatus create_status; auto c = CanonicalCookie::Create( this->http_www_foo_.url(), "bar=1; HttpOnly", base::Time::Now(), - absl::nullopt /* server_time */, &create_status); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */, &create_status); EXPECT_TRUE(c->IsHttpOnly()); EXPECT_TRUE(create_status.IsInclude()); EXPECT_TRUE(this->SetCanonicalCookieReturnAccessResult(
diff --git a/net/cookies/cookie_util_unittest.cc b/net/cookies/cookie_util_unittest.cc index 3daca89f..91d5558b 100644 --- a/net/cookies/cookie_util_unittest.cc +++ b/net/cookies/cookie_util_unittest.cc
@@ -307,13 +307,18 @@ for (const auto& test : kTests) { std::vector<std::unique_ptr<CanonicalCookie>> cookies; // It shouldn't depend on the cookie's secureness or actual source scheme. - cookies.push_back(CanonicalCookie::Create( - insecure_url, test.cookie, base::Time::Now(), absl::nullopt)); - cookies.push_back(CanonicalCookie::Create( - secure_url, test.cookie, base::Time::Now(), absl::nullopt)); cookies.push_back( - CanonicalCookie::Create(secure_url, test.cookie + "; Secure", - base::Time::Now(), absl::nullopt)); + CanonicalCookie::Create(insecure_url, test.cookie, base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); + cookies.push_back( + CanonicalCookie::Create(secure_url, test.cookie, base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); + cookies.push_back(CanonicalCookie::Create( + secure_url, test.cookie + "; Secure", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */)); for (const auto& cookie : cookies) { GURL simulated_source = cookie_util::SimulatedCookieSource(*cookie, test.source_scheme);
diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc index c746fb92..303eb67a 100644 --- a/net/dns/dns_transaction_unittest.cc +++ b/net/dns/dns_transaction_unittest.cc
@@ -2411,7 +2411,8 @@ config_.dns_over_https_servers[0].server_template)); auto cookie = CanonicalCookie::Create( cookie_url, "test-cookie=you-still-fail", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); request_context_->cookie_store()->SetCanonicalCookieAsync( std::move(cookie), cookie_url, CookieOptions(), base::BindOnce(&CookieCallback::SetCookieCallback,
diff --git a/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc index d5e4eb6..92777f98 100644 --- a/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc +++ b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc
@@ -1392,7 +1392,8 @@ GURL ftp_url("ftp://subdomain.ftperiffic.com/page/"); auto cookie = CanonicalCookie::Create(ftp_url, "A=B; max-age=3600", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cookie_monster->SetCanonicalCookieAsync(std::move(cookie), ftp_url, CookieOptions::MakeAllInclusive(), set_cookie_callback.MakeCallback()); @@ -1406,7 +1407,8 @@ GURL url(base::StringPrintf("http://example%d.com/", i)); auto canonical_cookie = CanonicalCookie::Create(url, "A=B; max-age=3600", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cookie_monster->SetCanonicalCookieAsync( std::move(canonical_cookie), url, CookieOptions::MakeAllInclusive(), set_cookie_callback2.MakeCallback()); @@ -1460,7 +1462,8 @@ GURL url("http://www.example.com/"); auto cookie = CanonicalCookie::Create(url, "A=B; max-age=3600", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cookie_monster->SetCanonicalCookieAsync(std::move(cookie), url, CookieOptions::MakeAllInclusive(), set_cookie_callback.MakeCallback()); @@ -1493,7 +1496,8 @@ std::unique_ptr<CanonicalCookie> cookie = CanonicalCookie::Create( GURL("http://www.example.com/path"), "Tasty=Yes", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); for (const TestCase& testcase : testcases) { Create(false, false, true /* want current thread to invoke the store. */); @@ -1546,11 +1550,13 @@ std::unique_ptr<CanonicalCookie> cookie1 = CanonicalCookie::Create( GURL("http://www.example.com/path"), "Tasty=Yes", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); std::unique_ptr<CanonicalCookie> cookie2 = CanonicalCookie::Create( GURL("http://not.example.com/path"), "Tasty=No", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); // Wedge the background thread to make sure that it doesn't start consuming // the queue.
diff --git a/net/reporting/reporting_uploader_unittest.cc b/net/reporting/reporting_uploader_unittest.cc index 484184b..d2de42ac 100644 --- a/net/reporting/reporting_uploader_unittest.cc +++ b/net/reporting/reporting_uploader_unittest.cc
@@ -452,8 +452,9 @@ ResultSavingCookieCallback<CookieAccessResult> cookie_callback; GURL url = server_.GetURL("/"); - auto cookie = CanonicalCookie::Create(url, "foo=bar", base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie = CanonicalCookie::Create( + url, "foo=bar", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); context_.cookie_store()->SetCanonicalCookieAsync( std::move(cookie), url, CookieOptions::MakeAllInclusive(), cookie_callback.MakeCallback());
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 2be96af..6e04b23 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc
@@ -779,7 +779,7 @@ std::unique_ptr<CanonicalCookie> cookie = net::CanonicalCookie::Create( request_->url(), cookie_string, base::Time::Now(), server_time, - &returned_status); + net::CookiePartitionKey::Todo(), &returned_status); absl::optional<CanonicalCookie> cookie_to_return = absl::nullopt; if (returned_status.IsInclude()) {
diff --git a/net/url_request/url_request_http_job_unittest.cc b/net/url_request/url_request_http_job_unittest.cc index efff817..6bde63c 100644 --- a/net/url_request/url_request_http_job_unittest.cc +++ b/net/url_request/url_request_http_job_unittest.cc
@@ -1664,8 +1664,9 @@ bool CreateAndSetCookie(CookieStore* cs, const GURL& url, const std::string& cookie_line) { - auto cookie = CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - absl::nullopt); + auto cookie = CanonicalCookie::Create( + url, cookie_line, base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); if (!cookie) return false; DCHECK(cs); @@ -1714,7 +1715,8 @@ // would normally only happen during an existing cookie DB version upgrade. std::unique_ptr<CanonicalCookie> unset_cookie1 = CanonicalCookie::Create( secure_url_for_unset1, "NoSourceSchemeHttps=val", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); unset_cookie1->SetSourceScheme(net::CookieSourceScheme::kUnset); CookieList list1 = {*unset_cookie1}; @@ -1734,7 +1736,8 @@ std::unique_ptr<CanonicalCookie> unset_cookie2 = CanonicalCookie::Create( nonsecure_url_for_unset2, "NoSourceSchemeHttp=val", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); unset_cookie2->SetSourceScheme(net::CookieSourceScheme::kUnset); CookieList list2 = {*unset_cookie2};
diff --git a/net/url_request/url_request_quic_unittest.cc b/net/url_request/url_request_quic_unittest.cc index 6d240ea..136c94f 100644 --- a/net/url_request/url_request_quic_unittest.cc +++ b/net/url_request/url_request_quic_unittest.cc
@@ -44,6 +44,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" +#include "url/origin.h" namespace net { @@ -395,15 +396,23 @@ run_loop.QuitClosure(), /*num_expected_requests=*/2); SetNetworkDelegate(&network_delegate); Init(); + + GURL url = GURL(UrlFromPath(kHelloPath)); + auto isolation_info = + IsolationInfo::CreateForInternalRequest(url::Origin::Create(url)); + CheckLoadTimingDelegate delegate(false); delegate.set_on_complete(base::DoNothing()); std::unique_ptr<URLRequest> request = - CreateRequest(GURL(UrlFromPath(kHelloPath)), DEFAULT_PRIORITY, &delegate); + CreateRequest(url, DEFAULT_PRIORITY, &delegate); + request->set_isolation_info(isolation_info); CheckLoadTimingDelegate delegate2(true); delegate2.set_on_complete(base::DoNothing()); - std::unique_ptr<URLRequest> request2 = CreateRequest( - GURL(UrlFromPath(kHelloPath)), DEFAULT_PRIORITY, &delegate2); + std::unique_ptr<URLRequest> request2 = + CreateRequest(url, DEFAULT_PRIORITY, &delegate2); + request2->set_isolation_info(isolation_info); + request->Start(); request2->Start(); ASSERT_TRUE(request->is_pending());
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 60433af..786fb06 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc
@@ -1636,15 +1636,17 @@ replace_scheme.SetSchemeStr("https"); GURL url = test_server.base_url().ReplaceComponents(replace_scheme); - auto cookie1 = CanonicalCookie::Create(url, "AlreadySetCookie=1;Secure", - base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie1 = CanonicalCookie::Create( + url, "AlreadySetCookie=1;Secure", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); delayed_cm->SetCanonicalCookieAsync(std::move(cookie1), url, net::CookieOptions::MakeAllInclusive(), CookieStore::SetCookiesCallback()); - auto cookie2 = CanonicalCookie::Create(url, "AlreadySetCookie=1;Secure", - base::Time::Now(), - absl::nullopt /* server_time */); + auto cookie2 = CanonicalCookie::Create( + url, "AlreadySetCookie=1;Secure", base::Time::Now(), + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cm->SetCanonicalCookieAsync(std::move(cookie2), url, net::CookieOptions::MakeAllInclusive(), CookieStore::SetCookiesCallback()); @@ -7714,8 +7716,9 @@ network_delegate.set_block_annotate_cookies(); { GURL url = test_server.GetURL("/"); - auto cookie1 = CanonicalCookie::Create(url, "cookienosamesite=1", - base::Time::Now(), absl::nullopt); + auto cookie1 = CanonicalCookie::Create( + url, "cookienosamesite=1", base::Time::Now(), absl::nullopt, + absl::nullopt /* cookie_partition_key */); base::RunLoop run_loop; CookieAccessResult access_result; cm.SetCanonicalCookieAsync( @@ -7756,8 +7759,9 @@ // Get cookies { GURL url = test_server.GetURL("/"); - auto cookie2 = CanonicalCookie::Create(url, "cookiewithpath=1;path=/foo", - base::Time::Now(), absl::nullopt); + auto cookie2 = CanonicalCookie::Create( + url, "cookiewithpath=1;path=/foo", base::Time::Now(), absl::nullopt, + absl::nullopt /* cookie_partition_key */); base::RunLoop run_loop; // Note: cookie1 from the previous testcase is still in the cookie store. CookieAccessResult access_result; @@ -7902,7 +7906,8 @@ std::make_unique<CookieMonster>(nullptr, nullptr); auto another_cookie = CanonicalCookie::Create( url_requiring_auth_wo_cookies, "another_cookie=true", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cm->SetCanonicalCookieAsync(std::move(another_cookie), url_requiring_auth_wo_cookies, net::CookieOptions::MakeAllInclusive(), @@ -7934,7 +7939,8 @@ cm->DeleteAllAsync(CookieStore::DeleteCallback()); auto one_more_cookie = CanonicalCookie::Create( url_requiring_auth_wo_cookies, "one_more_cookie=true", - base::Time::Now(), absl::nullopt /* server_time */); + base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cm->SetCanonicalCookieAsync(std::move(one_more_cookie), url_requiring_auth_wo_cookies, net::CookieOptions::MakeAllInclusive(), @@ -8313,7 +8319,8 @@ std::make_unique<CookieMonster>(nullptr, nullptr); auto another_cookie = CanonicalCookie::Create( original_url, "another_cookie=true", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cm->SetCanonicalCookieAsync(std::move(another_cookie), original_url, net::CookieOptions::MakeAllInclusive(), CookieStore::SetCookiesCallback()); @@ -8342,7 +8349,8 @@ cm->DeleteAllAsync(CookieStore::DeleteCallback()); auto one_more_cookie = CanonicalCookie::Create( original_url_wo_cookie, "one_more_cookie=true", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); cm->SetCanonicalCookieAsync(std::move(one_more_cookie), original_url_wo_cookie, net::CookieOptions::MakeAllInclusive(),
diff --git a/net/websockets/websocket_stream_cookie_test.cc b/net/websockets/websocket_stream_cookie_test.cc index e0ffcc67..3bce53c 100644 --- a/net/websockets/websocket_stream_cookie_test.cc +++ b/net/websockets/websocket_stream_cookie_test.cc
@@ -155,7 +155,8 @@ base::RunLoop run_loop; auto cookie = CanonicalCookie::Create(cookie_url, cookie_line, base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); store->SetCanonicalCookieAsync( std::move(cookie), cookie_url, net::CookieOptions::MakeAllInclusive(), base::BindOnce(&SetCookieHelperFunction, run_loop.QuitClosure(),
diff --git a/services/network/cookie_manager_unittest.cc b/services/network/cookie_manager_unittest.cc index 428ea681..a8ebc94 100644 --- a/services/network/cookie_manager_unittest.cc +++ b/services/network/cookie_manager_unittest.cc
@@ -1133,7 +1133,7 @@ GURL http_localhost_url("http://localhost/path"); auto http_localhost_cookie = net::CanonicalCookie::Create( http_localhost_url, "http_localhost=1; Secure", base::Time::Now(), - absl::nullopt); + absl::nullopt, absl::nullopt /* cookie_partition_key */); // Secure cookie can be set from non-cryptographic localhost URL. EXPECT_TRUE(service_wrapper() @@ -1153,7 +1153,8 @@ GURL http_other_url("http://other.test/path"); auto http_other_cookie = net::CanonicalCookie::Create( - http_other_url, "http_other=1; Secure", base::Time::Now(), absl::nullopt); + http_other_url, "http_other=1; Secure", base::Time::Now(), absl::nullopt, + absl::nullopt /* cookie_partition_key */); // Secure cookie cannot be set from another non-cryptographic URL if there is // no CookieAccessDelegate.
diff --git a/services/network/restricted_cookie_manager.cc b/services/network/restricted_cookie_manager.cc index 89b71bed..8e306dde 100644 --- a/services/network/restricted_cookie_manager.cc +++ b/services/network/restricted_cookie_manager.cc
@@ -527,7 +527,8 @@ net::CookieInclusionStatus status; std::unique_ptr<net::CanonicalCookie> parsed_cookie = net::CanonicalCookie::Create(url, cookie, base::Time::Now(), - absl::nullopt /* server_time */, &status); + absl::nullopt /* server_time */, + net::CookiePartitionKey::Todo(), &status); if (!parsed_cookie) { if (cookie_observer_) { std::vector<network::mojom::CookieOrLineWithAccessResultPtr>
diff --git a/services/network/restricted_cookie_manager_unittest.cc b/services/network/restricted_cookie_manager_unittest.cc index 0e65d9b..a856249 100644 --- a/services/network/restricted_cookie_manager_unittest.cc +++ b/services/network/restricted_cookie_manager_unittest.cc
@@ -886,7 +886,8 @@ // With default settings object, setting a third-party cookie is OK. auto cookie = net::CanonicalCookie::Create( kDefaultUrl, "A=B; SameSite=none; Secure", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); EXPECT_TRUE(sync_service_->SetCanonicalCookie( *cookie, kDefaultUrl, net::SiteForCookies(), kDefaultOrigin)); } @@ -908,7 +909,8 @@ cookie_settings_.set_block_third_party_cookies(true); auto cookie = net::CanonicalCookie::Create( kDefaultUrl, "A2=B2; SameSite=none; Secure", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); EXPECT_FALSE(sync_service_->SetCanonicalCookie( *cookie, kDefaultUrl, net::SiteForCookies(), kDefaultOrigin)); } @@ -949,7 +951,8 @@ service_->OverrideIsolationInfoForTesting(kOtherIsolationInfo); auto cookie = net::CanonicalCookie::Create( - kDefaultUrl, "A=B", base::Time::Now(), absl::nullopt /* server_time */); + kDefaultUrl, "A=B", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); EXPECT_FALSE(sync_service_->SetCanonicalCookie( *cookie, kDefaultUrl, net::SiteForCookies(), kDefaultOrigin)); @@ -1351,7 +1354,7 @@ auto cookie = net::CanonicalCookie::Create( kDefaultUrl, "cookie_with_no_samesite=unspecified", base::Time::Now(), - absl::nullopt); + absl::nullopt, absl::nullopt /* cookie_partition_key */); // Set cookie directly into the CookieMonster, using all-inclusive options. net::ResultSavingCookieCallback<net::CookieAccessResult> callback; @@ -1390,11 +1393,12 @@ auto unspecified_cookie = net::CanonicalCookie::Create( kDefaultUrl, "cookie_with_no_samesite=unspecified", base::Time::Now(), - absl::nullopt); + absl::nullopt, absl::nullopt /* cookie_partition_key */); auto samesite_none_cookie = net::CanonicalCookie::Create( kDefaultUrl, "samesite_none_cookie=none; SameSite=None; Secure", - base::Time::Now(), absl::nullopt); + base::Time::Now(), absl::nullopt, + absl::nullopt /* cookie_partition_key */); // Set cookies directly into the CookieMonster, using all-inclusive options. net::ResultSavingCookieCallback<net::CookieAccessResult> callback1;
diff --git a/services/network/url_loader_unittest.cc b/services/network/url_loader_unittest.cc index 83dc143..3f0858c 100644 --- a/services/network/url_loader_unittest.cc +++ b/services/network/url_loader_unittest.cc
@@ -4896,7 +4896,8 @@ GURL cookie_url = test_server()->GetURL("/"); auto cookie = net::CanonicalCookie::Create( - cookie_url, "a=b", base::Time::Now(), absl::nullopt /* server_time */); + cookie_url, "a=b", base::Time::Now(), absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); context()->cookie_store()->SetCanonicalCookieAsync( std::move(cookie), cookie_url, net::CookieOptions::MakeAllInclusive(), base::DoNothing()); @@ -4951,7 +4952,8 @@ GURL cookie_url = test_server()->GetURL("/"); auto cookie = net::CanonicalCookie::Create( cookie_url, "a=b;Path=/something-else", base::Time::Now(), - absl::nullopt /* server_time */); + absl::nullopt /* server_time */, + absl::nullopt /* cookie_partition_key */); context()->cookie_store()->SetCanonicalCookieAsync( std::move(cookie), cookie_url, net::CookieOptions::MakeAllInclusive(), base::DoNothing());
diff --git a/third_party/blink/common/use_counter/use_counter_feature.cc b/third_party/blink/common/use_counter/use_counter_feature.cc index 45f9f37..3ffd8c60 100644 --- a/third_party/blink/common/use_counter/use_counter_feature.cc +++ b/third_party/blink/common/use_counter/use_counter_feature.cc
@@ -34,6 +34,8 @@ mojom::CSSSampleId::kMaxValue) + 1; case mojom::UseCounterFeatureType::kPermissionsPolicyViolationEnforce: + case mojom::UseCounterFeatureType::kPermissionsPolicyHeader: + case mojom::UseCounterFeatureType::kPermissionsPolicyIframeAttribute: return value_ < static_cast<UseCounterFeature::EnumValue>( mojom::PermissionsPolicyFeature::kMaxValue) + 1;
diff --git a/third_party/blink/common/use_counter/use_counter_feature_mojom_traits.cc b/third_party/blink/common/use_counter/use_counter_feature_mojom_traits.cc index 755ee3a..2ac239b 100644 --- a/third_party/blink/common/use_counter/use_counter_feature_mojom_traits.cc +++ b/third_party/blink/common/use_counter/use_counter_feature_mojom_traits.cc
@@ -25,6 +25,8 @@ blink::mojom::CSSSampleId::kTotalPagesMeasured); case blink::mojom::UseCounterFeatureType:: kPermissionsPolicyViolationEnforce: + case blink::mojom::UseCounterFeatureType::kPermissionsPolicyHeader: + case blink::mojom::UseCounterFeatureType::kPermissionsPolicyIframeAttribute: return feature.value() == static_cast<blink::UseCounterFeature::EnumValue>( blink::mojom::PermissionsPolicyFeature::kNotFound);
diff --git a/third_party/blink/common/use_counter/use_counter_feature_tracker.cc b/third_party/blink/common/use_counter/use_counter_feature_tracker.cc index e5b924b..010fe7ae 100644 --- a/third_party/blink/common/use_counter/use_counter_feature_tracker.cc +++ b/third_party/blink/common/use_counter/use_counter_feature_tracker.cc
@@ -24,6 +24,10 @@ return animated_css_properties_.test(feature.value()); case FeatureType::kPermissionsPolicyViolationEnforce: return violated_permissions_policy_features_.test(feature.value()); + case FeatureType::kPermissionsPolicyIframeAttribute: + return iframe_permissions_policy_features_.test(feature.value()); + case FeatureType::kPermissionsPolicyHeader: + return header_permissions_policy_features_.test(feature.value()); } } @@ -55,6 +59,16 @@ if (violated_permissions_policy_features_.test(i)) ret.push_back({FeatureType::kPermissionsPolicyViolationEnforce, i}); } + + for (uint32_t i = 0; i < iframe_permissions_policy_features_.size(); i++) { + if (iframe_permissions_policy_features_.test(i)) + ret.push_back({FeatureType::kPermissionsPolicyIframeAttribute, i}); + } + + for (uint32_t i = 0; i < header_permissions_policy_features_.size(); i++) { + if (header_permissions_policy_features_.test(i)) + ret.push_back({FeatureType::kPermissionsPolicyHeader, i}); + } return ret; } @@ -86,6 +100,12 @@ case FeatureType::kPermissionsPolicyViolationEnforce: violated_permissions_policy_features_[feature.value()] = value; break; + case FeatureType::kPermissionsPolicyIframeAttribute: + iframe_permissions_policy_features_[feature.value()] = value; + break; + case FeatureType::kPermissionsPolicyHeader: + header_permissions_policy_features_[feature.value()] = value; + break; } }
diff --git a/third_party/blink/public/common/use_counter/use_counter_feature_tracker.h b/third_party/blink/public/common/use_counter/use_counter_feature_tracker.h index b360bee2..51e2600 100644 --- a/third_party/blink/public/common/use_counter/use_counter_feature_tracker.h +++ b/third_party/blink/public/common/use_counter/use_counter_feature_tracker.h
@@ -41,6 +41,14 @@ std::bitset<static_cast<size_t>(mojom::PermissionsPolicyFeature::kMaxValue) + 1> violated_permissions_policy_features_; + std::bitset<static_cast<size_t>( + blink::mojom::PermissionsPolicyFeature::kMaxValue) + + 1> + iframe_permissions_policy_features_; + std::bitset<static_cast<size_t>( + blink::mojom::PermissionsPolicyFeature::kMaxValue) + + 1> + header_permissions_policy_features_; }; } // namespace blink
diff --git a/third_party/blink/public/mojom/use_counter/use_counter_feature.mojom b/third_party/blink/public/mojom/use_counter/use_counter_feature.mojom index 2f54503..e5378ae 100644 --- a/third_party/blink/public/mojom/use_counter/use_counter_feature.mojom +++ b/third_party/blink/public/mojom/use_counter/use_counter_feature.mojom
@@ -15,6 +15,10 @@ kAnimatedCssProperty, // Blink.UseCounter.PermissionsPolicy.Violation.Enforce kPermissionsPolicyViolationEnforce, + // Blink.UseCounter.PermissionsPolicy.Allow + kPermissionsPolicyIframeAttribute, + // Blink.UseCounter.PermissionsPolicy.Header + kPermissionsPolicyHeader, }; // This struct corresponds to `blink::UseCounterFeature`.
diff --git a/third_party/blink/renderer/core/animation/css/css_animations.cc b/third_party/blink/renderer/core/animation/css/css_animations.cc index 6ae82948..64eee0f3 100644 --- a/third_party/blink/renderer/core/animation/css/css_animations.cc +++ b/third_party/blink/renderer/core/animation/css/css_animations.cc
@@ -86,7 +86,7 @@ namespace blink { -using PropertySet = HashSet<const CSSProperty*>; +using PropertySet = HashSet<CSSPropertyName>; namespace { @@ -329,12 +329,12 @@ // to animated properties. StringKeyframe* keyframe = keyframes[target_index]; for (const auto& property : rule_keyframe->Properties()) { - const CSSProperty& css_property = property.GetCSSProperty(); + CSSPropertyName property_name = property.GetCSSPropertyName(); // Since processing keyframes in reverse order, skipping properties that // have already been inserted prevents overwriting a later merged // keyframe. - if (current_offset_properties.Contains(&css_property)) + if (current_offset_properties.Contains(property_name)) continue; if (source_index != target_index) { @@ -343,12 +343,12 @@ rule_keyframe->CssPropertyValue(property)); } - current_offset_properties.insert(&css_property); - animated_properties.insert(&css_property); + current_offset_properties.insert(property_name); + animated_properties.insert(property_name); if (keyframe_offset == 0) - start_properties.insert(&css_property); + start_properties.insert(property_name); else if (keyframe_offset == 1) - end_properties.insert(&css_property); + end_properties.insert(property_name); } }
diff --git a/third_party/blink/renderer/core/frame/local_dom_window.cc b/third_party/blink/renderer/core/frame/local_dom_window.cc index 480b9eab1..3037630 100644 --- a/third_party/blink/renderer/core/frame/local_dom_window.cc +++ b/third_party/blink/renderer/core/frame/local_dom_window.cc
@@ -438,8 +438,10 @@ mojom::blink::PermissionsPolicyFeature feature, mojom::blink::PolicyDisposition disposition, const String& message) const { - if (disposition == mojom::blink::PolicyDisposition::kEnforce) - CountPermissionsPolicyViolation(feature); + if (disposition == mojom::blink::PolicyDisposition::kEnforce) { + const_cast<LocalDOMWindow*>(this)->CountPermissionsPolicyUsage( + feature, UseCounterImpl::PermissionsPolicyUsageType::kViolation); + } if (!RuntimeEnabledFeatures::FeaturePolicyReportingEnabled(this)) return; @@ -600,13 +602,14 @@ loader->CountUse(feature); } -void LocalDOMWindow::CountPermissionsPolicyViolation( - mojom::blink::PermissionsPolicyFeature feature) const { +void LocalDOMWindow::CountPermissionsPolicyUsage( + mojom::blink::PermissionsPolicyFeature feature, + UseCounterImpl::PermissionsPolicyUsageType type) { if (!GetFrame()) return; if (auto* loader = GetFrame()->Loader().GetDocumentLoader()) { - loader->GetUseCounter().CountPermissionsPolicyViolation(feature, - *GetFrame()); + loader->GetUseCounter().CountPermissionsPolicyUsage(feature, type, + *GetFrame()); } }
diff --git a/third_party/blink/renderer/core/frame/local_dom_window.h b/third_party/blink/renderer/core/frame/local_dom_window.h index a7c0ead9..6aa8079 100644 --- a/third_party/blink/renderer/core/frame/local_dom_window.h +++ b/third_party/blink/renderer/core/frame/local_dom_window.h
@@ -43,6 +43,7 @@ #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/frame/dom_window.h" #include "third_party/blink/renderer/core/frame/local_frame.h" +#include "third_party/blink/renderer/core/frame/use_counter_impl.h" #include "third_party/blink/renderer/core/geometry/dom_rect.h" #include "third_party/blink/renderer/core/loader/frame_loader.h" #include "third_party/blink/renderer/core/scroll/scrollable_area.h" @@ -195,6 +196,11 @@ // iframe. A "site" is a scheme and registrable domain. void CountUseOnlyInCrossSiteIframe(mojom::blink::WebFeature feature); + // Count permissions policy feature usage through use counter. + void CountPermissionsPolicyUsage( + mojom::blink::PermissionsPolicyFeature feature, + UseCounterImpl::PermissionsPolicyUsageType type); + Document* InstallNewDocument(const DocumentInit&); // EventTarget overrides: @@ -460,12 +466,6 @@ // Return the viewport size including scrollbars. IntSize GetViewportSize() const; - // Count feature disabled by Permissions Policy through use counter. - // The method is marked const as its caller |ReportPermissionsPolicyViolation| - // is marked const. - void CountPermissionsPolicyViolation( - mojom::blink::PermissionsPolicyFeature feature) const; - Member<ScriptController> script_controller_; Member<Document> document_;
diff --git a/third_party/blink/renderer/core/frame/use_counter_impl.cc b/third_party/blink/renderer/core/frame/use_counter_impl.cc index f84a851..b60019603 100644 --- a/third_party/blink/renderer/core/frame/use_counter_impl.cc +++ b/third_party/blink/renderer/core/frame/use_counter_impl.cc
@@ -54,6 +54,20 @@ return mojom::blink::UseCounterFeatureType::kAnimatedCssProperty; } } + +mojom::blink::UseCounterFeatureType ToFeatureType( + UseCounterImpl::PermissionsPolicyUsageType type) { + switch (type) { + case UseCounterImpl::PermissionsPolicyUsageType::kViolation: + return mojom::blink::UseCounterFeatureType:: + kPermissionsPolicyViolationEnforce; + case UseCounterImpl::PermissionsPolicyUsageType::kHeader: + return mojom::blink::UseCounterFeatureType::kPermissionsPolicyHeader; + case UseCounterImpl::PermissionsPolicyUsageType::kIframeAttribute: + return mojom::blink::UseCounterFeatureType:: + kPermissionsPolicyIframeAttribute; + } +} } // namespace UseCounterMuteScope::UseCounterMuteScope(const Element& element) @@ -197,14 +211,14 @@ source_frame); } -void UseCounterImpl::CountPermissionsPolicyViolation( +void UseCounterImpl::CountPermissionsPolicyUsage( mojom::blink::PermissionsPolicyFeature feature, + PermissionsPolicyUsageType usage_type, const LocalFrame& source_frame) { DCHECK_NE(mojom::blink::PermissionsPolicyFeature::kNotFound, feature); - Count( - {mojom::blink::UseCounterFeatureType::kPermissionsPolicyViolationEnforce, - static_cast<uint32_t>(feature)}, - &source_frame); + + Count({ToFeatureType(usage_type), static_cast<uint32_t>(feature)}, + &source_frame); } void UseCounterImpl::NotifyFeatureCounted(WebFeature feature) { @@ -285,6 +299,8 @@ break; case mojom::blink::UseCounterFeatureType:: kPermissionsPolicyViolationEnforce: + case mojom::blink::UseCounterFeatureType::kPermissionsPolicyHeader: + case mojom::blink::UseCounterFeatureType::kPermissionsPolicyIframeAttribute: // TODO(crbug.com/1206004): Add trace event for permissions policy metrics // gathering. return;
diff --git a/third_party/blink/renderer/core/frame/use_counter_impl.h b/third_party/blink/renderer/core/frame/use_counter_impl.h index 1ec525d..05e2a97 100644 --- a/third_party/blink/renderer/core/frame/use_counter_impl.h +++ b/third_party/blink/renderer/core/frame/use_counter_impl.h
@@ -87,6 +87,13 @@ // distinguish them. enum class CSSPropertyType { kDefault, kAnimation }; + enum class PermissionsPolicyUsageType { + kViolation, // Feature request denied by permissions policy. + kHeader, // Feature used in either Permissions-Policy or Feature-Policy + // HTTP header. + kIframeAttribute, // Feature used in 'allow' attribute on iframe element. + }; + explicit UseCounterImpl(Context = kDefaultContext, CommitState = kPreCommit); UseCounterImpl(const UseCounterImpl&) = delete; UseCounterImpl& operator=(const UseCounterImpl&) = delete; @@ -107,8 +114,9 @@ // Repeated calls are ignored. void Count(CSSPropertyID, CSSPropertyType, const LocalFrame*); void Count(WebFeature, const LocalFrame*); - void CountPermissionsPolicyViolation(mojom::blink::PermissionsPolicyFeature, - const LocalFrame&); + void CountPermissionsPolicyUsage(mojom::blink::PermissionsPolicyFeature, + PermissionsPolicyUsageType, + const LocalFrame&); // Return whether the feature has been seen since the last page load // (except when muted). Does include features seen in documents which have
diff --git a/third_party/blink/renderer/core/html/forms/resources/month_picker.js b/third_party/blink/renderer/core/html/forms/resources/month_picker.js index 0857c979..9d6051a 100644 --- a/third_party/blink/renderer/core/html/forms/resources/month_picker.js +++ b/third_party/blink/renderer/core/html/forms/resources/month_picker.js
@@ -36,6 +36,10 @@ this.append(this.yearListView_.element); this.initializeYearListView_(); + this.clearButton_ = new ClearButton(); + this.append(this.clearButton_.element); + this.initializeClearButton_(); + this.todayButton_ = new CalendarNavigationButton(); this.append(this.todayButton_.element); this.initializeTodayButton_(); @@ -85,6 +89,18 @@ window.pagePopupController.setValueAndClosePopup(0, selectedValue); }; + initializeClearButton_ = () => { + this.clearButton_.element.textContent = global.params.clearLabel; + this.clearButton_.element.setAttribute( + 'aria-label', global.params.clearLabel); + this.clearButton_.on( + ClearButton.EventTypeButtonClick, this.onClearButtonClick_); + }; + + onClearButtonClick_ = () => { + window.pagePopupController.setValueAndClosePopup(0, ''); + }; + initializeTodayButton_ = () => { this.todayButton_.element.textContent = global.params.todayLabel; this.todayButton_.element.setAttribute( @@ -106,9 +122,11 @@ onKeyDown_ = (event) => { switch (event.key) { case 'Enter': - // Don't do anything here if user has hit Enter on 'This month' - // button. We'll handle that in this.onTodayButtonClick_. - if (!event.target.matches('.calendar-navigation-button')) { + // Don't do anything here if user has hit Enter on 'Clear' or + // 'This month' buttons. We'll handle that respectively in + // this.onClearButtonClick_ and this.onTodayButtonClick_. + if (!event.target.matches( + '.calendar-navigation-button, .clear-button')) { if (this.selectedMonth) { window.pagePopupController.setValueAndClosePopup( 0, this.selectedMonth.toString());
diff --git a/third_party/blink/renderer/core/permissions_policy/permissions_policy_parser.cc b/third_party/blink/renderer/core/permissions_policy/permissions_policy_parser.cc index 9fa468e..1ad8188 100644 --- a/third_party/blink/renderer/core/permissions_policy/permissions_policy_parser.cc +++ b/third_party/blink/renderer/core/permissions_policy/permissions_policy_parser.cc
@@ -11,6 +11,7 @@ #include "net/http/structured_headers.h" #include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/web_feature.h" #include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h" #include "third_party/blink/renderer/core/origin_trials/origin_trials.h" @@ -18,6 +19,7 @@ #include "third_party/blink/renderer/platform/json/json_values.h" #include "third_party/blink/renderer/platform/network/http_parsers.h" #include "third_party/blink/renderer/platform/weborigin/security_origin.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h" #include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h" #include "url/origin.h" @@ -131,6 +133,7 @@ ParsedAllowlist ParseAllowlist(const Vector<String>& origin_strings); void ReportFeatureUsage(mojom::blink::PermissionsPolicyFeature feature); + void ReportFeatureUsageLegacy(mojom::blink::PermissionsPolicyFeature feature); // This function should be called after Allowlist Histograms related flags // have been captured. @@ -147,6 +150,9 @@ scoped_refptr<const SecurityOrigin> self_origin_; scoped_refptr<const SecurityOrigin> src_origin_; const FeatureNameMap& feature_names_; + // `execution_context_` is used for reporting various WebFeatures + // during the parsing process. + // `execution_context_` should only be `nullptr` in tests. ExecutionContext* execution_context_; // Flags for the types of items which can be used in allowlists. @@ -171,7 +177,9 @@ } } -void ParsingContext::ReportFeatureUsage( +// TODO: Remove this function once we verified the new histogram counts +// are consistent with old ones. +void ParsingContext::ReportFeatureUsageLegacy( mojom::blink::PermissionsPolicyFeature feature) { if (src_origin_) { if (!execution_context_ || @@ -184,6 +192,20 @@ } } +void ParsingContext::ReportFeatureUsage( + mojom::blink::PermissionsPolicyFeature feature) { + if (!execution_context_ || !execution_context_->IsWindow()) + return; + + LocalDOMWindow* local_dom_window = To<LocalDOMWindow>(execution_context_); + + auto usage_type = + src_origin_ ? UseCounterImpl::PermissionsPolicyUsageType::kIframeAttribute + : UseCounterImpl::PermissionsPolicyUsageType::kHeader; + + local_dom_window->CountPermissionsPolicyUsage(feature, usage_type); +} + void ParsingContext::RecordAllowlistTypeUsage(size_t origin_count) { // Record the type of allowlist used. if (origin_count == 0) { @@ -391,6 +413,7 @@ ParseFeature(declaration_node); if (parsed_feature) { ReportFeatureUsage(parsed_feature->feature); + ReportFeatureUsageLegacy(parsed_feature->feature); parsed_policy.push_back(*parsed_feature); } }
diff --git a/third_party/blink/renderer/modules/webcodecs/video_encoder.cc b/third_party/blink/renderer/modules/webcodecs/video_encoder.cc index a2efc862..c35ffaa 100644 --- a/third_party/blink/renderer/modules/webcodecs/video_encoder.cc +++ b/third_party/blink/renderer/modules/webcodecs/video_encoder.cc
@@ -10,6 +10,7 @@ #include "base/callback.h" #include "base/callback_helpers.h" #include "base/cxx17_backports.h" +#include "base/feature_list.h" #include "base/logging.h" #include "base/macros.h" #include "base/metrics/histogram_macros.h" @@ -57,6 +58,7 @@ #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h" +#include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_video_frame_pool.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" @@ -382,6 +384,23 @@ return result; } +#if defined(OS_MAC) +const base::Feature kWebCodecsEncoderGpuMemoryBufferReadback{ + "WebCodecsEncoderGpuMemoryBufferReadback", + base::FEATURE_ENABLED_BY_DEFAULT}; +#endif + +bool CanUseGpuMemoryBufferReadback(media::VideoPixelFormat format) { +#if defined(OS_MAC) + // GMB readback only works with NV12, so only opaque buffers can be used. + return (format == media::PIXEL_FORMAT_XBGR || + format == media::PIXEL_FORMAT_XRGB) && + base::FeatureList::IsEnabled(kWebCodecsEncoderGpuMemoryBufferReadback); +#else + return false; +#endif +} + } // namespace // static @@ -582,19 +601,73 @@ // Currently underlying encoders can't handle frame backed by textures, // so let's readback pixel data to CPU memory. + // TODO(crbug.com/1229845): We shouldn't be reading back frames here. if (frame->HasTextures() && !frame->HasGpuMemoryBuffer()) { - scoped_refptr<viz::RasterContextProvider> raster_provider; - auto wrapper = SharedGpuContext::ContextProviderWrapper(); - if (wrapper && wrapper->ContextProvider()) - raster_provider = wrapper->ContextProvider()->RasterContextProvider(); - if (raster_provider) { - auto* ri = raster_provider->RasterInterface(); - auto* gr_context = raster_provider->GrContext(); + const bool can_use_gmb = CanUseGpuMemoryBufferReadback(frame->format()); + if (can_use_gmb && !accelerated_frame_pool_) { + if (auto wrapper = SharedGpuContext::ContextProviderWrapper()) { + accelerated_frame_pool_ = + std::make_unique<WebGraphicsContext3DVideoFramePool>(wrapper); + } + } - frame = ReadbackTextureBackedFrameToMemorySync(*frame, ri, gr_context, - &readback_frame_pool_); + if (can_use_gmb && accelerated_frame_pool_) { + // This will execute shortly after CopyRGBATextureToVideoFrame() + // completes. |stall_request_processing_| = true will ensure that + // HasPendingActivity() keeps the VideoEncoder alive long enough. + auto blit_done_callback = [](VideoEncoder* self, bool keyframe, + media::VideoEncoder::StatusCB done_callback, + scoped_refptr<media::VideoFrame> frame) { + --self->requested_encodes_; + self->stall_request_processing_ = false; + self->media_encoder_->Encode(std::move(frame), keyframe, + std::move(done_callback)); + }; + + auto origin = frame->metadata().texture_origin_is_top_left + ? kTopLeft_GrSurfaceOrigin + : kBottomLeft_GrSurfaceOrigin; + + // TODO(crbug.com/1224279): This assumes that all frames are 8-bit sRGB. + // Expose the color space and pixel format that is backing + // `image->GetMailboxHolder()`, or, alternatively, expose an accelerated + // SkImage. + auto format = frame->format() == media::PIXEL_FORMAT_XBGR + ? viz::ResourceFormat::RGBA_8888 + : viz::ResourceFormat::BGRA_8888; + + // Stall request processing while we wait for the copy to complete. It'd + // be nice to not have to do this, but currently the request processing + // loop must execute synchronously or flush() will miss frames. Also it + // ensures the VideoEncoder remains alive while the copy completes. + stall_request_processing_ = true; + if (accelerated_frame_pool_->CopyRGBATextureToVideoFrame( + format, frame->coded_size(), gfx::ColorSpace::CreateSRGB(), + origin, frame->mailbox_holder(0), + WTF::Bind(blit_done_callback, WrapWeakPersistent(this), keyframe, + ConvertToBaseOnceCallback(CrossThreadBindOnce( + done_callback, WrapCrossThreadWeakPersistent(this), + WrapCrossThreadPersistent(request)))))) { + request->input->close(); + return; + } + + // Error occurred, fall through to error handling below. + stall_request_processing_ = false; } else { - frame.reset(); + auto wrapper = SharedGpuContext::ContextProviderWrapper(); + scoped_refptr<viz::RasterContextProvider> raster_provider; + if (wrapper && wrapper->ContextProvider()) + raster_provider = wrapper->ContextProvider()->RasterContextProvider(); + if (raster_provider) { + auto* ri = raster_provider->RasterInterface(); + auto* gr_context = raster_provider->GrContext(); + + frame = ReadbackTextureBackedFrameToMemorySync(*frame, ri, gr_context, + &readback_frame_pool_); + } else { + frame.reset(); + } } if (!frame) {
diff --git a/third_party/blink/renderer/modules/webcodecs/video_encoder.h b/third_party/blink/renderer/modules/webcodecs/video_encoder.h index ad1d24be..d5a0e7e 100644 --- a/third_party/blink/renderer/modules/webcodecs/video_encoder.h +++ b/third_party/blink/renderer/modules/webcodecs/video_encoder.h
@@ -28,6 +28,7 @@ class VideoEncoderConfig; class VideoEncoderInit; class VideoEncoderEncodeOptions; +class WebGraphicsContext3DVideoFramePool; class MODULES_EXPORT VideoEncoderTraits { public: @@ -108,6 +109,7 @@ scoped_refptr<media::VideoFrame> txt_frame); media::VideoFramePool readback_frame_pool_; + std::unique_ptr<WebGraphicsContext3DVideoFramePool> accelerated_frame_pool_; // The number of encoding requests currently handled by |media_encoder_| // Should not exceed |kMaxActiveEncodes|.
diff --git a/third_party/blink/web_tests/FlagExpectations/enable-features=BackForwardCache b/third_party/blink/web_tests/FlagExpectations/enable-features=BackForwardCache index 664a396..78465d4 100644 --- a/third_party/blink/web_tests/FlagExpectations/enable-features=BackForwardCache +++ b/third_party/blink/web_tests/FlagExpectations/enable-features=BackForwardCache
@@ -2,15 +2,6 @@ # tags: [ Release Debug ] # results: [ Timeout Crash Pass Failure Slow Skip ] -# Tests that are not compatible with same-site back-forward cache. To run these -# tests, we have to disable same-site back-forward cache. -crbug.com/1132180 http/tests/history/dynamic-frame-creation-order-inline-scripts.html [ Skip ] -crbug.com/1132180 http/tests/history/dynamic-frame-creation-order-onload-handler.html [ Skip ] -crbug.com/1132180 http/tests/misc/resource-timing-iframe-restored-from-history.html [ Skip ] -crbug.com/1132180 http/tests/misc/resource-timing-navigation-in-restored-iframe.html [ Skip ] -crbug.com/1132180 http/tests/navigation/back-to-dynamic-iframe.html [ Skip ] -crbug.com/1132180 http/tests/navigation/forward-to-fragment-fires-onload.html [ Skip ] - # TODO(peria): Make these tests work with same-site back-forward cache. crbug.com/1155125 http/tests/history/replacestate-post-to-get-2.html [ Timeout ]
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 605c4e4..2bd1b7f 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -6206,6 +6206,9 @@ crbug.com/1032451 virtual/threaded-no-composited-antialiasing/animations/stability/animation-iteration-event-destroy-renderer.html [ Pass Timeout ] crbug.com/931646 [ Mac ] http/tests/preload/meta-viewport-link-headers-imagesrcset.html [ Failure Pass ] +# Temporarily disabled to unblock https://crrev.com/c/3067319 +crbug.com/1199247 http/tests/devtools/console/console-log-side-effects.js [ Failure Pass ] + # Win7 suggestion picker appearance tests have a scrollbar flakiness issue crbug.com/1045510 [ Win7 ] fast/forms/suggestion-picker/date-suggestion-picker-appearance-rtl.html [ Failure Pass ] crbug.com/1045510 [ Win7 ] fast/forms/suggestion-picker/date-suggestion-picker-appearance-with-scroll-bar.html [ Failure Pass ] @@ -7076,9 +7079,6 @@ crbug.com/1218431 [ Mac ] virtual/file-system-access-access-handle/external/wpt/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker.html [ Failure Pass ] crbug.com/1218431 [ Mac ] virtual/file-system-access-access-handle/external/wpt/file-system-access/sandboxed_FileSystemSyncAccessHandle-truncate.https.tentative.worker.html [ Failure Pass ] -# DevTools roll -crbug.com/1187573 http/tests/devtools/throttling/mobile-throttling.js [ Skip ] - # Sheriff 2021-06-30 crbug.com/1216587 [ Win7 ] accessibility/scroll-window-sends-notification.html [ Failure Pass ]
diff --git a/third_party/blink/web_tests/external/wpt/css/css-animations/keyframes-unrelated-custom-property.html b/third_party/blink/web_tests/external/wpt/css/css-animations/keyframes-unrelated-custom-property.html new file mode 100644 index 0000000..c9ba768 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-animations/keyframes-unrelated-custom-property.html
@@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>Unrelated custom properties do not conflict with each other</title> +<link rel="help" href="https://drafts.csswg.org/css-animations/"> +<link rel="help" href="https://crbug.com/1236043"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + @keyframes test { + 0% { --x: green; } + 100% { --x: green; } + + /* This should not affect the background-color of #div: */ + 0% { --unused: yellow; } + } + #div { + animation: test 10s linear paused; + background-color: var(--x, red); + width: 100px; + height: 100px; + } +</style> +<div id=div></div> +<script> + +test(() => { + assert_equals(getComputedStyle(div).backgroundColor, 'rgb(0, 128, 0)'); +}, 'Unrelated custom properties do not conflict with each other'); + +</script>
diff --git a/third_party/blink/web_tests/external/wpt/fetch/http-cache/http-cache.js b/third_party/blink/web_tests/external/wpt/fetch/http-cache/http-cache.js index a47081b9..19f1ca9 100644 --- a/third_party/blink/web_tests/external/wpt/fetch/http-cache/http-cache.js +++ b/third_party/blink/web_tests/external/wpt/fetch/http-cache/http-cache.js
@@ -122,7 +122,9 @@ 'headers': [] } if ('request_method' in config) init.method = config['request_method'] - if ('request_headers' in config) init.headers = config['request_headers'] + // Note: init.headers must be a copy of config['request_headers'] array, + // because new elements are added later. + if ('request_headers' in config) init.headers = [...config['request_headers']]; if ('name' in config) init.headers.push(['Test-Name', config.name]) if ('request_body' in config) init.body = config['request_body'] if ('mode' in config) init.mode = config['mode']
diff --git a/third_party/blink/web_tests/fast/forms/calendar-picker/calendar-picker-clear-button.html b/third_party/blink/web_tests/fast/forms/calendar-picker/calendar-picker-clear-button.html index 12a24c5..947b1f95 100644 --- a/third_party/blink/web_tests/fast/forms/calendar-picker/calendar-picker-clear-button.html +++ b/third_party/blink/web_tests/fast/forms/calendar-picker/calendar-picker-clear-button.html
@@ -27,7 +27,7 @@ assert_equals(element.value, "", "Clear button should have updated in-page control to empty string."); assert_equals(internals.pagePopupWindow, null, "Click on Clear button should close popup."); }); - }, `Calendar picker: Clear button for input[type="${inputType}""] should clear date`); + }, `Calendar picker: Clear button for input[type="${inputType}"] should clear date`); } </script>
diff --git a/third_party/blink/web_tests/fast/forms/calendar-picker/month-picker-clear-button.html b/third_party/blink/web_tests/fast/forms/calendar-picker/month-picker-clear-button.html new file mode 100644 index 0000000..8e71340 --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/calendar-picker/month-picker-clear-button.html
@@ -0,0 +1,31 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../../resources/testharness.js"></script> +<script src="../../../resources/testharnessreport.js"></script> +<script src="../resources/common.js"></script> +<script src="../resources/picker-common.js"></script> +<script src="../calendar-picker/resources/calendar-picker-common.js"></script> +</head> +<body> +<input type="month" value="2021-07"> +<script> + +promise_test(() => { + let element = document.querySelector('input[type="month"]'); + return openPickerWithPromise(element) + .then(() => { + // Make the picker dismiss synchronously so we don't need to insert + // an artificial delay in the test + internals.pagePopupWindow.CalendarPicker.commitDelayMs = 0; + + clickClearMonthButton(); + + assert_equals(element.value, "", "Clear button should have updated in-page control to empty string."); + assert_equals(internals.pagePopupWindow, null, "Click on Clear button should close popup."); + }); +}, `Calendar picker: Clear button for input[type="month"] should clear date`); + +</script> +</body> +</html>
diff --git a/third_party/blink/web_tests/fast/forms/calendar-picker/resources/calendar-picker-common.js b/third_party/blink/web_tests/fast/forms/calendar-picker/resources/calendar-picker-common.js index 21c02f9..770c5c2 100644 --- a/third_party/blink/web_tests/fast/forms/calendar-picker/resources/calendar-picker-common.js +++ b/third_party/blink/web_tests/fast/forms/calendar-picker/resources/calendar-picker-common.js
@@ -203,10 +203,9 @@ eventSender.mouseUp(); } -function skipAnimationAndGetPositionOfThisMonthButton() { +function skipAnimationAndGetPositionOfGlobalPickerButton(selector) { skipAnimation(); - const button = - popupWindow.global.picker.querySelector('.today-button'); + const button = popupWindow.global.picker.querySelector(selector); var offset = cumulativeOffset(button); return { x: offset[0] + button.offsetWidth / 2, @@ -214,8 +213,21 @@ }; } +function hoverOverClearMonthButton() { + var position = + skipAnimationAndGetPositionOfGlobalPickerButton('.clear-button'); + eventSender.mouseMoveTo(position.x, position.y); +} + +function clickClearMonthButton() { + hoverOverClearMonthButton(); + eventSender.mouseDown(); + eventSender.mouseUp(); +} + function hoverOverThisMonthButton() { - var position = skipAnimationAndGetPositionOfThisMonthButton(); + var position = + skipAnimationAndGetPositionOfGlobalPickerButton('.today-button'); eventSender.mouseMoveTo(position.x, position.y); }
diff --git a/third_party/blink/web_tests/fast/forms/month/month-picker-this-month-button.html b/third_party/blink/web_tests/fast/forms/month/month-picker-this-month-button.html index 7adcb4d..43181d5 100644 --- a/third_party/blink/web_tests/fast/forms/month/month-picker-this-month-button.html +++ b/third_party/blink/web_tests/fast/forms/month/month-picker-this-month-button.html
@@ -34,6 +34,7 @@ let monthElement = document.getElementById('month1'); return openPickerWithPromise(monthElement) .then(() => { + eventSender.keyDown('Tab'); // Tab over to the 'Clear' button eventSender.keyDown('Tab'); // Tab over to the 'This month' button eventSender.keyDown('Enter');
diff --git a/third_party/blink/web_tests/fast/scrolling/scrollbars/mouse-autoscrolling-on-deleted-scrollbar.html b/third_party/blink/web_tests/fast/scrolling/scrollbars/mouse-autoscrolling-on-deleted-scrollbar.html index b100701..5befaeb 100644 --- a/third_party/blink/web_tests/fast/scrolling/scrollbars/mouse-autoscrolling-on-deleted-scrollbar.html +++ b/third_party/blink/web_tests/fast/scrolling/scrollbars/mouse-autoscrolling-on-deleted-scrollbar.html
@@ -6,9 +6,8 @@ <script src="../../../resources/scrollbar-util.js"></script> <div id="content" style="height: 10000px; width: 10000px; border: 1px solid;"></div> <script> + function resetScroller() { - window.removeEventListener("scroll", shortenHorizontalScroller); - window.removeEventListener("scroll", shortenVerticalScroller); window.scrollTo(0, 0); document.getElementById("content").style.width = "10000px"; document.getElementById("content").style.height = "10000px"; @@ -25,31 +24,44 @@ document.getElementById("content").style.height = "10px"; } + function createScrollPromise(callback) { + return new Promise((resolve, reject) => { + waitForScrollEvent(window).then(() => { + callback(); + resolve(); + }); + }); + } + // When pointerdown occurs, an autoscroll task gets scheduled to be // executed after 250ms. This code checks that the renderer doesn't // crash when the scrollbar is dynamically deleted while an auto // scroll task is scheduled. promise_test (async () => { + await waitForCompositorCommit(); resetScroller(); assert_equals(document.documentElement.style.overflowY, "visible", "Scroller is expected to be scrollable in the Y direction"); - window.addEventListener("scroll", shortenVerticalScroller); + const scrollPromise = createScrollPromise(shortenVerticalScroller); await mousePressOn(downArrow().x, downArrow().y, 300); + await scrollPromise; assert_equals(document.getElementById("content").style.height, "10px", "Scroller height should have been reduced to 10px."); },"Test same-axis autoscroll when vertical scrollbar deleted."); promise_test (async () => { + await waitForCompositorCommit(); resetScroller(); assert_equals(document.documentElement.style.overflowY, "visible", "Scroller is expected to be scrollable in the Y direction"); - window.addEventListener("scroll", shortenHorizontalScroller); + const scrollPromise = createScrollPromise(shortenHorizontalScroller); await mousePressOn(downArrow().x, downArrow().y, 300); + await scrollPromise; assert_equals(document.getElementById("content").style.width, "10px", "Scroller width should have been reduced to 10px."); },"Test cross-axis autoscroll when vertical scrollbar deleted."); -</script> \ No newline at end of file +</script>
diff --git a/third_party/blink/web_tests/flag-specific/disable-layout-ng/fast/forms/month/month-picker-appearance-zoom150-expected.png b/third_party/blink/web_tests/flag-specific/disable-layout-ng/fast/forms/month/month-picker-appearance-zoom150-expected.png index 6dc9022..9b5df1a 100644 --- a/third_party/blink/web_tests/flag-specific/disable-layout-ng/fast/forms/month/month-picker-appearance-zoom150-expected.png +++ b/third_party/blink/web_tests/flag-specific/disable-layout-ng/fast/forms/month/month-picker-appearance-zoom150-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-expected.png index ca172fab..a0f53b2 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-step-expected.png index 3b06378d..3b5ba6e 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/calendar-picker/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 6efc94c..5b966af 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 861db16..8d376e43 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index 401403a..aa0a90f 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-disabled-today-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-disabled-today-expected.png index 1019c07..f51c371d 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-disabled-today-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-disabled-today-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-rtl-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-rtl-expected.png index 02fc57c..2e95750 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-rtl-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-rtl-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-step-expected.png index 5b3aa0a..450b5e5 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png index 97df6e1d..fbb9830 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-zoom150-expected.png b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-zoom150-expected.png index 5e66ae81..5d885e5d 100644 --- a/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-zoom150-expected.png +++ b/third_party/blink/web_tests/flag-specific/highdpi/fast/forms/month/month-picker-appearance-zoom150-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/http/tests/devtools/throttling/mobile-throttling.js b/third_party/blink/web_tests/http/tests/devtools/throttling/mobile-throttling.js index 7a448ed2..9edbaf3b 100644 --- a/third_party/blink/web_tests/http/tests/devtools/throttling/mobile-throttling.js +++ b/third_party/blink/web_tests/http/tests/devtools/throttling/mobile-throttling.js
@@ -25,7 +25,7 @@ TestRunner.addResult('=== THROTTLING STATE ==='); var {download, upload, latency} = SDK.multitargetNetworkManager.networkConditions(); TestRunner.addResult(`Network throttling - download: ${Math.round(download)} upload: ${Math.round(upload)} latency: ${latency}`); - TestRunner.addResult('CPU throttling rate: ' + MobileThrottling.throttlingManager().cpuThrottlingRate()); + TestRunner.addResult('CPU throttling rate: ' + SDK.CPUThrottlingManager.instance().cpuThrottlingRate()); TestRunner.addResult('Device mode throttling: ' + deviceModeThrottling._text); TestRunner.addResult('Network panel throttling: ' + networkPanelThrottling.selectedOption().text); TestRunner.addResult('Network conditions drawer throttling: ' + networkConditionsDrawerThrottlingSelector.value); @@ -58,11 +58,11 @@ dumpThrottlingState(); TestRunner.addResult('Change CPU throttling to low-end mobile'); - MobileThrottling.throttlingManager().setCPUThrottlingRate(MobileThrottling.CPUThrottlingRates.LowEndMobile); + MobileThrottling.throttlingManager().setCPUThrottlingRate(SDK.CPUThrottlingManager.CPUThrottlingRates.LowEndMobile); dumpThrottlingState(); TestRunner.addResult('Change CPU throttling to mid-tier mobile'); - MobileThrottling.throttlingManager().setCPUThrottlingRate(MobileThrottling.CPUThrottlingRates.MidTierMobile); + MobileThrottling.throttlingManager().setCPUThrottlingRate(SDK.CPUThrottlingManager.CPUThrottlingRates.MidTierMobile); dumpThrottlingState(); TestRunner.addResult('Change to no throttling in device mode');
diff --git a/third_party/blink/web_tests/http/tests/history/.htaccess b/third_party/blink/web_tests/http/tests/history/.htaccess index d9793405..0c64a7af 100644 --- a/third_party/blink/web_tests/http/tests/history/.htaccess +++ b/third_party/blink/web_tests/http/tests/history/.htaccess
@@ -3,3 +3,13 @@ <Files "cross-origin-redirect-on-back.html"> Header set Cache-Control "no-store" </Files> +# dynamic-frame-creation-order-inline-scripts.html is not compatible with back-forward cache. +# The following setting disables back-forward cache. +<Files "dynamic-frame-creation-order-inline-scripts.html"> +Header set Cache-Control "no-store" +</Files> +# dynamic-frame-creation-order-onload-handler.html is not compatible with back-forward cache. +# The following setting disables back-forward cache. +<Files "dynamic-frame-creation-order-onload-handler.html"> +Header set Cache-Control "no-store" +</Files>
diff --git a/third_party/blink/web_tests/http/tests/misc/.htaccess b/third_party/blink/web_tests/http/tests/misc/.htaccess index 7853a29..8ad99c6 100644 --- a/third_party/blink/web_tests/http/tests/misc/.htaccess +++ b/third_party/blink/web_tests/http/tests/misc/.htaccess
@@ -5,3 +5,13 @@ ForceType "text/css; charset=utf-8" </Files> +# resource-timing-iframe-restored-from-history.html is not compatible with back-forward cache. +# The following setting disables back-forward cache. +<Files "resource-timing-iframe-restored-from-history.html"> +Header set Cache-Control "no-store" +</Files> +# resource-timing-navigation-in-restored-iframe.html is not compatible with back-forward cache. +# The following setting disables back-forward cache. +<Files "resource-timing-navigation-in-restored-iframe.html"> +Header set Cache-Control "no-store" +</Files>
diff --git a/third_party/blink/web_tests/http/tests/navigation/.htaccess b/third_party/blink/web_tests/http/tests/navigation/.htaccess new file mode 100644 index 0000000..3a1a68ca --- /dev/null +++ b/third_party/blink/web_tests/http/tests/navigation/.htaccess
@@ -0,0 +1,10 @@ +# back-to-dynamic-iframe.html is not compatible with back-forward cache. +# The following setting disables back-forward cache. +<Files "back-to-dynamic-iframe.html"> +Header set Cache-Control "no-store" +</Files> +# forward-to-fragment-fires-onload.html is not compatible with back-forward cache. +# The following setting disables back-forward cache. +<Files "forward-to-fragment-fires-onload.html"> +Header set Cache-Control "no-store" +</Files>
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png index 6c9b83fa..77a3992 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png index af26305..78f307ae 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 04a2cfd37..5a6ae80 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 1db632a..83edb14 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index 7b3e1f1..8e01d4dc 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-disabled-today-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-disabled-today-expected.png index 94a2cfc..2f6edd0 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-disabled-today-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-disabled-today-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-rtl-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-rtl-expected.png index 619d760..254e1fc 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-rtl-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-rtl-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-step-expected.png index f43db67..0bda3215 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png index d637ed5..79d7bc49 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-zoom150-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-zoom150-expected.png index e39ef4d..d58965d9 100644 --- a/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-zoom150-expected.png +++ b/third_party/blink/web_tests/platform/linux/fast/forms/month/month-picker-appearance-zoom150-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 14532d9..679fa66 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 144a8c6..f6d823d 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index 37d8063..28aca2e6 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 0368f08a..28884fd3 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 77197be3..3663643a 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index fbeff77..33e096c 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-expected.png index 41ae275..8b08e354 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-step-expected.png index bba8ea2..cf866cd 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 9c89ab1f..b8b22e9 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index b27b88ee..aa3c8c6e 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index c58ffc9..cdde3703 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-disabled-today-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-disabled-today-expected.png index 2b2758a..85deb2a 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-disabled-today-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-disabled-today-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-rtl-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-rtl-expected.png index aaeb7d8a..ccb3667 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-rtl-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-rtl-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-step-expected.png index d05f229b..f9f0508 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png index d3f64ca..c0bac6c 100644 --- a/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png +++ b/third_party/blink/web_tests/platform/mac/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 571a8364..0ee8d1c 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 986d758..b51a996 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index b4d97d3..858a143 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index ba64367..dd2b013 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index ad5c932..1771e9b 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index cfda00d..25c4d9a6 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png index 95d5617..cd99842 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png index 1e13a544..0709ed9 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 3a2084d..4fefc39 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 7162b27..8fbbd9a 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index b7006d3..0715a88 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-disabled-today-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-disabled-today-expected.png index 271a8584..d6cb3ae 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-disabled-today-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-disabled-today-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-rtl-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-rtl-expected.png index 5b8e03e..3224caa 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-rtl-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-rtl-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-step-expected.png index c78d312b..0a84ae2 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png index 6b09cb2..e588a68 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-zoom150-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-zoom150-expected.png index 433a8e9..fe1ae76 100644 --- a/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-zoom150-expected.png +++ b/third_party/blink/web_tests/platform/win/fast/forms/month/month-picker-appearance-zoom150-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 362481e4..f9e20f33 100644 --- a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 0c9e91f..0262c356 100644 --- a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index f8ddf3a..5c797fd 100644 --- a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 66f1410..9cefea7 100644 --- a/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 27b34da..4fc483b 100644 --- a/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index 36984bf..98de2ad 100644 --- a/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/win/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png index 78c20a88..09b719a5 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png index 3321a05..11c6b400 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 5c7d801..eb3af14 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 32efe7020..bf39923 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index 177c1eb..b1dfd141 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-disabled-today-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-disabled-today-expected.png index a1a0d85..6a9025936 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-disabled-today-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-disabled-today-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-rtl-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-rtl-expected.png index 75e1ce8..fb4fbb4 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-rtl-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-rtl-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-step-expected.png index 244fc432..3d54765c 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-step-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-step-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png index a377ddd..284610e 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-value-not-in-interval-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-zoom150-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-zoom150-expected.png index 27157e7..4e83fd5 100644 --- a/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-zoom150-expected.png +++ b/third_party/blink/web_tests/platform/win7/fast/forms/month/month-picker-appearance-zoom150-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 901360a..88490f7 100644 --- a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 6cff5e6..3a3c840 100644 --- a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index 1f29e9f..6e18317 100644 --- a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png b/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png index 002b8bf..869ecbc 100644 --- a/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png +++ b/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-disabled-values-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png index 2d9f571b..51d4fa2 100644 --- a/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png b/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png index 7c1b716..c7012f1e 100644 --- a/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png +++ b/third_party/blink/web_tests/platform/win7/virtual/dark-color-scheme/fast/forms/color-scheme/month-picker/month-picker-appearance-highlight-expected.png Binary files differ
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 49b01db..3f8ae58 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -5162,6 +5162,16 @@ <int value="28" label="TILE_SUGGESTION"/> </enum> +<enum name="AutoDSEPermissionRevertTransition"> + <int value="0" label="NO_DECISION_ASK"/> + <int value="1" label="PRESERVE_ALLOW"/> + <int value="2" label="CONFLICT_ASK"/> + <int value="3" label="PRESERVE_BLOCK_ASK"/> + <int value="4" label="PRESERVE_BLOCK_ALLOW"/> + <int value="5" label="PRESERVE_BLOCK_BLOCK"/> + <int value="6" label="INVALID_END_STATE"/> +</enum> + <enum name="AutofillAddressProfileImportCountrySpecificFieldRequirement"> <int value="0" label="All required fields present"/> <int value="1" label="Missing: ZIP"/> @@ -10605,6 +10615,9 @@ </enum> <enum name="CaptivePortalProbeReason"> + <obsolete> + Removed from code 2021-08. + </obsolete> <int value="0" label="UNSPECIFIED"/> <int value="1" label="TIMEOUT"/> <int value="2" label="CERTIFICATE_ERROR"/>
diff --git a/tools/metrics/histograms/metadata/blink/histograms.xml b/tools/metrics/histograms/metadata/blink/histograms.xml index 73519ef..aad4e57 100644 --- a/tools/metrics/histograms/metadata/blink/histograms.xml +++ b/tools/metrics/histograms/metadata/blink/histograms.xml
@@ -3019,7 +3019,7 @@ <owner>feature-control@chromium.org</owner> <summary> Counts the use of a specific feature policy via the "allow" - attribute. Each policy is counted only once per page load. + attribute. Each policy is counted only once per document load. </summary> </histogram> @@ -3144,6 +3144,28 @@ </details> </histogram> +<histogram name="Blink.UseCounter.PermissionsPolicy.Allow" + enum="FeaturePolicyFeature" expires_after="2022-05-30"> + <owner>iclelland@chromium.org</owner> + <owner>feature-control@chromium.org</owner> + <summary> + Counts the use of a specific permissions policy feature via the + "allow" attribute on iframes. Each policy is counted only once per + page load. + </summary> +</histogram> + +<histogram name="Blink.UseCounter.PermissionsPolicy.Header" + enum="FeaturePolicyFeature" expires_after="2022-05-30"> + <owner>iclelland@chromium.org</owner> + <owner>feature-control@chromium.org</owner> + <summary> + Counts the use of a specific permissions policy feature via both + "Feature-Policy" and "Permissions-Policy" HTTP response + header. Each policy is counted only once per page load. + </summary> +</histogram> + <histogram name="Blink.UseCounter.PermissionsPolicy.Violation.Enforce" enum="FeaturePolicyFeature" expires_after="2021-10-31"> <owner>iclelland@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/browser/histograms.xml b/tools/metrics/histograms/metadata/browser/histograms.xml index 7989f970..2948b7b4 100644 --- a/tools/metrics/histograms/metadata/browser/histograms.xml +++ b/tools/metrics/histograms/metadata/browser/histograms.xml
@@ -538,7 +538,7 @@ </histogram> <histogram name="Browser.Responsiveness.JankyIntervalsPerThirtySeconds3" - units="janks" expires_after="2021-07-31"> + units="janks" expires_after="2021-09-30"> <!-- on probation: expected to graduate as a go/chrome-browser-guiding-metrics --> <owner>etienneb@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml index eeda8912..982800b 100644 --- a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml +++ b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
@@ -13167,6 +13167,8 @@ useful data any longer. </obsolete> </affected-histogram> + <affected-histogram name="Permissions.DSE.AutoPermissionRevertTransition"/> + <affected-histogram name="Permissions.DSE.EffectiveSetting"/> <affected-histogram name="Permissions.MissingOSLevelPermission.Action"/> <affected-histogram name="Permissions.MissingOSLevelPermission.ShouldShow"/> <affected-histogram name="Permissions.Prompt.Accepted.Persisted"/>
diff --git a/tools/metrics/histograms/metadata/ios/histograms.xml b/tools/metrics/histograms/metadata/ios/histograms.xml index a4a72fb..44ea23c 100644 --- a/tools/metrics/histograms/metadata/ios/histograms.xml +++ b/tools/metrics/histograms/metadata/ios/histograms.xml
@@ -632,7 +632,7 @@ </histogram> <histogram name="IOS.MainThreadFreezeDetection.HangWithCleanExit" - enum="Boolean" expires_after="2021-12-11"> + enum="Boolean" expires_after="2022-09-12"> <owner>justincohen@chromium.org</owner> <owner>olivierrobin@chromium.org</owner> <summary> @@ -645,7 +645,7 @@ <histogram name="IOS.MainThreadFreezeDetection.NotRunningAfterReport" enum="IOSMainThreadFreezeDetectionNotRunningAfterReportBlock" - expires_after="2021-09-12"> + expires_after="2022-09-12"> <owner>justincohen@chromium.org</owner> <owner>olivierrobin@chromium.org</owner> <summary> @@ -655,7 +655,7 @@ </histogram> <histogram name="IOS.MainThreadFreezeDetection.RecoveredAfter" units="ms" - expires_after="2021-11-12"> + expires_after="2022-09-12"> <owner>justincohen@chromium.org</owner> <owner>olivierrobin@chromium.org</owner> <summary> @@ -1182,14 +1182,14 @@ </histogram> <histogram name="IOS.Spotlight.Action" enum="IOSSpotlightAction" - expires_after="2021-09-12"> + expires_after="2022-09-12"> <owner>olivierrobin@chromium.org</owner> <owner>rohitrao@chromium.org</owner> <summary>The Spotlight Action pressed by the user.</summary> </histogram> <histogram name="IOS.Spotlight.Availability" enum="IOSSpotlightAvailability" - expires_after="2021-09-12"> + expires_after="2022-09-12"> <owner>rohitrao@chromium.org</owner> <owner>olivierrobin@chromium.org</owner> <summary> @@ -1200,21 +1200,21 @@ </histogram> <histogram name="IOS.Spotlight.BookmarksIndexingDuration" units="ms" - expires_after="2021-09-12"> + expires_after="2022-09-12"> <owner>olivierrobin@chromium.org</owner> <owner>rohitrao@chromium.org</owner> <summary>Time spent in Spotlight initial indexation of bookmarks.</summary> </histogram> <histogram name="IOS.Spotlight.BookmarksInitialIndexSize" units="units" - expires_after="2021-11-14"> + expires_after="2022-09-12"> <owner>olivierrobin@chromium.org</owner> <owner>rohitrao@chromium.org</owner> <summary>Number of bookmarks indexed during initial indexation.</summary> </histogram> <histogram name="IOS.Spotlight.Origin" enum="IOSSpotlightOrigin" - expires_after="2021-10-10"> + expires_after="2022-09-12"> <owner>olivierrobin@chromium.org</owner> <owner>rohitrao@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/net/histograms.xml b/tools/metrics/histograms/metadata/net/histograms.xml index 5a5d5ad..7a005aa 100644 --- a/tools/metrics/histograms/metadata/net/histograms.xml +++ b/tools/metrics/histograms/metadata/net/histograms.xml
@@ -714,7 +714,7 @@ </histogram> <histogram name="Net.DNS.DnsTask.AdditionalHttps.Requested" - enum="UnsolicitedHttpsRecordStatus" expires_after="2021-08-06"> + enum="UnsolicitedHttpsRecordStatus" expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>dmcardle@chromium.org</owner> <summary> @@ -726,7 +726,7 @@ </histogram> <histogram name="Net.DNS.DnsTask.AdditionalHttps.Unsolicited" - enum="UnsolicitedHttpsRecordStatus" expires_after="2021-08-06"> + enum="UnsolicitedHttpsRecordStatus" expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>dmcardle@chromium.org</owner> <summary> @@ -784,7 +784,7 @@ </histogram> <histogram name="Net.DNS.DnsTransaction.AttemptType" enum="DNS.AttemptType" - expires_after="2021-12-19"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -795,7 +795,7 @@ </histogram> <histogram base="true" name="Net.DNS.DnsTransaction.Insecure.FailureTime" - units="ms" expires_after="2021-07-28"> + units="ms" expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -807,7 +807,7 @@ </histogram> <histogram base="true" name="Net.DNS.DnsTransaction.Insecure.SuccessTime" - units="ms" expires_after="2021-07-28"> + units="ms" expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -820,7 +820,7 @@ <histogram base="true" name="Net.DNS.DnsTransaction.SecureNotValidated.FailureError" - enum="NetErrorCodes" expires_after="2021-07-31"> + enum="NetErrorCodes" expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -835,7 +835,7 @@ <histogram base="true" name="Net.DNS.DnsTransaction.SecureNotValidated.FailureTime" units="ms" - expires_after="2021-07-31"> + expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -850,7 +850,7 @@ <histogram base="true" name="Net.DNS.DnsTransaction.SecureNotValidated.SuccessTime" units="ms" - expires_after="2021-07-31"> + expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -865,7 +865,7 @@ <histogram base="true" name="Net.DNS.DnsTransaction.SecureValidated.FailureError" - enum="NetErrorCodes" expires_after="2021-07-28"> + enum="NetErrorCodes" expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -881,7 +881,7 @@ <histogram base="true" name="Net.DNS.DnsTransaction.SecureValidated.FailureTime" units="ms" - expires_after="2021-07-28"> + expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -896,7 +896,7 @@ <histogram base="true" name="Net.DNS.DnsTransaction.SecureValidated.SuccessTime" units="ms" - expires_after="2021-07-28"> + expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -996,7 +996,7 @@ <histogram name="Net.DNS.HTTPSSVC.RecordHttps.AnyProvider.ExpectNoerror.Parsable" - enum="BooleanValid" expires_after="2022-01-16"> + enum="BooleanValid" expires_after="2022-02-14"> <owner>ericorth@chromium.org</owner> <owner>dmcardle@chromium.org</owner> <summary> @@ -1008,7 +1008,7 @@ <histogram name="Net.DNS.HTTPSSVC.RecordHttps.AnyProvider.ExpectNoerror.RecordWithError" - enum="Boolean" expires_after="2021-09-14"> + enum="Boolean" expires_after="2022-02-14"> <owner>ericorth@chromium.org</owner> <owner>dmcardle@chromium.org</owner> <summary> @@ -1019,7 +1019,7 @@ </histogram> <histogram base="true" name="Net.DNS.HTTPSSVC.RecordHttps.DnsRcode" - enum="HttpssvcDnsRcode" expires_after="2021-09-14"> + enum="HttpssvcDnsRcode" expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" and name="HttpssvcIntegrityExpectation" --> @@ -1035,7 +1035,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordHttps.ExpectIntact.Parsable" - enum="BooleanValid" expires_after="2021-09-14"> + enum="BooleanValid" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -1050,7 +1050,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordHttps.ExpectIntact.RecordWithError" - units="records" expires_after="2021-09-14"> + units="records" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -1065,7 +1065,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordHttps.ResolveTimeHttpsRecord" units="ms" - expires_after="2021-09-14"> + expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" and name="HttpssvcIntegrityExpectation" --> @@ -1078,7 +1078,7 @@ </histogram> <histogram base="true" name="Net.DNS.HTTPSSVC.RecordHttps.ResolveTimeRatio" - units="scaled ratio (% / 10)" expires_after="2021-09-14"> + units="scaled ratio (% / 10)" expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" and name="HttpssvcIntegrityExpectation" --> @@ -1096,7 +1096,7 @@ </histogram> <histogram base="true" name="Net.DNS.HTTPSSVC.RecordIntegrity.DnsRcode" - enum="HttpssvcDnsRcode" expires_after="2021-09-14"> + enum="HttpssvcDnsRcode" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" and name="HttpssvcIntegrityExpectation" --> @@ -1112,7 +1112,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordIntegrity.ExpectIntact.Integrity" - enum="HttpssvcIntegrityJudgment" expires_after="2021-09-14"> + enum="HttpssvcIntegrityJudgment" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -1127,7 +1127,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordIntegrity.ExpectIntact.RecordWithError" - units="records" expires_after="2021-09-14"> + units="records" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -1142,7 +1142,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordIntegrity.ExpectNoerror.RecordReceived" - units="records" expires_after="2021-09-14"> + units="records" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" --> @@ -1158,7 +1158,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordIntegrity.ResolveTimeIntegrityRecord" - units="ms" expires_after="2021-09-14"> + units="ms" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" and name="HttpssvcIntegrityExpectation" --> @@ -1172,7 +1172,7 @@ <histogram base="true" name="Net.DNS.HTTPSSVC.RecordIntegrity.ResolveTimeNonIntegrityRecord" - units="ms" expires_after="2021-09-14"> + units="ms" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" and name="HttpssvcIntegrityExpectation" --> @@ -1186,7 +1186,7 @@ </histogram> <histogram base="true" name="Net.DNS.HTTPSSVC.RecordIntegrity.ResolveTimeRatio" - units="%" expires_after="2021-09-14"> + units="%" expires_after="2022-02-14"> <!-- Name completed by histogram_suffixes name="DohProviderId" and name="HttpssvcIntegrityExpectation" --> @@ -1405,7 +1405,7 @@ </histogram> <histogram name="Net.DNS.SecureDnsMode.Automatic.ResolveTime" units="ms" - expires_after="2021-09-19"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1417,7 +1417,7 @@ </histogram> <histogram name="Net.DNS.SecureDnsMode.Off.ResolveTime" units="ms" - expires_after="2021-08-09"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1429,7 +1429,7 @@ </histogram> <histogram name="Net.DNS.SecureDnsMode.Secure.ResolveTime" units="ms" - expires_after="2021-08-01"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1441,7 +1441,7 @@ </histogram> <histogram name="Net.DNS.SecureDnsTask.DnsModeAutomatic.FailureTime" units="ms" - expires_after="2022-01-16"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1452,7 +1452,7 @@ </histogram> <histogram name="Net.DNS.SecureDnsTask.DnsModeSecure.FailureTime" units="ms" - expires_after="2021-12-12"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1489,7 +1489,7 @@ </histogram> <histogram base="true" name="Net.DNS.UI.DropdownSelectionEvent" - enum="DohProviderId" expires_after="2021-11-14"> + enum="DohProviderId" expires_after="2022-08-14"> <!-- Name completed by histogram_suffixes name="DnsDropdownSelectionEvent" --> @@ -1502,7 +1502,7 @@ </histogram> <histogram name="Net.DNS.UI.ProbeAttemptSuccess" enum="Boolean" - expires_after="2021-12-12"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1512,7 +1512,7 @@ </histogram> <histogram name="Net.DNS.UI.ValidationAttemptSuccess" enum="Boolean" - expires_after="2021-12-12"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1522,7 +1522,7 @@ </histogram> <histogram name="Net.DNS.UpgradeConfig.DotUpgradeSucceeded" enum="Boolean" - expires_after="2021-09-05"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1532,7 +1532,7 @@ </histogram> <histogram name="Net.DNS.UpgradeConfig.HasPublicInsecureNameserver" - enum="Boolean" expires_after="2022-01-09"> + enum="Boolean" expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1543,7 +1543,7 @@ </histogram> <histogram name="Net.DNS.UpgradeConfig.Ineligible.DohSpecified" enum="Boolean" - expires_after="2021-11-07"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1553,7 +1553,7 @@ </histogram> <histogram name="Net.DNS.UpgradeConfig.Ineligible.UnhandledOptions" - enum="Boolean" expires_after="2021-11-28"> + enum="Boolean" expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1564,7 +1564,7 @@ </histogram> <histogram name="Net.DNS.UpgradeConfig.InsecureUpgradeSucceeded" enum="Boolean" - expires_after="2022-01-09"> + expires_after="2022-08-14"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/others/histograms.xml b/tools/metrics/histograms/metadata/others/histograms.xml index cbfc8f9..60eb976 100644 --- a/tools/metrics/histograms/metadata/others/histograms.xml +++ b/tools/metrics/histograms/metadata/others/histograms.xml
@@ -2198,6 +2198,9 @@ <histogram name="CaptivePortal.ProbeReason" enum="CaptivePortalProbeReason" expires_after="2021-08-09"> + <obsolete> + Removed from code 2021-08. + </obsolete> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <owner>cros-networking@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/permissions/histograms.xml b/tools/metrics/histograms/metadata/permissions/histograms.xml index c89ae1c..16a42c2 100644 --- a/tools/metrics/histograms/metadata/permissions/histograms.xml +++ b/tools/metrics/histograms/metadata/permissions/histograms.xml
@@ -282,6 +282,29 @@ </summary> </histogram> +<histogram name="Permissions.DSE.AutoPermissionRevertTransition" + enum="AutoDSEPermissionRevertTransition" expires_after="2022-07-01"> + <owner>andypaicu@chromium.org</owner> + <owner>src/components/permissions/PERMISSIONS_OWNERS</owner> + <summary> + Recorded when the Default Search Engine automatic permission grant is + reverted. It tracks the transition that the settings for the DSE origin + takes when this happens. Suffixed by `PermissionTypes` to provide + information per permission type. + </summary> +</histogram> + +<histogram name="Permissions.DSE.EffectiveSetting" enum="ContentSetting" + expires_after="2022-07-01"> + <owner>andypaicu@chromium.org</owner> + <owner>src/components/permissions/PERMISSIONS_OWNERS</owner> + <summary> + Recorded at initialization and when the Default Search Engine origin is + changed. Tracks the setting for the Default Search Engine origin. Suffixed + by `PermissionTypes` to provide information per permission type. + </summary> +</histogram> + <histogram name="Permissions.Engagement.Accepted" units="%" expires_after="2021-12-26"> <owner>engedy@chromium.org</owner>
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index 2faceaa3..e864501 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json
@@ -1,16 +1,24 @@ { "trace_processor_shell": { + "linux_arm": { + "hash": "58893933be305d3bfe0a72ebebcacde2ac3ca893", + "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" + }, "win": { - "hash": "dfe3ae9820abd756129c53fc0ec7f50c0851723a", - "remote_path": "perfetto_binaries/trace_processor_shell/win/ef682fd91263e8e05e1b177649aeea3f18f37d79/trace_processor_shell.exe" + "hash": "3e1287fc3d95f3f9aa1c82fae2c45b16af78d8dd", + "remote_path": "perfetto_binaries/trace_processor_shell/win/f94e497acc562fab07b1cbe20e973c8e150900ec/trace_processor_shell.exe" }, "mac": { "hash": "e7000eeeefed60f263b77eea1156606a18304379", - "remote_path": "perfetto_binaries/trace_processor_shell/mac/171e281775914c1c427b926666bf1c0f8070e762/trace_processor_shell" + "remote_path": "perfetto_binaries/trace_processor_shell/mac/d3e40bdbdc699f7c0812d9d152e0ccddb13891ad/trace_processor_shell" + }, + "linux_arm64": { + "hash": "5074025a2898ec41a872e70a5719e417acb0a380", + "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm64/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" }, "linux": { "hash": "672ed966e2e8072a7d6322367ac35c5fedd1ff9f", - "remote_path": "perfetto_binaries/trace_processor_shell/linux/ef682fd91263e8e05e1b177649aeea3f18f37d79/trace_processor_shell" + "remote_path": "perfetto_binaries/trace_processor_shell/linux/6c633ff46becc2341908e7843360e0790fac81fe/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps_manager.py b/tools/perf/core/perfetto_binary_roller/binary_deps_manager.py index 85da6b4..daeec2b 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps_manager.py +++ b/tools/perf/core/perfetto_binary_roller/binary_deps_manager.py
@@ -6,6 +6,7 @@ import os import posixpath import stat +import subprocess import py_utils from py_utils import cloud_storage @@ -23,15 +24,51 @@ os.path.join(os.path.dirname(__file__), 'binary_deps.json')) +def _GetHostArch(): + uname_arch = subprocess.check_output(['uname', '-m']).strip() + if uname_arch == 'armv7l': + return 'arm' + elif uname_arch == 'aarch64': + return 'arm64' + return uname_arch + + +def _GetBinaryArch(binary_name): + file_output = subprocess.check_output(['file', binary_name]) + file_arch = file_output.split(',')[1].strip() + if file_arch == 'x86-64': + return 'x86_64' + elif file_arch == 'ARM': + return 'arm' + elif file_arch == 'ARM aarch64': + return 'arm64' + return file_arch + + def _GetHostPlatform(): os_name = py_utils.GetHostOsName() # If we're running directly on a Chrome OS device, fetch the binaries for # linux instead, which should be compatible with CrOS. - if os_name == 'chromeos': - os_name = 'linux' + if os_name in ['chromeos', 'linux']: + arch = _GetHostArch() + if arch == 'x86_64': + return 'linux' + return 'linux_' + arch return os_name +def _GetBinaryPlatform(binary_name): + host_platform = _GetHostPlatform() + # Binaries built on mac/windows are for mac/windows respectively. Binaries + # built on linux may be for linux or chromeos on different architectures. + if not host_platform.startswith('linux'): + return host_platform + arch = _GetBinaryArch(binary_name) + if arch == 'x86_64': + return 'linux' + return 'linux' + '_' + arch + + def _CalculateHash(remote_path): with tempfile_ext.NamedTemporaryFile() as f: f.close() @@ -60,7 +97,7 @@ affect which binaries will be downloaded by FetchHostBinary. """ filename = os.path.basename(binary_path) - platform = _GetHostPlatform() + platform = _GetBinaryPlatform(binary_path) remote_path = posixpath.join(BINARY_CS_FOLDER, binary_name, platform, version, filename) if not cloud_storage.Exists(BINARY_BUCKET, remote_path): @@ -96,8 +133,11 @@ """ with open(CONFIG_PATH) as f: config = json.load(f) - config[binary_name][platform]['remote_path'] = new_path - config[binary_name][platform]['hash'] = _CalculateHash(new_path) + config.setdefault(binary_name, {}).setdefault(platform, + {})['remote_path'] = new_path + config.setdefault(binary_name, + {}).setdefault(platform, + {})['hash'] = _CalculateHash(new_path) with open(CONFIG_PATH, 'w') as f: json.dump(config, f, indent=4, separators=(',', ': '))
diff --git a/tools/perf/core/perfetto_binary_roller/roll_trace_processor b/tools/perf/core/perfetto_binary_roller/roll_trace_processor index 0239a34..2f4580f 100755 --- a/tools/perf/core/perfetto_binary_roller/roll_trace_processor +++ b/tools/perf/core/perfetto_binary_roller/roll_trace_processor
@@ -21,7 +21,7 @@ if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument( - '--platform', help='linux/mac/win', required=True) + '--platform', help='linux/linux_arm/linux_arm64/mac/win', required=True) parser.add_argument( '--path', metavar='PATH', help='Switch to using a trace processor version' ' stored by this cloud path.')
diff --git a/tools/tracing/metadata_extractor.py b/tools/tracing/metadata_extractor.py index 643f844..046577f9 100644 --- a/tools/tracing/metadata_extractor.py +++ b/tools/tracing/metadata_extractor.py
@@ -105,6 +105,9 @@ self.version_number = version_number.split('/')[1] else: self.version_number = version_number + # Mac 64 traces add '-64' after the version number. + if self.version_number is not None and self.version_number.endswith('-64'): + self.version_number = self.version_number[:-3] raw_os_name = self._GetStringValueFromQuery(OS_NAME_QUERY) self.os_name = self._ParseOSName(raw_os_name)
diff --git a/tools/tracing/metadata_extractor_unittest.py b/tools/tracing/metadata_extractor_unittest.py index 507ef97e..2f6256a 100755 --- a/tools/tracing/metadata_extractor_unittest.py +++ b/tools/tracing/metadata_extractor_unittest.py
@@ -216,9 +216,10 @@ self.assertEqual(extractor.os_name, OSName.LINUX) - def testParseOSNameMac(self): + def testParseMac64(self): def side_effect(*args): - params = self._CreateRunQueryResultsFromValues(os_name='Mac OS X') + params = self._CreateRunQueryResultsFromValues( + os_name='Mac OS X', version_number='Chrome/28.9.9364.32-64') return params[args] extractor = metadata_extractor.MetadataExtractor(self.trace_processor_path, @@ -226,6 +227,7 @@ trace_processor.RunQuery = mock.MagicMock(side_effect=side_effect) extractor.Initialize() + self.assertEqual(extractor.version_number, '28.9.9364.32') self.assertEqual(extractor.os_name, OSName.MAC) def testParseOSNameWindows(self):
diff --git a/tools/traffic_annotation/auditor/README.md b/tools/traffic_annotation/auditor/README.md index 0e9a82d..93a40209 100644 --- a/tools/traffic_annotation/auditor/README.md +++ b/tools/traffic_annotation/auditor/README.md
@@ -1,4 +1,14 @@ # Network Traffic Annotation Auditor + +THIS CODEBASE IS DEPRECATED. It will be removed soon(ish). The new +implementation can be found at tools/traffic_annotation/auditor/auditor.py. It +is a drop-in replacement for traffic_annotation_auditor, so you can run it with +the same command-line arguments, etc. + +<!-- TODO(crbug.com/1119417): Remove t_a_auditor-related code after enough + time running auditor.py by default (to ensure it's relatively bug-free). + --> + This binary runs extractor.py for extraction of Network Traffic Annotations from chromium source code, collects and summarizes its outputs, and performs tests and maintenance.
diff --git a/tools/traffic_annotation/scripts/README.md b/tools/traffic_annotation/scripts/README.md index bfa5220..5d9f7370 100644 --- a/tools/traffic_annotation/scripts/README.md +++ b/tools/traffic_annotation/scripts/README.md
@@ -1,6 +1,12 @@ # Traffic Annotation Scripts This file describes the scripts in `tools/traffic_annotation/scripts`. +# auditor/auditor.py + +The new implementation of `traffic_annotation_auditor`. It is meant as a +drop-in replacement, i.e. you can call it with the same command-line arguments +and it should give similar output. + # check_annotations.py Runs traffic annotation tests on the changed files or all repository. The tests are run in error resilient mode. Requires a compiled build directory to run. @@ -50,4 +56,4 @@ object returned by the Google Docs API `get()` method. # generator_utils_tests.py -Unit tests for generator_utils.py. \ No newline at end of file +Unit tests for generator_utils.py.
diff --git a/tools/traffic_annotation/scripts/check_annotations.py b/tools/traffic_annotation/scripts/check_annotations.py index f87f566a..9485f7a 100755 --- a/tools/traffic_annotation/scripts/check_annotations.py +++ b/tools/traffic_annotation/scripts/check_annotations.py
@@ -21,9 +21,9 @@ # //tools/traffic_annotation/OWNERS. TEST_IS_ENABLED = True -# If the auditor.py part of this test starts failing, please set -# TEST_PYTHON_AUDITOR to "False" and file a bug (see comment above). -TEST_PYTHON_AUDITOR = True +# If this test starts failing due to a critical bug in auditor.py, please set +# USE_PYTHON_AUDITOR to "False" and file a bug (see comment above). +USE_PYTHON_AUDITOR = True # Threshold for the change list size to trigger full test. CHANGELIST_SIZE_TO_TRIGGER_FULL_TEST = 100 @@ -145,24 +145,7 @@ checker = NetworkTrafficAnnotationChecker(args.build_path) exit_code = checker.CheckFiles(args.complete, args.limit, - use_python_auditor=False) - - if TEST_PYTHON_AUDITOR: - print() - print("Now trying again with the experimental auditor.py script. This is " - "only for testing/debugging purposes.") - print() - print("YOU CAN SAFELY IGNORE ALL OUTPUT BELOW THIS LINE") - print("=" * 120) - - # Ignore all errors while running auditor.py. - try: - python_exit_code = checker.CheckFiles(args.complete, - args.limit, - use_python_auditor=True) - print("Exit code was %d." % python_exit_code) - except Exception as e: - traceback.print_exc() + use_python_auditor=USE_PYTHON_AUDITOR) return exit_code
diff --git a/tools/traffic_annotation/scripts/traffic_annotation_auditor_tests.py b/tools/traffic_annotation/scripts/traffic_annotation_auditor_tests.py index 2b7ac62..d1b7e0d 100755 --- a/tools/traffic_annotation/scripts/traffic_annotation_auditor_tests.py +++ b/tools/traffic_annotation/scripts/traffic_annotation_auditor_tests.py
@@ -20,9 +20,9 @@ # //tools/traffic_annotation/OWNERS. TEST_IS_ENABLED = True -# If the auditor.py part of this test starts failing, please set -# TEST_PYTHON_AUDITOR to "False" and file a bug (see comment above). -TEST_PYTHON_AUDITOR = True +# If this test starts failing due to a critical bug in auditor.py, please set +# USE_PYTHON_AUDITOR to "False" and file a bug (see comment above). +USE_PYTHON_AUDITOR = True MINIMUM_EXPECTED_NUMBER_OF_ANNOTATIONS = 260 @@ -74,20 +74,16 @@ ], ] - # Test both t_a_auditor.exe and auditor.py. - for use_python_auditor in [False, True]: - if use_python_auditor and not TEST_PYTHON_AUDITOR: - continue - self.last_result = None - for config in configs: - result = self._RunTest(config, use_python_auditor) - if not result: - print("No output for config: %s" % config) - return False - if self.last_result and self.last_result != result: - print("Unexpected different results for config: %s" % config) - return False - self.last_result = result + self.last_result = None + for config in configs: + result = self._RunTest(config, USE_PYTHON_AUDITOR) + if not result: + print("No output for config: %s" % config) + return False + if self.last_result and self.last_result != result: + print("Unexpected different results for config: %s" % config) + return False + self.last_result = result return True @@ -135,19 +131,12 @@ except OSError: pass - if use_python_auditor: - # Test the TSV codepath for auditor.py, but don't use its output to - # update go/network_traffic_annotations_sheet. - final_annotations_filename = self.annotations_filename + ".bak" - else: - final_annotations_filename = self.annotations_filename - stdout_text, stderr_text, return_code = self.tools.RunAuditor( - args + ["--annotations-file=%s" % final_annotations_filename], + args + ["--annotations-file=%s" % self.annotations_filename], use_python_auditor) annotations = None - if os.path.exists(final_annotations_filename): + if os.path.exists(self.annotations_filename): # When tests are run on all files (without filtering), there might be some # compile errors in irrelevant files on Windows that can be ignored. if (return_code and "--no-filtering" in args and @@ -155,9 +144,9 @@ print("Ignoring return code: %i" % return_code) return_code = 0 if not return_code: - annotations = open(final_annotations_filename).read() + annotations = open(self.annotations_filename).read() if not self.persist_annotations: - os.remove(final_annotations_filename) + os.remove(self.annotations_filename) if annotations: print("Test PASSED.")
diff --git a/tools/traffic_annotation/summary/README.md b/tools/traffic_annotation/summary/README.md index eca74820..0df4f6b 100644 --- a/tools/traffic_annotation/summary/README.md +++ b/tools/traffic_annotation/summary/README.md
@@ -11,7 +11,8 @@ * `hash_code`: Hash code of the unique id of the annotation. These values are used in the binary as annotation tags. * `type`: Type of the annotation (complete, partial, ...). Uses enum values - of `AnnotationInstance` in `tools/traffic_annotation/auditor/instance.h`. + of `Annotation.Type` in + `tools/traffic_annotation/scripts/auditor/auditor.py`. * `content_hash_code`: Hash code of the annotation content. This value is stored to check when an annotation is modified. * `os_list`: List of all platforms on which this annotation exists. @@ -27,8 +28,9 @@ Unique id of deprecated annotations cannot be reused. # How to Generate/Update. -Run `traffic_annotation_auditor` to check for annotations correctness and +Run `auditor.py` to check for annotations correctness and automatic update. There are also trybots on Linux and Windows to run the tests and suggest required updates. -The latest executable of `traffic_annotation_auditor` for supported platforms -can be found in `tools/traffic_annotation/bin/[platform]`. + +The script can be found in +`tools/traffic_annotation/scripts/auditor/auditor.py`.
diff --git a/tools/traffic_annotation/summary/grouping.xml b/tools/traffic_annotation/summary/grouping.xml index 29e13542..e5bf2b18 100644 --- a/tools/traffic_annotation/summary/grouping.xml +++ b/tools/traffic_annotation/summary/grouping.xml
@@ -15,7 +15,6 @@ <group name="Mobile" hidden="true"> <!-- Android-specific features --> <sender name="Android"> - <traffic_annotation unique_id="affiliation_lookup"/> <traffic_annotation unique_id="android_device_manager_socket"/> <traffic_annotation unique_id="android_web_socket"/> <traffic_annotation unique_id="query_tiles_fetcher"/>
diff --git a/ui/accessibility/ax_text_attributes.cc b/ui/accessibility/ax_text_attributes.cc index d2ec6ec2..b099be0e 100644 --- a/ui/accessibility/ax_text_attributes.cc +++ b/ui/accessibility/ax_text_attributes.cc
@@ -4,21 +4,11 @@ #include "ui/accessibility/ax_text_attributes.h" -constexpr int kUnsetValue = -1; - namespace ui { -AXTextAttributes::AXTextAttributes() - : background_color(kUnsetValue), - color(kUnsetValue), - invalid_state(kUnsetValue), - overline_style(kUnsetValue), - strikethrough_style(kUnsetValue), - text_direction(kUnsetValue), - text_position(kUnsetValue), - text_style(kUnsetValue), - underline_style(kUnsetValue), - font_size(kUnsetValue), - font_weight(kUnsetValue) {} + +AXTextAttributes::AXTextAttributes() = default; + +AXTextAttributes::~AXTextAttributes() = default; AXTextAttributes::AXTextAttributes(AXTextAttributes&& other) : background_color(other.background_color), @@ -35,6 +25,9 @@ font_family(std::move(other.font_family)) {} AXTextAttributes& AXTextAttributes::operator=(AXTextAttributes&& other) { + if (this == &other) + return *this; + background_color = other.background_color; color = other.color; invalid_state = other.invalid_state;
diff --git a/ui/accessibility/ax_text_attributes.h b/ui/accessibility/ax_text_attributes.h index 3ce02c0..5cdb6bb 100644 --- a/ui/accessibility/ax_text_attributes.h +++ b/ui/accessibility/ax_text_attributes.h
@@ -11,18 +11,21 @@ namespace ui { -// A compact representation of text styles on an AXNode. This data represents -// a snapshot at a given time and is not intended to be held for periods of -// time. For this reason, it is a move-only class, to encourage deliberate -// short-term usage. -struct AX_BASE_EXPORT AXTextAttributes { - AXTextAttributes(); +// A compact representation of text attributes, such as spelling markers and +// style information, on an `AXNode`. This data represents a snapshot at a given +// time and is not intended to be held for periods of time. For this reason, it +// is a move-only class, to encourage deliberate short-term usage. +struct AX_BASE_EXPORT AXTextAttributes final { + // For numeric attributes, the value to be used when a particular attribute is + // not set on the `AXNode`, or its value is otherwise unknown. + static constexpr int kUnsetValue = -1; - // Move-only class, explicitly delete copy-construction and assignment + AXTextAttributes(); + ~AXTextAttributes(); + AXTextAttributes(const AXTextAttributes& other) = delete; AXTextAttributes& operator=(const AXTextAttributes&) = delete; - // Move constructor and assignment AXTextAttributes(AXTextAttributes&& other); AXTextAttributes& operator=(AXTextAttributes&& other); @@ -32,17 +35,17 @@ bool IsUnset() const; - int32_t background_color; - int32_t color; - int32_t invalid_state; - int32_t overline_style; - int32_t strikethrough_style; - int32_t text_direction; - int32_t text_position; - int32_t text_style; - int32_t underline_style; - float font_size; - float font_weight; + int32_t background_color = kUnsetValue; + int32_t color = kUnsetValue; + int32_t invalid_state = kUnsetValue; + int32_t overline_style = kUnsetValue; + int32_t strikethrough_style = kUnsetValue; + int32_t text_direction = kUnsetValue; + int32_t text_position = kUnsetValue; + int32_t text_style = kUnsetValue; + int32_t underline_style = kUnsetValue; + float font_size = kUnsetValue; + float font_weight = kUnsetValue; std::string font_family; };
diff --git a/ui/android/java/src/org/chromium/ui/base/Clipboard.java b/ui/android/java/src/org/chromium/ui/base/Clipboard.java index b7c0653..79edebc 100644 --- a/ui/android/java/src/org/chromium/ui/base/Clipboard.java +++ b/ui/android/java/src/org/chromium/ui/base/Clipboard.java
@@ -262,7 +262,12 @@ // we will access the clipboard content and valid by URLUtil#isValidUrl. if (BuildInfo.isAtLeastS()) { ClipDescription description = mClipboardManager.getPrimaryClipDescription(); - if (description == null) return false; + // If getClassificationStatus() is not CLASSIFICATION_COMPLETE, + // ClipDescription#getConfidenceScore will trows exception. + if (description == null + || !ApiHelperForS.isGetClassificationStatusIsComplete(description)) { + return false; + } float score = ApiHelperForS.getConfidenceScore(description, TextClassifier.TYPE_URL); return score > CONFIDENCE_THRESHOLD_FOR_URL_DETECTION;
diff --git a/ui/file_manager/audio_player/manifest.json b/ui/file_manager/audio_player/manifest.json index f92d71c..fbc7230 100644 --- a/ui/file_manager/audio_player/manifest.json +++ b/ui/file_manager/audio_player/manifest.json
@@ -47,9 +47,6 @@ "background": { "page": "background.html" }, - // enhhojjnijigcajfphajepfemndkmdlo is the Dev Media Router component extension ID. - // pkedcjkdefgpdelpbcmbmeomcjbeemfm is the Stable Media Router component extension ID. - "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj chrome-extension://enhhojjnijigcajfphajepfemndkmdlo chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm; style-src 'self' blob: filesystem: chrome://resources 'unsafe-inline'; img-src 'self' blob: filesystem: chrome://theme chrome://resources data: https://www.googledrive.com; media-src 'self' blob: filesystem:; connect-src chrome://resources ; object-src 'self' blob: filesystem:; font-src chrome://resources;" + "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj; style-src 'self' blob: filesystem: chrome://resources 'unsafe-inline'; img-src 'self' blob: filesystem: chrome://theme chrome://resources data: https://www.googledrive.com; media-src 'self' blob: filesystem:; connect-src chrome://resources ; object-src 'self' blob: filesystem:; font-src chrome://resources;" } } -
diff --git a/ui/file_manager/video_player/manifest.json b/ui/file_manager/video_player/manifest.json index 8aa42d81..8fd92ef 100644 --- a/ui/file_manager/video_player/manifest.json +++ b/ui/file_manager/video_player/manifest.json
@@ -59,10 +59,8 @@ "background": { "page": "background.html" }, - // enhhojjnijigcajfphajepfemndkmdlo is the Dev Media Router component extension ID. - // pkedcjkdefgpdelpbcmbmeomcjbeemfm is the Stable Media Router component extension ID. // ljoplibgfehghmibaoaepfagnmbbfiga is the ui/file_manager/integration_tests component extension ID. // connect-src for Polymer: crbug.com/1022018 - "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj chrome-extension://enhhojjnijigcajfphajepfemndkmdlo chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga; style-src 'self' blob: filesystem: chrome://resources 'unsafe-inline'; img-src 'self' blob: filesystem: chrome://theme chrome://resources data: https://www.googledrive.com; media-src 'self' blob: filesystem:; object-src 'self' blob: filesystem:; font-src chrome://resources; connect-src chrome://resources;" + "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga; style-src 'self' blob: filesystem: chrome://resources 'unsafe-inline'; img-src 'self' blob: filesystem: chrome://theme chrome://resources data: https://www.googledrive.com; media-src 'self' blob: filesystem:; object-src 'self' blob: filesystem:; font-src chrome://resources; connect-src chrome://resources;" } }
diff --git a/ui/ozone/platform/wayland/BUILD.gn b/ui/ozone/platform/wayland/BUILD.gn index b8f51d3..7463596c 100644 --- a/ui/ozone/platform/wayland/BUILD.gn +++ b/ui/ozone/platform/wayland/BUILD.gn
@@ -63,8 +63,6 @@ "host/shell_surface_wrapper.h", "host/shell_toplevel_wrapper.cc", "host/shell_toplevel_wrapper.h", - "host/wayland_auxiliary_window.cc", - "host/wayland_auxiliary_window.h", "host/wayland_buffer_manager_connector.cc", "host/wayland_buffer_manager_connector.h", "host/wayland_buffer_manager_host.cc",
diff --git a/ui/ozone/platform/wayland/common/wayland_object.cc b/ui/ozone/platform/wayland/common/wayland_object.cc index fda1774..0f21da4 100644 --- a/ui/ozone/platform/wayland/common/wayland_object.cc +++ b/ui/ozone/platform/wayland/common/wayland_object.cc
@@ -85,9 +85,9 @@ void (*ObjectTraits<wl_proxy>::deleter)(void*) = &wl_proxy_wrapper_destroy; // The overwhelming majority of Wayland interfaces follow the fixed pattern for -// naming their interface definition struct and their deleter function, which -// lets us generate a lot of boilerplate code by a simple macro and. A few -// interfaces use special deleter functions. Two macros below generalise that. +// naming their interface definition struct and their deleter function, with the +// exception for a few interfaces that use special deleter functions. This lets +// us generate a lot of boilerplate code by two simple macros defined below. #define IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(TYPE, DELETER) \ const wl_interface* ObjectTraits<struct TYPE>::interface = \ &TYPE##_interface; \
diff --git a/ui/ozone/platform/wayland/common/wayland_object.h b/ui/ozone/platform/wayland/common/wayland_object.h index ea1fbea..88a5c055 100644 --- a/ui/ozone/platform/wayland/common/wayland_object.h +++ b/ui/ozone/platform/wayland/common/wayland_object.h
@@ -7,15 +7,52 @@ #include <memory> +#include "base/check.h" +#include "base/compiler_specific.h" #include "ui/ozone/platform/wayland/common/wayland.h" struct wl_proxy; +namespace ui { +class WaylandConnection; +} + namespace wl { template <typename T> struct ObjectTraits; +using GlobalObjectFactory = void (*)(ui::WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + +// This template forces T to declare two static methods, Register() and +// Instantiate(). The subclass must implement them as follows: +// +// void Register(ui::WaylandConnection* connection) +// - must call connection->RegisterGlobalObjectFactory() and pass there the name +// of the Wayland interface and the address of the subclass's Instantiate() +// method. The connection will use the name of the interface as a key to find +// and call the instantiation method when that interface is announced by the +// server. +// +// void Instantiate(WaylandConnection* connection, +// wl_registry* registry, +// uint32_t name, +// uint32_t version) +// - must bind the Wayland object and store it in the connection. +template <typename T> +class GlobalObjectRegistrar { + public: + GlobalObjectRegistrar() { + void (*Register)(ui::WaylandConnection*) = T::Register; + ALLOW_UNUSED_LOCAL(Register); + GlobalObjectFactory Instantiate = T::Instantiate; + ALLOW_UNUSED_LOCAL(Instantiate); + } +}; + struct Deleter { template <typename T> void operator()(T* obj) {
diff --git a/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc b/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc index 3d49d7a..6d201d8 100644 --- a/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc +++ b/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc
@@ -8,12 +8,45 @@ #include <memory> +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/gtk_primary_selection_device.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_data_source.h" namespace ui { +namespace { +constexpr uint32_t kMaxGtkPrimarySelectionDeviceManagerVersion = 1; +} + +// static +void GtkPrimarySelectionDeviceManager::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory( + "gtk_primary_selection_device_manager", + &GtkPrimarySelectionDeviceManager::Instantiate); +} + +// static +void GtkPrimarySelectionDeviceManager::Instantiate( + WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->gtk_primary_selection_device_manager()) + return; + + auto manager = wl::Bind<gtk_primary_selection_device_manager>( + registry, name, + std::min(version, kMaxGtkPrimarySelectionDeviceManagerVersion)); + if (!manager) { + LOG(ERROR) << "Failed to bind gtk_primary_selection_device_manager"; + return; + } + connection->gtk_primary_selection_device_manager_ = + std::make_unique<GtkPrimarySelectionDeviceManager>(manager.release(), + connection); +} + GtkPrimarySelectionDeviceManager::GtkPrimarySelectionDeviceManager( gtk_primary_selection_device_manager* manager, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.h b/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.h index b059c2c8..395f5db 100644 --- a/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.h +++ b/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.h
@@ -15,11 +15,18 @@ class GtkPrimarySelectionDevice; class WaylandConnection; -class GtkPrimarySelectionDeviceManager { +class GtkPrimarySelectionDeviceManager + : public wl::GlobalObjectRegistrar<GtkPrimarySelectionDeviceManager> { public: using DataSource = GtkPrimarySelectionSource; using DataDevice = GtkPrimarySelectionDevice; + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + GtkPrimarySelectionDeviceManager( gtk_primary_selection_device_manager* manager, WaylandConnection* connection);
diff --git a/ui/ozone/platform/wayland/host/gtk_shell1.cc b/ui/ozone/platform/wayland/host/gtk_shell1.cc index 18a50d0..88126d9d 100644 --- a/ui/ozone/platform/wayland/host/gtk_shell1.cc +++ b/ui/ozone/platform/wayland/host/gtk_shell1.cc
@@ -6,10 +6,45 @@ #include <gtk-shell-client-protocol.h> +#include "base/logging.h" +#include "base/metrics/histogram_functions.h" #include "ui/ozone/platform/wayland/host/gtk_surface1.h" +#include "ui/ozone/platform/wayland/host/wayland_connection.h" namespace ui { +namespace { +// gtk_shell1 exposes request_focus() since version 3. Below that, it is not +// interesting for us, although it provides some shell integration that might be +// useful. +constexpr uint32_t kMinGtkShell1Version = 3; +constexpr uint32_t kMaxGtkShell1Version = 4; +} // namespace + +// static +void GtkShell1::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("gtk_shell1", + &GtkShell1::Instantiate); +} + +// static +void GtkShell1::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->gtk_shell1_ || version < kMinGtkShell1Version) + return; + + auto gtk_shell1 = wl::Bind<::gtk_shell1>( + registry, name, std::min(version, kMaxGtkShell1Version)); + if (!gtk_shell1) { + LOG(ERROR) << "Failed to bind gtk_shell1"; + return; + } + connection->gtk_shell1_ = std::make_unique<GtkShell1>(gtk_shell1.release()); + ReportShellUMA(UMALinuxWaylandShell::kGtkShell1); +} + GtkShell1::GtkShell1(gtk_shell1* shell1) : shell1_(shell1) {} GtkShell1::~GtkShell1() = default;
diff --git a/ui/ozone/platform/wayland/host/gtk_shell1.h b/ui/ozone/platform/wayland/host/gtk_shell1.h index bcf40a7..ed52a69 100644 --- a/ui/ozone/platform/wayland/host/gtk_shell1.h +++ b/ui/ozone/platform/wayland/host/gtk_shell1.h
@@ -13,8 +13,14 @@ class GtkSurface1; -class GtkShell1 { +class GtkShell1 : public wl::GlobalObjectRegistrar<GtkShell1> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + explicit GtkShell1(gtk_shell1* shell1); GtkShell1(const GtkShell1&) = delete; GtkShell1& operator=(const GtkShell1&) = delete;
diff --git a/ui/ozone/platform/wayland/host/org_kde_kwin_idle.cc b/ui/ozone/platform/wayland/host/org_kde_kwin_idle.cc index 8c6c25c..d990c81 100644 --- a/ui/ozone/platform/wayland/host/org_kde_kwin_idle.cc +++ b/ui/ozone/platform/wayland/host/org_kde_kwin_idle.cc
@@ -6,12 +6,15 @@ #include <idle-client-protocol.h> +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" namespace ui { namespace { +constexpr uint32_t kMaxOrgKdeKwinIdleVersion = 1; + // After the system has gone idle, it will wait for this time before notifying // us. This reduces "jitter" of the idle/active state, but also adds some lag // in responsiveness: when we are finally notified that the idle state has come, @@ -44,6 +47,30 @@ base::Time idle_timestamp_; }; +// static +void OrgKdeKwinIdle::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("org_kde_kwin_idle", + &OrgKdeKwinIdle::Instantiate); +} + +// static +void OrgKdeKwinIdle::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->org_kde_kwin_idle_) + return; + + auto idle = wl::Bind<struct org_kde_kwin_idle>( + registry, name, std::min(version, kMaxOrgKdeKwinIdleVersion)); + if (!idle) { + LOG(ERROR) << "Failed to bind to org_kde_kwin_idle global"; + return; + } + connection->org_kde_kwin_idle_ = + std::make_unique<OrgKdeKwinIdle>(idle.release(), connection); +} + OrgKdeKwinIdle::OrgKdeKwinIdle(org_kde_kwin_idle* idle, WaylandConnection* connection) : idle_(idle), connection_(connection) {}
diff --git a/ui/ozone/platform/wayland/host/org_kde_kwin_idle.h b/ui/ozone/platform/wayland/host/org_kde_kwin_idle.h index fd300abf..303f5f2 100644 --- a/ui/ozone/platform/wayland/host/org_kde_kwin_idle.h +++ b/ui/ozone/platform/wayland/host/org_kde_kwin_idle.h
@@ -17,8 +17,14 @@ // Wraps the KDE Wayland user idle time manager, which is provided via // org_kde_kwin_idle interface. -class OrgKdeKwinIdle { +class OrgKdeKwinIdle : public wl::GlobalObjectRegistrar<OrgKdeKwinIdle> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + OrgKdeKwinIdle(org_kde_kwin_idle* idle, WaylandConnection* connection); OrgKdeKwinIdle(const OrgKdeKwinIdle&) = delete; OrgKdeKwinIdle& operator=(const OrgKdeKwinIdle&) = delete;
diff --git a/ui/ozone/platform/wayland/host/wayland_auxiliary_window.cc b/ui/ozone/platform/wayland/host/wayland_auxiliary_window.cc deleted file mode 100644 index 42f30c81..0000000 --- a/ui/ozone/platform/wayland/host/wayland_auxiliary_window.cc +++ /dev/null
@@ -1,111 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/ozone/platform/wayland/host/wayland_auxiliary_window.h" - -#include "ui/ozone/platform/wayland/common/wayland_util.h" -#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h" -#include "ui/ozone/platform/wayland/host/wayland_connection.h" -#include "ui/ozone/platform/wayland/host/wayland_data_drag_controller.h" -#include "ui/ozone/platform/wayland/host/wayland_window_manager.h" - -namespace ui { - -WaylandAuxiliaryWindow::WaylandAuxiliaryWindow(PlatformWindowDelegate* delegate, - WaylandConnection* connection, - WaylandWindow* parent) - : WaylandWindow(delegate, connection) { - set_parent_window(parent); -} - -WaylandAuxiliaryWindow::~WaylandAuxiliaryWindow() = default; - -void WaylandAuxiliaryWindow::Show(bool inactive) { - if (subsurface_) - return; - - CreateSubsurface(); - UpdateWindowScale(false); - WaylandWindow::Show(inactive); -} - -void WaylandAuxiliaryWindow::Hide() { - if (!subsurface_) - return; - WaylandWindow::Hide(); - - subsurface_.reset(); - - // Detach buffer from surface in order to completely shutdown menus and - // tooltips, and release resources. - connection()->buffer_manager_host()->ResetSurfaceContents(root_surface()); -} - -bool WaylandAuxiliaryWindow::IsVisible() const { - return !!subsurface_; -} - -void WaylandAuxiliaryWindow::SetBounds(const gfx::Rect& bounds) { - auto old_bounds = GetBounds(); - WaylandWindow::SetBounds(bounds); - - if (old_bounds == bounds || !parent_window() || !subsurface_) - return; - - auto subsurface_bounds_dip = - wl::TranslateWindowBoundsToParentDIP(this, parent_window()); - wl_subsurface_set_position(subsurface_.get(), subsurface_bounds_dip.x(), - subsurface_bounds_dip.y()); - root_surface()->Commit(); - connection()->ScheduleFlush(); -} - -void WaylandAuxiliaryWindow::CreateSubsurface() { - // wl_subsurface can be used for either tooltips or drag arrow windows. - // If we are in a drag process, the current parent is the entered window, so - // reparent the surface unconditionally. - if (connection()->IsDragInProgress()) - set_parent_window(connection()->data_drag_controller()->entered_window()); - - if (!parent_window()) { - LOG(WARNING) << "Parent was not set for the auxiliary window; guessing it!"; - set_parent_window( - connection()->wayland_window_manager()->GetCurrentFocusedWindow()); - } - - DCHECK(parent_window()); - - // We need to make sure that window scale matches the parent window. - UpdateWindowScale(true); - - subsurface_ = - root_surface()->CreateSubsurface(parent_window()->root_surface()); - - auto subsurface_bounds_dip = - wl::TranslateWindowBoundsToParentDIP(this, parent_window()); - - DCHECK(subsurface_); - // Convert position to DIP. - wl_subsurface_set_position(subsurface_.get(), subsurface_bounds_dip.x(), - subsurface_bounds_dip.y()); - wl_subsurface_set_desync(subsurface_.get()); - root_surface()->Commit(); - connection()->ScheduleFlush(); - - // Notify the observers the window has been configured. Please note that - // subsurface doesn't send ack configure events. Thus, notify the observers as - // soon as the subsurface is created. - connection()->wayland_window_manager()->NotifyWindowConfigured(this); -} - -bool WaylandAuxiliaryWindow::OnInitialize( - PlatformWindowInitProperties properties) { - return true; -} - -bool WaylandAuxiliaryWindow::IsSurfaceConfigured() { - return !!subsurface_; -} - -} // namespace ui
diff --git a/ui/ozone/platform/wayland/host/wayland_auxiliary_window.h b/ui/ozone/platform/wayland/host/wayland_auxiliary_window.h deleted file mode 100644 index 1ec6536..0000000 --- a/ui/ozone/platform/wayland/host/wayland_auxiliary_window.h +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_AUXILIARY_WINDOW_H_ -#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_AUXILIARY_WINDOW_H_ - -#include "ui/ozone/platform/wayland/host/wayland_window.h" - -namespace ui { - -// A WaylandWindow implementation to show tooltips and arrow windows. -class WaylandAuxiliaryWindow : public WaylandWindow { - public: - WaylandAuxiliaryWindow(PlatformWindowDelegate* delegate, - WaylandConnection* connection, - WaylandWindow* parent); - WaylandAuxiliaryWindow(const WaylandAuxiliaryWindow&) = delete; - WaylandAuxiliaryWindow& operator=(const WaylandAuxiliaryWindow&) = delete; - ~WaylandAuxiliaryWindow() override; - - // PlatformWindow overrides: - void Show(bool inactive) override; - void Hide() override; - bool IsVisible() const override; - void SetBounds(const gfx::Rect& bounds) override; - - private: - // WaylandWindow overrides: - bool OnInitialize(PlatformWindowInitProperties properties) override; - bool IsSurfaceConfigured() override; - - // Creates (if necessary) and shows a subsurface window. - void CreateSubsurface(); - - wl::Object<wl_subsurface> subsurface_; -}; - -} // namespace ui - -#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_AUXILIARY_WINDOW_H_
diff --git a/ui/ozone/platform/wayland/host/wayland_connection.cc b/ui/ozone/platform/wayland/host/wayland_connection.cc index bbd65f6..534b676 100644 --- a/ui/ozone/platform/wayland/host/wayland_connection.cc +++ b/ui/ozone/platform/wayland/host/wayland_connection.cc
@@ -67,60 +67,20 @@ namespace { -// These values are persisted to logs. Entries should not be renumbered and -// numeric values should never be reused. -// -// Append new shells before kMaxValue and update LinuxWaylandShell -// in tools/metrics/histograms/enums.xml accordingly. -// -// See also tools/metrics/histograms/README.md#enum-histograms -enum class UMALinuxWaylandShell { - kZauraShell = 0, - kGtkShell1 = 1, - kOrgKdePlasmaShell = 2, - kXdgWmBase = 3, - kXdgShellV6 = 4, - kZwlrLayerShellV1 = 5, - kMaxValue = kZwlrLayerShellV1, -}; - // The maximum supported versions for a given interface. // The version bound will be the minimum of the value and the version // advertised by the server. -constexpr uint32_t kMaxAuraShellVersion = 21; constexpr uint32_t kMaxCompositorVersion = 4; -constexpr uint32_t kMaxCursorShapesVersion = 1; -constexpr uint32_t kMaxGtkPrimarySelectionDeviceManagerVersion = 1; constexpr uint32_t kMaxKeyboardExtensionVersion = 2; -constexpr uint32_t kMaxLinuxDmabufVersion = 3; constexpr uint32_t kMaxSeatVersion = 5; -constexpr uint32_t kMaxShmVersion = 1; constexpr uint32_t kMaxXdgShellVersion = 3; constexpr uint32_t kMaxZXdgShellVersion = 1; -constexpr uint32_t kMaxDeviceManagerVersion = 3; constexpr uint32_t kMaxWpPresentationVersion = 1; constexpr uint32_t kMaxWpViewporterVersion = 1; constexpr uint32_t kMaxTextInputManagerVersion = 1; constexpr uint32_t kMaxExplicitSyncVersion = 2; constexpr uint32_t kMaxXdgDecorationVersion = 1; constexpr uint32_t kMaxExtendedDragVersion = 1; -// The minimum required version for a given interface. -// Ensures that the version bound (advertised by server) is higher than this -// value. -constexpr uint32_t kMinWlDrmVersion = 2; -constexpr uint32_t kMinWlOutputVersion = 2; -constexpr uint32_t kMinZwpPointerConstraintsVersion = 1; -constexpr uint32_t kMinZwpPointerGesturesVersion = 1; -constexpr uint32_t kMinZwpRelativePointerManagerVersion = 1; - -// gtk_shell1 exposes request_focus() since version 3. Below that, it is not -// interesting for us, although it provides some shell integration that might be -// useful. -constexpr uint32_t kMinGtkShell1Version = 3; -constexpr uint32_t kMaxGtkShell1Version = 4; - -constexpr uint32_t kMaxOrgKdeKwinIdleVersion = 1; -constexpr uint32_t kMaxZwpIdleInhibitManagerVersion = 1; int64_t ConvertTimespecToMicros(const struct timespec& ts) { // On 32-bit systems, the calculation cannot overflow int64_t. @@ -147,6 +107,8 @@ return result.ValueOrDie(); } +} // namespace + void ReportShellUMA(UMALinuxWaylandShell shell) { static std::set<UMALinuxWaylandShell> reported_shells; if (reported_shells.count(shell) > 0) @@ -155,8 +117,6 @@ reported_shells.insert(shell); } -} // namespace - WaylandConnection::WaylandConnection() = default; WaylandConnection::~WaylandConnection() = default; @@ -191,6 +151,25 @@ } #endif + // Register factories for classes that implement wl::GlobalObjectRegistrar<T>. + // Keep alphabetical order for convenience. + GtkPrimarySelectionDeviceManager::Register(this); + GtkShell1::Register(this); + OrgKdeKwinIdle::Register(this); + WaylandDataDeviceManager::Register(this); + WaylandDrm::Register(this); + WaylandOutput::Register(this); + WaylandShm::Register(this); + WaylandZAuraShell::Register(this); + WaylandZcrCursorShapes::Register(this); + WaylandZwpLinuxDmabuf::Register(this); + WaylandZwpPointerConstraints::Register(this); + WaylandZwpPointerGestures::Register(this); + WaylandZwpRelativePointerManager::Register(this); + XdgForeignWrapper::Register(this); + ZwpIdleInhibitManager::Register(this); + ZwpPrimarySelectionDeviceManager::Register(this); + static constexpr wl_registry_listener registry_listener = { &Global, &GlobalRemove, @@ -252,6 +231,14 @@ return true; } +void WaylandConnection::RegisterGlobalObjectFactory( + const char* interface_name, + wl::GlobalObjectFactory factory) { + DCHECK_EQ(global_object_factories_.count(interface_name), 0U); + + global_object_factories_[interface_name] = factory; +} + void WaylandConnection::ScheduleFlush() { // When we are in tests, the message loop is set later when the // initialization of the OzonePlatform complete. Thus, just @@ -447,7 +434,12 @@ }; WaylandConnection* connection = static_cast<WaylandConnection*>(data); - if (!connection->compositor_ && strcmp(interface, "wl_compositor") == 0) { + + auto factory_it = connection->global_object_factories_.find(interface); + if (factory_it != connection->global_object_factories_.end()) { + (*factory_it->second)(connection, registry, name, version); + } else if (!connection->compositor_ && + strcmp(interface, "wl_compositor") == 0) { connection->compositor_ = wl::Bind<wl_compositor>( registry, name, std::min(version, kMaxCompositorVersion)); connection->compositor_version_ = version; @@ -462,14 +454,6 @@ LOG(ERROR) << "Failed to bind to wl_subcompositor global"; return; } - } else if (!connection->shm_ && strcmp(interface, "wl_shm") == 0) { - wl::Object<wl_shm> shm = - wl::Bind<wl_shm>(registry, name, std::min(version, kMaxShmVersion)); - connection->shm_ = std::make_unique<WaylandShm>(shm.release(), connection); - if (!connection->shm_) { - LOG(ERROR) << "Failed to bind to wl_shm global"; - return; - } } else if (!connection->seat_ && strcmp(interface, "wl_seat") == 0) { connection->seat_ = wl::Bind<wl_seat>(registry, name, std::min(version, kMaxSeatVersion)); @@ -501,84 +485,6 @@ xdg_wm_base_add_listener(connection->shell_.get(), &shell_listener, connection); ReportShellUMA(UMALinuxWaylandShell::kXdgWmBase); - } else if (base::EqualsCaseInsensitiveASCII(interface, "wl_output")) { - if (version < kMinWlOutputVersion) { - LOG(ERROR) - << "Unable to bind to the unsupported wl_output object with version= " - << version << ". Minimum supported version is " - << kMinWlOutputVersion; - return; - } - - auto output = wl::Bind<wl_output>(registry, name, version); - if (!output) { - LOG(ERROR) << "Failed to bind to wl_output global"; - return; - } - - if (!connection->wayland_output_manager_) { - connection->wayland_output_manager_ = - std::make_unique<WaylandOutputManager>(connection); - } - connection->wayland_output_manager_->AddWaylandOutput(name, - output.release()); - } else if (!connection->data_device_manager_ && - strcmp(interface, "wl_data_device_manager") == 0) { - auto data_device_manager = wl::Bind<wl_data_device_manager>( - registry, name, std::min(version, kMaxDeviceManagerVersion)); - if (!data_device_manager) { - LOG(ERROR) << "Failed to bind to wl_data_device_manager global"; - return; - } - connection->data_device_manager_ = - std::make_unique<WaylandDataDeviceManager>( - data_device_manager.release(), connection); - connection->CreateDataObjectsIfReady(); - } else if (!connection->gtk_primary_selection_device_manager_ && - strcmp(interface, "gtk_primary_selection_device_manager") == 0) { - auto manager = wl::Bind<::gtk_primary_selection_device_manager>( - registry, name, - std::min(version, kMaxGtkPrimarySelectionDeviceManagerVersion)); - if (!manager) { - LOG(ERROR) << "Failed to bind gtk_primary_selection_device_manager"; - return; - } - connection->gtk_primary_selection_device_manager_ = - std::make_unique<GtkPrimarySelectionDeviceManager>(manager.release(), - connection); - } else if (!connection->gtk_shell1_ && strcmp(interface, "gtk_shell1") == 0 && - version >= kMinGtkShell1Version) { - auto gtk_shell1 = wl::Bind<::gtk_shell1>( - registry, name, std::min(version, kMaxGtkShell1Version)); - if (!gtk_shell1) { - LOG(ERROR) << "Failed to bind gtk_shell1"; - return; - } - connection->gtk_shell1_ = std::make_unique<GtkShell1>(gtk_shell1.release()); - ReportShellUMA(UMALinuxWaylandShell::kGtkShell1); - } else if (!connection->zwp_idle_inhibit_manager_ && - strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0) { - auto manager = wl::Bind<zwp_idle_inhibit_manager_v1>( - registry, name, std::min(version, kMaxZwpIdleInhibitManagerVersion)); - if (!manager) { - LOG(ERROR) << "Failed to bind zwp_idle_inhibit_manager_v1"; - return; - } - connection->zwp_idle_inhibit_manager_ = - std::make_unique<ZwpIdleInhibitManager>(manager.release(), connection); - } else if (!connection->zwp_primary_selection_device_manager_ && - strcmp(interface, "zwp_primary_selection_device_manager_v1") == - 0) { - auto manager = wl::Bind<zwp_primary_selection_device_manager_v1>( - registry, name, - std::min(version, kMaxGtkPrimarySelectionDeviceManagerVersion)); - if (!manager) { - LOG(ERROR) << "Failed to bind zwp_primary_selection_device_manager_v1"; - return; - } - connection->zwp_primary_selection_device_manager_ = - std::make_unique<ZwpPrimarySelectionDeviceManager>(manager.release(), - connection); } else if (!connection->linux_explicit_synchronization_ && (strcmp(interface, "zwp_linux_explicit_synchronization_v1") == 0)) { @@ -589,16 +495,6 @@ LOG(ERROR) << "Failed to bind zwp_linux_explicit_synchronization_v1"; return; } - } else if (!connection->zwp_dmabuf_ && - (strcmp(interface, "zwp_linux_dmabuf_v1") == 0)) { - auto zwp_linux_dmabuf = wl::Bind<zwp_linux_dmabuf_v1>( - registry, name, std::min(version, kMaxLinuxDmabufVersion)); - if (!zwp_linux_dmabuf) { - LOG(ERROR) << "Failed to bind zwp_linux_dmabuf_v1"; - return; - } - connection->zwp_dmabuf_ = std::make_unique<WaylandZwpLinuxDmabuf>( - zwp_linux_dmabuf.release(), connection); } else if (!connection->presentation_ && (strcmp(interface, "wp_presentation") == 0)) { connection->presentation_ = wl::Bind<wp_presentation>( @@ -617,16 +513,6 @@ LOG(ERROR) << "Failed to bind wp_viewporter"; return; } - } else if (!connection->zcr_cursor_shapes_ && - strcmp(interface, "zcr_cursor_shapes_v1") == 0) { - auto zcr_cursor_shapes = wl::Bind<zcr_cursor_shapes_v1>( - registry, name, std::min(version, kMaxCursorShapesVersion)); - if (!zcr_cursor_shapes) { - LOG(ERROR) << "Failed to bind zcr_cursor_shapes_v1"; - return; - } - connection->zcr_cursor_shapes_ = std::make_unique<WaylandZcrCursorShapes>( - zcr_cursor_shapes.release(), connection); } else if (!connection->keyboard_extension_v1_ && strcmp(interface, "zcr_keyboard_extension_v1") == 0) { connection->keyboard_extension_v1_ = wl::Bind<zcr_keyboard_extension_v1>( @@ -646,73 +532,6 @@ LOG(ERROR) << "Failed to bind to zwp_text_input_manager_v1 global"; return; } - } else if (!connection->xdg_foreign_ && - strcmp(interface, "zxdg_exporter_v1") == 0) { - auto zxdg_exporter = wl::Bind<zxdg_exporter_v1>(registry, name, version); - if (!zxdg_exporter) { - LOG(ERROR) << "Failed to bind zxdg_exporter"; - return; - } - connection->xdg_foreign_ = std::make_unique<XdgForeignWrapper>( - connection, std::move(zxdg_exporter)); - } else if (!connection->drm_ && (strcmp(interface, "wl_drm") == 0) && - version >= kMinWlDrmVersion) { - auto wl_drm = wl::Bind<struct wl_drm>(registry, name, version); - if (!wl_drm) { - LOG(ERROR) << "Failed to bind wl_drm"; - return; - } - connection->drm_ = - std::make_unique<WaylandDrm>(wl_drm.release(), connection); - } else if (!connection->zaura_shell_ && - (strcmp(interface, "zaura_shell") == 0)) { - auto zaura_shell = wl::Bind<struct zaura_shell>( - registry, name, std::min(version, kMaxAuraShellVersion)); - if (!zaura_shell) { - LOG(ERROR) << "Failed to bind zaura_shell"; - return; - } - connection->zaura_shell_ = - std::make_unique<WaylandZAuraShell>(zaura_shell.release(), connection); - ReportShellUMA(UMALinuxWaylandShell::kZauraShell); - } else if (!connection->wayland_zwp_pointer_gestures_ && - strcmp(interface, "zwp_pointer_gestures_v1") == 0 && - version >= kMinZwpPointerGesturesVersion) { - auto zwp_pointer_gestures_v1 = - wl::Bind<struct zwp_pointer_gestures_v1>(registry, name, version); - if (!zwp_pointer_gestures_v1) { - LOG(ERROR) << "Failed to bind wp_pointer_gestures_v1"; - return; - } - connection->wayland_zwp_pointer_gestures_ = - std::make_unique<WaylandZwpPointerGestures>( - zwp_pointer_gestures_v1.release(), connection, - connection->event_source()); - } else if (!connection->wayland_zwp_pointer_constraints_ && - strcmp(interface, "zwp_pointer_constraints_v1") == 0 && - version >= kMinZwpPointerConstraintsVersion) { - auto zwp_pointer_constraints_v1 = - wl::Bind<struct zwp_pointer_constraints_v1>(registry, name, version); - if (!zwp_pointer_constraints_v1) { - LOG(ERROR) << "Failed to bind wp_pointer_constraints_v1"; - return; - } - connection->wayland_zwp_pointer_constraints_ = - std::make_unique<WaylandZwpPointerConstraints>( - zwp_pointer_constraints_v1.release(), connection); - } else if (!connection->wayland_zwp_relative_pointer_manager_ && - strcmp(interface, "zwp_relative_pointer_manager_v1") == 0 && - version >= kMinZwpRelativePointerManagerVersion) { - auto zwp_relative_pointer_manager_v1 = - wl::Bind<struct zwp_relative_pointer_manager_v1>(registry, name, - version); - if (!zwp_relative_pointer_manager_v1) { - LOG(ERROR) << "Failed to bind zwp_relative_pointer_manager_v1"; - return; - } - connection->wayland_zwp_relative_pointer_manager_ = - std::make_unique<WaylandZwpRelativePointerManager>( - zwp_relative_pointer_manager_v1.release(), connection); } else if (!connection->xdg_decoration_manager_ && strcmp(interface, "zxdg_decoration_manager_v1") == 0) { connection->xdg_decoration_manager_ = @@ -730,16 +549,6 @@ LOG(ERROR) << "Failed to bind to zcr_extended_drag_v1 global"; return; } - } else if (!connection->org_kde_kwin_idle_ && - strcmp(interface, "org_kde_kwin_idle") == 0) { - auto idle = wl::Bind<struct org_kde_kwin_idle>( - registry, name, std::min(version, kMaxOrgKdeKwinIdleVersion)); - if (!idle) { - LOG(ERROR) << "Failed to bind to org_kde_kwin_idle global"; - return; - } - connection->org_kde_kwin_idle_ = - std::make_unique<OrgKdeKwinIdle>(idle.release(), connection); } else if (strcmp(interface, "org_kde_plasma_shell") == 0) { NOTIMPLEMENTED_LOG_ONCE() << interface << " is recognized but not yet supported";
diff --git a/ui/ozone/platform/wayland/host/wayland_connection.h b/ui/ozone/platform/wayland/host/wayland_connection.h index 1565ae8..a24d47c 100644 --- a/ui/ozone/platform/wayland/host/wayland_connection.h +++ b/ui/ozone/platform/wayland/host/wayland_connection.h
@@ -7,8 +7,10 @@ #include <time.h> #include <memory> +#include <string> #include <vector> +#include "base/containers/flat_map.h" #include "base/time/time.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/events/event.h" @@ -58,6 +60,25 @@ class ZwpPrimarySelectionDeviceManager; class XdgForeignWrapper; +// These values are persisted to logs. Entries should not be renumbered and +// numeric values should never be reused. +// +// Append new shells before kMaxValue and update LinuxWaylandShell +// in tools/metrics/histograms/enums.xml accordingly. +// +// See also tools/metrics/histograms/README.md#enum-histograms +enum class UMALinuxWaylandShell { + kZauraShell = 0, + kGtkShell1 = 1, + kOrgKdePlasmaShell = 2, + kXdgWmBase = 3, + kXdgShellV6 = 4, + kZwlrLayerShellV1 = 5, + kMaxValue = kZwlrLayerShellV1, +}; + +void ReportShellUMA(UMALinuxWaylandShell shell); + class WaylandConnection { public: // Stores the last serial and the event type it is associated with. @@ -73,6 +94,9 @@ bool Initialize(); + void RegisterGlobalObjectFactory(const char* interface_name, + wl::GlobalObjectFactory factory); + // Schedules a flush of the Wayland connection. void ScheduleFlush(); @@ -246,6 +270,29 @@ private: friend class WaylandConnectionTestApi; + // All global Wayland objects are friends of the Wayland connection. + // Conceptually, this is correct: globals are owned by the connection and are + // accessed via it, so they are essentially parts of it. Also this friendship + // makes it possible to avoid exposing setters for all those global objects: + // these setters would only be needed by the globals but would be visible to + // everyone. + friend class GtkPrimarySelectionDeviceManager; + friend class GtkShell1; + friend class OrgKdeKwinIdle; + friend class WaylandDataDeviceManager; + friend class WaylandDrm; + friend class WaylandOutput; + friend class WaylandShm; + friend class WaylandZAuraShell; + friend class WaylandZwpLinuxDmabuf; + friend class WaylandZwpPointerConstraints; + friend class WaylandZwpPointerGestures; + friend class WaylandZwpRelativePointerManager; + friend class WaylandZcrCursorShapes; + friend class XdgForeignWrapper; + friend class ZwpIdleInhibitManager; + friend class ZwpPrimarySelectionDeviceManager; + void Flush(); void UpdateInputDevices(wl_seat* seat, uint32_t capabilities); @@ -280,6 +327,8 @@ // xdg_wm_base_listener static void ClockId(void* data, wp_presentation* shell_v6, uint32_t clk_id); + base::flat_map<std::string, wl::GlobalObjectFactory> global_object_factories_; + uint32_t compositor_version_ = 0; wl::Object<wl_display> display_; wl::Object<wl_proxy> wrapped_display_;
diff --git a/ui/ozone/platform/wayland/host/wayland_data_device_manager.cc b/ui/ozone/platform/wayland/host/wayland_data_device_manager.cc index f800dcb..036512a 100644 --- a/ui/ozone/platform/wayland/host/wayland_data_device_manager.cc +++ b/ui/ozone/platform/wayland/host/wayland_data_device_manager.cc
@@ -6,12 +6,42 @@ #include <memory> +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_data_device.h" #include "ui/ozone/platform/wayland/host/wayland_data_source.h" namespace ui { +namespace { +constexpr uint32_t kMaxDeviceManagerVersion = 3; +} + +// static +void WaylandDataDeviceManager::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory( + "wl_data_device_manager", &WaylandDataDeviceManager::Instantiate); +} + +// static +void WaylandDataDeviceManager::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->data_device_manager_) + return; + + auto data_device_manager = wl::Bind<wl_data_device_manager>( + registry, name, std::min(version, kMaxDeviceManagerVersion)); + if (!data_device_manager) { + LOG(ERROR) << "Failed to bind to wl_data_device_manager global"; + return; + } + connection->data_device_manager_ = std::make_unique<WaylandDataDeviceManager>( + data_device_manager.release(), connection); + connection->CreateDataObjectsIfReady(); +} + WaylandDataDeviceManager::WaylandDataDeviceManager( wl_data_device_manager* device_manager, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/wayland_data_device_manager.h b/ui/ozone/platform/wayland/host/wayland_data_device_manager.h index 7ed3a33..76925e8 100644 --- a/ui/ozone/platform/wayland/host/wayland_data_device_manager.h +++ b/ui/ozone/platform/wayland/host/wayland_data_device_manager.h
@@ -15,8 +15,15 @@ class WaylandConnection; class WaylandDataDevice; -class WaylandDataDeviceManager { +class WaylandDataDeviceManager + : public wl::GlobalObjectRegistrar<WaylandDataDeviceManager> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + using DataSource = WaylandDataSource; using DataDevice = WaylandDataDevice;
diff --git a/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc b/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc index 779febc..fcc4995 100644 --- a/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc
@@ -761,7 +761,7 @@ auto* surface = self->GetMockSurface(popup_window->root_surface()->GetSurfaceId()); ASSERT_TRUE(surface); - EXPECT_NE(nullptr, surface->sub_surface()); + EXPECT_NE(nullptr, surface->xdg_surface()->xdg_popup()); }; ScheduleTestTask(base::BindOnce(test, base::Unretained(this)));
diff --git a/ui/ozone/platform/wayland/host/wayland_drm.cc b/ui/ozone/platform/wayland/host/wayland_drm.cc index 121cbb0b..cb1062d 100644 --- a/ui/ozone/platform/wayland/host/wayland_drm.cc +++ b/ui/ozone/platform/wayland/host/wayland_drm.cc
@@ -16,6 +16,31 @@ namespace ui { +namespace { +constexpr uint32_t kMinWlDrmVersion = 2; +} + +// static +void WaylandDrm::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("wl_drm", &WaylandDrm::Instantiate); +} + +// static +void WaylandDrm::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->drm_ || version < kMinWlDrmVersion) + return; + + auto wl_drm = wl::Bind<struct wl_drm>(registry, name, version); + if (!wl_drm) { + LOG(ERROR) << "Failed to bind wl_drm"; + return; + } + connection->drm_ = std::make_unique<WaylandDrm>(wl_drm.release(), connection); +} + WaylandDrm::WaylandDrm(wl_drm* drm, WaylandConnection* connection) : wl_drm_(drm), connection_(connection) { static constexpr wl_drm_listener kDrmListener = {
diff --git a/ui/ozone/platform/wayland/host/wayland_drm.h b/ui/ozone/platform/wayland/host/wayland_drm.h index 0a774327..eafb9ed 100644 --- a/ui/ozone/platform/wayland/host/wayland_drm.h +++ b/ui/ozone/platform/wayland/host/wayland_drm.h
@@ -27,8 +27,14 @@ // Wrapper around |wl_drm| Wayland factory, which creates // |wl_buffer|s backed by dmabuf prime file descriptors. -class WaylandDrm { +class WaylandDrm : public wl::GlobalObjectRegistrar<WaylandDrm> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + WaylandDrm(wl_drm* drm, WaylandConnection* connection); ~WaylandDrm();
diff --git a/ui/ozone/platform/wayland/host/wayland_output.cc b/ui/ozone/platform/wayland/host/wayland_output.cc index 1275889..526647e 100644 --- a/ui/ozone/platform/wayland/host/wayland_output.cc +++ b/ui/ozone/platform/wayland/host/wayland_output.cc
@@ -4,12 +4,49 @@ #include "ui/ozone/platform/wayland/host/wayland_output.h" +#include "base/logging.h" #include "ui/display/display.h" #include "ui/gfx/color_space.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" +#include "ui/ozone/platform/wayland/host/wayland_output_manager.h" namespace ui { +namespace { +constexpr uint32_t kMinWlOutputVersion = 2; +} + +// static +void WaylandOutput::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("wl_output", + &WaylandOutput::Instantiate); +} + +// static +void WaylandOutput::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (version < kMinWlOutputVersion) { + LOG(ERROR) + << "Unable to bind to the unsupported wl_output object with version= " + << version << ". Minimum supported version is " << kMinWlOutputVersion; + return; + } + + auto output = wl::Bind<wl_output>(registry, name, version); + if (!output) { + LOG(ERROR) << "Failed to bind to wl_output global"; + return; + } + + if (!connection->wayland_output_manager_) { + connection->wayland_output_manager_ = + std::make_unique<WaylandOutputManager>(connection); + } + connection->wayland_output_manager_->AddWaylandOutput(name, output.release()); +} + WaylandOutput::WaylandOutput(uint32_t output_id, wl_output* output) : output_id_(output_id), output_(output),
diff --git a/ui/ozone/platform/wayland/host/wayland_output.h b/ui/ozone/platform/wayland/host/wayland_output.h index a60b05f..1c8b691a 100644 --- a/ui/ozone/platform/wayland/host/wayland_output.h +++ b/ui/ozone/platform/wayland/host/wayland_output.h
@@ -16,8 +16,14 @@ // WaylandOutput objects keep track of the current output of display // that are available to the application. -class WaylandOutput { +class WaylandOutput : public wl::GlobalObjectRegistrar<WaylandOutput> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + class Delegate { public: virtual void OnOutputHandleMetrics(uint32_t output_id,
diff --git a/ui/ozone/platform/wayland/host/wayland_popup.cc b/ui/ozone/platform/wayland/host/wayland_popup.cc index 02c85dd..4e79c56 100644 --- a/ui/ozone/platform/wayland/host/wayland_popup.cc +++ b/ui/ozone/platform/wayland/host/wayland_popup.cc
@@ -127,11 +127,21 @@ if (shell_popup_ && old_bounds != bounds && !wayland_sets_bounds_) { const auto bounds_dip = wl::TranslateWindowBoundsToParentDIP(this, parent_window()); + + // If Wayland moved the popup (for example, a dnd arrow icon), schedule + // redraw as Aura doesn't do that for moved surfaces. If redraw has not been + // scheduled and a new buffer is not attached, some compositors may not + // apply a new state. And committing the surface without attaching a buffer + // won't make Wayland compositor apply these new bounds. + schedule_redraw_ = old_bounds.origin() != GetBounds().origin(); + // If ShellPopup doesn't support repositioning, the popup will be recreated // with new geometry applied. Availability of methods to move/resize popup // surfaces purely depends on a protocol. See implementations of ShellPopup // for more details. if (!shell_popup_->SetBounds(bounds_dip)) { + // Always force redraw for recreated objects. + schedule_redraw_ = true; // This will also close all the children windows... Hide(); // ... and will result in showing them again starting with their parents. @@ -190,6 +200,11 @@ } void WaylandPopup::HandleSurfaceConfigure(uint32_t serial) { + if (schedule_redraw_) { + delegate()->OnDamageRect(gfx::Rect{{0, 0}, GetBounds().size()}); + schedule_redraw_ = false; + } + shell_popup()->AckConfigure(serial); }
diff --git a/ui/ozone/platform/wayland/host/wayland_popup.h b/ui/ozone/platform/wayland/host/wayland_popup.h index ec1a0c8..d0c5174 100644 --- a/ui/ozone/platform/wayland/host/wayland_popup.h +++ b/ui/ozone/platform/wayland/host/wayland_popup.h
@@ -60,6 +60,11 @@ // resulted in calling SetBounds. bool wayland_sets_bounds_ = false; + // If WaylandPopup has been moved, schedule redraw as the client of the + // Ozone/Wayland may not do so. Otherwise, a new state (if bounds has been + // changed) won't be applied. + bool schedule_redraw_ = false; + DISALLOW_COPY_AND_ASSIGN(WaylandPopup); };
diff --git a/ui/ozone/platform/wayland/host/wayland_shm.cc b/ui/ozone/platform/wayland/host/wayland_shm.cc index 9128e31e..27afbcf 100644 --- a/ui/ozone/platform/wayland/host/wayland_shm.cc +++ b/ui/ozone/platform/wayland/host/wayland_shm.cc
@@ -4,16 +4,38 @@ #include "ui/ozone/platform/wayland/host/wayland_shm.h" +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" namespace ui { namespace { - +constexpr uint32_t kMaxShmVersion = 1; constexpr uint32_t kShmFormat = WL_SHM_FORMAT_ARGB8888; - } // namespace +// static +void WaylandShm::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("wl_shm", &WaylandShm::Instantiate); +} + +// static +void WaylandShm::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->shm_) + return; + + auto shm = + wl::Bind<wl_shm>(registry, name, std::min(version, kMaxShmVersion)); + if (!shm) { + LOG(ERROR) << "Failed to bind to wl_shm global"; + return; + } + connection->shm_ = std::make_unique<WaylandShm>(shm.release(), connection); +} + WaylandShm::WaylandShm(wl_shm* shm, WaylandConnection* connection) : shm_(shm), connection_(connection) {}
diff --git a/ui/ozone/platform/wayland/host/wayland_shm.h b/ui/ozone/platform/wayland/host/wayland_shm.h index 1eafd53..7424127 100644 --- a/ui/ozone/platform/wayland/host/wayland_shm.h +++ b/ui/ozone/platform/wayland/host/wayland_shm.h
@@ -18,8 +18,14 @@ // Wrapper around |wl_shm| Wayland factory, which creates // |wl_buffer|s backed by a fd to a shared memory. -class WaylandShm { +class WaylandShm : public wl::GlobalObjectRegistrar<WaylandShm> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + WaylandShm(wl_shm* shm, WaylandConnection* connection); ~WaylandShm();
diff --git a/ui/ozone/platform/wayland/host/wayland_window_factory.cc b/ui/ozone/platform/wayland/host/wayland_window_factory.cc index a49ecc2..7cff660 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_factory.cc +++ b/ui/ozone/platform/wayland/host/wayland_window_factory.cc
@@ -7,7 +7,6 @@ #include "base/compiler_specific.h" #include "base/logging.h" #include "ui/gfx/native_widget_types.h" -#include "ui/ozone/platform/wayland/host/wayland_auxiliary_window.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_popup.h" #include "ui/ozone/platform/wayland/host/wayland_toplevel_window.h" @@ -36,7 +35,7 @@ if (connection->IsDragInProgress()) { // We are in the process of drag and requested a popup. Most probably, // it is an arrow window. - window = std::make_unique<WaylandAuxiliaryWindow>( + window = std::make_unique<WaylandPopup>( delegate, connection, GetParentWindow(connection, properties.parent_widget)); break;
diff --git a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc index 6986ac7..68121c6 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
@@ -3101,6 +3101,9 @@ VerifyAndClearExpectations(); + const gfx::Rect damage_rect = {0, 0, menu_window_bounds.width(), + menu_window_bounds.height()}; + EXPECT_CALL(delegate_, OnDamageRect(Eq(damage_rect))).Times(1); menu_window_bounds.set_origin({10, 10}); menu_window->SetBounds(menu_window_bounds);
diff --git a/ui/ozone/platform/wayland/host/wayland_zaura_shell.cc b/ui/ozone/platform/wayland/host/wayland_zaura_shell.cc index cad7227..171acf0 100644 --- a/ui/ozone/platform/wayland/host/wayland_zaura_shell.cc +++ b/ui/ozone/platform/wayland/host/wayland_zaura_shell.cc
@@ -7,12 +7,42 @@ #include <components/exo/wayland/protocol/aura-shell-client-protocol.h> #include "base/check.h" +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_output_manager.h" #include "ui/ozone/platform/wayland/host/wayland_screen.h" namespace ui { +namespace { +constexpr uint32_t kMaxAuraShellVersion = 21; +} + +// static +void WaylandZAuraShell::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("zaura_shell", + &WaylandZAuraShell::Instantiate); +} + +// static +void WaylandZAuraShell::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->zaura_shell_) + return; + + auto zaura_shell = wl::Bind<struct zaura_shell>( + registry, name, std::min(version, kMaxAuraShellVersion)); + if (!zaura_shell) { + LOG(ERROR) << "Failed to bind zaura_shell"; + return; + } + connection->zaura_shell_ = + std::make_unique<WaylandZAuraShell>(zaura_shell.release(), connection); + ReportShellUMA(UMALinuxWaylandShell::kZauraShell); +} + WaylandZAuraShell::WaylandZAuraShell(zaura_shell* aura_shell, WaylandConnection* connection) : obj_(aura_shell), connection_(connection) {
diff --git a/ui/ozone/platform/wayland/host/wayland_zaura_shell.h b/ui/ozone/platform/wayland/host/wayland_zaura_shell.h index 82a35ba..334f58a 100644 --- a/ui/ozone/platform/wayland/host/wayland_zaura_shell.h +++ b/ui/ozone/platform/wayland/host/wayland_zaura_shell.h
@@ -14,8 +14,14 @@ class WaylandConnection; // Wraps the zaura_shell object. -class WaylandZAuraShell { +class WaylandZAuraShell : public wl::GlobalObjectRegistrar<WaylandZAuraShell> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + WaylandZAuraShell(zaura_shell* aura_shell, WaylandConnection* connection); WaylandZAuraShell(const WaylandZAuraShell&) = delete; WaylandZAuraShell& operator=(const WaylandZAuraShell&) = delete;
diff --git a/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.cc b/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.cc index b805560..651e4f8 100644 --- a/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.cc +++ b/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.cc
@@ -15,8 +15,36 @@ namespace ui { +namespace { +constexpr uint32_t kMaxCursorShapesVersion = 1; +} + using mojom::CursorType; +// static +void WaylandZcrCursorShapes::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("zcr_cursor_shapes_v1", + &WaylandZcrCursorShapes::Instantiate); +} + +// static +void WaylandZcrCursorShapes::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->zcr_cursor_shapes_) + return; + + auto zcr_cursor_shapes = wl::Bind<zcr_cursor_shapes_v1>( + registry, name, std::min(version, kMaxCursorShapesVersion)); + if (!zcr_cursor_shapes) { + LOG(ERROR) << "Failed to bind zcr_cursor_shapes_v1"; + return; + } + connection->zcr_cursor_shapes_ = std::make_unique<WaylandZcrCursorShapes>( + zcr_cursor_shapes.release(), connection); +} + WaylandZcrCursorShapes::WaylandZcrCursorShapes( zcr_cursor_shapes_v1* zcr_cursor_shapes, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.h b/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.h index 0b78df0..9780c13 100644 --- a/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.h +++ b/ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.h
@@ -16,8 +16,15 @@ // Wraps the zcr_cursor_shapes interface for Wayland (exo) server-side cursor // support. Exists to support Lacros, which uses server-side cursors for // consistency with ARC++ and for accessibility support. -class WaylandZcrCursorShapes { +class WaylandZcrCursorShapes + : public wl::GlobalObjectRegistrar<WaylandZcrCursorShapes> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + WaylandZcrCursorShapes(zcr_cursor_shapes_v1* zcr_cursor_shapes, WaylandConnection* connection); WaylandZcrCursorShapes(const WaylandZcrCursorShapes&) = delete;
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc b/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc index 31bd50ae..edc00fc5 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc +++ b/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc
@@ -7,11 +7,40 @@ #include <drm_fourcc.h> #include <linux-dmabuf-unstable-v1-client-protocol.h> +#include "base/logging.h" #include "ui/gfx/linux/drm_util_linux.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" namespace ui { +namespace { +constexpr uint32_t kMaxLinuxDmabufVersion = 3; +} + +// static +void WaylandZwpLinuxDmabuf::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("zwp_linux_dmabuf_v1", + &WaylandZwpLinuxDmabuf::Instantiate); +} + +// static +void WaylandZwpLinuxDmabuf::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->zwp_dmabuf()) + return; + + auto zwp_linux_dmabuf = wl::Bind<zwp_linux_dmabuf_v1>( + registry, name, std::min(version, kMaxLinuxDmabufVersion)); + if (!zwp_linux_dmabuf) { + LOG(ERROR) << "Failed to bind zwp_linux_dmabuf_v1"; + return; + } + connection->zwp_dmabuf_ = std::make_unique<WaylandZwpLinuxDmabuf>( + zwp_linux_dmabuf.release(), connection); +} + WaylandZwpLinuxDmabuf::WaylandZwpLinuxDmabuf( zwp_linux_dmabuf_v1* zwp_linux_dmabuf, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h b/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h index 3139ce2..e6c4763 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h +++ b/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h
@@ -27,8 +27,15 @@ // Wrapper around |zwp_linux_dmabuf_v1| Wayland factory, which creates // |wl_buffer|s backed by dmabuf prime file descriptor. -class WaylandZwpLinuxDmabuf { +class WaylandZwpLinuxDmabuf + : public wl::GlobalObjectRegistrar<WaylandZwpLinuxDmabuf> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + WaylandZwpLinuxDmabuf(zwp_linux_dmabuf_v1* zwp_linux_dmabuf, WaylandConnection* connection); ~WaylandZwpLinuxDmabuf();
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.cc b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.cc index 887467af..b0c3544 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.cc +++ b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.cc
@@ -6,6 +6,7 @@ #include <pointer-constraints-unstable-v1-client-protocol.h> +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_pointer.h" #include "ui/ozone/platform/wayland/host/wayland_surface.h" @@ -13,6 +14,37 @@ namespace ui { +namespace { +constexpr uint32_t kMinZwpPointerConstraintsVersion = 1; +} + +// static +void WaylandZwpPointerConstraints::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory( + "zwp_pointer_constraints_v1", &WaylandZwpPointerConstraints::Instantiate); +} + +// static +void WaylandZwpPointerConstraints::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->wayland_zwp_pointer_constraints_ || + version < kMinZwpPointerConstraintsVersion) { + return; + } + + auto zwp_pointer_constraints_v1 = + wl::Bind<struct zwp_pointer_constraints_v1>(registry, name, version); + if (!zwp_pointer_constraints_v1) { + LOG(ERROR) << "Failed to bind wp_pointer_constraints_v1"; + return; + } + connection->wayland_zwp_pointer_constraints_ = + std::make_unique<WaylandZwpPointerConstraints>( + zwp_pointer_constraints_v1.release(), connection); +} + WaylandZwpPointerConstraints::WaylandZwpPointerConstraints( zwp_pointer_constraints_v1* pointer_constraints, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.h b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.h index c0f04fe..31f1262 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.h +++ b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_constraints.h
@@ -13,8 +13,15 @@ class WaylandSurface; // Wraps the zwp_pointer_constraints_v1 object. -class WaylandZwpPointerConstraints { +class WaylandZwpPointerConstraints + : public wl::GlobalObjectRegistrar<WaylandZwpPointerConstraints> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + WaylandZwpPointerConstraints(zwp_pointer_constraints_v1* pointer_constraints, WaylandConnection* connection);
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.cc b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.cc index 814b4d8..86a0d3a 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.cc +++ b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.cc
@@ -7,15 +7,48 @@ #include <pointer-gestures-unstable-v1-client-protocol.h> #include <wayland-util.h> +#include "base/logging.h" #include "ui/gfx/geometry/vector2d_f.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_cursor_position.h" +#include "ui/ozone/platform/wayland/host/wayland_event_source.h" #include "ui/ozone/platform/wayland/host/wayland_pointer.h" #include "ui/ozone/platform/wayland/host/wayland_window_manager.h" namespace ui { +namespace { +constexpr uint32_t kMinZwpPointerGesturesVersion = 1; +} + +// static +void WaylandZwpPointerGestures::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory( + "zwp_pointer_gestures_v1", &WaylandZwpPointerGestures::Instantiate); +} + +// static +void WaylandZwpPointerGestures::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->wayland_zwp_pointer_gestures_ || + version < kMinZwpPointerGesturesVersion) + return; + + auto zwp_pointer_gestures_v1 = + wl::Bind<struct zwp_pointer_gestures_v1>(registry, name, version); + if (!zwp_pointer_gestures_v1) { + LOG(ERROR) << "Failed to bind wp_pointer_gestures_v1"; + return; + } + connection->wayland_zwp_pointer_gestures_ = + std::make_unique<WaylandZwpPointerGestures>( + zwp_pointer_gestures_v1.release(), connection, + connection->event_source()); +} + WaylandZwpPointerGestures::WaylandZwpPointerGestures( zwp_pointer_gestures_v1* pointer_gestures, WaylandConnection* connection,
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.h b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.h index 3c3ad05..ab24678 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.h +++ b/ui/ozone/platform/wayland/host/wayland_zwp_pointer_gestures.h
@@ -19,8 +19,15 @@ class WaylandConnection; // Wraps the zwp_pointer_gestures and zwp_pointer_gesture_pinch_v1 objects. -class WaylandZwpPointerGestures { +class WaylandZwpPointerGestures + : public wl::GlobalObjectRegistrar<WaylandZwpPointerGestures> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + class Delegate; WaylandZwpPointerGestures(zwp_pointer_gestures_v1* pointer_gestures,
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.cc b/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.cc index 6925a6d..26c9cc38 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.cc +++ b/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.cc
@@ -6,12 +6,45 @@ #include <relative-pointer-unstable-v1-client-protocol.h> +#include "base/logging.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_pointer.h" namespace ui { +namespace { +constexpr uint32_t kMinZwpRelativePointerManagerVersion = 1; +} + +// static +void WaylandZwpRelativePointerManager::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory( + "zwp_relative_pointer_manager_v1", + &WaylandZwpRelativePointerManager::Instantiate); +} + +// static +void WaylandZwpRelativePointerManager::Instantiate( + WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->wayland_zwp_relative_pointer_manager_ || + version < kMinZwpRelativePointerManagerVersion) + return; + + auto zwp_relative_pointer_manager_v1 = + wl::Bind<struct zwp_relative_pointer_manager_v1>(registry, name, version); + if (!zwp_relative_pointer_manager_v1) { + LOG(ERROR) << "Failed to bind zwp_relative_pointer_manager_v1"; + return; + } + connection->wayland_zwp_relative_pointer_manager_ = + std::make_unique<WaylandZwpRelativePointerManager>( + zwp_relative_pointer_manager_v1.release(), connection); +} + WaylandZwpRelativePointerManager::WaylandZwpRelativePointerManager( zwp_relative_pointer_manager_v1* relative_pointer_manager, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.h b/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.h index 473f1379..48799e8 100644 --- a/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.h +++ b/ui/ozone/platform/wayland/host/wayland_zwp_relative_pointer_manager.h
@@ -16,8 +16,15 @@ class WaylandConnection; // Wraps the zwp_relative_pointer_manager_v1 object. -class WaylandZwpRelativePointerManager { +class WaylandZwpRelativePointerManager + : public wl::GlobalObjectRegistrar<WaylandZwpRelativePointerManager> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + class Delegate; WaylandZwpRelativePointerManager(
diff --git a/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc b/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc index bb2cd600..43a419c1 100644 --- a/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc +++ b/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc
@@ -6,12 +6,36 @@ #include <xdg-foreign-unstable-v1-client-protocol.h> +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_window.h" #include "ui/platform_window/platform_window_init_properties.h" namespace ui { +// static +void XdgForeignWrapper::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("zxdg_exporter_v1", + &XdgForeignWrapper::Instantiate); +} + +// static +void XdgForeignWrapper::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->xdg_foreign_) + return; + + auto zxdg_exporter = wl::Bind<zxdg_exporter_v1>(registry, name, version); + if (!zxdg_exporter) { + LOG(ERROR) << "Failed to bind zxdg_exporter"; + return; + } + connection->xdg_foreign_ = + std::make_unique<XdgForeignWrapper>(connection, std::move(zxdg_exporter)); +} + struct XdgForeignWrapper::ExportedSurface { ExportedSurface(wl_surface* surface, OnHandleExported cb); ExportedSurface(ExportedSurface&& buffer);
diff --git a/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.h b/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.h index 50bb4f9..4187d80 100644 --- a/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.h +++ b/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.h
@@ -21,8 +21,15 @@ // may be exported. Currently supports only exporting surfaces. // // TODO(1126817): consider supporting xdg-foreign-v2. -class XdgForeignWrapper : public WaylandWindowObserver { +class XdgForeignWrapper : public wl::GlobalObjectRegistrar<XdgForeignWrapper>, + public WaylandWindowObserver { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + using OnHandleExported = base::OnceCallback<void(const std::string&)>; XdgForeignWrapper(WaylandConnection* connection,
diff --git a/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.cc b/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.cc index e431da6..ef9cf6fd 100644 --- a/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.cc +++ b/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.cc
@@ -6,10 +6,39 @@ #include <idle-inhibit-unstable-v1-client-protocol.h> +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" namespace ui { +namespace { +constexpr uint32_t kMaxZwpIdleInhibitManagerVersion = 1; +} + +// static +void ZwpIdleInhibitManager::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory("zwp_idle_inhibit_manager_v1", + &ZwpIdleInhibitManager::Instantiate); +} + +// static +void ZwpIdleInhibitManager::Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->zwp_idle_inhibit_manager_) + return; + + auto manager = wl::Bind<zwp_idle_inhibit_manager_v1>( + registry, name, std::min(version, kMaxZwpIdleInhibitManagerVersion)); + if (!manager) { + LOG(ERROR) << "Failed to bind zwp_idle_inhibit_manager_v1"; + return; + } + connection->zwp_idle_inhibit_manager_ = + std::make_unique<ZwpIdleInhibitManager>(manager.release(), connection); +} + ZwpIdleInhibitManager::ZwpIdleInhibitManager( zwp_idle_inhibit_manager_v1* manager, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.h b/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.h index eabda81..796945f 100644 --- a/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.h +++ b/ui/ozone/platform/wayland/host/zwp_idle_inhibit_manager.h
@@ -13,8 +13,15 @@ // Wraps the idle inhibit manager, which is provided via // zwp_idle_inhibit_manager_v1 interface. -class ZwpIdleInhibitManager { +class ZwpIdleInhibitManager + : public wl::GlobalObjectRegistrar<ZwpIdleInhibitManager> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + explicit ZwpIdleInhibitManager(zwp_idle_inhibit_manager_v1* manager, WaylandConnection* connection); ZwpIdleInhibitManager(const ZwpIdleInhibitManager&) = delete;
diff --git a/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc b/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc index f117180..532cf86e6 100644 --- a/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc +++ b/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc
@@ -8,12 +8,45 @@ #include <memory> -#include "ui/ozone/platform/wayland/host/zwp_primary_selection_device.h" +#include "base/logging.h" #include "ui/ozone/platform/wayland/host/wayland_connection.h" #include "ui/ozone/platform/wayland/host/wayland_data_source.h" +#include "ui/ozone/platform/wayland/host/zwp_primary_selection_device.h" namespace ui { +namespace { +constexpr uint32_t kMaxGtkPrimarySelectionDeviceManagerVersion = 1; +} // namespace + +// static +void ZwpPrimarySelectionDeviceManager::Register(WaylandConnection* connection) { + connection->RegisterGlobalObjectFactory( + "zwp_primary_selection_device_manager_v1", + &ZwpPrimarySelectionDeviceManager::Instantiate); +} + +// static +void ZwpPrimarySelectionDeviceManager::Instantiate( + WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version) { + if (connection->zwp_primary_selection_device_manager_) + return; + + auto manager = wl::Bind<zwp_primary_selection_device_manager_v1>( + registry, name, + std::min(version, kMaxGtkPrimarySelectionDeviceManagerVersion)); + if (!manager) { + LOG(ERROR) << "Failed to bind zwp_primary_selection_device_manager_v1"; + return; + } + connection->zwp_primary_selection_device_manager_ = + std::make_unique<ZwpPrimarySelectionDeviceManager>(manager.release(), + connection); +} + ZwpPrimarySelectionDeviceManager::ZwpPrimarySelectionDeviceManager( zwp_primary_selection_device_manager_v1* manager, WaylandConnection* connection)
diff --git a/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.h b/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.h index cdb44e5..5fe8fc8 100644 --- a/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.h +++ b/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.h
@@ -15,8 +15,15 @@ class ZwpPrimarySelectionDevice; class WaylandConnection; -class ZwpPrimarySelectionDeviceManager { +class ZwpPrimarySelectionDeviceManager + : public wl::GlobalObjectRegistrar<ZwpPrimarySelectionDeviceManager> { public: + static void Register(WaylandConnection* connection); + static void Instantiate(WaylandConnection* connection, + wl_registry* registry, + uint32_t name, + uint32_t version); + using DataSource = ZwpPrimarySelectionSource; using DataDevice = ZwpPrimarySelectionDevice;
diff --git a/weblayer/browser/cookie_manager_impl.cc b/weblayer/browser/cookie_manager_impl.cc index da88448..0c594c8 100644 --- a/weblayer/browser/cookie_manager_impl.cc +++ b/weblayer/browser/cookie_manager_impl.cc
@@ -151,8 +151,9 @@ bool CookieManagerImpl::SetCookieInternal(const GURL& url, const std::string& value, SetCookieCallback callback) { - auto cc = net::CanonicalCookie::Create(url, value, base::Time::Now(), - absl::nullopt); + auto cc = + net::CanonicalCookie::Create(url, value, base::Time::Now(), absl::nullopt, + net::CookiePartitionKey::Todo()); if (!cc) { return false; }