diff --git a/AUTHORS b/AUTHORS index 41f5b22d..4bb6b20 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -34,6 +34,7 @@ Aditya Bhargava <heuristicist@gmail.com> Adrian Belgun <adrian.belgun@intel.com> Adrian Ratiu <adrian.ratiu@collabora.corp-partner.google.com> +Adrià Vilanova Martínez <me@avm99963.com> Ahmet Emir Ercin <ahmetemiremir@gmail.com> Ajay Berwal <a.berwal@samsung.com> Ajay Berwal <ajay.berwal@samsung.com> @@ -924,6 +925,7 @@ Ryan Norton <rnorton10@gmail.com> Ryan Sleevi <ryan-chromium-dev@sleevi.com> Ryan Yoakum <ryoakum@skobalt.com> +Ryo Ogawa <negibokken@gmail.com> Ryuan Choi <ryuan.choi@samsung.com> Saikrishna Arcot <saiarcot895@gmail.com> Sajal Khandelwal <skhandelwa22@bloomberg.net>
diff --git a/DEPS b/DEPS index c3fde421..99484029 100644 --- a/DEPS +++ b/DEPS
@@ -209,11 +209,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': '08d0d86b8180011a57f00281f1884a74476850a8', + 'skia_revision': 'bb04e3d47ef89f03e22dcb299d1088fe05834200', # 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': 'ce8c2c2e4c61e901b5844e5d0f0abbbbbc904ccc', + 'v8_revision': 'f45b3fc3345843779621a676877f43b2f67b94e6', # 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. @@ -221,7 +221,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': '10f15011da42241e7053bd8a9d95d3a876faf75d', + 'angle_revision': '8664fbc0fb4608f7d034b3fb0eeecd8c34516c43', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -280,7 +280,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': '712eb08096321db1e89699f933c14fbd11fcb0ed', + 'catapult_revision': 'b8eb01bccda98024e755a2cc25b487f7e49097f2', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -288,7 +288,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': 'f5ed01df29c3e27ab2e9b21389ec7c46a38e7368', + 'devtools_frontend_revision': '278a9445896c9efcbe50529f79ff2fc0021ff4c7', # 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. @@ -328,7 +328,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': 'b44000e7af648a05fe7075ac189d9174a05654b0', + 'dawn_revision': 'c91ffdb37717762b05784ddf618279ff8aca01ad', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -946,7 +946,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' + '@' + 'ad4379840822c3831e1d3c00d613d67012fdf811', + 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '982a27aa6b95c0e515730c1ac2b89efb3c338e9c', 'condition': 'checkout_chromeos', }, @@ -966,7 +966,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '88910921065a288830f04199aedd2a41da3c6c40', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '8b3bc259a0e075b5fe351422f6c9c0ec7d0ed5e6', 'src/third_party/devtools-frontend/src': Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), @@ -1349,7 +1349,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + '5874d918cfb305895233228f4307b00fe5ac9c2d', + Var('android_git') + '/platform/external/perfetto.git' + '@' + '2d7bf1e435f95bbe0b2f7973c5ec978bd72ec41b', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1574,7 +1574,7 @@ Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '6e5cab434bacd6fcbb833b8e5cb8ff47495d4a64', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + 'd25af8ceac786684fed6c801b0f9c5e76443b640', + Var('webrtc_git') + '/src.git' + '@' + '1b63db956fb1131c540b701403acce9107f45148', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'), @@ -1601,7 +1601,7 @@ 'packages': [ { 'package': 'skia/tools/goldctl/linux-amd64', - 'version': 'fVbmAq5SyEKlNV_cPvOrlJbBRmDAWApv309sIMdbgq8C', + 'version': 'SB2wGV5iqWiiLLc3ZLU2sn1CcUnFefPLkUKPCgQ9swkC', }, ], 'dep_type': 'cipd', @@ -1611,7 +1611,7 @@ 'packages': [ { 'package': 'skia/tools/goldctl/windows-amd64', - 'version': 'hySBvc3hf9NRFmfS2oG52F9ZzLpvX9bFuyybtZ92CNAC', + 'version': 'C5XvIOVnzzsQevJZRD08B1C_6mhdpxvY9vPiHf4iZJ0C', }, ], 'dep_type': 'cipd', @@ -1621,7 +1621,7 @@ 'packages': [ { 'package': 'skia/tools/goldctl/mac-amd64', - 'version': 'SGAjTHEDDOpAgPQYJcSEmMh4E6afvlKQKzBjwSTf5dwC', + 'version': '3aDI3FukPbExUrKO2_xiMcP1_2EEcWDoL1X9tb3N1ucC', }, ], 'dep_type': 'cipd', @@ -1635,7 +1635,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@d932a2542eedd96d513e33e17cc2afb2a9120eec', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@c1bd44d9a514a09a16df6f6ca0460be6b2d1a217', 'condition': 'checkout_src_internal', }, @@ -1665,7 +1665,7 @@ 'packages': [ { 'package': 'chromeos_internal/apps/media_app/app', - 'version': 'nZQbCLVLZXhqeQVND_suj9_gQyVSt-tl7jFkdicBEyYC', + 'version': 'r2Fx9-2kUKP9602kDlV1UtcS3Z7XPdUyRd2f6hfUh8kC', }, ], 'condition': 'checkout_chromeos and checkout_src_internal',
diff --git a/android_webview/renderer/aw_content_renderer_client.cc b/android_webview/renderer/aw_content_renderer_client.cc index b903efcd..6b75f1bb 100644 --- a/android_webview/renderer/aw_content_renderer_client.cc +++ b/android_webview/renderer/aw_content_renderer_client.cc
@@ -170,9 +170,8 @@ new page_load_metrics::MetricsRenderFrameObserver(render_frame); } -void AwContentRendererClient::RenderViewCreated( - content::RenderView* render_view) { - AwRenderViewExt::WebViewCreated(render_view->GetWebView()); +void AwContentRendererClient::WebViewCreated(blink::WebView* web_view) { + AwRenderViewExt::WebViewCreated(web_view); } void AwContentRendererClient::PrepareErrorPage(
diff --git a/android_webview/renderer/aw_content_renderer_client.h b/android_webview/renderer/aw_content_renderer_client.h index 012ed6a0..18b3208 100644 --- a/android_webview/renderer/aw_content_renderer_client.h +++ b/android_webview/renderer/aw_content_renderer_client.h
@@ -38,7 +38,7 @@ void RenderThreadStarted() override; void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override; void RenderFrameCreated(content::RenderFrame* render_frame) override; - void RenderViewCreated(content::RenderView* render_view) override; + void WebViewCreated(blink::WebView* web_view) override; void PrepareErrorPage(content::RenderFrame* render_frame, const blink::WebURLError& error, const std::string& http_method,
diff --git a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java index e5fffa49..be927ad 100644 --- a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java +++ b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
@@ -704,6 +704,7 @@ settings.setGeolocationEnabled(true); settings.setDatabaseEnabled(true); settings.setDomStorageEnabled(true); + settings.setAllowFileAccess(true); // Default layout behavior for chrome on android. settings.setUseWideViewPort(true);
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 547d6e7..b324c46 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -641,8 +641,6 @@ "login/ui/login_error_bubble.h", "login/ui/login_expanded_public_account_view.cc", "login/ui/login_expanded_public_account_view.h", - "login/ui/login_menu_view.cc", - "login/ui/login_menu_view.h", "login/ui/login_palette.cc", "login/ui/login_palette.h", "login/ui/login_password_view.cc", @@ -653,10 +651,10 @@ "login/ui/login_pin_view.h", "login/ui/login_public_account_user_view.cc", "login/ui/login_public_account_user_view.h", + "login/ui/login_remove_account_dialog.cc", + "login/ui/login_remove_account_dialog.h", "login/ui/login_tooltip_view.cc", "login/ui/login_tooltip_view.h", - "login/ui/login_user_menu_view.cc", - "login/ui/login_user_menu_view.h", "login/ui/login_user_view.cc", "login/ui/login_user_view.h", "login/ui/media_controls_header_view.cc", @@ -671,8 +669,10 @@ "login/ui/pin_request_view.h", "login/ui/pin_request_widget.cc", "login/ui/pin_request_widget.h", - "login/ui/public_account_warning_dialog.cc", - "login/ui/public_account_warning_dialog.h", + "login/ui/public_account_menu_view.cc", + "login/ui/public_account_menu_view.h", + "login/ui/public_account_monitoring_info_dialog.cc", + "login/ui/public_account_monitoring_info_dialog.h", "login/ui/scrollable_users_list_view.cc", "login/ui/scrollable_users_list_view.h", "login/ui/system_label_button.cc", @@ -2169,11 +2169,11 @@ "login/ui/login_pin_input_view_unittest.cc", "login/ui/login_pin_view_unittest.cc", "login/ui/login_public_account_user_view_unittest.cc", + "login/ui/login_remove_account_dialog_unittest.cc", "login/ui/login_test_base.cc", "login/ui/login_test_base.h", "login/ui/login_test_utils.cc", "login/ui/login_test_utils.h", - "login/ui/login_user_menu_view_unittest.cc", "login/ui/login_user_view_unittest.cc", "login/ui/note_action_launch_button_unittest.cc", "login/ui/pin_request_view_unittest.cc", @@ -2470,6 +2470,7 @@ "//ash/public/cpp/external_arc:unit_tests", "//ash/public/cpp/holding_space:test_support", "//ash/resources/vector_icons", + "//ash/services/recording:test_support", "//ash/shortcut_viewer:unit_tests", "//ash/strings", "//ash/system/machine_learning:user_settings_event_proto", @@ -2840,6 +2841,7 @@ "//ash/keyboard/ui:test_support", "//ash/public/cpp", "//ash/public/cpp:test_support", + "//ash/services/recording:test_support", "//ash/services/recording/public/mojom", "//base", "//base:i18n",
diff --git a/ash/app_list/app_list_presenter_unittest.cc b/ash/app_list/app_list_presenter_unittest.cc index 2be0104..5be6ef5 100644 --- a/ash/app_list/app_list_presenter_unittest.cc +++ b/ash/app_list/app_list_presenter_unittest.cc
@@ -893,7 +893,7 @@ dragged_view->FireMouseDragTimerForTest(); event_generator->MoveMouseTo( apps_grid_view_->GetItemViewAt(2)->GetBoundsInScreen().left_center()); - EXPECT_TRUE(apps_grid_view_->dragging()); + EXPECT_TRUE(apps_grid_view_->IsDragging()); display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); display_manager()->SetDisplayRotation( @@ -906,7 +906,7 @@ app_list_view_->OnParentWindowBoundsChanged(); // Verify that mouse drag has been canceled due to mouse capture loss. - EXPECT_FALSE(apps_grid_view_->dragging()); + EXPECT_FALSE(apps_grid_view_->IsDragging()); EXPECT_EQ("Item 0", apps_grid_view_->GetItemViewAt(0)->item()->id()); EXPECT_EQ("Item 1", apps_grid_view_->GetItemViewAt(1)->item()->id()); EXPECT_EQ("Item 2", apps_grid_view_->GetItemViewAt(2)->item()->id()); @@ -940,7 +940,7 @@ EXPECT_TRUE(item_view->layer()) << "at " << i; } - EXPECT_TRUE(apps_grid_view_->dragging()); + EXPECT_TRUE(apps_grid_view_->IsDragging()); event_generator->ReleaseLeftButton(); // After the drag is released, the item bounds should animate to their final @@ -1086,8 +1086,8 @@ // The current behavior on app list bounds change is to close the active // folder, canceling the drag. EXPECT_FALSE(AppListIsInFolderView()); - EXPECT_FALSE(apps_grid_view_->dragging()); - EXPECT_FALSE(folder_view()->items_grid_view()->dragging()); + EXPECT_FALSE(apps_grid_view_->IsDragging()); + EXPECT_FALSE(folder_view()->items_grid_view()->IsDragging()); EXPECT_EQ("Item 0", apps_grid_view_->GetItemViewAt(0)->item()->id()); EXPECT_EQ("Item 1", apps_grid_view_->GetItemViewAt(1)->item()->id()); @@ -1223,7 +1223,7 @@ apps_grid_view_->GetItemViewAt(3)->GetBoundsInScreen().CenterPoint()); EXPECT_TRUE(apps_grid_view_->FireFolderDroppingTimerForTest()); event_generator->ReleaseLeftButton(); - EXPECT_FALSE(apps_grid_view_->dragging()); + EXPECT_FALSE(apps_grid_view_->IsDragging()); EXPECT_TRUE(apps_grid_view_->GetItemViewAt(3)->item()->is_folder()); EXPECT_EQ(dragged_item->folder_id(),
diff --git a/ash/app_list/views/app_list_folder_view.cc b/ash/app_list/views/app_list_folder_view.cc index a8acfa76..3852865 100644 --- a/ash/app_list/views/app_list_folder_view.cc +++ b/ash/app_list/views/app_list_folder_view.cc
@@ -774,7 +774,7 @@ } void AppListFolderView::ResetItemsGridForClose() { - if (items_grid_view()->dragging()) + if (items_grid_view()->IsDragging()) items_grid_view()->EndDrag(true); items_grid_view()->ClearAnySelectedView(); }
diff --git a/ash/app_list/views/app_list_item_view.cc b/ash/app_list/views/app_list_item_view.cc index 21b40b2..9522b50 100644 --- a/ash/app_list/views/app_list_item_view.cc +++ b/ash/app_list/views/app_list_item_view.cc
@@ -745,7 +745,7 @@ // 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 // now as there will be nothing else to do anyway as - // grid_delegate_->dragging() will be false. + // grid_delegate_->IsDragging() will be false. if (!grid_delegate_->UpdateDragFromItem(/*is_touch=*/false, event)) return true; }
diff --git a/ash/app_list/views/app_list_view_unittest.cc b/ash/app_list/views/app_list_view_unittest.cc index 36d3a3ec..cca06ea 100644 --- a/ash/app_list/views/app_list_view_unittest.cc +++ b/ash/app_list/views/app_list_view_unittest.cc
@@ -1581,14 +1581,14 @@ // Test that focus followed to the next page. EXPECT_EQ(view_model->view_at(test_api()->TilesPerPage()), - apps_grid_view()->GetSelectedView()); + apps_grid_view()->selected_view()); // Select the first page. apps_grid_view()->pagination_model()->SelectPage(0, false); // Test that focus followed. EXPECT_EQ(view_model->view_at(test_api()->TilesPerPage() - 1), - apps_grid_view()->GetSelectedView()); + apps_grid_view()->selected_view()); } // Tests that the selection highlight only shows up inside a folder if the @@ -1639,7 +1639,7 @@ // Test that the focused view is also selected. AppsGridView* items_grid_view = app_list_folder_view()->items_grid_view(); - EXPECT_EQ(items_grid_view->GetSelectedView(), focused_view()); + EXPECT_EQ(items_grid_view->selected_view(), focused_view()); EXPECT_EQ(items_grid_view->view_model()->view_at(0), focused_view()); // Hide the folder, expect that the folder is selected and focused.
diff --git a/ash/app_list/views/apps_grid_view.cc b/ash/app_list/views/apps_grid_view.cc index 40b4135..25e7073 100644 --- a/ash/app_list/views/apps_grid_view.cc +++ b/ash/app_list/views/apps_grid_view.cc
@@ -452,12 +452,6 @@ return selected_view_ == view; } -AppListItemView* AppsGridView::GetSelectedView() const { - if (selected_view_) - return selected_view_; - return nullptr; -} - void AppsGridView::InitiateDrag(AppListItemView* view, const gfx::Point& location, const gfx::Point& root_location) { @@ -513,7 +507,7 @@ ExtractDragLocation(event.root_location(), &drag_point_in_grid_view); const Pointer pointer = is_touch ? TOUCH : MOUSE; UpdateDrag(pointer, drag_point_in_grid_view); - if (!dragging()) + if (!IsDragging()) return false; // If a drag and drop host is provided, see if the drag operation needs to be @@ -537,7 +531,7 @@ return; // Drag canceled. const gfx::Vector2d drag_vector(point - drag_start_grid_view_); - if (!dragging() && ExceededDragThreshold(drag_vector)) + if (!IsDragging() && ExceededDragThreshold(drag_vector)) TryStartDragAndDropHostDrag(pointer, point); if (drag_pointer_ != pointer) @@ -648,7 +642,7 @@ return; } - if (!cancel && dragging()) { + if (!cancel && IsDragging()) { // Regular drag ending path, ie, not for reparenting. UpdateDropTargetRegion(); if (drop_target_region_ == ON_ITEM && DraggedItemCanEnterFolder() && @@ -847,7 +841,7 @@ } bool AppsGridView::IsDragging() const { - return dragging(); + return drag_pointer_ != NONE; } bool AppsGridView::IsDraggedView(const AppListItemView* view) const { @@ -2356,7 +2350,7 @@ return; } - if (dragging()) + if (IsDragging()) return; if (contents_view_->apps_container_view()
diff --git a/ash/app_list/views/apps_grid_view.h b/ash/app_list/views/apps_grid_view.h index 3c7e18f..d607063 100644 --- a/ash/app_list/views/apps_grid_view.h +++ b/ash/app_list/views/apps_grid_view.h
@@ -164,13 +164,10 @@ // Return true if the |bounds_animator_| is animating |view|. bool IsAnimatingView(AppListItemView* view); - // TODO(crbug.com/1211608): Replace these with selected_view(). bool has_selected_view() const { return selected_view_ != nullptr; } - AppListItemView* GetSelectedView() const; + AppListItemView* selected_view() const { return selected_view_; } bool has_dragged_view() const { return drag_view_ != nullptr; } - // TODO(crbug.com/1211608): Remove this in favor of IsDragging(). - bool dragging() const { return drag_pointer_ != NONE; } const AppListItemView* drag_view() const { return drag_view_; } // Gets the PaginationModel used for the grid view.
diff --git a/ash/app_list/views/paged_apps_grid_view.cc b/ash/app_list/views/paged_apps_grid_view.cc index 90beb1a..1e7dad9 100644 --- a/ash/app_list/views/paged_apps_grid_view.cc +++ b/ash/app_list/views/paged_apps_grid_view.cc
@@ -534,7 +534,7 @@ AppListPageCreationType type = AppListPageCreationType::kSyncOrInstall; if (handling_keyboard_move()) type = AppListPageCreationType::kMovingAppWithKeyboard; - else if (dragging()) + else if (IsDragging()) type = AppListPageCreationType::kDraggingApp; UMA_HISTOGRAM_ENUMERATION("Apps.AppList.AppsGridAddPage", type); } @@ -543,7 +543,7 @@ void PagedAppsGridView::SelectedPageChanged(int old_selected, int new_selected) { items_container()->layer()->SetTransform(gfx::Transform()); - if (dragging()) { + if (IsDragging()) { drag_view_->layer()->SetTransform(gfx::Transform()); // Sets the transform to locate the scrolled content. @@ -563,18 +563,18 @@ Layout(); MaybeStartPageFlipTimer(last_drag_point()); } else { - AppListItemView* selected_view = GetSelectedView(); - // If |selected_view| is no longer on the page, select the first item in + // If the selected view is no longer on the page, select the first item in // the page relative to the page swap in order to keep keyboard focus // movement predictable. - if (selected_view && GetIndexOfView(selected_view).page != new_selected) { - GetViewAtIndex( - GridIndex(new_selected, (old_selected < new_selected) - ? 0 - : (GetItemsNumOfPage(new_selected) - 1))) - ->RequestFocus(); + if (selected_view() && + GetIndexOfView(selected_view()).page != new_selected) { + GridIndex new_index(new_selected, + (old_selected < new_selected) + ? 0 + : (GetItemsNumOfPage(new_selected) - 1)); + GetViewAtIndex(new_index)->RequestFocus(); } else { - ClearSelectedView(selected_view); + ClearSelectedView(selected_view()); } Layout(); }
diff --git a/ash/capture_mode/capture_mode_controller.cc b/ash/capture_mode/capture_mode_controller.cc index c21ea9c..88fe699 100644 --- a/ash/capture_mode/capture_mode_controller.cc +++ b/ash/capture_mode/capture_mode_controller.cc
@@ -851,6 +851,7 @@ // Resetting the service remote would terminate its process. recording_service_remote_.reset(); + delegate_->OnServiceRemoteReset(); recording_service_client_receiver_.reset(); OnVideoFileSaved(thumbnail, success);
diff --git a/ash/capture_mode/capture_mode_unittests.cc b/ash/capture_mode/capture_mode_unittests.cc index 4082a4b..a333102 100644 --- a/ash/capture_mode/capture_mode_unittests.cc +++ b/ash/capture_mode/capture_mode_unittests.cc
@@ -30,6 +30,7 @@ #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/capture_mode_test_api.h" #include "ash/root_window_controller.h" +#include "ash/services/recording/recording_service_test_api.h" #include "ash/shell.h" #include "ash/system/status_area_widget.h" #include "ash/test/ash_test_base.h" @@ -41,6 +42,7 @@ #include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" +#include "base/bind.h" #include "base/callback_helpers.h" #include "base/run_loop.h" #include "base/scoped_observation.h" @@ -1800,27 +1802,31 @@ CaptureModeType::kVideo); controller->StartVideoRecordingImmediatelyForTesting(); EXPECT_TRUE(controller->is_recording_in_progress()); + CaptureModeTestApi().FlushRecordingServiceForTesting(); auto* test_delegate = static_cast<TestCaptureModeDelegate*>(controller->delegate_for_testing()); - // Use a random bitmap as the fake thumbnail. - SkBitmap thumbnail; - thumbnail.allocN32Pixels(400, 300); - EXPECT_FALSE(thumbnail.drawsNothing()); - test_delegate->SetVideoThumbnail( - gfx::ImageSkia::CreateFrom1xBitmap(thumbnail)); + // Request and wait for a video frame so that the recording service can use it + // to create a video thumbnail. + test_delegate->RequestAndWaitForVideoFrame(); + SkBitmap service_thumbnail = + gfx::Image(test_delegate->GetVideoThumbnail()).AsBitmap(); + EXPECT_FALSE(service_thumbnail.drawsNothing()); CaptureNotificationWaiter waiter; controller->EndVideoRecording(EndRecordingReason::kStopRecordingButton); EXPECT_FALSE(controller->is_recording_in_progress()); waiter.Wait(); + // Verify that the service's thumbnail is the same image shown in the + // notification shown when recording ends. const message_center::Notification* notification = GetPreviewNotification(); EXPECT_TRUE(notification); EXPECT_FALSE(notification->image().IsEmpty()); - const SkBitmap actual_thumbnail = notification->image().AsBitmap(); - EXPECT_TRUE(gfx::test::AreBitmapsEqual(actual_thumbnail, thumbnail)); + const SkBitmap notification_thumbnail = notification->image().AsBitmap(); + EXPECT_TRUE( + gfx::test::AreBitmapsEqual(notification_thumbnail, service_thumbnail)); } TEST_F(CaptureModeTest, WindowRecordingCaptureId) { @@ -2087,6 +2093,48 @@ EXPECT_EQ(gfx::Size(100, 200), test_delegate->GetCurrentVideoSize()); } +// Tests that the video frames delivered to the service for recorded windows are +// valid (i.e. they have the correct size, and suffer from no letterboxing, even +// when the window gets resized). +// TODO(https://crbug.com/1214023): This test is currently broken due to a +// recent change in the Viz capturer. Re-enable the test once fixed. +TEST_F(CaptureModeTest, DISABLED_VerifyWindowRecordingVideoFrames) { + auto window = CreateTestWindow(gfx::Rect(100, 50, 200, 200)); + StartCaptureSession(CaptureModeSource::kWindow, CaptureModeType::kVideo); + + auto* event_generator = GetEventGenerator(); + event_generator->MoveMouseToCenterOf(window.get()); + auto* controller = CaptureModeController::Get(); + controller->StartVideoRecordingImmediatelyForTesting(); + EXPECT_TRUE(controller->is_recording_in_progress()); + CaptureModeTestApi test_api; + test_api.FlushRecordingServiceForTesting(); + + auto verify_video_frame = [](const media::VideoFrame& frame, + const gfx::Rect& content_rect) { + // TODO(afakhry): Add more checks here. + EXPECT_EQ(gfx::Point(), content_rect.origin()); + }; + + auto* test_delegate = + static_cast<TestCaptureModeDelegate*>(controller->delegate_for_testing()); + ASSERT_TRUE(test_delegate->recording_service()); + test_delegate->recording_service()->RequestAndWaitForVideoFrame( + base::BindOnce(verify_video_frame)); + + // Even when the window is resized and the throttled size reaches the service, + // new video frames should still be valid. + window->SetBounds(gfx::Rect(120, 60, 600, 500)); + auto* recording_watcher = controller->video_recording_watcher_for_testing(); + recording_watcher->SendThrottledWindowSizeChangedNowForTesting(); + test_api.FlushRecordingServiceForTesting(); + test_delegate->recording_service()->RequestAndWaitForVideoFrame( + base::BindOnce(verify_video_frame)); + + controller->EndVideoRecording(EndRecordingReason::kStopRecordingButton); + EXPECT_FALSE(controller->is_recording_in_progress()); +} + // Tests the behavior of screen recording with the presence of HDCP secure // content on the screen in all capture mode sources (fullscreen, region, and // window) depending on the test param.
diff --git a/ash/capture_mode/test_capture_mode_delegate.cc b/ash/capture_mode/test_capture_mode_delegate.cc index a599f5fb..22e7439 100644 --- a/ash/capture_mode/test_capture_mode_delegate.cc +++ b/ash/capture_mode/test_capture_mode_delegate.cc
@@ -6,115 +6,12 @@ #include "ash/capture_mode/capture_mode_types.h" #include "ash/services/recording/public/mojom/recording_service.mojom.h" +#include "ash/services/recording/recording_service_test_api.h" #include "base/files/file_util.h" #include "base/threading/thread_restrictions.h" namespace ash { -// ----------------------------------------------------------------------------- -// FakeRecordingService: - -class FakeRecordingService : public recording::mojom::RecordingService { - public: - FakeRecordingService() : receiver_(this) {} - FakeRecordingService(const FakeRecordingService&) = delete; - FakeRecordingService& operator=(const FakeRecordingService&) = delete; - ~FakeRecordingService() override = default; - - const viz::FrameSinkId& current_frame_sink_id() const { - return current_frame_sink_id_; - } - gfx::Size frame_sink_size() const { return frame_sink_size_; } - const gfx::Size& video_size() const { return video_size_; } - void set_thumbnail(const gfx::ImageSkia& thumbnail) { - thumbnail_ = thumbnail; - } - - void Bind( - mojo::PendingReceiver<recording::mojom::RecordingService> receiver) { - receiver_.Bind(std::move(receiver)); - } - - // mojom::RecordingService: - void RecordFullscreen( - mojo::PendingRemote<recording::mojom::RecordingServiceClient> client, - mojo::PendingRemote<viz::mojom::FrameSinkVideoCapturer> video_capturer, - mojo::PendingRemote<media::mojom::AudioStreamFactory> - audio_stream_factory, - const base::FilePath& webm_file_path, - const viz::FrameSinkId& frame_sink_id, - const gfx::Size& frame_sink_size) override { - remote_client_.Bind(std::move(client)); - current_frame_sink_id_ = frame_sink_id; - current_capture_source_ = CaptureModeSource::kFullscreen; - frame_sink_size_ = frame_sink_size; - video_size_ = frame_sink_size; - } - void RecordWindow( - mojo::PendingRemote<recording::mojom::RecordingServiceClient> client, - mojo::PendingRemote<viz::mojom::FrameSinkVideoCapturer> video_capturer, - mojo::PendingRemote<media::mojom::AudioStreamFactory> - audio_stream_factory, - const base::FilePath& webm_file_path, - const viz::FrameSinkId& frame_sink_id, - const gfx::Size& frame_sink_size, - const viz::SubtreeCaptureId& subtree_capture_id, - const gfx::Size& window_size) override { - remote_client_.Bind(std::move(client)); - current_frame_sink_id_ = frame_sink_id; - current_capture_source_ = CaptureModeSource::kWindow; - frame_sink_size_ = frame_sink_size; - video_size_ = window_size; - } - void RecordRegion( - mojo::PendingRemote<recording::mojom::RecordingServiceClient> client, - mojo::PendingRemote<viz::mojom::FrameSinkVideoCapturer> video_capturer, - mojo::PendingRemote<media::mojom::AudioStreamFactory> - audio_stream_factory, - const base::FilePath& webm_file_path, - const viz::FrameSinkId& frame_sink_id, - const gfx::Size& frame_sink_size, - const gfx::Rect& crop_region) override { - remote_client_.Bind(std::move(client)); - current_frame_sink_id_ = frame_sink_id; - current_capture_source_ = CaptureModeSource::kRegion; - frame_sink_size_ = frame_sink_size; - video_size_ = crop_region.size(); - } - void StopRecording() override { - remote_client_->OnRecordingEnded( - recording::mojom::RecordingStatus::kSuccess, thumbnail_); - remote_client_.FlushForTesting(); - } - void OnRecordedWindowChangingRoot( - const viz::FrameSinkId& new_frame_sink_id, - const gfx::Size& new_frame_sink_size) override { - DCHECK_EQ(current_capture_source_, CaptureModeSource::kWindow); - current_frame_sink_id_ = new_frame_sink_id; - frame_sink_size_ = new_frame_sink_size; - } - void OnRecordedWindowSizeChanged(const gfx::Size& new_window_size) override { - DCHECK_EQ(current_capture_source_, CaptureModeSource::kWindow); - video_size_ = new_window_size; - } - void OnFrameSinkSizeChanged(const gfx::Size& new_frame_sink_size) override { - DCHECK_NE(current_capture_source_, CaptureModeSource::kFullscreen); - frame_sink_size_ = new_frame_sink_size; - } - - private: - mojo::Receiver<recording::mojom::RecordingService> receiver_; - mojo::Remote<recording::mojom::RecordingServiceClient> remote_client_; - viz::FrameSinkId current_frame_sink_id_; - CaptureModeSource current_capture_source_ = CaptureModeSource::kFullscreen; - gfx::Size frame_sink_size_; - gfx::Size video_size_; - gfx::ImageSkia thumbnail_; -}; - -// ----------------------------------------------------------------------------- -// TestCaptureModeDelegate: - TestCaptureModeDelegate::TestCaptureModeDelegate() { base::ScopedAllowBlockingForTesting allow_blocking; const bool result = @@ -125,22 +22,29 @@ TestCaptureModeDelegate::~TestCaptureModeDelegate() = default; viz::FrameSinkId TestCaptureModeDelegate::GetCurrentFrameSinkId() const { - return fake_service_ ? fake_service_->current_frame_sink_id() - : viz::FrameSinkId(); + return recording_service_ ? recording_service_->GetCurrentFrameSinkId() + : viz::FrameSinkId(); } gfx::Size TestCaptureModeDelegate::GetCurrentFrameSinkSize() const { - return fake_service_ ? fake_service_->frame_sink_size() : gfx::Size(); + return recording_service_ ? recording_service_->GetCurrentFrameSinkSize() + : gfx::Size(); } gfx::Size TestCaptureModeDelegate::GetCurrentVideoSize() const { - return fake_service_ ? fake_service_->video_size() : gfx::Size(); + return recording_service_ ? recording_service_->GetCurrentVideoSize() + : gfx::Size(); } -void TestCaptureModeDelegate::SetVideoThumbnail( - const gfx::ImageSkia& thumbnail) { - if (fake_service_) - fake_service_->set_thumbnail(thumbnail); +gfx::ImageSkia TestCaptureModeDelegate::GetVideoThumbnail() const { + return recording_service_ ? recording_service_->GetVideoThumbnail() + : gfx::ImageSkia(); +} + +void TestCaptureModeDelegate::RequestAndWaitForVideoFrame() { + DCHECK(recording_service_); + + recording_service_->RequestAndWaitForVideoFrame(); } base::FilePath TestCaptureModeDelegate::GetScreenCaptureDir() const { @@ -180,10 +84,10 @@ mojo::Remote<recording::mojom::RecordingService> TestCaptureModeDelegate::LaunchRecordingService() { - fake_service_ = std::make_unique<FakeRecordingService>(); - mojo::Remote<recording::mojom::RecordingService> service; - fake_service_->Bind(service.BindNewPipeAndPassReceiver()); - return service; + mojo::Remote<recording::mojom::RecordingService> service_remote; + recording_service_ = std::make_unique<recording::RecordingServiceTestApi>( + service_remote.BindNewPipeAndPassReceiver()); + return service_remote; } void TestCaptureModeDelegate::BindAudioStreamFactory( @@ -191,4 +95,11 @@ void TestCaptureModeDelegate::OnSessionStateChanged(bool started) {} +void TestCaptureModeDelegate::OnServiceRemoteReset() { + // We simulate what the ServiceProcessHost does when the service remote is + // reset (on which it shuts down the service process). Here since the service + // is running in-process with ash_unittests, we just delete the instance. + recording_service_.reset(); +} + } // namespace ash
diff --git a/ash/capture_mode/test_capture_mode_delegate.h b/ash/capture_mode/test_capture_mode_delegate.h index 04f4e47..1ced147 100644 --- a/ash/capture_mode/test_capture_mode_delegate.h +++ b/ash/capture_mode/test_capture_mode_delegate.h
@@ -14,9 +14,11 @@ #include "ui/gfx/geometry/size.h" #include "ui/gfx/image/image_skia.h" -namespace ash { +namespace recording { +class RecordingServiceTestApi; +} // namespace recording -class FakeRecordingService; +namespace ash { class TestCaptureModeDelegate : public CaptureModeDelegate { public: @@ -25,18 +27,26 @@ TestCaptureModeDelegate& operator=(const TestCaptureModeDelegate&) = delete; ~TestCaptureModeDelegate() override; - // Gets the current frame sink id being captured by the fake service. + recording::RecordingServiceTestApi* recording_service() const { + return recording_service_.get(); + } + + // Gets the current frame sink id being captured by the service. viz::FrameSinkId GetCurrentFrameSinkId() const; // Gets the current size of the frame sink being recorded. gfx::Size GetCurrentFrameSinkSize() const; - // Gets the current video size being captured by the fake service. + // Gets the current video size being captured by the service. gfx::Size GetCurrentVideoSize() const; - // Sets the thumbnail image that will be used by the fake service to provide - // it to the client. - void SetVideoThumbnail(const gfx::ImageSkia& thumbnail); + // Gets the thumbnail image that will be used by the service to provide it to + // the client. + gfx::ImageSkia GetVideoThumbnail() const; + + // Requests a video frame from the video capturer and waits for it to be + // delivered to the service. + void RequestAndWaitForVideoFrame(); // CaptureModeDelegate: base::FilePath GetScreenCaptureDir() const override; @@ -59,9 +69,10 @@ mojo::PendingReceiver<media::mojom::AudioStreamFactory> receiver) override; void OnSessionStateChanged(bool started) override; + void OnServiceRemoteReset() override; private: - std::unique_ptr<FakeRecordingService> fake_service_; + std::unique_ptr<recording::RecordingServiceTestApi> recording_service_; base::FilePath fake_downloads_dir_; };
diff --git a/ash/content/shimless_rma/resources/fake_shimless_rma_service.js b/ash/content/shimless_rma/resources/fake_shimless_rma_service.js index 3a4b24a2..659d7fd 100644 --- a/ash/content/shimless_rma/resources/fake_shimless_rma_service.js +++ b/ash/content/shimless_rma/resources/fake_shimless_rma_service.js
@@ -288,9 +288,9 @@ * @param {!Array<!Component>} components * @return {!Promise<!StateResult>} */ - setComponentsRepairState(components) { + setComponentList(components) { return this.getNextStateForMethod_( - 'setComponentsRepairState', RmaState.kSelectComponents); + 'setComponentList', RmaState.kSelectComponents); } /** @@ -498,17 +498,27 @@ } /** - * @return {!Promise<!{error: !RmadErrorCode}>} + * @return {!Promise<!StateResult>} */ - cutoffBattery() { - return this.methods_.resolveMethod('cutoffBattery'); + finalizeAndReboot() { + return this.getNextStateForMethod_( + 'finalizeAndReboot', RmaState.kRepairComplete); } /** - * @param {!RmadErrorCode} error + * @return {!Promise<!StateResult>} */ - setCutoffBatteryResult(error) { - this.methods_.setResult('cutoffBattery', {error: error}); + finalizeAndShutdown() { + return this.getNextStateForMethod_( + 'finalizeAndShutdown', RmaState.kRepairComplete); + } + + /** + * @return {!Promise<!StateResult>} + */ + cutoffBattery() { + return this.getNextStateForMethod_( + 'cutoffBattery', RmaState.kRepairComplete); } /** @@ -698,7 +708,7 @@ this.methods_.register('setRsuDisableWriteProtectCode'); this.methods_.register('getComponentList'); - this.methods_.register('setComponentsRepairState'); + this.methods_.register('setComponentList'); this.methods_.register('reworkMainboard'); this.methods_.register('reimageRequired'); @@ -718,6 +728,8 @@ this.methods_.register('getSku'); this.methods_.register('setSku'); + this.methods_.register('finalizeAndReboot'); + this.methods_.register('finalizeAndShutdown'); this.methods_.register('cutoffBattery'); }
diff --git a/ash/content/shimless_rma/resources/onboarding_choose_destination_page.js b/ash/content/shimless_rma/resources/onboarding_choose_destination_page.js index f10a025..a8dca290 100644 --- a/ash/content/shimless_rma/resources/onboarding_choose_destination_page.js +++ b/ash/content/shimless_rma/resources/onboarding_choose_destination_page.js
@@ -40,7 +40,7 @@ this.shimlessRmaService_ = getShimlessRmaService(); } - // TODO(gavindodd): Implement onNextBtnClicked that will: + // TODO(gavindodd): Implement onNextButtonClicked that will: // - call shimlessRmaService_.setSameOwner() if original owner chosen. // - call shimlessRmaService_.setDifferentOwner() if different owner chosen. };
diff --git a/ash/content/shimless_rma/resources/onboarding_choose_wp_disable_method_page.js b/ash/content/shimless_rma/resources/onboarding_choose_wp_disable_method_page.js index 4e8fc73..848268b 100644 --- a/ash/content/shimless_rma/resources/onboarding_choose_wp_disable_method_page.js +++ b/ash/content/shimless_rma/resources/onboarding_choose_wp_disable_method_page.js
@@ -40,7 +40,7 @@ this.shimlessRmaService_ = getShimlessRmaService(); } - // TODO(gavindodd): Implement onNextBtnClicked that will: + // TODO(gavindodd): Implement onNextButtonClicked that will: // - call shimlessRmaService_.chooseManuallyDisableWriteProtect() if manual // chosen. // - call shimlessRmaService_.chooseRsuDisableWriteProtect(code) if RSU
diff --git a/ash/content/shimless_rma/resources/onboarding_enter_rsu_wp_disable_code_page.js b/ash/content/shimless_rma/resources/onboarding_enter_rsu_wp_disable_code_page.js index 14157cf5..4d3dca9 100644 --- a/ash/content/shimless_rma/resources/onboarding_enter_rsu_wp_disable_code_page.js +++ b/ash/content/shimless_rma/resources/onboarding_enter_rsu_wp_disable_code_page.js
@@ -40,7 +40,7 @@ this.shimlessRmaService_ = getShimlessRmaService(); } - // TODO(gavindodd): Implement onNextBtnClicked that will: + // TODO(gavindodd): Implement onNextButtonClicked that will: // - call shimlessRmaService_.rsuDisableWriteProtect(code) when code entered. };
diff --git a/ash/content/shimless_rma/resources/onboarding_select_components_page.html b/ash/content/shimless_rma/resources/onboarding_select_components_page.html index 5c5b98f8..eed24d77 100644 --- a/ash/content/shimless_rma/resources/onboarding_select_components_page.html +++ b/ash/content/shimless_rma/resources/onboarding_select_components_page.html
@@ -17,7 +17,7 @@ </template> </div> <div>If you are reworking a motherboard to use in another device, go to the - <a href="#" id="reworkFlow" on-click="onReworkFlowBtnClicked_"> + <a href="#" id="reworkFlow" on-click="onReworkFlowButtonClicked_"> rework flow </a> .
diff --git a/ash/content/shimless_rma/resources/onboarding_select_components_page.js b/ash/content/shimless_rma/resources/onboarding_select_components_page.js index f6b6ecb..578e2e6 100644 --- a/ash/content/shimless_rma/resources/onboarding_select_components_page.js +++ b/ash/content/shimless_rma/resources/onboarding_select_components_page.js
@@ -122,7 +122,7 @@ } /** @protected */ - onReworkFlowBtnClicked_(e) { + onReworkFlowButtonClicked_(e) { // TODO(gavindodd): Debug, remove when onNext implemented. console.log('Components repair state:'); this.getComponentRepairStateList_().forEach(item => {
diff --git a/ash/content/shimless_rma/resources/shimless_rma.js b/ash/content/shimless_rma/resources/shimless_rma.js index e9d244e..b05ab08 100644 --- a/ash/content/shimless_rma/resources/shimless_rma.js +++ b/ash/content/shimless_rma/resources/shimless_rma.js
@@ -58,45 +58,45 @@ // TODO(joonbug): update to correct RmaState [RmaState.kSelectComponents]: { componentIs: 'onboarding-update-page', - btnNext: ButtonState.VISIBLE, - btnCancel: ButtonState.VISIBLE, - btnBack: ButtonState.VISIBLE, + buttonNext: ButtonState.VISIBLE, + buttonCancel: ButtonState.VISIBLE, + buttonBack: ButtonState.VISIBLE, }, [RmaState.kChooseDestination]: { componentIs: 'onboarding-choose-destination-page', - btnNext: ButtonState.HIDDEN, - btnCancel: ButtonState.VISIBLE, - btnBack: ButtonState.VISIBLE, + buttonNext: ButtonState.HIDDEN, + buttonCancel: ButtonState.VISIBLE, + buttonBack: ButtonState.VISIBLE, }, [RmaState.kChooseWriteProtectDisableMethod]: { componentIs: 'onboarding-choose-wp-disable-method-page', - btnNext: ButtonState.VISIBLE, - btnCancel: ButtonState.VISIBLE, - btnBack: ButtonState.VISIBLE, + buttonNext: ButtonState.VISIBLE, + buttonCancel: ButtonState.VISIBLE, + buttonBack: ButtonState.VISIBLE, }, [RmaState.kWaitForManualWPDisable]: { componentIs: 'onboarding-wait-for-manual-wp-disable-page', - btnNext: ButtonState.VISIBLE, - btnCancel: ButtonState.HIDDEN, - btnBack: ButtonState.VISIBLE, + buttonNext: ButtonState.VISIBLE, + buttonCancel: ButtonState.HIDDEN, + buttonBack: ButtonState.VISIBLE, }, [RmaState.kUpdateChrome]: { componentIs: 'onboarding-update-page', - btnNext: ButtonState.VISIBLE, - btnCancel: ButtonState.VISIBLE, - btnBack: ButtonState.VISIBLE, + buttonNext: ButtonState.VISIBLE, + buttonCancel: ButtonState.VISIBLE, + buttonBack: ButtonState.VISIBLE, }, [RmaState.kSelectComponents]: { componentIs: 'onboarding-select-components-page', - btnNext: ButtonState.HIDDEN, - btnCancel: ButtonState.VISIBLE, - btnBack: ButtonState.VISIBLE, + buttonNext: ButtonState.HIDDEN, + buttonCancel: ButtonState.VISIBLE, + buttonBack: ButtonState.VISIBLE, }, [RmaState.kEnterRSUWPDisableCode]: { componentIs: 'onboarding-enter-rsu-wp-disable-code-page', - btnNext: ButtonState.HIDDEN, - btnCancel: ButtonState.HIDDEN, - btnBack: ButtonState.VISIBLE, + buttonNext: ButtonState.HIDDEN, + buttonCancel: ButtonState.HIDDEN, + buttonBack: ButtonState.VISIBLE, }, };
diff --git a/ash/login/login_screen_test_api.cc b/ash/login/login_screen_test_api.cc index ea7ee43..9b802bc 100644 --- a/ash/login/login_screen_test_api.cc +++ b/ash/login/login_screen_test_api.cc
@@ -16,7 +16,7 @@ #include "ash/login/ui/login_expanded_public_account_view.h" #include "ash/login/ui/login_password_view.h" #include "ash/login/ui/login_pin_view.h" -#include "ash/login/ui/login_user_menu_view.h" +#include "ash/login/ui/login_remove_account_dialog.h" #include "ash/login/ui/login_user_view.h" #include "ash/login/ui/pin_request_view.h" #include "ash/login/ui/pin_request_widget.h" @@ -322,7 +322,7 @@ } // static -bool LoginScreenTestApi::IsManagedMessageInMenuShown( +bool LoginScreenTestApi::IsManagedMessageInDialogShown( const AccountId& account_id) { LoginBigUserView* big_user_view = GetBigUserView(account_id); if (!big_user_view) { @@ -330,8 +330,9 @@ return false; } LoginUserView::TestApi user_test(big_user_view->GetUserView()); - LoginUserMenuView::TestApi user_menu_test(user_test.menu()); - auto* managed_user_data = user_menu_test.managed_user_data(); + LoginRemoveAccountDialog::TestApi user_dialog_test( + user_test.remove_account_dialog()); + auto* managed_user_data = user_dialog_test.managed_user_data(); return managed_user_data && managed_user_data->GetVisible(); } @@ -713,8 +714,8 @@ return std::u16string(); } LoginUserView::TestApi user_test(big_user_view->GetUserView()); - LoginUserMenuView::TestApi user_menu_test(user_test.menu()); - return user_menu_test.management_disclosure_label()->GetText(); + LoginRemoveAccountDialog::TestApi dialog(user_test.remove_account_dialog()); + return dialog.management_disclosure_label()->GetText(); } // static
diff --git a/ash/login/ui/lock_contents_view.cc b/ash/login/ui/lock_contents_view.cc index 4a38f0d..b71f6e1 100644 --- a/ash/login/ui/lock_contents_view.cc +++ b/ash/login/ui/lock_contents_view.cc
@@ -1157,13 +1157,14 @@ LayoutAuth(big_user, nullptr /*opt_to_hide*/, true /*animate*/); } -void LockContentsView::OnShowEasyUnlockIcon(const AccountId& user, - const EasyUnlockIconOptions& icon) { +void LockContentsView::OnShowEasyUnlockIcon( + const AccountId& user, + const EasyUnlockIconInfo& icon_info) { UserState* state = FindStateForUser(user); if (!state) return; - state->easy_unlock_state = icon; + state->easy_unlock_icon_info = icon_info; UpdateEasyUnlockIconForUser(user); // Show tooltip only if the user is actively showing auth. @@ -1175,9 +1176,9 @@ if (tooltip_bubble_->GetVisible()) tooltip_bubble_->Hide(); - if (icon.autoshow_tooltip) { + if (icon_info.autoshow_tooltip) { tooltip_bubble_->SetAnchorView(big_user->auth_user()->GetActiveInputView()); - tooltip_bubble_->set_text(icon.tooltip); + tooltip_bubble_->set_text(icon_info.tooltip); tooltip_bubble_->Show(); tooltip_bubble_->SetVisible(true); } @@ -2018,21 +2019,21 @@ UserState* state = FindStateForUser(user); DCHECK(state); - // Hide easy unlock icon if there is no data is available. - if (!state->easy_unlock_state) { - big_view->auth_user()->SetEasyUnlockIcon(EasyUnlockIconId::NONE, + // Hide easy unlock icon if there is no data available. + if (!state->easy_unlock_icon_info) { + big_view->auth_user()->SetEasyUnlockIcon(EasyUnlockIconState::NONE, std::u16string()); return; } // TODO(jdufault): Make easy unlock backend always send aria_label, right now // it is only sent if there is no tooltip. - std::u16string accessibility_label = state->easy_unlock_state->aria_label; + std::u16string accessibility_label = state->easy_unlock_icon_info->aria_label; if (accessibility_label.empty()) - accessibility_label = state->easy_unlock_state->tooltip; + accessibility_label = state->easy_unlock_icon_info->tooltip; - big_view->auth_user()->SetEasyUnlockIcon(state->easy_unlock_state->icon, - accessibility_label); + big_view->auth_user()->SetEasyUnlockIcon( + state->easy_unlock_icon_info->icon_state, accessibility_label); } LoginBigUserView* LockContentsView::CurrentBigUserView() { @@ -2124,11 +2125,11 @@ UserState* state = FindStateForUser(big_view->GetCurrentUser().basic_user_info.account_id); DCHECK(state); - DCHECK(state->easy_unlock_state); + DCHECK(state->easy_unlock_icon_info); - if (!state->easy_unlock_state->tooltip.empty()) { + if (!state->easy_unlock_icon_info->tooltip.empty()) { tooltip_bubble_->SetAnchorView(big_view->auth_user()->GetActiveInputView()); - tooltip_bubble_->set_text(state->easy_unlock_state->tooltip); + tooltip_bubble_->set_text(state->easy_unlock_icon_info->tooltip); tooltip_bubble_->Show(); } } @@ -2137,9 +2138,9 @@ UserState* state = FindStateForUser( CurrentBigUserView()->GetCurrentUser().basic_user_info.account_id); DCHECK(state); - DCHECK(state->easy_unlock_state); + DCHECK(state->easy_unlock_icon_info); - if (state->easy_unlock_state->hardlock_on_click) { + if (state->easy_unlock_icon_info->hardlock_on_click) { AccountId user = CurrentBigUserView()->GetCurrentUser().basic_user_info.account_id; Shell::Get()->login_screen_controller()->HardlockPod(user);
diff --git a/ash/login/ui/lock_contents_view.h b/ash/login/ui/lock_contents_view.h index 3e423e84..7e1b88e5 100644 --- a/ash/login/ui/lock_contents_view.h +++ b/ash/login/ui/lock_contents_view.h
@@ -181,7 +181,7 @@ bool enabled) override; void OnForceOnlineSignInForUser(const AccountId& user) override; void OnShowEasyUnlockIcon(const AccountId& user, - const EasyUnlockIconOptions& icon) override; + const EasyUnlockIconInfo& icon_info) override; void OnWarningMessageUpdated(const std::u16string& message) override; void OnSystemInfoChanged(bool show, bool enforced, @@ -248,7 +248,7 @@ bool disable_auth = false; bool show_pin_pad_for_password = false; size_t autosubmit_pin_length = 0; - absl::optional<EasyUnlockIconOptions> easy_unlock_state = absl::nullopt; + absl::optional<EasyUnlockIconInfo> easy_unlock_icon_info = absl::nullopt; FingerprintState fingerprint_state; // When present, indicates that the TPM is locked. absl::optional<base::TimeDelta> time_until_tpm_unlock = absl::nullopt;
diff --git a/ash/login/ui/lock_contents_view_unittest.cc b/ash/login/ui/lock_contents_view_unittest.cc index 0711dd9..cb3034a 100644 --- a/ash/login/ui/lock_contents_view_unittest.cc +++ b/ash/login/ui/lock_contents_view_unittest.cc
@@ -937,17 +937,17 @@ // Show an icon with |autoshow_tooltip| is false. Tooltip bubble is not // activated. - EasyUnlockIconOptions icon; - icon.icon = EasyUnlockIconId::LOCKED; - icon.autoshow_tooltip = false; + EasyUnlockIconInfo icon_info; + icon_info.icon_state = EasyUnlockIconState::LOCKED; + icon_info.autoshow_tooltip = false; DataDispatcher()->ShowEasyUnlockIcon(users()[0].basic_user_info.account_id, - icon); + icon_info); EXPECT_FALSE(test_api.tooltip_bubble()->GetVisible()); // Show icon with |autoshow_tooltip| set to true. Tooltip bubble is shown. - icon.autoshow_tooltip = true; + icon_info.autoshow_tooltip = true; DataDispatcher()->ShowEasyUnlockIcon(users()[0].basic_user_info.account_id, - icon); + icon_info); EXPECT_TRUE(test_api.tooltip_bubble()->GetVisible()); } @@ -979,18 +979,18 @@ // Enables easy unlock icon for |view|. auto enable_icon = [&](LoginBigUserView* view) { - EasyUnlockIconOptions icon; - icon.icon = EasyUnlockIconId::LOCKED; + EasyUnlockIconInfo icon_info; + icon_info.icon_state = EasyUnlockIconState::LOCKED; DataDispatcher()->ShowEasyUnlockIcon( - view->GetCurrentUser().basic_user_info.account_id, icon); + view->GetCurrentUser().basic_user_info.account_id, icon_info); }; // Disables easy unlock icon for |view|. auto disable_icon = [&](LoginBigUserView* view) { - EasyUnlockIconOptions icon; - icon.icon = EasyUnlockIconId::NONE; + EasyUnlockIconInfo icon_info; + icon_info.icon_state = EasyUnlockIconState::NONE; DataDispatcher()->ShowEasyUnlockIcon( - view->GetCurrentUser().basic_user_info.account_id, icon); + view->GetCurrentUser().basic_user_info.account_id, icon_info); }; // Makes |view| the active auth view so it will can show auth methods. @@ -1022,7 +1022,7 @@ make_active_auth_view(primary); EXPECT_TRUE(showing_easy_unlock_icon(primary)); - // Activate icon for secondary. Primary visiblity does not change. + // Activate icon for secondary. Primary visibility does not change. enable_icon(secondary); EXPECT_TRUE(showing_easy_unlock_icon(primary)); @@ -2539,7 +2539,7 @@ generator->PressKey(ui::KeyboardCode::VKEY_RETURN, 0); base::RunLoop().RunUntilIdle(); // Focus the remove user bubble, tap twice to remove the user. - user_test_api.menu()->RequestFocus(); + user_test_api.remove_account_dialog()->RequestFocus(); generator->PressKey(ui::KeyboardCode::VKEY_RETURN, 0); base::RunLoop().RunUntilIdle(); generator->PressKey(ui::KeyboardCode::VKEY_RETURN, 0);
diff --git a/ash/login/ui/lock_debug_view.cc b/ash/login/ui/lock_debug_view.cc index 77538657..0b71f89 100644 --- a/ash/login/ui/lock_debug_view.cc +++ b/ash/login/ui/lock_debug_view.cc
@@ -82,7 +82,7 @@ bool enable_challenge_response = false; // Smart Card bool enable_auth = true; user_manager::UserType type = user_manager::USER_TYPE_REGULAR; - EasyUnlockIconId easy_unlock_id = EasyUnlockIconId::NONE; + EasyUnlockIconState easy_unlock_icon_state = EasyUnlockIconState::NONE; FingerprintState fingerprint_state = FingerprintState::UNAVAILABLE; }; @@ -264,50 +264,52 @@ DCHECK(user_index >= 0 && user_index < debug_users_.size()); UserMetadata* debug_user = &debug_users_[user_index]; - // EasyUnlockIconId state transition. - auto get_next_id = [](EasyUnlockIconId id) { - switch (id) { - case EasyUnlockIconId::NONE: - return EasyUnlockIconId::SPINNER; - case EasyUnlockIconId::SPINNER: - return EasyUnlockIconId::LOCKED; - case EasyUnlockIconId::LOCKED: - return EasyUnlockIconId::LOCKED_TO_BE_ACTIVATED; - case EasyUnlockIconId::LOCKED_TO_BE_ACTIVATED: - return EasyUnlockIconId::LOCKED_WITH_PROXIMITY_HINT; - case EasyUnlockIconId::LOCKED_WITH_PROXIMITY_HINT: - return EasyUnlockIconId::HARDLOCKED; - case EasyUnlockIconId::HARDLOCKED: - return EasyUnlockIconId::UNLOCKED; - case EasyUnlockIconId::UNLOCKED: - return EasyUnlockIconId::NONE; + // EasyUnlockIconState transition. + auto get_next_state = [](EasyUnlockIconState icon_state) { + switch (icon_state) { + case EasyUnlockIconState::NONE: + return EasyUnlockIconState::SPINNER; + case EasyUnlockIconState::SPINNER: + return EasyUnlockIconState::LOCKED; + case EasyUnlockIconState::LOCKED: + return EasyUnlockIconState::LOCKED_TO_BE_ACTIVATED; + case EasyUnlockIconState::LOCKED_TO_BE_ACTIVATED: + return EasyUnlockIconState::LOCKED_WITH_PROXIMITY_HINT; + case EasyUnlockIconState::LOCKED_WITH_PROXIMITY_HINT: + return EasyUnlockIconState::HARDLOCKED; + case EasyUnlockIconState::HARDLOCKED: + return EasyUnlockIconState::UNLOCKED; + case EasyUnlockIconState::UNLOCKED: + return EasyUnlockIconState::NONE; } - return EasyUnlockIconId::NONE; + return EasyUnlockIconState::NONE; }; - debug_user->easy_unlock_id = get_next_id(debug_user->easy_unlock_id); + debug_user->easy_unlock_icon_state = + get_next_state(debug_user->easy_unlock_icon_state); // Enable/disable click to unlock. debug_user->enable_tap_to_unlock = - debug_user->easy_unlock_id == EasyUnlockIconId::UNLOCKED; + debug_user->easy_unlock_icon_state == EasyUnlockIconState::UNLOCKED; // Prepare icon that we will show. - EasyUnlockIconOptions icon; - icon.icon = debug_user->easy_unlock_id; - if (icon.icon == EasyUnlockIconId::SPINNER) { - icon.aria_label = u"Icon is spinning"; - } else if (icon.icon == EasyUnlockIconId::LOCKED || - icon.icon == EasyUnlockIconId::LOCKED_TO_BE_ACTIVATED) { - icon.autoshow_tooltip = true; - icon.tooltip = base::ASCIIToUTF16( + EasyUnlockIconInfo icon_info; + icon_info.icon_state = debug_user->easy_unlock_icon_state; + if (icon_info.icon_state == EasyUnlockIconState::SPINNER) { + icon_info.aria_label = u"Icon is spinning"; + } else if (icon_info.icon_state == EasyUnlockIconState::LOCKED || + icon_info.icon_state == + EasyUnlockIconState::LOCKED_TO_BE_ACTIVATED) { + icon_info.autoshow_tooltip = true; + icon_info.tooltip = base::ASCIIToUTF16( "This is a long message to trigger overflow. This should show up " - "automatically. icon_id=" + - base::NumberToString(static_cast<int>(icon.icon))); + "automatically. icon_state=" + + base::NumberToString(static_cast<int>(icon_info.icon_state))); } else { - icon.tooltip = u"This should not show up automatically."; + icon_info.tooltip = u"This should not show up automatically."; } // Show icon and enable/disable click to unlock. - debug_dispatcher_.ShowEasyUnlockIcon(debug_user->account_id, icon); + debug_dispatcher_.ShowEasyUnlockIcon(debug_user->account_id, icon_info); debug_dispatcher_.SetTapToUnlockEnabledForUser( debug_user->account_id, debug_user->enable_tap_to_unlock); } @@ -473,8 +475,8 @@ debug_dispatcher_.SetLockScreenNoteState(state); } void OnShowEasyUnlockIcon(const AccountId& user, - const EasyUnlockIconOptions& icon) override { - debug_dispatcher_.ShowEasyUnlockIcon(user, icon); + const EasyUnlockIconInfo& icon_info) override { + debug_dispatcher_.ShowEasyUnlockIcon(user, icon_info); } void OnDetachableBasePairingStatusChanged( DetachableBasePairingStatus pairing_status) override {
diff --git a/ash/login/ui/lock_screen_sanity_unittest.cc b/ash/login/ui/lock_screen_sanity_unittest.cc index 31f1afd..e864a40b 100644 --- a/ash/login/ui/lock_screen_sanity_unittest.cc +++ b/ash/login/ui/lock_screen_sanity_unittest.cc
@@ -381,18 +381,19 @@ // The secondary user is not removable (as configured above) so showing the // dropdown does not result in an interactive/focusable view. focus_and_submit(secondary().dropdown()); - EXPECT_TRUE(secondary().menu()); - EXPECT_FALSE(HasFocusInAnyChildView(secondary().menu())); - // TODO(jdufault): Run submit() and then EXPECT_FALSE(secondary().menu()); to + EXPECT_TRUE(secondary().remove_account_dialog()); + EXPECT_FALSE(HasFocusInAnyChildView(secondary().remove_account_dialog())); + // TODO(jdufault): Run submit() and then + // EXPECT_FALSE(secondary().remove_account_dialog()); to // verify that double-enter closes the bubble. - // The primary user is removable, so the menu is interactive. Submitting the - // first time shows the remove user warning, submitting the second time - // actually removes the user. Removing the user triggers a mojo API call as - // well as removes the user from the UI. + // The primary user is removable, so the remove account dialog is interactive. + // Submitting the first time shows the remove user warning, submitting the + // second time actually removes the user. Removing the user triggers a mojo + // API call as well as removes the user from the UI. focus_and_submit(primary().dropdown()); - EXPECT_TRUE(primary().menu()); - EXPECT_TRUE(HasFocusInAnyChildView(primary().menu())); + EXPECT_TRUE(primary().remove_account_dialog()); + EXPECT_TRUE(HasFocusInAnyChildView(primary().remove_account_dialog())); EXPECT_CALL(*client, OnRemoveUserWarningShown()).Times(1); submit(); EXPECT_CALL(*client, RemoveUser(users()[0].basic_user_info.account_id))
diff --git a/ash/login/ui/login_auth_user_view.cc b/ash/login/ui/login_auth_user_view.cc index 7dee15ce..fa9fc8c 100644 --- a/ash/login/ui/login_auth_user_view.cc +++ b/ash/login/ui/login_auth_user_view.cc
@@ -1308,13 +1308,13 @@ } void LoginAuthUserView::SetEasyUnlockIcon( - EasyUnlockIconId id, + EasyUnlockIconState icon_state, const std::u16string& accessibility_label) { - password_view_->SetEasyUnlockIcon(id, accessibility_label); + password_view_->SetEasyUnlockIcon(icon_state, accessibility_label); const std::string& user_display_email = current_user().basic_user_info.display_email; - if (id == EasyUnlockIconId::UNLOCKED) { + if (icon_state == EasyUnlockIconState::UNLOCKED) { password_view_->SetAccessibleName(l10n_util::GetStringFUTF16( IDS_ASH_LOGIN_POD_AUTH_TAP_PASSWORD_FIELD_ACCESSIBLE_NAME, base::UTF8ToUTF16(user_display_email)));
diff --git a/ash/login/ui/login_auth_user_view.h b/ash/login/ui/login_auth_user_view.h index a2459c21..19ea809 100644 --- a/ash/login/ui/login_auth_user_view.h +++ b/ash/login/ui/login_auth_user_view.h
@@ -145,7 +145,7 @@ InputFieldMode input_field_mode() const { return input_field_mode_; } // Add an easy unlock icon. - void SetEasyUnlockIcon(EasyUnlockIconId id, + void SetEasyUnlockIcon(EasyUnlockIconState icon_state, const std::u16string& accessibility_label); // Captures any metadata about the current view state that will be used for
diff --git a/ash/login/ui/login_data_dispatcher.cc b/ash/login/ui/login_data_dispatcher.cc index 4bc694f..d338904 100644 --- a/ash/login/ui/login_data_dispatcher.cc +++ b/ash/login/ui/login_data_dispatcher.cc
@@ -55,7 +55,7 @@ void LoginDataDispatcher::Observer::OnShowEasyUnlockIcon( const AccountId& user, - const EasyUnlockIconOptions& icon) {} + const EasyUnlockIconInfo& icon_info) {} void LoginDataDispatcher::Observer::OnWarningMessageUpdated( const std::u16string& message) {} @@ -184,9 +184,9 @@ void LoginDataDispatcher::ShowEasyUnlockIcon( const AccountId& user, - const EasyUnlockIconOptions& icon) { + const EasyUnlockIconInfo& icon_info) { for (auto& observer : observers_) - observer.OnShowEasyUnlockIcon(user, icon); + observer.OnShowEasyUnlockIcon(user, icon_info); } void LoginDataDispatcher::UpdateWarningMessage(const std::u16string& message) {
diff --git a/ash/login/ui/login_data_dispatcher.h b/ash/login/ui/login_data_dispatcher.h index 063548a9..1397315 100644 --- a/ash/login/ui/login_data_dispatcher.h +++ b/ash/login/ui/login_data_dispatcher.h
@@ -95,7 +95,7 @@ // Called when an easy unlock icon should be displayed. virtual void OnShowEasyUnlockIcon(const AccountId& user, - const EasyUnlockIconOptions& icon); + const EasyUnlockIconInfo& icon_info); // Called when a warning message should be displayed, or hidden if |message| // is empty. @@ -181,7 +181,7 @@ void ForceOnlineSignInForUser(const AccountId& user) override; void SetLockScreenNoteState(mojom::TrayActionState state); void ShowEasyUnlockIcon(const AccountId& user, - const EasyUnlockIconOptions& icon) override; + const EasyUnlockIconInfo& icon_info) override; void UpdateWarningMessage(const std::u16string& message) override; void SetSystemInfo(bool show, bool enforced,
diff --git a/ash/login/ui/login_expanded_public_account_view.cc b/ash/login/ui/login_expanded_public_account_view.cc index b6126ba1..b281fdfc 100644 --- a/ash/login/ui/login_expanded_public_account_view.cc +++ b/ash/login/ui/login_expanded_public_account_view.cc
@@ -12,7 +12,7 @@ #include "ash/login/ui/arrow_button_view.h" #include "ash/login/ui/login_button.h" #include "ash/login/ui/login_user_view.h" -#include "ash/login/ui/public_account_warning_dialog.h" +#include "ash/login/ui/public_account_monitoring_info_dialog.h" #include "ash/login/ui/views_utils.h" #include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/login_types.h" @@ -488,7 +488,7 @@ : MonitoringWarningView::WarningType::kSoftWarning); } - void OnLanguageSelected(LoginMenuView::Item item) { + void OnLanguageSelected(PublicAccountMenuView::Item item) { language_changed_by_user_ = true; selected_language_item_ = item; language_selection_->SetText(base::UTF8ToUTF16(item.title)); @@ -502,7 +502,7 @@ current_user_.basic_user_info.account_id, item.value); } - void OnKeyboardSelected(LoginMenuView::Item item) { + void OnKeyboardSelected(PublicAccountMenuView::Item item) { selected_keyboard_item_ = item; keyboard_selection_->SetText(base::UTF8ToUTF16(item.title)); } @@ -510,7 +510,7 @@ void PopulateLanguageItems(const std::vector<LocaleItem>& locales) { language_items_.clear(); for (const auto& locale : locales) { - LoginMenuView::Item item; + PublicAccountMenuView::Item item; if (locale.group_name) { item.title = locale.group_name.value(); item.is_group = true; @@ -526,9 +526,9 @@ selected_language_item_ = item; } - LoginMenuView* old_language_menu_view = language_menu_view_; + PublicAccountMenuView* old_language_menu_view = language_menu_view_; - language_menu_view_ = new LoginMenuView( + language_menu_view_ = new PublicAccountMenuView( language_items_, language_selection_ /*anchor_view*/, language_selection_ /*bubble_opener*/, base::BindRepeating(&RightPaneView::OnLanguageSelected, @@ -544,7 +544,7 @@ const std::vector<InputMethodItem>& keyboard_layouts) { keyboard_items_.clear(); for (const auto& keyboard : keyboard_layouts) { - LoginMenuView::Item item; + PublicAccountMenuView::Item item; item.title = keyboard.title; item.value = keyboard.ime_id; item.is_group = false; @@ -555,9 +555,9 @@ selected_keyboard_item_ = item; } - LoginMenuView* old_keyboard_menu_view = keyboard_menu_view_; + PublicAccountMenuView* old_keyboard_menu_view = keyboard_menu_view_; - keyboard_menu_view_ = new LoginMenuView( + keyboard_menu_view_ = new PublicAccountMenuView( keyboard_items_, keyboard_selection_ /*anchor_view*/, keyboard_selection_ /*bubble_opener*/, base::BindRepeating(&RightPaneView::OnKeyboardSelected, @@ -648,13 +648,13 @@ // |language_menu_view_| and |keyboard_menu_view_| are parented by the top // level view, either LockContentsView or LockDebugView. This allows the menu // items to be clicked outside the bounds of the right pane view. - LoginMenuView* language_menu_view_ = nullptr; - LoginMenuView* keyboard_menu_view_ = nullptr; + PublicAccountMenuView* language_menu_view_ = nullptr; + PublicAccountMenuView* keyboard_menu_view_ = nullptr; - LoginMenuView::Item selected_language_item_; - LoginMenuView::Item selected_keyboard_item_; - std::vector<LoginMenuView::Item> language_items_; - std::vector<LoginMenuView::Item> keyboard_items_; + PublicAccountMenuView::Item selected_language_item_; + PublicAccountMenuView::Item selected_keyboard_item_; + std::vector<PublicAccountMenuView::Item> language_items_; + std::vector<PublicAccountMenuView::Item> keyboard_items_; // Local states to check if the locale and whether to show advanced view // has been changed by the user. This ensures user action won't be overridden @@ -692,9 +692,9 @@ return view_->right_pane_->advanced_view_; } -PublicAccountWarningDialog* -LoginExpandedPublicAccountView::TestApi::warning_dialog() { - return view_->warning_dialog_; +PublicAccountMonitoringInfoDialog* +LoginExpandedPublicAccountView::TestApi::learn_more_dialog() { + return view_->learn_more_dialog_; } views::StyledLabel* @@ -712,20 +712,22 @@ return view_->right_pane_->keyboard_selection_; } -LoginMenuView* LoginExpandedPublicAccountView::TestApi::language_menu_view() { +PublicAccountMenuView* +LoginExpandedPublicAccountView::TestApi::language_menu_view() { return view_->right_pane_->language_menu_view_; } -LoginMenuView* LoginExpandedPublicAccountView::TestApi::keyboard_menu_view() { +PublicAccountMenuView* +LoginExpandedPublicAccountView::TestApi::keyboard_menu_view() { return view_->right_pane_->keyboard_menu_view_; } -LoginMenuView::Item +PublicAccountMenuView::Item LoginExpandedPublicAccountView::TestApi::selected_language_item() { return view_->right_pane_->selected_language_item_; } -LoginMenuView::Item +PublicAccountMenuView::Item LoginExpandedPublicAccountView::TestApi::selected_keyboard_item() { return view_->right_pane_->selected_keyboard_item_; } @@ -751,7 +753,7 @@ bool LoginExpandedPublicAccountView::TestApi::SelectLanguage( const std::string& language_code) { - for (LoginMenuView::Item item : view_->right_pane_->language_items_) { + for (PublicAccountMenuView::Item item : view_->right_pane_->language_items_) { if (item.value == language_code) { view_->right_pane_->OnLanguageSelected(item); return true; @@ -762,7 +764,7 @@ bool LoginExpandedPublicAccountView::TestApi::SelectKeyboard( const std::string& ime_id) { - for (LoginMenuView::Item item : view_->right_pane_->keyboard_items_) { + for (PublicAccountMenuView::Item item : view_->right_pane_->keyboard_items_) { if (item.value == ime_id) { view_->right_pane_->OnKeyboardSelected(item); return true; @@ -773,7 +775,7 @@ std::vector<LocaleItem> LoginExpandedPublicAccountView::TestApi::GetLocales() { std::vector<LocaleItem> locales; - for (LoginMenuView::Item item : view_->right_pane_->language_items_) { + for (PublicAccountMenuView::Item item : view_->right_pane_->language_items_) { LocaleItem locale; locale.title = item.title; locale.language_code = item.value; @@ -835,8 +837,8 @@ if (!GetVisible()) return; - // Keep this view to be visible until warning dialog is dismissed. - if (warning_dialog_ && warning_dialog_->IsVisible()) + // Keep this view to be visible until learn more dialog is dismissed. + if (learn_more_dialog_ && learn_more_dialog_->IsVisible()) return; if (GetBoundsInScreen().Contains(event->root_location())) @@ -872,13 +874,14 @@ } void LoginExpandedPublicAccountView::ShowWarningDialog() { - DCHECK(!warning_dialog_); - warning_dialog_ = new PublicAccountWarningDialog(weak_factory_.GetWeakPtr()); - warning_dialog_->Show(); + DCHECK(!learn_more_dialog_); + learn_more_dialog_ = + new PublicAccountMonitoringInfoDialog(weak_factory_.GetWeakPtr()); + learn_more_dialog_->Show(); } -void LoginExpandedPublicAccountView::OnWarningDialogClosed() { - warning_dialog_ = nullptr; +void LoginExpandedPublicAccountView::OnLearnMoreDialogClosed() { + learn_more_dialog_ = nullptr; } void LoginExpandedPublicAccountView::SetShowFullManagementDisclosure( @@ -901,8 +904,8 @@ if (!GetVisible() || event->type() != ui::ET_KEY_PRESSED) return; - // Give warning dialog a chance to handle key event. - if (warning_dialog_ && warning_dialog_->IsVisible()) + // Give learn more dialog a chance to handle key event. + if (learn_more_dialog_ && learn_more_dialog_->IsVisible()) return; if (event->key_code() == ui::KeyboardCode::VKEY_ESCAPE) {
diff --git a/ash/login/ui/login_expanded_public_account_view.h b/ash/login/ui/login_expanded_public_account_view.h index b1c7f4c..c315278 100644 --- a/ash/login/ui/login_expanded_public_account_view.h +++ b/ash/login/ui/login_expanded_public_account_view.h
@@ -8,8 +8,8 @@ #include <memory> #include "ash/ash_export.h" -#include "ash/login/ui/login_menu_view.h" #include "ash/login/ui/non_accessible_view.h" +#include "ash/login/ui/public_account_menu_view.h" #include "ui/events/event_handler.h" #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" @@ -24,7 +24,7 @@ struct LocaleItem; class LoginUserView; class RightPaneView; -class PublicAccountWarningDialog; +class PublicAccountMonitoringInfoDialog; struct LoginUserInfo; // Implements an expanded view for the public account user to select language @@ -41,14 +41,14 @@ views::View* advanced_view_button(); ArrowButtonView* submit_button(); views::View* advanced_view(); - PublicAccountWarningDialog* warning_dialog(); + PublicAccountMonitoringInfoDialog* learn_more_dialog(); views::StyledLabel* learn_more_label(); views::View* language_selection_button(); views::View* keyboard_selection_button(); - LoginMenuView* language_menu_view(); - LoginMenuView* keyboard_menu_view(); - LoginMenuView::Item selected_language_item(); - LoginMenuView::Item selected_keyboard_item(); + PublicAccountMenuView* language_menu_view(); + PublicAccountMenuView* keyboard_menu_view(); + PublicAccountMenuView::Item selected_language_item(); + PublicAccountMenuView::Item selected_keyboard_item(); views::ImageView* monitoring_warning_icon(); views::Label* monitoring_warning_label(); void ResetUserForTest(); @@ -72,7 +72,7 @@ const LoginUserInfo& current_user() const; void Hide(); void ShowWarningDialog(); - void OnWarningDialogClosed(); + void OnLearnMoreDialogClosed(); void SetShowFullManagementDisclosure(bool show_full_management_disclosure); // views::View: @@ -85,7 +85,7 @@ LoginUserView* user_view_ = nullptr; RightPaneView* right_pane_ = nullptr; OnPublicSessionViewDismissed on_dismissed_; - PublicAccountWarningDialog* warning_dialog_ = nullptr; + PublicAccountMonitoringInfoDialog* learn_more_dialog_ = nullptr; std::unique_ptr<ui::EventHandler> event_handler_; base::WeakPtrFactory<LoginExpandedPublicAccountView> weak_factory_{this};
diff --git a/ash/login/ui/login_expanded_public_account_view_unittest.cc b/ash/login/ui/login_expanded_public_account_view_unittest.cc index 2440970e..087bf04 100644 --- a/ash/login/ui/login_expanded_public_account_view_unittest.cc +++ b/ash/login/ui/login_expanded_public_account_view_unittest.cc
@@ -8,7 +8,7 @@ #include "ash/login/ui/arrow_button_view.h" #include "ash/login/ui/login_test_base.h" #include "ash/login/ui/login_test_utils.h" -#include "ash/login/ui/public_account_warning_dialog.h" +#include "ash/login/ui/public_account_monitoring_info_dialog.h" #include "ash/login/ui/views_utils.h" #include "ash/public/cpp/login_types.h" #include "ash/strings/grit/ash_strings.h" @@ -156,10 +156,10 @@ EXPECT_EQ(public_account_->height(), kBubbleTotalHeightDp); } -// Verifies warning dialog shows up correctly. -TEST_P(LoginExpandedPublicAccountViewTest, ShowWarningDialog) { +// Verifies learn more dialog shows up correctly. +TEST_P(LoginExpandedPublicAccountViewTest, ShowLearnMoreDialog) { LoginExpandedPublicAccountView::TestApi test_api(public_account_); - EXPECT_EQ(test_api.warning_dialog(), nullptr); + EXPECT_EQ(test_api.learn_more_dialog(), nullptr); // Tap on the learn more link. const auto& children = test_api.learn_more_label()->children(); @@ -167,21 +167,21 @@ &views::View::GetClassName); DCHECK(it != children.cend()); TapOnView(*it); - ASSERT_NE(test_api.warning_dialog(), nullptr); - EXPECT_TRUE(test_api.warning_dialog()->GetVisible()); + ASSERT_NE(test_api.learn_more_dialog(), nullptr); + EXPECT_TRUE(test_api.learn_more_dialog()->GetVisible()); - // When warning dialog is shown, tap outside of public account expanded view - // should not hide it. + // When learn more dialog is shown, tap outside of public account expanded + // view should not hide it. TapOnView(other_view_); EXPECT_TRUE(public_account_->GetVisible()); - ASSERT_NE(test_api.warning_dialog(), nullptr); - EXPECT_TRUE(test_api.warning_dialog()->GetVisible()); + ASSERT_NE(test_api.learn_more_dialog(), nullptr); + EXPECT_TRUE(test_api.learn_more_dialog()->GetVisible()); - // If the warning dialog is shown, escape key should close the waring dialog, - // but not the public account view. + // If the learn more dialog is shown, escape key should close the learn more + // dialog, but not the public account view. GetEventGenerator()->PressKey(ui::KeyboardCode::VKEY_ESCAPE, 0); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(test_api.warning_dialog(), nullptr); + EXPECT_EQ(test_api.learn_more_dialog(), nullptr); EXPECT_TRUE(public_account_->GetVisible()); // Press escape again should hide the public account expanded view. @@ -205,7 +205,7 @@ EXPECT_EQ(selected_language, kEnglishLanguageCode); EXPECT_EQ(selected_keyboard, kKeyboardIdForItem2); - // Expect LanuchPublicSession mojo call when the submit button is clicked. + // Expect LaunchPublicSession mojo call when the submit button is clicked. auto client = std::make_unique<MockLoginScreenClient>(); EXPECT_CALL(*client, LaunchPublicSession(user_.basic_user_info.account_id, @@ -233,7 +233,8 @@ // First language item is selected, and selected item should have focus. EXPECT_EQ(test_api.selected_language_item().value, kEnglishLanguageCode); - LoginMenuView::TestApi language_test_api(test_api.language_menu_view()); + PublicAccountMenuView::TestApi language_test_api( + test_api.language_menu_view()); ASSERT_EQ(2u, language_test_api.contents()->children().size()); EXPECT_TRUE(language_test_api.contents()->children()[0]->HasFocus()); @@ -247,7 +248,8 @@ // Second keyboard item is selected, and selected item should have focus. EXPECT_EQ(test_api.selected_keyboard_item().value, kKeyboardIdForItem2); - LoginMenuView::TestApi keyboard_test_api(test_api.keyboard_menu_view()); + PublicAccountMenuView::TestApi keyboard_test_api( + test_api.keyboard_menu_view()); ASSERT_EQ(2u, keyboard_test_api.contents()->children().size()); EXPECT_TRUE(keyboard_test_api.contents()->children()[1]->HasFocus()); @@ -278,7 +280,8 @@ user_.basic_user_info.account_id, kFrenchLanguageCode)); EXPECT_EQ(test_api.selected_language_item().value, kEnglishLanguageCode); - LoginMenuView::TestApi language_test_api(test_api.language_menu_view()); + PublicAccountMenuView::TestApi language_test_api( + test_api.language_menu_view()); TapOnView(language_test_api.contents()->children()[1]); EXPECT_FALSE(test_api.language_menu_view()->GetVisible()); EXPECT_EQ(test_api.selected_language_item().value, kFrenchLanguageCode); @@ -293,7 +296,8 @@ // 1. Keyboard menu will be closed automatically. // 2. Selected keyboard item will change. EXPECT_EQ(test_api.selected_keyboard_item().value, kKeyboardIdForItem2); - LoginMenuView::TestApi keyboard_test_api(test_api.keyboard_menu_view()); + PublicAccountMenuView::TestApi keyboard_test_api( + test_api.keyboard_menu_view()); TapOnView(keyboard_test_api.contents()->children()[0]); EXPECT_FALSE(test_api.keyboard_menu_view()->GetVisible()); EXPECT_EQ(test_api.selected_keyboard_item().value, kKeyboardIdForItem1);
diff --git a/ash/login/ui/login_password_view.cc b/ash/login/ui/login_password_view.cc index 822454b..880fd27 100644 --- a/ash/login/ui/login_password_view.cc +++ b/ash/login/ui/login_password_view.cc
@@ -329,10 +329,10 @@ base::Unretained(this))); } - void SetEasyUnlockIcon(EasyUnlockIconId icon_id, + void SetEasyUnlockIcon(EasyUnlockIconState icon_state, const std::u16string& accessibility_label) { - icon_id_ = icon_id; - UpdateImage(icon_id); + icon_state_ = icon_state; + UpdateImage(icon_state); SetAccessibleName(accessibility_label); } @@ -341,7 +341,7 @@ // views::View: void OnThemeChanged() override { views::View::OnThemeChanged(); - UpdateImage(icon_id_); + UpdateImage(icon_state_); } // views::Button: @@ -369,8 +369,8 @@ : ButtonState::STATE_NORMAL); } - void UpdateImage(EasyUnlockIconId icon_id) { - // If the icon state changes from EasyUnlockIconId::SPINNER to something + void UpdateImage(EasyUnlockIconState icon_state) { + // If the icon state changes from EasyUnlockIconState::SPINNER to something // else, we need to abort the current opacity animation and set back the // opacity to 100%. This can be done by destroying the layer that we do not // use anymore. @@ -382,32 +382,32 @@ SkColor color = color_provider->GetContentLayerColor( AshColorProvider::ContentLayerType::kIconColorPrimary); - switch (icon_id) { - case EasyUnlockIconId::NONE: + switch (icon_state) { + case EasyUnlockIconState::NONE: // The easy unlock icon will be set to invisible. Do nothing. break; - case EasyUnlockIconId::HARDLOCKED: + case EasyUnlockIconState::HARDLOCKED: color = color_provider->GetContentLayerColor( AshColorProvider::ContentLayerType::kIconColorProminent); break; - case EasyUnlockIconId::LOCKED: + case EasyUnlockIconState::LOCKED: // This is the default case in terms of icon and color. break; - case EasyUnlockIconId::LOCKED_TO_BE_ACTIVATED: + case EasyUnlockIconState::LOCKED_TO_BE_ACTIVATED: color = AshColorProvider::GetDisabledColor( color_provider->GetContentLayerColor( AshColorProvider::ContentLayerType::kIconColorPrimary)); break; - case EasyUnlockIconId::LOCKED_WITH_PROXIMITY_HINT: + case EasyUnlockIconState::LOCKED_WITH_PROXIMITY_HINT: color = color_provider->GetContentLayerColor( AshColorProvider::ContentLayerType::kIconColorWarning); break; - case EasyUnlockIconId::UNLOCKED: + case EasyUnlockIconState::UNLOCKED: icon = &kLockScreenEasyUnlockOpenIcon; color = color_provider->GetContentLayerColor( AshColorProvider::ContentLayerType::kIconColorPositive); break; - case EasyUnlockIconId::SPINNER: { + case EasyUnlockIconState::SPINNER: { SetPaintToLayer(); layer()->SetFillsBoundsOpaquely(false); std::unique_ptr<ui::LayerAnimationSequence> opacity_sequence = @@ -444,7 +444,7 @@ // run immediately. bool immediately_hover_for_test_ = false; - EasyUnlockIconId icon_id_ = EasyUnlockIconId::LOCKED; + EasyUnlockIconState icon_state_ = EasyUnlockIconState::LOCKED; DISALLOW_COPY_AND_ASSIGN(EasyUnlockIcon); }; @@ -711,13 +711,13 @@ } void LoginPasswordView::SetEasyUnlockIcon( - EasyUnlockIconId id, + EasyUnlockIconState icon_state, const std::u16string& accessibility_label) { // Update icon. - easy_unlock_icon_->SetEasyUnlockIcon(id, accessibility_label); + easy_unlock_icon_->SetEasyUnlockIcon(icon_state, accessibility_label); - // Update icon visiblity. - bool has_icon = id != EasyUnlockIconId::NONE; + // Update icon visibility. + bool has_icon = icon_state != EasyUnlockIconState::NONE; // We do not want to schedule a new animation when the user switches from an // account to another. if (should_show_easy_unlock_ == has_icon)
diff --git a/ash/login/ui/login_password_view.h b/ash/login/ui/login_password_view.h index b3398d7..9c511f6 100644 --- a/ash/login/ui/login_password_view.h +++ b/ash/login/ui/login_password_view.h
@@ -25,7 +25,7 @@ namespace ash { class ArrowButtonView; -enum class EasyUnlockIconId; +enum class EasyUnlockIconState; // Contains a textfield and a submit button. When the display password button // is visible, the textfield contains a button in the form of an eye icon that @@ -97,11 +97,11 @@ const OnEasyUnlockIconHovered& on_easy_unlock_icon_hovered, views::Button::PressedCallback on_easy_unlock_icon_tapped); - // Is the password field enabled when there is no text? + // Whether or not the password field is enabled when there is no text. void SetEnabledOnEmptyPassword(bool enabled); // Change the active icon for easy unlock. - void SetEasyUnlockIcon(EasyUnlockIconId id, + void SetEasyUnlockIcon(EasyUnlockIconState icon_state, const std::u16string& accessibility_label); // Set the textfield name used for accessibility.
diff --git a/ash/login/ui/login_password_view_test.cc b/ash/login/ui/login_password_view_test.cc index d8221bb..ee1dde5 100644 --- a/ash/login/ui/login_password_view_test.cc +++ b/ash/login/ui/login_password_view_test.cc
@@ -244,7 +244,7 @@ ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); // Enable icon. - view_->SetEasyUnlockIcon(EasyUnlockIconId::SPINNER, + view_->SetEasyUnlockIcon(EasyUnlockIconState::SPINNER, std::u16string() /*accessibility_label*/); ASSERT_TRUE(test_api.easy_unlock_icon()->GetVisible()); @@ -276,7 +276,7 @@ ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); // Enable icon, enable immediate hovering. - view_->SetEasyUnlockIcon(EasyUnlockIconId::SPINNER, + view_->SetEasyUnlockIcon(EasyUnlockIconState::SPINNER, std::u16string() /*accessibility_label*/); test_api.set_immediately_hover_easy_unlock_icon(); ASSERT_TRUE(test_api.easy_unlock_icon()->GetVisible()); @@ -316,7 +316,7 @@ EXPECT_FALSE(test_api.capslock_icon()->GetVisible()); // Show the easy unlock icon. - view_->SetEasyUnlockIcon(EasyUnlockIconId::SPINNER, + view_->SetEasyUnlockIcon(EasyUnlockIconState::SPINNER, std::u16string() /*accessibility_label*/); // The easy unlock icon should be visible. EXPECT_TRUE(test_api.easy_unlock_icon()->GetVisible()); @@ -347,7 +347,7 @@ EXPECT_FALSE(test_api.capslock_icon()->GetVisible()); // Hide the easy unlock icon. - view_->SetEasyUnlockIcon(EasyUnlockIconId::NONE, + view_->SetEasyUnlockIcon(EasyUnlockIconState::NONE, std::u16string() /*accessibility_label*/); // Nothing should be displayed. EXPECT_FALSE(test_api.easy_unlock_icon()->GetVisible()); @@ -359,13 +359,13 @@ EXPECT_TRUE(test_api.capslock_icon()->GetVisible()); // Then trigger the easy unlock icon, it should be displayed immediately. - view_->SetEasyUnlockIcon(EasyUnlockIconId::SPINNER, + view_->SetEasyUnlockIcon(EasyUnlockIconState::SPINNER, std::u16string() /*accessibility_label*/); EXPECT_TRUE(test_api.easy_unlock_icon()->GetVisible()); EXPECT_FALSE(test_api.capslock_icon()->GetVisible()); // Hide the easy unlock icon, the capslock icon should be shown. - view_->SetEasyUnlockIcon(EasyUnlockIconId::NONE, + view_->SetEasyUnlockIcon(EasyUnlockIconState::NONE, std::u16string() /*accessibility_label*/); EXPECT_FALSE(test_api.easy_unlock_icon()->GetVisible()); EXPECT_TRUE(test_api.capslock_icon()->GetVisible());
diff --git a/ash/login/ui/login_user_menu_view.cc b/ash/login/ui/login_remove_account_dialog.cc similarity index 78% rename from ash/login/ui/login_user_menu_view.cc rename to ash/login/ui/login_remove_account_dialog.cc index 7577d62..2d9bc7a3 100644 --- a/ash/login/ui/login_user_menu_view.cc +++ b/ash/login/ui/login_remove_account_dialog.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/login/ui/login_user_menu_view.h" +#include "ash/login/ui/login_remove_account_dialog.h" #include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/system_label_button.h" #include "ash/login/ui/views_utils.h" @@ -24,25 +24,25 @@ namespace ash { namespace { // Vertical margin between username and mail. -constexpr int kUserMenuVerticalMarginUsernameMailDp = 8; +constexpr int kVerticalMarginUsernameMailDp = 8; // Vertical margin between labels. -constexpr int kUserMenuVerticalMarginBetweenLabelsDp = 16; +constexpr int kVerticalMarginBetweenLabelsDp = 16; -// Horizontal and vertical padding of login user menu view. -constexpr int kHorizontalPaddingLoginUserMenuViewDp = 8; -constexpr int kVerticalPaddingLoginUserMenuViewDp = 8; +// Horizontal and vertical padding of the remove account dialog. +constexpr int kHorizontalPaddingRemoveAccountDialogDp = 8; +constexpr int kVerticalPaddingRemoveAccountDialogDp = 8; -constexpr int kUserMenuRemoveUserButtonIdForTest = 1; +constexpr int kRemoveUserButtonIdForTest = 1; // Font name of the username headline. -constexpr char kUserMenuFontNameUsername[] = "Google Sans"; +constexpr char kFontNameUsername[] = "Google Sans"; // Font size of the username headline. -constexpr int kUserMenuFontSizeUsername = 15; +constexpr int kFontSizeUsername = 15; // Line height of the username headline. -constexpr int kUserMenuLineHeightUsername = 22; +constexpr int kLineHeightUsername = 22; // Traps the focus so it does not move from the |trapped_focus| view. class TrappedFocusSearch : public views::FocusSearch { @@ -75,7 +75,7 @@ // A button that holds a child view. class RemoveUserButton : public SystemLabelButton { public: - RemoveUserButton(PressedCallback callback, LoginUserMenuView* bubble) + RemoveUserButton(PressedCallback callback, LoginRemoveAccountDialog* bubble) : SystemLabelButton(std::move(callback), l10n_util::GetStringUTF16( IDS_ASH_LOGIN_POD_REMOVE_ACCOUNT_ACCESSIBLE_NAME), @@ -83,6 +83,8 @@ /*multiline*/ true), bubble_(bubble) {} + RemoveUserButton(const RemoveUserButton&) = delete; + RemoveUserButton& operator=(const RemoveUserButton&) = delete; ~RemoveUserButton() override = default; private: @@ -103,35 +105,33 @@ views::Button::OnKeyEvent(event); } - LoginUserMenuView* bubble_; - - DISALLOW_COPY_AND_ASSIGN(RemoveUserButton); + LoginRemoveAccountDialog* bubble_; }; -LoginUserMenuView::TestApi::TestApi(LoginUserMenuView* bubble) +LoginRemoveAccountDialog::TestApi::TestApi(LoginRemoveAccountDialog* bubble) : bubble_(bubble) {} -views::View* LoginUserMenuView::TestApi::remove_user_button() { +views::View* LoginRemoveAccountDialog::TestApi::remove_user_button() { return bubble_->remove_user_button_; } -views::View* LoginUserMenuView::TestApi::remove_user_confirm_data() { +views::View* LoginRemoveAccountDialog::TestApi::remove_user_confirm_data() { return bubble_->remove_user_confirm_data_; } -views::View* LoginUserMenuView::TestApi::managed_user_data() { +views::View* LoginRemoveAccountDialog::TestApi::managed_user_data() { return bubble_->managed_user_data_; } -views::Label* LoginUserMenuView::TestApi::username_label() { +views::Label* LoginRemoveAccountDialog::TestApi::username_label() { return bubble_->username_label_; } -views::Label* LoginUserMenuView::TestApi::management_disclosure_label() { +views::Label* LoginRemoveAccountDialog::TestApi::management_disclosure_label() { return bubble_->management_disclosure_label_; } -LoginUserMenuView::LoginUserMenuView( +LoginRemoveAccountDialog::LoginRemoveAccountDialog( const LoginUserInfo& user, views::View* anchor_view, LoginButton* bubble_opener, @@ -145,7 +145,7 @@ base::UTF8ToUTF16(user.basic_user_info.display_email); bool is_owner = user.is_device_owner; - // User information. + // Add texts with user information such as username, email and ownership. { const std::u16string& username = base::UTF8ToUTF16(user.basic_user_info.display_name); @@ -158,21 +158,20 @@ new NonAccessibleView("UsernameLabel MarginContainer"); container->SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical, gfx::Insets(), - kUserMenuVerticalMarginUsernameMailDp)); + kVerticalMarginUsernameMailDp)); AddChildView(container); // Colors should be updated in OnThemeChanged. username_label_ = container->AddChildView(login_views_utils::CreateBubbleLabel( display_username, nullptr, SK_ColorGREEN, - gfx::FontList({kUserMenuFontNameUsername}, - gfx::Font::FontStyle::NORMAL, - kUserMenuFontSizeUsername, gfx::Font::Weight::MEDIUM), - kUserMenuLineHeightUsername)); + gfx::FontList({kFontNameUsername}, gfx::Font::FontStyle::NORMAL, + kFontSizeUsername, gfx::Font::Weight::MEDIUM), + kLineHeightUsername)); email_label_ = container->AddChildView(login_views_utils::CreateBubbleLabel(email)); } - // User is managed. + // Add a warning text if the user is managed. if (user.user_account_manager) { managed_user_data_ = new views::View(); managed_user_data_->SetLayoutManager(std::make_unique<views::BoxLayout>( @@ -191,7 +190,7 @@ // accessible data is displayed by accessibility tools. set_notify_alert_on_show(!user.can_remove); - // Remove user. + // Add the remove user button and texts about consequences of user removal. if (user.can_remove) { DCHECK(!is_owner); user_manager::UserType type = user.basic_user_info.type; @@ -208,7 +207,7 @@ remove_user_confirm_data_->SetLayoutManager( std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical, gfx::Insets(), - kUserMenuVerticalMarginBetweenLabelsDp)); + kVerticalMarginBetweenLabelsDp)); remove_user_confirm_data_->SetVisible(false); remove_user_confirm_data_->AddChildView( @@ -218,10 +217,10 @@ login_views_utils::CreateBubbleLabel(part2, this)); remove_user_button_ = new RemoveUserButton( - base::BindRepeating(&LoginUserMenuView::RemoveUserButtonPressed, + base::BindRepeating(&LoginRemoveAccountDialog::RemoveUserButtonPressed, base::Unretained(this)), this); - remove_user_button_->SetID(kUserMenuRemoveUserButtonIdForTest); + remove_user_button_->SetID(kRemoveUserButtonIdForTest); AddChildView(remove_user_button_); // Traps the focus on the remove user button. @@ -229,13 +228,13 @@ } set_positioning_strategy(PositioningStrategy::kTryAfterThenBefore); - SetPadding(kHorizontalPaddingLoginUserMenuViewDp, - kVerticalPaddingLoginUserMenuViewDp); + SetPadding(kHorizontalPaddingRemoveAccountDialogDp, + kVerticalPaddingRemoveAccountDialogDp); } -LoginUserMenuView::~LoginUserMenuView() = default; +LoginRemoveAccountDialog::~LoginRemoveAccountDialog() = default; -void LoginUserMenuView::ResetState() { +void LoginRemoveAccountDialog::ResetState() { if (managed_user_data_) managed_user_data_->SetVisible(true); if (remove_user_confirm_data_) { @@ -248,11 +247,11 @@ } } -LoginButton* LoginUserMenuView::GetBubbleOpener() const { +LoginButton* LoginRemoveAccountDialog::GetBubbleOpener() const { return bubble_opener_; } -void LoginUserMenuView::OnThemeChanged() { +void LoginRemoveAccountDialog::OnThemeChanged() { LoginBaseBubbleView::OnThemeChanged(); username_label_->SetEnabledColor( AshColorProvider::Get()->GetContentLayerColor( @@ -269,22 +268,23 @@ } } -void LoginUserMenuView::RequestFocus() { +void LoginRemoveAccountDialog::RequestFocus() { // This view has no actual interesting contents to focus, so immediately // forward to the button. if (remove_user_button_) remove_user_button_->RequestFocus(); } -bool LoginUserMenuView::HasFocus() const { +bool LoginRemoveAccountDialog::HasFocus() const { return remove_user_button_ && remove_user_button_->HasFocus(); } -const char* LoginUserMenuView::GetClassName() const { - return "LoginUserMenuView"; +const char* LoginRemoveAccountDialog::GetClassName() const { + return "LoginRemoveAccountDialog"; } -void LoginUserMenuView::GetAccessibleNodeData(ui::AXNodeData* node_data) { +void LoginRemoveAccountDialog::GetAccessibleNodeData( + ui::AXNodeData* node_data) { if (remove_user_button_) { node_data->SetName(l10n_util::GetStringUTF16( IDS_ASH_LOGIN_POD_REMOVE_ACCOUNT_ACCESSIBLE_NAME)); @@ -304,23 +304,23 @@ node_data->AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true); } -views::FocusTraversable* LoginUserMenuView::GetPaneFocusTraversable() { +views::FocusTraversable* LoginRemoveAccountDialog::GetPaneFocusTraversable() { return this; } -views::FocusSearch* LoginUserMenuView::GetFocusSearch() { +views::FocusSearch* LoginRemoveAccountDialog::GetFocusSearch() { return focus_search_.get(); } -views::FocusTraversable* LoginUserMenuView::GetFocusTraversableParent() { +views::FocusTraversable* LoginRemoveAccountDialog::GetFocusTraversableParent() { return nullptr; } -views::View* LoginUserMenuView::GetFocusTraversableParentView() { +views::View* LoginRemoveAccountDialog::GetFocusTraversableParentView() { return nullptr; } -void LoginUserMenuView::RemoveUserButtonPressed() { +void LoginRemoveAccountDialog::RemoveUserButtonPressed() { // Show confirmation warning. The user has to click the button again before // we actually allow the exit. if (!remove_user_confirm_data_->GetVisible()) {
diff --git a/ash/login/ui/login_user_menu_view.h b/ash/login/ui/login_remove_account_dialog.h similarity index 66% rename from ash/login/ui/login_user_menu_view.h rename to ash/login/ui/login_remove_account_dialog.h index 6fd1994..3e5802b 100644 --- a/ash/login/ui/login_user_menu_view.h +++ b/ash/login/ui/login_remove_account_dialog.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_LOGIN_UI_LOGIN_USER_MENU_VIEW_H_ -#define ASH_LOGIN_UI_LOGIN_USER_MENU_VIEW_H_ +#ifndef ASH_LOGIN_UI_LOGIN_REMOVE_ACCOUNT_DIALOG_H_ +#define ASH_LOGIN_UI_LOGIN_REMOVE_ACCOUNT_DIALOG_H_ #include <string> @@ -20,12 +20,16 @@ struct LoginUserInfo; class RemoveUserButton; -class ASH_EXPORT LoginUserMenuView : public LoginBaseBubbleView, - public views::FocusTraversable { +class ASH_EXPORT LoginRemoveAccountDialog : public LoginBaseBubbleView, + public views::FocusTraversable { public: class TestApi { public: - explicit TestApi(LoginUserMenuView* bubble); + explicit TestApi(LoginRemoveAccountDialog* bubble); + TestApi(const TestApi&) = delete; + TestApi& operator=(const TestApi&) = delete; + ~TestApi() = default; + views::View* remove_user_button(); views::View* remove_user_confirm_data(); views::View* managed_user_data(); @@ -33,18 +37,17 @@ views::Label* management_disclosure_label(); private: - LoginUserMenuView* bubble_; - - DISALLOW_COPY_AND_ASSIGN(TestApi); + LoginRemoveAccountDialog* bubble_; }; - LoginUserMenuView(const LoginUserInfo& user, - views::View* anchor_view, - LoginButton* bubble_opener, - base::RepeatingClosure on_remove_user_warning_shown, - base::RepeatingClosure on_remove_user_requested); - - ~LoginUserMenuView() override; + LoginRemoveAccountDialog(const LoginUserInfo& user, + views::View* anchor_view, + LoginButton* bubble_opener, + base::RepeatingClosure on_remove_user_warning_shown, + base::RepeatingClosure on_remove_user_requested); + LoginRemoveAccountDialog(const LoginRemoveAccountDialog&) = delete; + LoginRemoveAccountDialog& operator=(const LoginRemoveAccountDialog&) = delete; + ~LoginRemoveAccountDialog() override; // Resets the user menu to the state where Remove User has not been pressed. void ResetState(); @@ -81,10 +84,8 @@ std::u16string warning_message_; std::unique_ptr<views::FocusSearch> focus_search_; - - DISALLOW_COPY_AND_ASSIGN(LoginUserMenuView); }; } // namespace ash -#endif // ASH_LOGIN_UI_LOGIN_USER_MENU_VIEW_H_ +#endif // ASH_LOGIN_UI_LOGIN_REMOVE_ACCOUNT_DIALOG_H_
diff --git a/ash/login/ui/login_user_menu_view_unittest.cc b/ash/login/ui/login_remove_account_dialog_unittest.cc similarity index 83% rename from ash/login/ui/login_user_menu_view_unittest.cc rename to ash/login/ui/login_remove_account_dialog_unittest.cc index d868194..0083a9c 100644 --- a/ash/login/ui/login_user_menu_view_unittest.cc +++ b/ash/login/ui/login_remove_account_dialog_unittest.cc
@@ -5,8 +5,8 @@ #include <memory> #include "ash/login/ui/login_button.h" +#include "ash/login/ui/login_remove_account_dialog.h" #include "ash/login/ui/login_test_base.h" -#include "ash/login/ui/login_user_menu_view.h" #include "base/bind.h" #include "base/callback_helpers.h" #include "base/strings/utf_string_conversions.h" @@ -21,9 +21,9 @@ constexpr int kBubbleAnchorViewSizeDp = 100; } // namespace -using LoginUserMenuViewTest = LoginTestBase; +using LoginRemoveAccountDialogTest = LoginTestBase; -TEST_F(LoginUserMenuViewTest, RemoveUserRequiresTwoActivations) { +TEST_F(LoginRemoveAccountDialogTest, RemoveUserRequiresTwoActivations) { auto* anchor = new views::View; anchor->SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical)); @@ -34,7 +34,7 @@ LoginUserInfo login_user_info; login_user_info.can_remove = true; - auto* bubble = new LoginUserMenuView( + auto* bubble = new LoginRemoveAccountDialog( login_user_info, anchor, nullptr /*bubble_opener*/, base::BindRepeating([](bool* warning_called) { *warning_called = true; }, &remove_warning_called), @@ -63,7 +63,7 @@ EXPECT_TRUE(remove_called); } -TEST_F(LoginUserMenuViewTest, LongUserNameAndEmailLaidOutCorrectly) { +TEST_F(LoginRemoveAccountDialogTest, LongUserNameAndEmailLaidOutCorrectly) { auto* anchor = new views::View; anchor->SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical)); @@ -77,16 +77,16 @@ login_user_info.basic_user_info.type = user_manager::USER_TYPE_REGULAR; login_user_info.is_device_owner = false; login_user_info.can_remove = true; - auto* bubble = - new LoginUserMenuView(login_user_info, anchor, nullptr /*bubble_opener*/, - base::DoNothing(), base::DoNothing()); + auto* bubble = new LoginRemoveAccountDialog( + login_user_info, anchor, nullptr /*bubble_opener*/, base::DoNothing(), + base::DoNothing()); anchor->AddChildView(bubble); bubble->Show(); EXPECT_TRUE(bubble->GetVisible()); - LoginUserMenuView::TestApi test_api(bubble); + LoginRemoveAccountDialog::TestApi test_api(bubble); views::View* remove_user_button = test_api.remove_user_button(); views::View* remove_user_confirm_data = test_api.remove_user_confirm_data(); views::View* username_label = test_api.username_label(); @@ -109,7 +109,7 @@ remove_user_button->GetBoundsInScreen())); } -TEST_F(LoginUserMenuViewTest, LoginButtonRipple) { +TEST_F(LoginRemoveAccountDialogTest, LoginButtonRipple) { auto* container = new views::View(); container->SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical)); @@ -127,9 +127,9 @@ EXPECT_EQ(ink_drop_api.ink_drop_mode(), views::InkDropHost::InkDropMode::ON); EXPECT_TRUE(ink_drop_api.HasInkDrop()); - auto* bubble = new LoginUserMenuView(LoginUserInfo(), container /*anchor*/, - bubble_opener, base::DoNothing(), - base::DoNothing()); + auto* bubble = new LoginRemoveAccountDialog( + LoginUserInfo(), container /*anchor*/, bubble_opener, base::DoNothing(), + base::DoNothing()); container->AddChildView(bubble); @@ -147,7 +147,7 @@ EXPECT_FALSE(ink_drop_api.GetInkDrop()->IsHighlightFadingInOrVisible()); } -TEST_F(LoginUserMenuViewTest, ResetStateHidesConfirmData) { +TEST_F(LoginRemoveAccountDialogTest, ResetStateHidesConfirmData) { auto* container = new views::View; container->SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical)); @@ -155,14 +155,14 @@ LoginUserInfo login_user_info; login_user_info.can_remove = true; - auto* bubble = new LoginUserMenuView(login_user_info, nullptr /*anchor*/, - nullptr /*bubble_opener*/, - base::DoNothing(), base::DoNothing()); + auto* bubble = new LoginRemoveAccountDialog( + login_user_info, nullptr /*anchor*/, nullptr /*bubble_opener*/, + base::DoNothing(), base::DoNothing()); container->AddChildView(bubble); bubble->Show(); - LoginUserMenuView::TestApi test_api(bubble); + LoginRemoveAccountDialog::TestApi test_api(bubble); EXPECT_FALSE(test_api.remove_user_confirm_data()->GetVisible()); test_api.remove_user_button()->RequestFocus();
diff --git a/ash/login/ui/login_user_view.cc b/ash/login/ui/login_user_view.cc index df220e66..ba6f714 100644 --- a/ash/login/ui/login_user_view.cc +++ b/ash/login/ui/login_user_view.cc
@@ -379,8 +379,9 @@ return view_->dropdown_; } -LoginUserMenuView* LoginUserView::TestApi::menu() const { - return view_->menu_; +LoginRemoveAccountDialog* LoginUserView::TestApi::remove_account_dialog() + const { + return view_->remove_account_dialog_; } views::View* LoginUserView::TestApi::enterprise_icon() const { @@ -480,15 +481,15 @@ void LoginUserView::UpdateForUser(const LoginUserInfo& user, bool animate) { current_user_ = user; - if (menu_ && menu_->parent()) { - menu_->parent()->RemoveChildView(menu_); - delete menu_; + if (remove_account_dialog_ && remove_account_dialog_->parent()) { + remove_account_dialog_->parent()->RemoveChildView(remove_account_dialog_); + delete remove_account_dialog_; } - menu_ = new LoginUserMenuView(current_user_, dropdown_ /*anchor_view*/, - dropdown_ /*bubble_opener*/, - on_remove_warning_shown_, on_remove_); - menu_->SetVisible(false); + remove_account_dialog_ = new LoginRemoveAccountDialog( + current_user_, dropdown_ /*anchor_view*/, dropdown_ /*bubble_opener*/, + on_remove_warning_shown_, on_remove_); + remove_account_dialog_->SetVisible(false); if (animate) { // Stop any existing animation. @@ -597,29 +598,30 @@ void LoginUserView::DropdownButtonPressed() { DCHECK(dropdown_); - DCHECK(menu_); + DCHECK(remove_account_dialog_); - // If menu is showing, just close it - if (menu_->GetVisible()) { - menu_->Hide(); + // If the remove account dialog is showing, just close it. + if (remove_account_dialog_->GetVisible()) { + remove_account_dialog_->Hide(); return; } - bool opener_focused = - menu_->GetBubbleOpener() && menu_->GetBubbleOpener()->HasFocus(); + bool opener_focused = remove_account_dialog_->GetBubbleOpener() && + remove_account_dialog_->GetBubbleOpener()->HasFocus(); - if (!menu_->parent()) - login_views_utils::GetBubbleContainer(this)->AddChildView(menu_); + if (!remove_account_dialog_->parent()) + login_views_utils::GetBubbleContainer(this)->AddChildView( + remove_account_dialog_); // Reset state in case the remove-user button was clicked once previously. - menu_->ResetState(); - menu_->Show(); + remove_account_dialog_->ResetState(); + remove_account_dialog_->Show(); - // If the menu was opened by pressing Enter on the focused dropdown, focus - // should automatically go to the remove-user button (for keyboard - // accessibility). + // If the remove account dialog was opened by pressing Enter on the focused + // dropdown, focus should automatically go to the remove-user button (for + // keyboard accessibility). if (opener_focused) - menu_->RequestFocus(); + remove_account_dialog_->RequestFocus(); } void LoginUserView::UpdateCurrentUserState() {
diff --git a/ash/login/ui/login_user_view.h b/ash/login/ui/login_user_view.h index a30205c..12e5187 100644 --- a/ash/login/ui/login_user_view.h +++ b/ash/login/ui/login_user_view.h
@@ -8,7 +8,7 @@ #include "ash/ash_export.h" #include "ash/login/ui/login_base_bubble_view.h" #include "ash/login/ui/login_display_style.h" -#include "ash/login/ui/login_user_menu_view.h" +#include "ash/login/ui/login_remove_account_dialog.h" #include "ash/public/cpp/login_types.h" #include "base/macros.h" #include "base/scoped_observation.h" @@ -20,8 +20,8 @@ class HoverNotifier; class LoginButton; -// Display the user's profile icon, name, and a menu icon in various layout -// styles. +// Display the user's profile icon, name, and a remove_account_dialog icon in +// various layout styles. class ASH_EXPORT LoginUserView : public views::View, public display::DisplayConfigurator::Observer { public: @@ -38,7 +38,7 @@ views::View* user_label() const; views::View* tap_button() const; views::View* dropdown() const; - LoginUserMenuView* menu() const; + LoginRemoveAccountDialog* remove_account_dialog() const; views::View* enterprise_icon() const; void OnTap() const; @@ -126,10 +126,11 @@ LoginButton* dropdown_ = nullptr; TapButton* tap_button_ = nullptr; - // Bubble used for displaying the user dropdown menu. Its parent is the top - // level view, either LockContentsView or LockDebugView. This allows the menu - // to be clicked outside the bounds of the user view. - LoginUserMenuView* menu_ = nullptr; + // Bubble used for displaying the user remove account dialog. Its parent is + // the top level view, either LockContentsView or LockDebugView. This allows + // the remove account dialog to be clicked outside the bounds of the user + // view. + LoginRemoveAccountDialog* remove_account_dialog_ = nullptr; // True iff the view is currently opaque (ie, opacity = 1). bool is_opaque_ = false;
diff --git a/ash/login/ui/login_menu_view.cc b/ash/login/ui/public_account_menu_view.cc similarity index 77% rename from ash/login/ui/login_menu_view.cc rename to ash/login/ui/public_account_menu_view.cc index 6c0631a..e5f7818 100644 --- a/ash/login/ui/login_menu_view.cc +++ b/ash/login/ui/public_account_menu_view.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/login/ui/login_menu_view.h" +#include "ash/login/ui/public_account_menu_view.h" #include <algorithm> #include <iterator> @@ -32,8 +32,8 @@ class MenuItemView : public views::Button { public: - MenuItemView(const LoginMenuView::Item& item, - const LoginMenuView::OnHighlight& on_highlight) + MenuItemView(const PublicAccountMenuView::Item& item, + const PublicAccountMenuView::OnHighlight& on_highlight) : views::Button(base::BindRepeating(&MenuItemView::ButtonPressed, base::Unretained(this))), item_(item), @@ -65,7 +65,8 @@ this, base::BindRepeating(&MenuItemView::OnHover, base::Unretained(this))); } - + MenuItemView(const MenuItemView&) = delete; + MenuItemView& operator=(const MenuItemView&) = delete; ~MenuItemView() override = default; // views::View: @@ -84,7 +85,7 @@ on_highlight_.Run(false /*by_selection*/); } - const LoginMenuView::Item& item() const { return item_; } + const PublicAccountMenuView::Item& item() const { return item_; } private: void ButtonPressed() { @@ -92,43 +93,42 @@ on_highlight_.Run(true /*by_selection*/); } - const LoginMenuView::Item item_; - const LoginMenuView::OnHighlight on_highlight_; + const PublicAccountMenuView::Item item_; + const PublicAccountMenuView::OnHighlight on_highlight_; std::unique_ptr<HoverNotifier> hover_notifier_; - - DISALLOW_COPY_AND_ASSIGN(MenuItemView); }; class LoginScrollBar : public views::OverlayScrollBar { public: LoginScrollBar() : OverlayScrollBar(false) {} + LoginScrollBar(const LoginScrollBar&) = delete; + LoginScrollBar& operator=(const LoginScrollBar&) = delete; + ~LoginScrollBar() override = default; // OverlayScrollBar: bool OnKeyPressed(const ui::KeyEvent& event) override { // Let LoginMenuView to handle up/down keypress. return false; } - - private: - DISALLOW_COPY_AND_ASSIGN(LoginScrollBar); }; } // namespace -LoginMenuView::TestApi::TestApi(LoginMenuView* view) : view_(view) {} +PublicAccountMenuView::TestApi::TestApi(PublicAccountMenuView* view) + : view_(view) {} -LoginMenuView::TestApi::~TestApi() = default; +PublicAccountMenuView::TestApi::~TestApi() = default; -views::View* LoginMenuView::TestApi::contents() const { +views::View* PublicAccountMenuView::TestApi::contents() const { return view_->contents_; } -LoginMenuView::Item::Item() = default; +PublicAccountMenuView::Item::Item() = default; -LoginMenuView::LoginMenuView(const std::vector<Item>& items, - views::View* anchor_view, - LoginButton* opener, - const OnSelect& on_select) +PublicAccountMenuView::PublicAccountMenuView(const std::vector<Item>& items, + views::View* anchor_view, + LoginButton* opener, + const OnSelect& on_select) : LoginBaseBubbleView(anchor_view), opener_(opener), on_select_(on_select) { SetFocusBehavior(views::View::FocusBehavior::ALWAYS); @@ -154,7 +154,7 @@ for (size_t i = 0; i < items.size(); i++) { const Item& item = items[i]; contents->AddChildView(new MenuItemView( - item, base::BindRepeating(&LoginMenuView::OnHighlightChange, + item, base::BindRepeating(&PublicAccountMenuView::OnHighlightChange, base::Unretained(this), i))); if (item.selected) @@ -164,9 +164,10 @@ scroller_->SetVerticalScrollBar(std::make_unique<LoginScrollBar>()); } -LoginMenuView::~LoginMenuView() = default; +PublicAccountMenuView::~PublicAccountMenuView() = default; -void LoginMenuView::OnHighlightChange(size_t item_index, bool by_selection) { +void PublicAccountMenuView::OnHighlightChange(size_t item_index, + bool by_selection) { selected_index_ = item_index; views::View* highlight_item = contents_->children()[item_index]; for (views::View* child : contents_->GetChildrenInZOrder()) { @@ -182,16 +183,16 @@ contents_->SchedulePaint(); } -LoginButton* LoginMenuView::GetBubbleOpener() const { +LoginButton* PublicAccountMenuView::GetBubbleOpener() const { return opener_; } -void LoginMenuView::OnFocus() { +void PublicAccountMenuView::OnFocus() { // Forward the focus to the selected child view. contents_->children()[selected_index_]->RequestFocus(); } -bool LoginMenuView::OnKeyPressed(const ui::KeyEvent& event) { +bool PublicAccountMenuView::OnKeyPressed(const ui::KeyEvent& event) { const ui::KeyboardCode key = event.key_code(); if (key == ui::VKEY_UP || key == ui::VKEY_DOWN) { FindNextItem(key == ui::VKEY_UP)->RequestFocus(); @@ -201,12 +202,13 @@ return false; } -void LoginMenuView::VisibilityChanged(View* starting_from, bool is_visible) { +void PublicAccountMenuView::VisibilityChanged(View* starting_from, + bool is_visible) { if (is_visible) contents_->children()[selected_index_]->RequestFocus(); } -views::View* LoginMenuView::FindNextItem(bool reverse) { +views::View* PublicAccountMenuView::FindNextItem(bool reverse) { const auto& children = contents_->children(); const auto is_item = [](views::View* v) { return !static_cast<MenuItemView*>(v)->item().is_group;
diff --git a/ash/login/ui/login_menu_view.h b/ash/login/ui/public_account_menu_view.h similarity index 69% rename from ash/login/ui/login_menu_view.h rename to ash/login/ui/public_account_menu_view.h index a6dcc3a..db9885fe 100644 --- a/ash/login/ui/login_menu_view.h +++ b/ash/login/ui/public_account_menu_view.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_LOGIN_UI_LOGIN_MENU_VIEW_H_ -#define ASH_LOGIN_UI_LOGIN_MENU_VIEW_H_ +#ifndef ASH_LOGIN_UI_PUBLIC_ACCOUNT_MENU_VIEW_H_ +#define ASH_LOGIN_UI_PUBLIC_ACCOUNT_MENU_VIEW_H_ #include "ash/ash_export.h" #include "ash/login/ui/login_base_bubble_view.h" @@ -13,24 +13,24 @@ namespace ash { -// Implements a menu view for login screen. +// Implements a menu view for the login screen's expanded public account view. // This is used instead of views::Combobox because we want a more customisable // view for the menu items to support some sepcific styles like nested menu // entries which have different left margin (less than regular items) and are // not selectable. views::Combobox uses views::MenuItemView which is not very // straightforward to customize. -class ASH_EXPORT LoginMenuView : public LoginBaseBubbleView { +class ASH_EXPORT PublicAccountMenuView : public LoginBaseBubbleView { public: // TestApi is used for tests to get internal implementation details. class ASH_EXPORT TestApi { public: - explicit TestApi(LoginMenuView* view); + explicit TestApi(PublicAccountMenuView* view); ~TestApi(); views::View* contents() const; private: - LoginMenuView* const view_; + PublicAccountMenuView* const view_; }; struct Item { @@ -45,11 +45,13 @@ using OnSelect = base::RepeatingCallback<void(Item item)>; using OnHighlight = base::RepeatingCallback<void(bool by_selection)>; - LoginMenuView(const std::vector<Item>& items, - views::View* anchor_view, - LoginButton* opener_, - const OnSelect& on_select); - ~LoginMenuView() override; + PublicAccountMenuView(const std::vector<Item>& items, + views::View* anchor_view, + LoginButton* opener_, + const OnSelect& on_select); + PublicAccountMenuView(const PublicAccountMenuView&) = delete; + PublicAccountMenuView& operator=(const PublicAccountMenuView&) = delete; + ~PublicAccountMenuView() override; void OnHighlightChange(size_t item_index, bool by_selection); @@ -74,10 +76,8 @@ const OnSelect on_select_; size_t selected_index_ = 0; - - DISALLOW_COPY_AND_ASSIGN(LoginMenuView); }; } // namespace ash -#endif // ASH_LOGIN_UI_LOGIN_MENU_VIEW_H_ +#endif // ASH_LOGIN_UI_PUBLIC_ACCOUNT_MENU_VIEW_H_
diff --git a/ash/login/ui/public_account_warning_dialog.cc b/ash/login/ui/public_account_monitoring_info_dialog.cc similarity index 87% rename from ash/login/ui/public_account_warning_dialog.cc rename to ash/login/ui/public_account_monitoring_info_dialog.cc index ca3a35e6..e78ded39 100644 --- a/ash/login/ui/public_account_warning_dialog.cc +++ b/ash/login/ui/public_account_monitoring_info_dialog.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/login/ui/public_account_warning_dialog.h" +#include "ash/login/ui/public_account_monitoring_info_dialog.h" #include "ash/login/ui/login_expanded_public_account_view.h" #include "ash/strings/grit/ash_strings.h" @@ -31,7 +31,8 @@ public: explicit BulletView(SkColor color, int radius) : color_(color), radius_(radius) {} - + BulletView(const BulletView&) = delete; + BulletView& operator=(const BulletView&) = delete; ~BulletView() override = default; // views::View: @@ -52,14 +53,11 @@ private: SkColor color_; int radius_; - - DISALLOW_COPY_AND_ASSIGN(BulletView); }; } // namespace -// TODO(crbug.com/1142953): Rename to PublicAccountLearnMoreDialog. -PublicAccountWarningDialog::PublicAccountWarningDialog( +PublicAccountMonitoringInfoDialog::PublicAccountMonitoringInfoDialog( base::WeakPtr<LoginExpandedPublicAccountView> controller) : controller_(controller) { SetModalType(ui::MODAL_TYPE_SYSTEM); @@ -107,21 +105,21 @@ this, nullptr, controller->GetWidget()->GetNativeView()); } -PublicAccountWarningDialog::~PublicAccountWarningDialog() { +PublicAccountMonitoringInfoDialog::~PublicAccountMonitoringInfoDialog() { if (controller_) - controller_->OnWarningDialogClosed(); + controller_->OnLearnMoreDialogClosed(); } -bool PublicAccountWarningDialog::IsVisible() { +bool PublicAccountMonitoringInfoDialog::IsVisible() { return GetWidget() && GetWidget()->IsVisible(); } -void PublicAccountWarningDialog::Show() { +void PublicAccountMonitoringInfoDialog::Show() { if (GetWidget()) GetWidget()->Show(); } -void PublicAccountWarningDialog::AddedToWidget() { +void PublicAccountMonitoringInfoDialog::AddedToWidget() { std::unique_ptr<views::Label> title_label = views::BubbleFrameView::CreateDefaultTitleLabel(l10n_util::GetStringUTF16( IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO)); @@ -132,7 +130,7 @@ frame_view->SetTitleView(std::move(title_label)); } -gfx::Size PublicAccountWarningDialog::CalculatePreferredSize() const { +gfx::Size PublicAccountMonitoringInfoDialog::CalculatePreferredSize() const { return {kDialogWidthDp, GetHeightForWidth(kDialogWidthDp)}; }
diff --git a/ash/login/ui/public_account_monitoring_info_dialog.h b/ash/login/ui/public_account_monitoring_info_dialog.h new file mode 100644 index 0000000..48ae8524 --- /dev/null +++ b/ash/login/ui/public_account_monitoring_info_dialog.h
@@ -0,0 +1,44 @@ +// Copyright 2018 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_LOGIN_UI_PUBLIC_ACCOUNT_MONITORING_INFO_DIALOG_H_ +#define ASH_LOGIN_UI_PUBLIC_ACCOUNT_MONITORING_INFO_DIALOG_H_ + +#include "ash/ash_export.h" +#include "base/memory/weak_ptr.h" +#include "ui/views/window/dialog_delegate.h" + +namespace ash { + +class LoginExpandedPublicAccountView; + +// Dialog displayed after selecting the public session learn more button, +// present on the public account expanded view. +class ASH_EXPORT PublicAccountMonitoringInfoDialog + : public views::DialogDelegateView { + public: + explicit PublicAccountMonitoringInfoDialog( + base::WeakPtr<LoginExpandedPublicAccountView> controller); + PublicAccountMonitoringInfoDialog(const PublicAccountMonitoringInfoDialog&) = + delete; + PublicAccountMonitoringInfoDialog& operator=( + const PublicAccountMonitoringInfoDialog&) = delete; + ~PublicAccountMonitoringInfoDialog() override; + + bool IsVisible(); + void Show(); + + // views::DialogDelegate: + void AddedToWidget() override; + + // views::View: + gfx::Size CalculatePreferredSize() const override; + + private: + base::WeakPtr<LoginExpandedPublicAccountView> controller_; +}; + +} // namespace ash + +#endif // ASH_LOGIN_UI_PUBLIC_ACCOUNT_MONITORING_INFO_DIALOG_H_
diff --git a/ash/login/ui/public_account_warning_dialog.h b/ash/login/ui/public_account_warning_dialog.h deleted file mode 100644 index b1042cb..0000000 --- a/ash/login/ui/public_account_warning_dialog.h +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2018 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_LOGIN_UI_PUBLIC_ACCOUNT_WARNING_DIALOG_H_ -#define ASH_LOGIN_UI_PUBLIC_ACCOUNT_WARNING_DIALOG_H_ - -#include "ash/ash_export.h" -#include "base/memory/weak_ptr.h" -#include "ui/views/window/dialog_delegate.h" - -namespace ash { - -class LoginExpandedPublicAccountView; - -// Dialog for displaying public session warning. This is shown when a user -// clicks on the learn more link on the pubic account expanded view. -class ASH_EXPORT PublicAccountWarningDialog : public views::DialogDelegateView { - public: - explicit PublicAccountWarningDialog( - base::WeakPtr<LoginExpandedPublicAccountView> controller); - ~PublicAccountWarningDialog() override; - - bool IsVisible(); - void Show(); - - // views::DialogDelegate: - void AddedToWidget() override; - - // views::View: - gfx::Size CalculatePreferredSize() const override; - - private: - base::WeakPtr<LoginExpandedPublicAccountView> controller_; - - DISALLOW_COPY_AND_ASSIGN(PublicAccountWarningDialog); -}; - -} // namespace ash - -#endif // ASH_LOGIN_UI_PUBLIC_ACCOUNT_WARNING_DIALOG_H_
diff --git a/ash/public/cpp/capture_mode_delegate.h b/ash/public/cpp/capture_mode_delegate.h index 1356821..05603f2 100644 --- a/ash/public/cpp/capture_mode_delegate.h +++ b/ash/public/cpp/capture_mode_delegate.h
@@ -88,6 +88,10 @@ // Called when a capture mode session starts or stops. virtual void OnSessionStateChanged(bool started) = 0; + + // Called after the controller resets its |mojo::Remote| instance of the + // service. + virtual void OnServiceRemoteReset() = 0; }; } // namespace ash
diff --git a/ash/public/cpp/holding_space/holding_space_image_unittest.cc b/ash/public/cpp/holding_space/holding_space_image_unittest.cc index c521bc4..66ff4a3 100644 --- a/ash/public/cpp/holding_space/holding_space_image_unittest.cc +++ b/ash/public/cpp/holding_space/holding_space_image_unittest.cc
@@ -651,7 +651,7 @@ // Update the backing file path before any image representations are // requested. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); // Create test image client to issue an image request. @@ -705,7 +705,7 @@ // Update the backing file path, and verify requests for 2x bitmap will use // the new file path. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); EXPECT_EQ(0u, image_generator.NumberOfPendingRequests()); @@ -740,7 +740,7 @@ // Update the backing file path, and simulate image load failure. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); EXPECT_EQ(1u, image_generator.NumberOfPendingRequests()); image_generator.FailRequest(0); @@ -782,7 +782,7 @@ // Update the backing file path, and verify the failed request was not // retried. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); // Verify that image load is retried using the new file path. @@ -807,7 +807,7 @@ // Update the backing file path before creating a client that requests an // image representation. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); // Create test image client, and simulate image load failure. @@ -848,7 +848,7 @@ // Update the backing file path, and verify the image load is not requested // again. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); image = holding_space_item->image().GetImageSkia(); @@ -878,7 +878,7 @@ // Update the backing file path, and verify the image load is not requested // again. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); EXPECT_EQ(1u, image_generator.NumberOfPendingRequests()); @@ -920,7 +920,7 @@ // Update the backing file path, and then invalidate the image. const base::FilePath kUpdatedTestFile("updated_test_file.test"); - holding_space_item->UpdateBackingFile( + holding_space_item->SetBackingFile( kUpdatedTestFile, GURL("filesystem:updated_file_system_url")); holding_space_item->InvalidateImage(); ASSERT_TRUE(
diff --git a/ash/public/cpp/holding_space/holding_space_item.cc b/ash/public/cpp/holding_space/holding_space_item.cc index 5a7e9a80..19862a25 100644 --- a/ash/public/cpp/holding_space/holding_space_item.cc +++ b/ash/public/cpp/holding_space/holding_space_item.cc
@@ -159,8 +159,8 @@ file_system_url_ = file_system_url; } -bool HoldingSpaceItem::UpdateBackingFile(const base::FilePath& file_path, - const GURL& file_system_url) { +bool HoldingSpaceItem::SetBackingFile(const base::FilePath& file_path, + const GURL& file_system_url) { if (file_path_ == file_path && file_system_url_ == file_system_url) return false; @@ -176,7 +176,7 @@ return progress_ != 1.f; } -bool HoldingSpaceItem::UpdateProgress(const absl::optional<float>& progress) { +bool HoldingSpaceItem::SetProgress(const absl::optional<float>& progress) { // NOTE: Progress can only be updated for in progress items. if (progress_ == progress || !IsInProgress()) return false; @@ -220,7 +220,7 @@ return paused_; } -bool HoldingSpaceItem::UpdatePause(bool paused) { +bool HoldingSpaceItem::SetPaused(bool paused) { if (!IsInProgress() || paused_ == paused) return false;
diff --git a/ash/public/cpp/holding_space/holding_space_item.h b/ash/public/cpp/holding_space/holding_space_item.h index 8f27f60..a67bc63 100644 --- a/ash/public/cpp/holding_space/holding_space_item.h +++ b/ash/public/cpp/holding_space/holding_space_item.h
@@ -104,18 +104,19 @@ // `Deserialize()`. void Initialize(const GURL& file_system_url); - // Updates the file backing the item to `file_path` and `file_system_url`, - // returning `false` to indicate no-op. - bool UpdateBackingFile(const base::FilePath& file_path, - const GURL& file_system_url); + // Sets the file backing the item to `file_path` and `file_system_url`, + // returning `true` if a change occurred or `false` to indicate no-op. + bool SetBackingFile(const base::FilePath& file_path, + const GURL& file_system_url); // Returns whether the item is in progress. bool IsInProgress() const; - // Updates the `progress_` of the item, returning `false` to indicate no-op. + // Sets the `progress_` of the item, returning `true` if a change occurred or + // `false` to indicate no-op. // NOTE: If present, `progress` must be >= `0.f` and <= `1.f`. // NOTE: Progress can only be updated for in progress items. - bool UpdateProgress(const absl::optional<float>& progress); + bool SetProgress(const absl::optional<float>& progress); // Invalidates the current holding space image, so fresh image representations // are loaded when the image is next needed. @@ -128,10 +129,10 @@ // NOTE: Only in-progress items can be paused. bool IsPaused() const; - // Updates whether progress of this item is `paused_`, returning `false` to - // indicate no-op. + // Sets whether progress of this item is `paused_`, returning `true` if a + // change occurred or `false` to indicate no-op. // NOTE: Only in-progress items can be paused. - bool UpdatePause(bool paused); + bool SetPaused(bool paused); const std::string& id() const { return id_; }
diff --git a/ash/public/cpp/holding_space/holding_space_item_unittest.cc b/ash/public/cpp/holding_space/holding_space_item_unittest.cc index f5a8119..6e48a2fe 100644 --- a/ash/public/cpp/holding_space/holding_space_item_unittest.cc +++ b/ash/public/cpp/holding_space/holding_space_item_unittest.cc
@@ -89,22 +89,22 @@ EXPECT_FALSE(holding_space_item->IsPaused()); // It should be possible to update pause to a new value. - EXPECT_TRUE(holding_space_item->UpdatePause(true)); + EXPECT_TRUE(holding_space_item->SetPaused(true)); EXPECT_TRUE(holding_space_item->IsPaused()); // It should no-op to try to update pause to its existing value. - EXPECT_FALSE(holding_space_item->UpdatePause(true)); + EXPECT_FALSE(holding_space_item->SetPaused(true)); EXPECT_TRUE(holding_space_item->IsPaused()); // Once progress has been marked completed, items are no longer paused. - EXPECT_TRUE(holding_space_item->UpdateProgress(1.f)); + EXPECT_TRUE(holding_space_item->SetProgress(1.f)); EXPECT_EQ(holding_space_item->progress(), 1.f); EXPECT_FALSE(holding_space_item->IsPaused()); // It should no-op to try to update pause for items which are not in-progress. - EXPECT_FALSE(holding_space_item->UpdatePause(true)); + EXPECT_FALSE(holding_space_item->SetPaused(true)); EXPECT_FALSE(holding_space_item->IsPaused()); - EXPECT_FALSE(holding_space_item->UpdatePause(false)); + EXPECT_FALSE(holding_space_item->SetPaused(false)); EXPECT_FALSE(holding_space_item->IsPaused()); } @@ -120,23 +120,23 @@ EXPECT_EQ(holding_space_item->progress(), 0.5f); // It should be possible to update progress to a new value. - EXPECT_TRUE(holding_space_item->UpdateProgress(0.75f)); + EXPECT_TRUE(holding_space_item->SetProgress(0.75f)); EXPECT_EQ(holding_space_item->progress(), 0.75f); // It should no-op to try to update progress to its existing value. - EXPECT_FALSE(holding_space_item->UpdateProgress(0.75f)); + EXPECT_FALSE(holding_space_item->SetProgress(0.75f)); EXPECT_EQ(holding_space_item->progress(), 0.75f); // It should be possible to set indeterminate progress. - EXPECT_TRUE(holding_space_item->UpdateProgress(absl::nullopt)); + EXPECT_TRUE(holding_space_item->SetProgress(absl::nullopt)); EXPECT_EQ(holding_space_item->progress(), absl::nullopt); // It should be possible to set progress complete. - EXPECT_TRUE(holding_space_item->UpdateProgress(1.f)); + EXPECT_TRUE(holding_space_item->SetProgress(1.f)); EXPECT_EQ(holding_space_item->progress(), 1.f); // Once progress has been marked completed, it should become read-only. - EXPECT_FALSE(holding_space_item->UpdateProgress(0.75f)); + EXPECT_FALSE(holding_space_item->SetProgress(0.75f)); EXPECT_EQ(holding_space_item->progress(), 1.f); // Create a `holding_space_item` w/ default progress. @@ -149,7 +149,7 @@ EXPECT_EQ(holding_space_item->progress(), 1.f); // Since progress is marked completed, it should be read-only. - EXPECT_FALSE(holding_space_item->UpdateProgress(0.75f)); + EXPECT_FALSE(holding_space_item->SetProgress(0.75f)); EXPECT_EQ(holding_space_item->progress(), 1.f); }
diff --git a/ash/public/cpp/holding_space/holding_space_model.cc b/ash/public/cpp/holding_space/holding_space_model.cc index e78725e..53b06dc 100644 --- a/ash/public/cpp/holding_space/holding_space_model.cc +++ b/ash/public/cpp/holding_space/holding_space_model.cc
@@ -10,9 +10,67 @@ #include "base/bind.h" #include "base/check.h" #include "base/containers/contains.h" +#include "base/memory/ptr_util.h" namespace ash { +// HoldingSpaceModel::ScopedItemUpdate ----------------------------------------- + +HoldingSpaceModel::ScopedItemUpdate::~ScopedItemUpdate() { + bool did_update = false; + + // Update backing file. + if (file_path_ && file_system_url_) { + did_update |= + item_->SetBackingFile(file_path_.value(), file_system_url_.value()); + } + + // Update pause. + if (paused_) + did_update |= item_->SetPaused(paused_.value()); + + // Update progress. + if (progress_) + did_update |= item_->SetProgress(progress_.value()); + + // Notify observers if and only if an update occurred. + if (did_update) { + for (auto& observer : model_->observers_) + observer.OnHoldingSpaceItemUpdated(item_); + } +} + +HoldingSpaceModel::ScopedItemUpdate& +HoldingSpaceModel::ScopedItemUpdate::SetBackingFile( + const base::FilePath& file_path, + const GURL& file_system_url) { + file_path_ = file_path; + file_system_url_ = file_system_url; + return *this; +} + +HoldingSpaceModel::ScopedItemUpdate& +HoldingSpaceModel::ScopedItemUpdate::SetPaused(bool paused) { + paused_ = paused; + return *this; +} + +HoldingSpaceModel::ScopedItemUpdate& +HoldingSpaceModel::ScopedItemUpdate::SetProgress( + const absl::optional<float>& progress) { + progress_ = progress; + return *this; +} + +HoldingSpaceModel::ScopedItemUpdate::ScopedItemUpdate(HoldingSpaceModel* model, + HoldingSpaceItem* item) + : model_(model), item_(item) { + DCHECK(model_); + DCHECK(item_); +} + +// HoldingSpaceModel ----------------------------------------------------------- + HoldingSpaceModel::HoldingSpaceModel() = default; HoldingSpaceModel::~HoldingSpaceModel() = default; @@ -76,63 +134,15 @@ observer.OnHoldingSpaceItemInitialized(item); } -void HoldingSpaceModel::UpdateBackingFileForItem( - const std::string& id, - const base::FilePath& file_path, - const GURL& file_system_url) { - auto item_it = std::find_if( - items_.begin(), items_.end(), - [&id](const std::unique_ptr<HoldingSpaceItem>& item) -> bool { - return item->id() == id; - }); +std::unique_ptr<HoldingSpaceModel::ScopedItemUpdate> +HoldingSpaceModel::UpdateItem(const std::string& id) { + auto item_it = + std::find_if(items_.begin(), items_.end(), + [&id](const std::unique_ptr<HoldingSpaceItem>& item) { + return item->id() == id; + }); DCHECK(item_it != items_.end()); - - HoldingSpaceItem* item = item_it->get(); - DCHECK(item->IsInitialized()); - - if (!item->UpdateBackingFile(file_path, file_system_url)) - return; - - for (auto& observer : observers_) - observer.OnHoldingSpaceItemUpdated(item); -} - -void HoldingSpaceModel::UpdatePauseForItem(const std::string& id, bool paused) { - auto item_it = std::find_if( - items_.begin(), items_.end(), - [&id](const std::unique_ptr<HoldingSpaceItem>& item) -> bool { - return item->id() == id; - }); - DCHECK(item_it != items_.end()); - - HoldingSpaceItem* item = item_it->get(); - DCHECK(item->IsInitialized()); - - if (!item->UpdatePause(paused)) - return; - - for (auto& observer : observers_) - observer.OnHoldingSpaceItemUpdated(item); -} - -void HoldingSpaceModel::UpdateProgressForItem( - const std::string& id, - const absl::optional<float>& progress) { - auto item_it = std::find_if( - items_.begin(), items_.end(), - [&id](const std::unique_ptr<HoldingSpaceItem>& item) -> bool { - return item->id() == id; - }); - DCHECK(item_it != items_.end()); - - HoldingSpaceItem* item = item_it->get(); - DCHECK(item->IsInitialized()); - - if (!item->UpdateProgress(progress)) - return; - - for (auto& observer : observers_) - observer.OnHoldingSpaceItemUpdated(item); + return base::WrapUnique(new ScopedItemUpdate(this, item_it->get())); } void HoldingSpaceModel::RemoveIf(Predicate predicate) {
diff --git a/ash/public/cpp/holding_space/holding_space_model.h b/ash/public/cpp/holding_space/holding_space_model.h index 5f0fcd3..814feea 100644 --- a/ash/public/cpp/holding_space/holding_space_model.h +++ b/ash/public/cpp/holding_space/holding_space_model.h
@@ -26,8 +26,6 @@ class HoldingSpaceModelObserver; -// TODO(crbug.com/1213274): Merge `Update*ForItem()` APIs to allow for updating -// multiple holding space item attributes atomically. // The data model for the temporary holding space UI. It contains the list of // items that should be shown in the temporary holding space UI - each item will // represent a piece of data added to the holding space by the user (for @@ -39,6 +37,41 @@ public: using ItemList = std::vector<std::unique_ptr<HoldingSpaceItem>>; + // A class which performs an atomic update of a single holding space item on + // destruction, notifying model observers of the event if a change in state + // did in fact occur. + class ScopedItemUpdate { + public: + ScopedItemUpdate(const ScopedItemUpdate&) = delete; + ScopedItemUpdate& operator=(const ScopedItemUpdate&) = delete; + ~ScopedItemUpdate(); + + // Sets the backing file for the item and returns a reference to `this`. + ScopedItemUpdate& SetBackingFile(const base::FilePath& file_path, + const GURL& file_system_url); + + // Sets if progress of the item is `paused` and returns a ref to `this`. + // NOTE: Only in-progress holding space items can be paused. + ScopedItemUpdate& SetPaused(bool paused); + + // Sets the `progress` of the item and returns a reference to `this`. + // NOTE: If present, `progress` must be >= `0.f` and <= `1.f`. + // NOTE: Once set to `1.f`, holding space item progress becomes read-only. + ScopedItemUpdate& SetProgress(const absl::optional<float>& progress); + + private: + friend class HoldingSpaceModel; + ScopedItemUpdate(HoldingSpaceModel* model, HoldingSpaceItem* item); + + HoldingSpaceModel* const model_; + HoldingSpaceItem* const item_; + + absl::optional<base::FilePath> file_path_; + absl::optional<GURL> file_system_url_; + absl::optional<bool> paused_; + absl::optional<absl::optional<float>> progress_; + }; + HoldingSpaceModel(); HoldingSpaceModel(const HoldingSpaceModel& other) = delete; HoldingSpaceModel& operator=(const HoldingSpaceModel& other) = delete; @@ -62,21 +95,9 @@ void InitializeOrRemoveItem(const std::string& id, const GURL& file_system_url); - // Updates the backing file for a single holding space item to the specified - // `file_path` and `file_system_url`. - void UpdateBackingFileForItem(const std::string& id, - const base::FilePath& file_path, - const GURL& file_system_url); - - // Updates whether progress is `paused` for a single holding space item. - // NOTE: Only in-progress holding space items can be paused. - void UpdatePauseForItem(const std::string& id, bool paused); - - // Updates the progress for a single holding space item. - // NOTE: If present, `progress` must be >= `0.f` and <= `1.f`. - // NOTE: Once set to `1.f`, holding space item progress becomes read-only. - void UpdateProgressForItem(const std::string& id, - const absl::optional<float>& progress); + // Returns an object which, upon its destruction, performs an atomic update to + // the holding space item associated with the specified `id`. + std::unique_ptr<ScopedItemUpdate> UpdateItem(const std::string& id); // Removes all holding space items from the model for which the specified // `predicate` returns true.
diff --git a/ash/public/cpp/holding_space/holding_space_model_unittest.cc b/ash/public/cpp/holding_space/holding_space_model_unittest.cc index 0f2a213..600eaef 100644 --- a/ash/public/cpp/holding_space/holding_space_model_unittest.cc +++ b/ash/public/cpp/holding_space/holding_space_model_unittest.cc
@@ -57,10 +57,19 @@ return result; } + // Returns the count of times for which `OnHoldingSpaceItemUpdated()` was + // called, clearing the cached value. + int TakeUpdatedItemCount() { + const int result = updated_item_count_; + updated_item_count_ = 0; + return result; + } + private: // HoldingSpaceModel::Observer: void OnHoldingSpaceItemUpdated(const HoldingSpaceItem* item) override { last_updated_item_ = item; + ++updated_item_count_; } // The last `HoldingSpaceItem` for which `OnHoldingSpaceItemUpdated()` was @@ -68,6 +77,10 @@ // `TakeLastUpdatedItem()`. const HoldingSpaceItem* last_updated_item_ = nullptr; + // The count of times for which `OnHoldingSpaceItemUpdated()` was called. May + // be reset following a call to `TakeUpdatedItemCount()`. + int updated_item_count_ = 0; + base::ScopedObservation<HoldingSpaceModel, HoldingSpaceModelObserver> observation_{this}; }; @@ -94,8 +107,100 @@ // Tests ----------------------------------------------------------------------- -// Verifies that `HoldingSpaceModel::UpdatePauseForItem()` works as intended. -TEST_P(HoldingSpaceModelTest, UpdatePauseForItem) { +// Verifies that updating multiple item attributes is atomic. +TEST_P(HoldingSpaceModelTest, UpdateItem_Atomic) { + ScopedModelObservation observation(&model()); + + // Verify the `model()` is initially empty. + EXPECT_EQ(model().items().size(), 0u); + + // Create a holding space `item`. + auto item = HoldingSpaceItem::CreateFileBackedItem( + /*type=*/GetParam(), base::FilePath("file_path"), + GURL("filesystem::file_system_url"), + /*progress=*/absl::nullopt, + /*image_resolver=*/base::BindOnce(&CreateFakeHoldingSpaceImage)); + auto* item_ptr = item.get(); + + // Add `item` to the `model()`. + model().AddItem(std::move(item)); + EXPECT_EQ(model().items().size(), 1u); + EXPECT_EQ(model().items()[0].get(), item_ptr); + + // Update backing file. + base::FilePath updated_file_path("updated_file_path"); + GURL updated_file_system_url("filesystem::updated_file_system_url"); + model() + .UpdateItem(item_ptr->id()) + ->SetBackingFile(updated_file_path, updated_file_system_url); + EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); + EXPECT_EQ(observation.TakeUpdatedItemCount(), 1); + EXPECT_EQ(item_ptr->file_path(), updated_file_path); + EXPECT_EQ(item_ptr->file_system_url(), updated_file_system_url); + + // Update paused state. + model().UpdateItem(item_ptr->id())->SetPaused(true); + EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); + EXPECT_EQ(observation.TakeUpdatedItemCount(), 1); + EXPECT_TRUE(item_ptr->IsPaused()); + + // Update progress. + model().UpdateItem(item_ptr->id())->SetProgress(0.5f); + EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); + EXPECT_EQ(observation.TakeUpdatedItemCount(), 1); + EXPECT_EQ(item_ptr->progress(), 0.5f); + + // Update all attributes. + updated_file_path = base::FilePath("again_updated_file_path"); + updated_file_system_url = GURL("filesystem::again_updated_file_system_url"); + model() + .UpdateItem(item_ptr->id()) + ->SetBackingFile(updated_file_path, updated_file_system_url) + .SetPaused(false) + .SetProgress(0.75f); + EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); + EXPECT_EQ(observation.TakeUpdatedItemCount(), 1); + EXPECT_EQ(item_ptr->file_path(), updated_file_path); + EXPECT_EQ(item_ptr->file_system_url(), updated_file_system_url); + EXPECT_FALSE(item_ptr->IsPaused()); + EXPECT_EQ(item_ptr->progress(), 0.75f); +} + +// Verifies that updating items will no-op appropriately. +TEST_P(HoldingSpaceModelTest, UpdateItem_Noop) { + ScopedModelObservation observation(&model()); + + // Verify the `model()` is initially empty. + EXPECT_EQ(model().items().size(), 0u); + + // Create a holding space `item`. + auto item = HoldingSpaceItem::CreateFileBackedItem( + /*type=*/GetParam(), base::FilePath("file_path"), + GURL("filesystem::file_system_url"), + /*progress=*/absl::nullopt, + /*image_resolver=*/base::BindOnce(&CreateFakeHoldingSpaceImage)); + auto* item_ptr = item.get(); + + // Add `item` to the `model()`. + model().AddItem(std::move(item)); + EXPECT_EQ(model().items().size(), 1u); + EXPECT_EQ(model().items()[0].get(), item_ptr); + + // Perform a no-op update. No observers should be notified. + model().UpdateItem(item_ptr->id()); + EXPECT_EQ(observation.TakeUpdatedItemCount(), 0); + + // Perform another no-op update. No observers should be notified. + model() + .UpdateItem(item_ptr->id()) + ->SetBackingFile(item_ptr->file_path(), item_ptr->file_system_url()) + .SetPaused(item_ptr->IsPaused()) + .SetProgress(item_ptr->progress()); + EXPECT_EQ(observation.TakeUpdatedItemCount(), 0); +} + +// Verifies that updating item paused state works as intended. +TEST_P(HoldingSpaceModelTest, UpdateItem_Pause) { ScopedModelObservation observation(&model()); // Verify the `model()` is initially empty. @@ -118,39 +223,38 @@ EXPECT_FALSE(item_ptr->IsPaused()); // Attempt to update pause to `false`. This should no-op. - model().UpdatePauseForItem(item_ptr->id(), false); + model().UpdateItem(item_ptr->id())->SetPaused(false); EXPECT_FALSE(observation.TakeLastUpdatedItem()); EXPECT_FALSE(item_ptr->IsPaused()); // Update pause to `true`. - model().UpdatePauseForItem(item_ptr->id(), true); + model().UpdateItem(item_ptr->id())->SetPaused(true); EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); EXPECT_TRUE(item_ptr->IsPaused()); // Update pause to `false`. - model().UpdatePauseForItem(item_ptr->id(), false); + model().UpdateItem(item_ptr->id())->SetPaused(false); EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); EXPECT_FALSE(item_ptr->IsPaused()); // Update pause to `true` and progress to completion. Because the item is no // longer in progress, it should no longer be paused. - model().UpdatePauseForItem(item_ptr->id(), true); - model().UpdateProgressForItem(item_ptr->id(), 1.f); + model().UpdateItem(item_ptr->id())->SetPaused(true).SetProgress(1.f); EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); EXPECT_EQ(item_ptr->progress(), 1.f); EXPECT_FALSE(item_ptr->IsPaused()); // Attempts to update pause should no-op for completed items. - model().UpdatePauseForItem(item_ptr->id(), true); + model().UpdateItem(item_ptr->id())->SetPaused(true); EXPECT_FALSE(observation.TakeLastUpdatedItem()); EXPECT_FALSE(item_ptr->IsPaused()); - model().UpdatePauseForItem(item_ptr->id(), false); + model().UpdateItem(item_ptr->id())->SetPaused(false); EXPECT_FALSE(observation.TakeLastUpdatedItem()); EXPECT_FALSE(item_ptr->IsPaused()); } -// Verifies that `HoldingSpaceModel::UpdateProgressForItem()` works as intended. -TEST_P(HoldingSpaceModelTest, UpdateProgressForItem) { +// Verifies that updating item progress works as intended. +TEST_P(HoldingSpaceModelTest, UpdateItem_Progress) { ScopedModelObservation observation(&model()); // Verify the `model()` is initially empty. @@ -173,28 +277,28 @@ EXPECT_EQ(item_ptr->progress(), absl::nullopt); // Update progress to `0.5f`. - model().UpdateProgressForItem(item_ptr->id(), 0.5f); + model().UpdateItem(item_ptr->id())->SetProgress(0.5f); EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); EXPECT_EQ(item_ptr->progress(), 0.5f); // Update progress to `0.5f` again. This should no-op. - model().UpdateProgressForItem(item_ptr->id(), 0.5f); + model().UpdateItem(item_ptr->id())->SetProgress(0.5f); EXPECT_FALSE(observation.TakeLastUpdatedItem()); EXPECT_EQ(item_ptr->progress(), 0.5f); // Update progress to indeterminate. - model().UpdateProgressForItem(item_ptr->id(), absl::nullopt); + model().UpdateItem(item_ptr->id())->SetProgress(absl::nullopt); EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); EXPECT_EQ(item_ptr->progress(), absl::nullopt); // Update progress to complete. - model().UpdateProgressForItem(item_ptr->id(), 1.f); + model().UpdateItem(item_ptr->id())->SetProgress(1.f); EXPECT_EQ(observation.TakeLastUpdatedItem(), item_ptr); EXPECT_EQ(item_ptr->progress(), 1.f); // Update progress to `0.5f`. This should no-op as progress becomes read-only // after being marked completed. - model().UpdateProgressForItem(item_ptr->id(), 0.5f); + model().UpdateItem(item_ptr->id())->SetProgress(0.5f); EXPECT_FALSE(observation.TakeLastUpdatedItem()); EXPECT_EQ(item_ptr->progress(), 1.f); }
diff --git a/ash/public/cpp/login_screen_model.h b/ash/public/cpp/login_screen_model.h index 4b89254..9d0dae2 100644 --- a/ash/public/cpp/login_screen_model.h +++ b/ash/public/cpp/login_screen_model.h
@@ -17,7 +17,7 @@ enum class FingerprintState; enum class OobeDialogState; struct AuthDisabledData; -struct EasyUnlockIconOptions; +struct EasyUnlockIconInfo; struct InputMethodItem; struct LocaleItem; struct LoginUserInfo; @@ -38,9 +38,9 @@ // Requests to show the custom icon in the user pod. // |account_id|: The account id of the user in the user pod. - // |icon|: Information regarding the icon. + // |icon_info|: Information regarding the icon. virtual void ShowEasyUnlockIcon(const AccountId& account_id, - const EasyUnlockIconOptions& icon) = 0; + const EasyUnlockIconInfo& icon_info) = 0; // Update the status of the challenge-response authentication against a // security token for the given user.
diff --git a/ash/public/cpp/login_screen_test_api.h b/ash/public/cpp/login_screen_test_api.h index f2b5bf57..aaa1486a 100644 --- a/ash/public/cpp/login_screen_test_api.h +++ b/ash/public/cpp/login_screen_test_api.h
@@ -42,7 +42,7 @@ static bool IsPasswordFieldShown(const AccountId& account_id); static bool IsDisplayPasswordButtonShown(const AccountId& account_id); static bool IsManagedIconShown(const AccountId& account_id); - static bool IsManagedMessageInMenuShown(const AccountId& account_id); + static bool IsManagedMessageInDialogShown(const AccountId& account_id); static bool IsForcedOnlineSignin(const AccountId& account_id); static void SubmitPassword(const AccountId& account_id, const std::string& password,
diff --git a/ash/public/cpp/login_types.cc b/ash/public/cpp/login_types.cc index 5b0da29..a3f4b68 100644 --- a/ash/public/cpp/login_types.cc +++ b/ash/public/cpp/login_types.cc
@@ -8,17 +8,16 @@ namespace ash { -EasyUnlockIconOptions::EasyUnlockIconOptions() = default; -EasyUnlockIconOptions::EasyUnlockIconOptions( - const EasyUnlockIconOptions& other) = default; -EasyUnlockIconOptions::EasyUnlockIconOptions(EasyUnlockIconOptions&& other) = +EasyUnlockIconInfo::EasyUnlockIconInfo() = default; +EasyUnlockIconInfo::EasyUnlockIconInfo(const EasyUnlockIconInfo& other) = default; -EasyUnlockIconOptions::~EasyUnlockIconOptions() = default; +EasyUnlockIconInfo::EasyUnlockIconInfo(EasyUnlockIconInfo&& other) = default; +EasyUnlockIconInfo::~EasyUnlockIconInfo() = default; -EasyUnlockIconOptions& EasyUnlockIconOptions::operator=( - const EasyUnlockIconOptions& other) = default; -EasyUnlockIconOptions& EasyUnlockIconOptions::operator=( - EasyUnlockIconOptions&& other) = default; +EasyUnlockIconInfo& EasyUnlockIconInfo::operator=( + const EasyUnlockIconInfo& other) = default; +EasyUnlockIconInfo& EasyUnlockIconInfo::operator=(EasyUnlockIconInfo&& other) = + default; InputMethodItem::InputMethodItem() = default; InputMethodItem::InputMethodItem(const InputMethodItem& other) = default;
diff --git a/ash/public/cpp/login_types.h b/ash/public/cpp/login_types.h index 7c74bccc..ec44b46 100644 --- a/ash/public/cpp/login_types.h +++ b/ash/public/cpp/login_types.h
@@ -80,8 +80,8 @@ OWNER_PRIMARY_ONLY = 3, }; -// Easy unlock icon choices. -enum class EasyUnlockIconId { +// Easy unlock icon states. +enum class EasyUnlockIconState { // No icon shown. NONE, // The user has clicked the easy unlock icon and disabled easy unlock for this @@ -122,17 +122,17 @@ }; // Information about the custom icon in the user pod. -struct ASH_PUBLIC_EXPORT EasyUnlockIconOptions { - EasyUnlockIconOptions(); - EasyUnlockIconOptions(const EasyUnlockIconOptions& other); - EasyUnlockIconOptions(EasyUnlockIconOptions&& other); - ~EasyUnlockIconOptions(); +struct ASH_PUBLIC_EXPORT EasyUnlockIconInfo { + EasyUnlockIconInfo(); + EasyUnlockIconInfo(const EasyUnlockIconInfo& other); + EasyUnlockIconInfo(EasyUnlockIconInfo&& other); + ~EasyUnlockIconInfo(); - EasyUnlockIconOptions& operator=(const EasyUnlockIconOptions& other); - EasyUnlockIconOptions& operator=(EasyUnlockIconOptions&& other); + EasyUnlockIconInfo& operator=(const EasyUnlockIconInfo& other); + EasyUnlockIconInfo& operator=(EasyUnlockIconInfo&& other); // Icon that should be displayed. - EasyUnlockIconId icon = EasyUnlockIconId::NONE; + EasyUnlockIconState icon_state = EasyUnlockIconState::NONE; // Tooltip that is associated with the icon. This is shown automatically if // |autoshow_tooltip| is true. The user can always see the tooltip if they // hover over the icon. The tooltip should be used for the accessibility label
diff --git a/ash/services/recording/BUILD.gn b/ash/services/recording/BUILD.gn index a38155b..f4910a0 100644 --- a/ash/services/recording/BUILD.gn +++ b/ash/services/recording/BUILD.gn
@@ -20,3 +20,19 @@ "//services/audio/public/cpp", ] } + +source_set("test_support") { + testonly = true + + sources = [ + "recording_service_test_api.cc", + "recording_service_test_api.h", + ] + + deps = [ + "//ash/services/recording", + "//ash/services/recording/public/mojom", + "//base", + "//media", + ] +}
diff --git a/ash/services/recording/recording_service.cc b/ash/services/recording/recording_service.cc index 36fc860..e478677 100644 --- a/ash/services/recording/recording_service.cc +++ b/ash/services/recording/recording_service.cc
@@ -322,6 +322,11 @@ if (video_thumbnail_.isNull()) video_thumbnail_ = ExtractImageFromVideoFrame(*frame); + if (on_video_frame_delivered_callback_for_testing_) { + std::move(on_video_frame_delivered_callback_for_testing_) + .Run(*frame, content_rect); + } + encoder_muxer_.AsyncCall(&RecordingEncoderMuxer::EncodeVideo).WithArgs(frame); }
diff --git a/ash/services/recording/recording_service.h b/ash/services/recording/recording_service.h index d88ddce..27c68b5 100644 --- a/ash/services/recording/recording_service.h +++ b/ash/services/recording/recording_service.h
@@ -33,6 +33,8 @@ namespace recording { +class RecordingServiceTestApi; + // Implements the mojo interface of the recording service which handles // recording audio and video of the screen or portion of it, and writes the webm // muxed video chunks directly to a file at a path provided to the Record*() @@ -103,6 +105,8 @@ void OnCaptureMuted(bool is_muted) override; private: + friend class RecordingServiceTestApi; + void StartNewRecording( mojo::PendingRemote<mojom::RecordingServiceClient> client, mojo::PendingRemote<viz::mojom::FrameSinkVideoCapturer> video_capturer, @@ -200,6 +204,14 @@ mojo::Remote<mojom::RecordingServiceClient> client_remote_ GUARDED_BY_CONTEXT(main_thread_checker_); + // A callback used for testing, which will be triggered when a video frame is + // delivered to the service from the Viz capturer. + using OnVideoFrameDeliveredCallback = + base::OnceCallback<void(const media::VideoFrame& frame, + const gfx::Rect& content_rect)>; + OnVideoFrameDeliveredCallback on_video_frame_delivered_callback_for_testing_ + GUARDED_BY_CONTEXT(main_thread_checker_); + // A cached scaled down rgb image of the first valid video frame which will be // used to provide the client with an image thumbnail representing the // recorded video.
diff --git a/ash/services/recording/recording_service_test_api.cc b/ash/services/recording/recording_service_test_api.cc new file mode 100644 index 0000000..9e7d598 --- /dev/null +++ b/ash/services/recording/recording_service_test_api.cc
@@ -0,0 +1,75 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/services/recording/recording_service_test_api.h" + +#include "base/bind.h" +#include "base/run_loop.h" +#include "base/threading/thread_checker.h" + +namespace recording { + +RecordingServiceTestApi::RecordingServiceTestApi( + mojo::PendingReceiver<mojom::RecordingService> receiver) + : recording_service_(std::move(receiver)) {} + +viz::FrameSinkId RecordingServiceTestApi::GetCurrentFrameSinkId() const { + DCHECK_CALLED_ON_VALID_THREAD(recording_service_.main_thread_checker_); + DCHECK(recording_service_.current_video_capture_params_); + + return recording_service_.current_video_capture_params_->frame_sink_id(); +} + +gfx::Size RecordingServiceTestApi::GetCurrentFrameSinkSize() const { + DCHECK_CALLED_ON_VALID_THREAD(recording_service_.main_thread_checker_); + DCHECK(recording_service_.current_video_capture_params_); + + return recording_service_.current_video_capture_params_ + ->current_frame_sink_size(); +} + +gfx::Size RecordingServiceTestApi::GetCurrentVideoSize() const { + DCHECK_CALLED_ON_VALID_THREAD(recording_service_.main_thread_checker_); + DCHECK(recording_service_.current_video_capture_params_); + + return recording_service_.current_video_capture_params_->GetVideoSize(); +} + +gfx::ImageSkia RecordingServiceTestApi::GetVideoThumbnail() const { + DCHECK_CALLED_ON_VALID_THREAD(recording_service_.main_thread_checker_); + + return recording_service_.video_thumbnail_; +} + +void RecordingServiceTestApi::RequestAndWaitForVideoFrame( + VerifyVideoFrameCallback verify_frame_callback) { + DCHECK_CALLED_ON_VALID_THREAD(recording_service_.main_thread_checker_); + DCHECK(recording_service_.video_capturer_remote_); + DCHECK(!recording_service_.on_video_frame_delivered_callback_for_testing_); + + // Flush any pending calls from before. + recording_service_.video_capturer_remote_.FlushForTesting(); + recording_service_.consumer_receiver_.FlushForTesting(); + + base::RunLoop run_loop; + + recording_service_.on_video_frame_delivered_callback_for_testing_ = + base::BindOnce( + [](base::OnceClosure run_loop_quit_closure, + VerifyVideoFrameCallback verify_callback, + const media::VideoFrame& frame, const gfx::Rect& content_rect) { + if (verify_callback) + std::move(verify_callback).Run(frame, content_rect); + + std::move(run_loop_quit_closure).Run(); + }, + run_loop.QuitClosure(), std::move(verify_frame_callback)); + + recording_service_.video_capturer_remote_->RequestRefreshFrame(); + recording_service_.video_capturer_remote_.FlushForTesting(); + + run_loop.Run(); +} + +} // namespace recording
diff --git a/ash/services/recording/recording_service_test_api.h b/ash/services/recording/recording_service_test_api.h new file mode 100644 index 0000000..6bb95ba --- /dev/null +++ b/ash/services/recording/recording_service_test_api.h
@@ -0,0 +1,57 @@ +// 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_SERVICES_RECORDING_RECORDING_SERVICE_TEST_API_H_ +#define ASH_SERVICES_RECORDING_RECORDING_SERVICE_TEST_API_H_ + +#include "ash/services/recording/public/mojom/recording_service.mojom.h" +#include "ash/services/recording/recording_service.h" +#include "base/callback_forward.h" +#include "base/callback_helpers.h" +#include "media/base/video_frame.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "ui/gfx/image/image_skia.h" + +namespace recording { + +// Defines an API to test the internals of the recording service. The recording +// service instance is created (in-process) and owned by this class. +class RecordingServiceTestApi { + public: + explicit RecordingServiceTestApi( + mojo::PendingReceiver<mojom::RecordingService> receiver); + RecordingServiceTestApi(const RecordingServiceTestApi&) = delete; + RecordingServiceTestApi& operator=(const RecordingServiceTestApi&) = delete; + ~RecordingServiceTestApi() = default; + + // Gets the current frame sink id being captured by the service. + viz::FrameSinkId GetCurrentFrameSinkId() const; + + // Gets the current size of the frame sink being recorded. + gfx::Size GetCurrentFrameSinkSize() const; + + // Gets the current video size being captured by the service. + gfx::Size GetCurrentVideoSize() const; + + // Gets the thumbnail image that will be used by the service to provide it to + // the client. + gfx::ImageSkia GetVideoThumbnail() const; + + // Requests a video frame from the video capturer and waits for it to be + // delivered to the service. If the caller provided a non-null + // |verify_frame_callback| it will be called before this function returns. + using VerifyVideoFrameCallback = + base::OnceCallback<void(const media::VideoFrame& frame, + const gfx::Rect& content_rect)>; + void RequestAndWaitForVideoFrame( + VerifyVideoFrameCallback verify_frame_callback = base::NullCallback()); + + private: + // The actual recording service instance. + RecordingService recording_service_; +}; + +} // namespace recording + +#endif // ASH_SERVICES_RECORDING_RECORDING_SERVICE_TEST_API_H_
diff --git a/ash/services/recording/video_capture_params.h b/ash/services/recording/video_capture_params.h index e338827..54197185 100644 --- a/ash/services/recording/video_capture_params.h +++ b/ash/services/recording/video_capture_params.h
@@ -38,7 +38,7 @@ const gfx::Size& frame_sink_size); // Returns a capture params instance for a recording of a window. The given - //|frame_sink_id| is either of that window (if it submits compositor frames + // |frame_sink_id| is either of that window (if it submits compositor frames // independently), or of the root window it descends from (if it doesn't // submit its compositor frames). In the latter case, the window must be // identifiable by a valid |subtree_capture_id| (created by calling @@ -62,6 +62,9 @@ const gfx::Size& frame_sink_size, const gfx::Rect& crop_region); + const viz::FrameSinkId& frame_sink_id() const { return frame_sink_id_; } + gfx::Size current_frame_sink_size() const { return current_frame_sink_size_; } + // Initializes the given |capturer| (passed by ref) according to the capture // parameters. The given |capturer| must be bound before calling this. void InitializeVideoCapturer(
diff --git a/ash/wm/window_cycle/window_cycle_list.cc b/ash/wm/window_cycle/window_cycle_list.cc index 56ff1a5f..3bea636d 100644 --- a/ash/wm/window_cycle/window_cycle_list.cc +++ b/ash/wm/window_cycle/window_cycle_list.cc
@@ -605,6 +605,12 @@ if (Shell::Get() ->window_cycle_controller() ->IsInteractiveAltTabModeAllowed()) { + // |mirror_container_| can have window list with width smaller the tab + // slider's width. The padding should be 64px from the tab slider. + const int min_width = + tab_slider_container_->GetPreferredSize().width() + + 2 * WindowCycleList::kInsideBorderHorizontalPaddingDp; + size.set_width(std::max(size.width(), min_width)); size.Enlarge(0, tab_slider_container_->GetPreferredSize().height() + kTabSliderContainerVerticalPaddingDp); }
diff --git a/base/allocator/partition_allocator/partition_root.h b/base/allocator/partition_allocator/partition_root.h index e6ae008..e07e9acd 100644 --- a/base/allocator/partition_allocator/partition_root.h +++ b/base/allocator/partition_allocator/partition_root.h
@@ -972,14 +972,12 @@ } else { slot_start = bucket->SlowPathAlloc(this, flags, raw_size, slot_span_alignment, is_already_zeroed); - // TODO(palmer): See if we can afford to make this a CHECK. - PA_DCHECK(!slot_start || - IsValidSlotSpan(SlotSpan::FromSlotStartPtr(slot_start))); - if (UNLIKELY(!slot_start)) return nullptr; slot_span = SlotSpan::FromSlotStartPtr(slot_start); + // TODO(palmer): See if we can afford to make this a CHECK. + PA_DCHECK(IsValidSlotSpan(slot_span)); // For direct mapped allocations, |bucket| is the sentinel. PA_DCHECK((slot_span->bucket == bucket) || (slot_span->bucket->is_direct_mapped() &&
diff --git a/base/allocator/partition_allocator/thread_cache.h b/base/allocator/partition_allocator/thread_cache.h index 12fe21f..3a402d0 100644 --- a/base/allocator/partition_allocator/thread_cache.h +++ b/base/allocator/partition_allocator/thread_cache.h
@@ -23,8 +23,6 @@ #if defined(ARCH_CPU_X86_64) && defined(PA_HAS_64_BITS_POINTERS) #include <algorithm> - -#include <emmintrin.h> #endif namespace base { @@ -486,16 +484,14 @@ int slot_size_remaining_in_16_bytes = std::min(bucket.slot_size / 16, distance_to_next_cacheline_in_16_bytes); - __m128i* address_aligned = reinterpret_cast<__m128i*>(address); - // Not a random value. If set to 0, then the compiler is "smart enough" to - // replace the loop below with a call to memset()@plt, which is not so great - // when trying to zero an integer multiple of 16 bytes, aligned on a 16 byte - // boundary. Various ways to defeat that are brittle, to better make sure - // that the loop doesn't fit memset()'s use cases. - __m128i value = _mm_set1_epi32(0xdeadbeef); - for (auto i = 0; i < slot_size_remaining_in_16_bytes; i++) { - _mm_store_si128(address_aligned, value); - address_aligned += 1; + static const uint32_t poison_16_bytes[4] = {0xdeadbeef, 0xdeadbeef, + 0xdeadbeef, 0xdeadbeef}; + uint32_t* address_aligned = reinterpret_cast<uint32_t*>(address); + + for (int i = 0; i < slot_size_remaining_in_16_bytes; i++) { + // Clang will expand the memcpy to a 16-byte write (movups on x86). + memcpy(address_aligned, poison_16_bytes, sizeof(poison_16_bytes)); + address_aligned += 4; } #endif // defined(ARCH_CPU_X86_64) && defined(PA_HAS_64_BITS_POINTERS)
diff --git a/base/trace_event/trace_log.h b/base/trace_event/trace_log.h index 8be87489..8e6c712 100644 --- a/base/trace_event/trace_log.h +++ b/base/trace_event/trace_log.h
@@ -346,7 +346,10 @@ TraceEventHandle handle); int process_id() const { return process_id_; } - const std::string& process_name() const { return process_name_; } + std::string process_name() const { + AutoLock lock(lock_); + return process_name_; + } uint64_t MangleEventId(uint64_t id); @@ -378,7 +381,10 @@ process_name_ = process_name; } - bool IsProcessNameEmpty() const { return process_name_.empty(); } + bool IsProcessNameEmpty() const { + AutoLock lock(lock_); + return process_name_.empty(); + } // Processes can have labels in addition to their names. Use labels, for // instance, to list out the web page titles that a process is handling.
diff --git a/base/values.cc b/base/values.cc index e9ffb074..2ac181a8 100644 --- a/base/values.cc +++ b/base/values.cc
@@ -1333,24 +1333,6 @@ const_cast<const ListValue**>(out_value)); } -bool DictionaryValue::GetWithoutPathExpansion(StringPiece key, - const Value** out_value) const { - DCHECK(IsStringUTF8AllowingNoncharacters(key)); - auto entry_iterator = dict().find(key); - if (entry_iterator == dict().end()) - return false; - - if (out_value) - *out_value = entry_iterator->second.get(); - return true; -} - -bool DictionaryValue::GetWithoutPathExpansion(StringPiece key, - Value** out_value) { - return as_const(*this).GetWithoutPathExpansion( - key, const_cast<const Value**>(out_value)); -} - bool DictionaryValue::GetBooleanWithoutPathExpansion(StringPiece key, bool* out_value) const { const Value* value = FindKey(key); @@ -1360,15 +1342,6 @@ return value->GetAsBoolean(out_value); } -bool DictionaryValue::GetIntegerWithoutPathExpansion(StringPiece key, - int* out_value) const { - const Value* value = FindKey(key); - if (!value) - return false; - - return value->GetAsInteger(out_value); -} - bool DictionaryValue::GetDoubleWithoutPathExpansion(StringPiece key, double* out_value) const { const Value* value = FindKey(key);
diff --git a/base/values.h b/base/values.h index 2acd617..4c87676b1 100644 --- a/base/values.h +++ b/base/values.h
@@ -737,14 +737,8 @@ // Like `Get()`, but without special treatment of '.'. This allows e.g. URLs // to be used as paths. - // DEPRECATED, use `Value::FindKey(key)` instead. - bool GetWithoutPathExpansion(StringPiece key, const Value** out_value) const; - // DEPRECATED, use `Value::FindKey(key)` instead. - bool GetWithoutPathExpansion(StringPiece key, Value** out_value); // DEPRECATED, use `Value::FindBoolKey(key)` instead. bool GetBooleanWithoutPathExpansion(StringPiece key, bool* out_value) const; - // DEPRECATED, use `Value::FindIntKey(key)` instead. - bool GetIntegerWithoutPathExpansion(StringPiece key, int* out_value) const; // DEPRECATED, use `Value::FindDoubleKey(key)` instead. bool GetDoubleWithoutPathExpansion(StringPiece key, double* out_value) const; // DEPRECATED, use `Value::FindStringKey(key)` instead.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java index 26e408a5..d37ae71 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java
@@ -70,13 +70,6 @@ * Once finished, calls onFlowIsKnown(). */ public void start() { - if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) - || ApiCompatibilityUtils.isDemoUser() - || ApiCompatibilityUtils.isRunningInUserTestHarness()) { - onFlowIsKnown(null); - return; - } - long childAccountStatusStart = SystemClock.elapsedRealtime(); ChildAccountService.checkChildAccountStatus(status -> { RecordHistogram.recordTimesHistogram("MobileFre.ChildAccountStatusDuration", @@ -150,13 +143,6 @@ } void processFreEnvironmentPreNative() { - if (isFirstRunFlowComplete()) { - assert isFirstRunEulaAccepted(); - // We do not need any interactive FRE. - onFlowIsKnown(null); - return; - } - Bundle freProperties = new Bundle(); freProperties.putInt(SyncConsentFirstRunFragment.CHILD_ACCOUNT_STATUS, mChildAccountStatus);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OWNERS b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OWNERS index c2baf126..28ccc94 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OWNERS +++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OWNERS
@@ -1,7 +1,5 @@ file://components/omnibox/browser/android/OWNERS -# For changes to Suggestions/Autocomplete: -ender@google.com - # For changes to LocationBar: pnoland@chromium.org +wylieb@chromium.org
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java index 99fe1ba..a27e2e8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java
@@ -449,6 +449,13 @@ @Override public boolean isPaintPreview() { + // Start Surface homepage is not bound with a tab and mTab is kept as the previous tab if + // the homepage is shown. This is added here to make sure Start Surface homepage is not + // regarded as a paint preview. + if (isInOverviewAndShowingOmnibox() + || StartSurfaceConfiguration.shouldHandleAsNtp(getTab())) { + return false; + } return hasTab() && TabbedPaintPreview.get(mTab).isShowing(); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialog.java index 45e2b38..0fd80c1 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialog.java
@@ -35,6 +35,9 @@ // The short name of the app before update. private String mOldAppShortName; + // The package name for this app. + private String mPackageName; + // The callback to run when the user has made a decision. private Callback<Integer> mDialogResultCallback; @@ -43,6 +46,7 @@ /** * Shows the dialog. * @param manager The {@ModalDialogManager} to use. + * @param packageName The package name for this app. * @param iconChanging Whether an icon change has been detected. * @param shortNameChanging Whether a short name change has been detected. * @param nameChanging Whether a name change has been detected. @@ -56,13 +60,15 @@ * @param newIconAdaptive Whether the updated icon is adaptive. * @param callback The callback to use to communicate the results. */ - public void show(ModalDialogManager manager, boolean iconChanging, boolean shortNameChanging, - boolean nameChanging, String oldAppShortName, String newAppShortName, String oldAppName, - String newAppName, Bitmap currentAppIcon, Bitmap updatedAppIcon, - boolean oldIconAdaptive, boolean newIconAdaptive, Callback<Integer> callback) { + public void show(ModalDialogManager manager, String packageName, boolean iconChanging, + boolean shortNameChanging, boolean nameChanging, String oldAppShortName, + String newAppShortName, String oldAppName, String newAppName, Bitmap currentAppIcon, + Bitmap updatedAppIcon, boolean oldIconAdaptive, boolean newIconAdaptive, + Callback<Integer> callback) { Context context = ContextUtils.getApplicationContext(); Resources resources = context.getResources(); mOldAppShortName = oldAppShortName; + mPackageName = packageName; mDialogResultCallback = callback; int titleId = 0; @@ -121,7 +127,7 @@ break; case ModalDialogProperties.ButtonType.NEGATIVE: WebApkUpdateReportAbuseDialog reportAbuseDialog = new WebApkUpdateReportAbuseDialog( - mModalDialogManager, mOldAppShortName, this::onUninstall); + mModalDialogManager, mPackageName, mOldAppShortName, this::onUninstall); reportAbuseDialog.show(); break; default:
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java index 58fd7aa..c76016e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java
@@ -202,10 +202,10 @@ ModalDialogManager dialogManager = mTabProvider.get().getWindowAndroid().getModalDialogManager(); WebApkIconNameUpdateDialog dialog = new WebApkIconNameUpdateDialog(); - dialog.show(dialogManager, iconChanging, shortNameChanging, nameChanging, mInfo.shortName(), - mFetchedInfo.shortName(), mInfo.name(), mFetchedInfo.name(), mInfo.icon().bitmap(), - mFetchedInfo.icon().bitmap(), mInfo.isIconAdaptive(), mFetchedInfo.isIconAdaptive(), - this::onUserApprovedUpdate); + dialog.show(dialogManager, mInfo.webApkPackageName(), iconChanging, shortNameChanging, + nameChanging, mInfo.shortName(), mFetchedInfo.shortName(), mInfo.name(), + mFetchedInfo.name(), mInfo.icon().bitmap(), mFetchedInfo.icon().bitmap(), + mInfo.isIconAdaptive(), mFetchedInfo.isIconAdaptive(), this::onUserApprovedUpdate); } protected void onUserApprovedUpdate(int dismissalCause) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateReportAbuseDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateReportAbuseDialog.java index 41256b69..6b6524b 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateReportAbuseDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateReportAbuseDialog.java
@@ -5,12 +5,16 @@ package org.chromium.chrome.browser.webapps; import android.content.Context; +import android.content.Intent; import android.content.res.Resources; +import android.net.Uri; +import android.provider.Settings; import android.view.View; import android.widget.CheckBox; import org.chromium.base.ContextUtils; import org.chromium.base.Log; +import org.chromium.base.PackageUtils; import org.chromium.ui.LayoutInflaterUtils; import org.chromium.ui.modaldialog.DialogDismissalCause; import org.chromium.ui.modaldialog.ModalDialogManager; @@ -38,15 +42,19 @@ // The short name of the app the user is uninstalling. private String mAppShortName; + // The package name for the app the user is uninstalling. + private String mAppPackageName; + // When checked, the app will not just be uninstalled, but also reported for abuse. private CheckBox mReportAbuseCheckBox; // Notifies the parent (dialog beneath us) that uninstalling was the action taken by the user. private Callback mOnUninstallCallback; - public WebApkUpdateReportAbuseDialog( - ModalDialogManager manager, String appShortName, Callback callback) { + public WebApkUpdateReportAbuseDialog(ModalDialogManager manager, String appPackageName, + String appShortName, Callback callback) { mModalDialogManager = manager; + mAppPackageName = appPackageName; mAppShortName = appShortName; mOnUninstallCallback = callback; } @@ -102,11 +110,23 @@ if (mReportAbuseCheckBox.isChecked()) { // TODO(finnur): Implement sending info to the SafeBrowsing team. - Log.i(TAG, "Uninstall and report abuse"); - } else { - // TODO(finnur): Implement opening the uninstall screen. - Log.i(TAG, "Uninstall without reporting abuse"); + Log.i(TAG, "Send report to SafeBrowsing"); } + + showAppInfoToUninstall(); } } + + private void showAppInfoToUninstall() { + Context context = ContextUtils.getApplicationContext(); + if (!PackageUtils.isPackageInstalled(context, mAppPackageName)) { + Log.i(TAG, "WebApk not found:" + mAppPackageName); + return; + } + + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.addCategory(Intent.CATEGORY_DEFAULT); + intent.setData(Uri.parse("package:" + mAppPackageName)); + context.startActivity(intent); + } }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerTest.java index 13996b17..9cd73c4 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerTest.java
@@ -49,6 +49,7 @@ import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CriteriaHelper; import org.chromium.base.test.util.DisableIf; +import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Restriction; import org.chromium.chrome.browser.accessibility_tab_switcher.OverviewListLayout; @@ -498,6 +499,7 @@ @MediumTest @DisableIf.Build(sdk_is_greater_than = N_MR1, message = "crbug.com/1139943") @DisableIf.Build(sdk_is_less_than = N, message = "crbug.com/1190231") + @DisabledTest(message = "crbug.com/1216438") // Failures on N. @Features.EnableFeatures({ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID}) public void testLayoutObserverNotification_ShowAndHide_TabSwitcher() throws TimeoutException { LayoutObserverCallbackHelper startedShowingCallback = new LayoutObserverCallbackHelper();
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/settings/MainSettingsFragmentTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/settings/MainSettingsFragmentTest.java index 935a6ce..0ef2b1a 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/settings/MainSettingsFragmentTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/settings/MainSettingsFragmentTest.java
@@ -77,6 +77,7 @@ import org.chromium.components.signin.base.CoreAccountInfo; import org.chromium.components.signin.metrics.SigninAccessPoint; import org.chromium.content_public.browser.test.util.TestThreadUtils; +import org.chromium.ui.test.util.RenderTestRule; import java.io.IOException; import java.util.HashSet; @@ -177,6 +178,10 @@ // Sign in and render changes. mSyncTestRule.setUpAccountAndEnableSyncForTesting(); SyncTestUtil.waitForSyncFeatureActive(); + // Waiting for sync to become active might take some time, so the scrollbar on the settings + // view starts to fade, making the test flaky due to differences in the rendered image. + // Sanitize the view to hide scrollbars (see https://crbug.com/1204117 for details). + RenderTestRule.sanitize(view); mRenderTestRule.render(view, "main_settings_signed_in"); }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialogTest.java index b680131..946b0ec1 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialogTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIconNameUpdateDialogTest.java
@@ -145,11 +145,11 @@ WebApkIconNameUpdateDialog dialog = new WebApkIconNameUpdateDialog(); - dialog.show(modalDialogManager, dialogParams.iconChanged, dialogParams.shortNameChanged, - dialogParams.nameChanged, dialogParams.shortNameBefore, - dialogParams.shortNameAfter, dialogParams.nameBefore, dialogParams.nameAfter, - dialogParams.bitmapBefore, dialogParams.bitmapAfter, false, false, - this::onUpdateDialogResult); + dialog.show(modalDialogManager, /* packageName= */ "", dialogParams.iconChanged, + dialogParams.shortNameChanged, dialogParams.nameChanged, + dialogParams.shortNameBefore, dialogParams.shortNameAfter, + dialogParams.nameBefore, dialogParams.nameAfter, dialogParams.bitmapBefore, + dialogParams.bitmapAfter, false, false, this::onUpdateDialogResult); Assert.assertEquals( dialogParams.shortNameChanged || dialogParams.expectShortNameShownAnyway @@ -192,8 +192,9 @@ ModalDialogManager modalDialogManager = mActivityTestRule.getActivity().getModalDialogManager(); - WebApkUpdateReportAbuseDialog dialog = new WebApkUpdateReportAbuseDialog( - modalDialogManager, shortAppName, this::onAbuseDialogResult); + WebApkUpdateReportAbuseDialog dialog = + new WebApkUpdateReportAbuseDialog(modalDialogManager, /* packageName= */ "", + shortAppName, this::onAbuseDialogResult); dialog.show(); Assert.assertEquals(expectedTitle, getDialogTitle());
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java index 7b6c2cf3..4a03cab9 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencerTest.java
@@ -6,7 +6,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import android.accounts.Account; @@ -136,23 +135,6 @@ @Test @Feature({"FirstRun"}) - public void testFirstRunComplete() { - mSequencer.isFirstRunFlowComplete = true; - mSequencer.isSignedIn = false; - mSequencer.isSyncAllowed = true; - mSequencer.googleAccounts = - Collections.singletonList(new Account(DEFAULT_ACCOUNT, GOOGLE_ACCOUNT_TYPE)); - mSequencer.shouldSkipFirstUseHints = false; - mSequencer.isFirstRunEulaAccepted = true; - mSequencer.initializeSharedState(ChildAccountStatus.NOT_CHILD); - - mSequencer.processFreEnvironmentPreNative(); - assertTrue(mSequencer.calledOnFlowIsKnown); - assertNull(mSequencer.returnedBundle); - } - - @Test - @Feature({"FirstRun"}) public void testStandardFlowTosNotSeen() { mSequencer.isFirstRunFlowComplete = false; mSequencer.isSignedIn = false;
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index 9a8d8d7b..3985576 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd
@@ -1110,9 +1110,42 @@ Install Chromium OS </message> + <!-- OS install screen --> <message name="IDS_OS_INSTALL_SCREEN_INTRO_TITLE" desc="Title of the introduction page in the OS install screen"> Install Chromium OS </message> + <message name="IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE" desc="Subtitle text of the OS install screen's introduction step"> + Installing Chromium OS will overwrite all data on your device. + </message> + <message name="IDS_OS_INSTALL_SCREEN_INTRO_BODY" desc="Body text of the OS install screen's introduction step"> + <ph name="BEGIN_PARAGRAPH1"><p></ph>Before we get started, please ensure that you have an up-to-date backup of your data. Installing Chromium OS will overwrite all data on your hard drive.<ph name="END_PARAGRAPH1"></p></ph> + <ph name="BEGIN_PARAGRAPH2"><p></ph>Google is not responsible for any data loss, and makes no guarantee that Chromium OS will work on uncertified models. Please visit [TBD] to learn more about certified models.<ph name="END_PARAGRAPH2"></p></ph> + <ph name="BEGIN_PARAGRAPH3"><p></ph>Learn more about installing Chromium OS and data erasure: [TBD URL]<ph name="END_PARAGRAPH3"></p></ph> + <ph name="BEGIN_PARAGRAPH4"><p></ph>If you are ready to proceed, click “Install Chromium OS” and we'll guide you through the installation in just a couple easy steps. You'll have another chance to confirm before we make any changes to your computer.<ph name="END_PARAGRAPH4"></p></ph> + </message> + <message name="IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON" desc="Text of the next button on the introduction page of the OS install screen"> + Install Chromium OS + </message> + <message name="IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE" desc="Title of the confirmation page of the OS install screen"> + Ready to install Chromium OS + </message> + <message name="IDS_OS_INSTALL_SCREEN_CONFIRM_BODY" desc="Body text of the OS install screen's confirmation step"> + <ph name="BEGIN_PARAGRAPH1"><p></ph>We’re ready to install Chromium OS! Once you proceed: + <ph name="BEGIN_LIST"><ul></ph> + <ph name="LIST_ITEM"><li></ph>Files, data, and your current operating system will be erased. + <ph name="LIST_ITEM"><li></ph>Chromium OS will be installed. + <ph name="LIST_ITEM"><li></ph>Your device will shut down once the installation is complete. + <ph name="END_LIST"></ul></ph> + <ph name="END_PARAGRAPH1"></p></ph> + <ph name="BEGIN_PARAGRAPH2"><p></ph>One last reminder: installation will erase your entire hard drive. Please make sure you have any data you care about backed up.<ph name="END_PARAGRAPH2"></p></ph> + <ph name="BEGIN_PARAGRAPH3"><p></ph>Once installation starts it cannot be canceled.<ph name="END_PARAGRAPH3"></p></ph> + </message> + <message name="IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON" desc="Text of the next button on the confirmation page of the OS install screen"> + Erase Hard Drive & Install Chromium OS + </message> + <message name="IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE" desc="Title of the in-progress page of the OS install screen"> + Chromium OS installation in progress + </message> </if> <!-- Welcome page (chrome://welcome) strings -->
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_BODY.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_BODY.png.sha1 new file mode 100644 index 0000000..f40f3dc --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_BODY.png.sha1
@@ -0,0 +1 @@ +f48b0307ab76cbed08305e8a1c4e6b61020bdac3 \ No newline at end of file
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON.png.sha1 new file mode 100644 index 0000000..f524038da --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON.png.sha1
@@ -0,0 +1 @@ +c472551d63c08d84fcb8563d9df225cefc0f5606 \ No newline at end of file
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE.png.sha1 new file mode 100644 index 0000000..f40f3dc --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE.png.sha1
@@ -0,0 +1 @@ +f48b0307ab76cbed08305e8a1c4e6b61020bdac3 \ No newline at end of file
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_BODY.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_BODY.png.sha1 new file mode 100644 index 0000000..f524038da --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_BODY.png.sha1
@@ -0,0 +1 @@ +c472551d63c08d84fcb8563d9df225cefc0f5606 \ No newline at end of file
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON.png.sha1 new file mode 100644 index 0000000..f524038da --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON.png.sha1
@@ -0,0 +1 @@ +c472551d63c08d84fcb8563d9df225cefc0f5606 \ No newline at end of file
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE.png.sha1 new file mode 100644 index 0000000..f524038da --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE.png.sha1
@@ -0,0 +1 @@ +c472551d63c08d84fcb8563d9df225cefc0f5606 \ No newline at end of file
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_PARAGRAPH1.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_PARAGRAPH1.png.sha1 new file mode 100644 index 0000000..54d85cd --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_PARAGRAPH1.png.sha1
@@ -0,0 +1 @@ +e1ba06122a8035e56f7780ae600ac59d562ddf9f \ No newline at end of file
diff --git a/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE.png.sha1 b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE.png.sha1 new file mode 100644 index 0000000..54d85cd --- /dev/null +++ b/chrome/app/chromium_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE.png.sha1
@@ -0,0 +1 @@ +e1ba06122a8035e56f7780ae600ac59d562ddf9f \ No newline at end of file
diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index 40d35bd..469a383 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd
@@ -1125,9 +1125,42 @@ Install Chrome OS </message> + <!-- OS install screen --> <message name="IDS_OS_INSTALL_SCREEN_INTRO_TITLE" desc="Title of the introduction page in the OS install screen"> Install Chrome OS </message> + <message name="IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE" desc="Subtitle text of the OS install screen's introduction step"> + Installing Chrome OS will overwrite all data on your device. + </message> + <message name="IDS_OS_INSTALL_SCREEN_INTRO_BODY" desc="Body text of the OS install screen's introduction step"> + <ph name="BEGIN_PARAGRAPH1"><p></ph>Before we get started, please ensure that you have an up-to-date backup of your data. Installing Chrome OS will overwrite all data on your hard drive.<ph name="END_PARAGRAPH1"></p></ph> + <ph name="BEGIN_PARAGRAPH2"><p></ph>Google is not responsible for any data loss, and makes no guarantee that Chrome OS will work on uncertified models. Please visit [TBD] to learn more about certified models.<ph name="END_PARAGRAPH2"></p></ph> + <ph name="BEGIN_PARAGRAPH3"><p></ph>Learn more about installing Chrome OS and data erasure: [TBD URL]<ph name="END_PARAGRAPH3"></p></ph> + <ph name="BEGIN_PARAGRAPH4"><p></ph>If you are ready to proceed, click “Install Chrome OS” and we'll guide you through the installation in just a couple easy steps. You'll have another chance to confirm before we make any changes to your computer.<ph name="END_PARAGRAPH4"></p></ph> + </message> + <message name="IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON" desc="Text of the next button on the introduction page of the OS install screen"> + Install Chrome OS + </message> + <message name="IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE" desc="Title of the confirmation page of the OS install screen"> + Ready to install Chrome OS + </message> + <message name="IDS_OS_INSTALL_SCREEN_CONFIRM_BODY" desc="Body text of the OS install screen's confirmation step"> + <ph name="BEGIN_PARAGRAPH1"><p></ph>We’re ready to install Chrome OS! Once you proceed: + <ph name="BEGIN_LIST"><ul></ph> + <ph name="LIST_ITEM"><li></ph>Files, data, and your current operating system will be erased. + <ph name="LIST_ITEM"><li></ph>Chrome OS will be installed. + <ph name="LIST_ITEM"><li></ph>Your device will shut down once the installation is complete. + <ph name="END_LIST"></ul></ph> + <ph name="END_PARAGRAPH1"></p></ph> + <ph name="BEGIN_PARAGRAPH2"><p></ph>One last reminder: installation will erase your entire hard drive. Please make sure you have any data you care about backed up.<ph name="END_PARAGRAPH2"></p></ph> + <ph name="BEGIN_PARAGRAPH3"><p></ph>Once installation starts it cannot be canceled.<ph name="END_PARAGRAPH3"></p></ph> + </message> + <message name="IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON" desc="Text of the next button on the confirmation page of the OS install screen"> + Erase Hard Drive & Install Chrome OS + </message> + <message name="IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE" desc="Title of the in-progress page of the OS install screen"> + Chrome OS installation in progress + </message> </if> <!-- Welcome page (chrome://welcome) strings -->
diff --git a/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_BODY.png.sha1 b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_BODY.png.sha1 new file mode 100644 index 0000000..93237e5 --- /dev/null +++ b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_BODY.png.sha1
@@ -0,0 +1 @@ +e29d0c803f1bedb5b9fd8d2ad357fa4f71a30e09 \ No newline at end of file
diff --git a/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON.png.sha1 b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON.png.sha1 new file mode 100644 index 0000000..93237e5 --- /dev/null +++ b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON.png.sha1
@@ -0,0 +1 @@ +e29d0c803f1bedb5b9fd8d2ad357fa4f71a30e09 \ No newline at end of file
diff --git a/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE.png.sha1 b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE.png.sha1 new file mode 100644 index 0000000..93237e5 --- /dev/null +++ b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE.png.sha1
@@ -0,0 +1 @@ +e29d0c803f1bedb5b9fd8d2ad357fa4f71a30e09 \ No newline at end of file
diff --git a/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_BODY.png.sha1 b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_BODY.png.sha1 new file mode 100644 index 0000000..c49b56d --- /dev/null +++ b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_BODY.png.sha1
@@ -0,0 +1 @@ +23029f5c89f7c4c8f1613eeaa7e37b3ac22c288c \ No newline at end of file
diff --git a/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON.png.sha1 b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON.png.sha1 new file mode 100644 index 0000000..c49b56d --- /dev/null +++ b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON.png.sha1
@@ -0,0 +1 @@ +23029f5c89f7c4c8f1613eeaa7e37b3ac22c288c \ No newline at end of file
diff --git a/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE.png.sha1 b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE.png.sha1 new file mode 100644 index 0000000..c49b56d --- /dev/null +++ b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE.png.sha1
@@ -0,0 +1 @@ +23029f5c89f7c4c8f1613eeaa7e37b3ac22c288c \ No newline at end of file
diff --git a/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE.png.sha1 b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE.png.sha1 new file mode 100644 index 0000000..14d01e8 --- /dev/null +++ b/chrome/app/google_chrome_strings_grd/IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE.png.sha1
@@ -0,0 +1 @@ +420457d64191487a452c01cacf397e9f33271395 \ No newline at end of file
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index c4f4c5e..9fc06b1 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -2638,6 +2638,10 @@ {"enable-webrtc-hybrid-agc", flag_descriptions::kWebrtcHybridAgcName, flag_descriptions::kWebrtcHybridAgcDescription, kOsAll, FEATURE_VALUE_TYPE(features::kWebRtcHybridAgc)}, + {"enable-webrtc-analog-agc-clipping-control", + flag_descriptions::kWebrtcAnalogAgcClippingControlName, + flag_descriptions::kWebrtcAnalogAgcClippingControlDescription, kOsDesktop, + FEATURE_VALUE_TYPE(features::kWebRtcAnalogAgcClippingControl)}, {"enable-webrtc-hide-local-ips-with-mdns", flag_descriptions::kWebrtcHideLocalIpsWithMdnsName, flag_descriptions::kWebrtcHideLocalIpsWithMdnsDecription, kOsDesktop, @@ -4691,15 +4695,6 @@ FEATURE_VALUE_TYPE(features::kUserMediaScreenCapturing)}, #endif -#if defined(OS_ANDROID) - {"prefetch-notification-scheduling-integration", - flag_descriptions::kPrefetchNotificationSchedulingIntegrationName, - flag_descriptions::kPrefetchNotificationSchedulingIntegrationDescription, - kOsAndroid, - FEATURE_VALUE_TYPE( - chrome::android::kPrefetchNotificationSchedulingIntegration)}, -#endif - #if BUILDFLAG(GOOGLE_CHROME_BRANDING) {"chrome-tips-in-main-menu", flag_descriptions::kChromeTipsInMainMenuName, flag_descriptions::kChromeTipsInMainMenuDescription, kOsDesktop, @@ -4748,16 +4743,6 @@ {"accessible-pdf-form", flag_descriptions::kAccessiblePDFFormName, flag_descriptions::kAccessiblePDFFormDescription, kOsDesktop, FEATURE_VALUE_TYPE(chrome_pdf::features::kAccessiblePDFForm)}, - - {"pdf-viewer-document-properties", - flag_descriptions::kPdfViewerDocumentPropertiesName, - flag_descriptions::kPdfViewerDocumentPropertiesDescription, kOsDesktop, - FEATURE_VALUE_TYPE(chrome_pdf::features::kPdfViewerDocumentProperties)}, - - {"pdf-viewer-presentation-mode", - flag_descriptions::kPdfViewerPresentationModeName, - flag_descriptions::kPdfViewerPresentationModeDescription, kOsDesktop, - FEATURE_VALUE_TYPE(chrome_pdf::features::kPdfViewerPresentationMode)}, #endif // BUILDFLAG(ENABLE_PDF) #if BUILDFLAG(ENABLE_PRINTING) @@ -7197,6 +7182,15 @@ {"enable-generated-webapks", flag_descriptions::kEnableGeneratedWebApksName, flag_descriptions::kEnableGeneratedWebApksDescription, kOsCrOS, FEATURE_VALUE_TYPE(ash::features::kWebApkGenerator)}, + + {"enable-projector-feature-pod", + flag_descriptions::kProjectorFeaturePodName, + flag_descriptions::kProjectorFeaturePodDescription, kOsCrOS, + FEATURE_VALUE_TYPE(ash::features::kProjectorFeaturePod)}, + + {"enable-projector-feature", flag_descriptions::kProjectorName, + flag_descriptions::kProjectorDescription, kOsCrOS, + FEATURE_VALUE_TYPE(ash::features::kProjector)}, #endif // BUILDFLAG(IS_CHROMEOS_ASH) {"use-passthrough-command-decoder",
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 6e0338f..4e221aa 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm
@@ -1187,7 +1187,7 @@ if (g_browser_process->IsShuttingDown()) return; - Profile* lastProfile = [self safeLastProfileForNewWindows]; + Profile* lastProfile = [self safeProfileForNewWindows:[self lastProfile]]; // Handle the case where we're dispatching a command from a sender that's in a // browser window. This means that the command came from a background window @@ -1548,9 +1548,7 @@ return GetLastProfileMac(); } -- (Profile*)safeLastProfileForNewWindows { - Profile* profile = [self lastProfile]; - +- (Profile*)safeProfileForNewWindows:(Profile*)profile { if (!profile) return nullptr; @@ -1563,7 +1561,7 @@ // Returns true if a browser window may be opened for the last active profile. - (bool)canOpenNewBrowser { - Profile* profile = [self safeLastProfileForNewWindows]; + Profile* profile = [self safeProfileForNewWindows:[self lastProfile]]; const PrefService* prefs = g_browser_process->local_state(); return (!profile->IsGuestSession() && !profile->IsEphemeralGuestProfile()) || @@ -1582,7 +1580,7 @@ StartupBrowserCreator::MaybeHandleProfileAgnosticUrls( urls, base::BindOnce(&OpenUrlsInBrowser, urls, - [self safeLastProfileForNewWindows])); + [self safeProfileForNewWindows:[self lastProfile]])); } - (void)getUrl:(NSAppleEventDescriptor*)event @@ -1633,12 +1631,13 @@ // Show the preferences window, or bring it to the front if it's already // visible. - (IBAction)showPreferences:(id)sender { - if (Browser* browser = ActivateBrowser([self lastProfile])) { + Profile* lastProfile = [self lastProfile]; + if (Browser* browser = ActivateBrowser(lastProfile)) { // Show options tab in the active browser window. chrome::ShowSettings(browser); } else if ([self canOpenNewBrowser]) { // No browser window, so create one for the options tab. - chrome::OpenOptionsWindow([self safeLastProfileForNewWindows]); + chrome::OpenOptionsWindow([self safeProfileForNewWindows:lastProfile]); } else { // No way to create a browser, default to the Profile Picker. On profile // selection, it opens the profile on the settings page. @@ -1648,11 +1647,12 @@ } - (IBAction)orderFrontStandardAboutPanel:(id)sender { - if (Browser* browser = ActivateBrowser([self lastProfile])) { + Profile* lastProfile = [self lastProfile]; + if (Browser* browser = ActivateBrowser(lastProfile)) { chrome::ShowAboutChrome(browser); } else if ([self canOpenNewBrowser]) { // No browser window, so create one for the options tab. - chrome::OpenAboutWindow([self safeLastProfileForNewWindows]); + chrome::OpenAboutWindow([self safeProfileForNewWindows:lastProfile]); } else { // No way to create a browser, default to the User Manager. On profile // selection, it opens the profile on chrome help page.
diff --git a/chrome/browser/ash/login/auth/chrome_login_performer.h b/chrome/browser/ash/login/auth/chrome_login_performer.h index 74bb16a..a068a19 100644 --- a/chrome/browser/ash/login/auth/chrome_login_performer.h +++ b/chrome/browser/ash/login/auth/chrome_login_performer.h
@@ -10,7 +10,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/policy/wildcard_login_checker.h" +#include "chrome/browser/chromeos/policy/login/wildcard_login_checker.h" #include "chromeos/login/auth/auth_status_consumer.h" #include "chromeos/login/auth/authenticator.h" #include "chromeos/login/auth/extended_authenticator.h"
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_auth_attempt_unittest.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_auth_attempt_unittest.cc index 34cc7c7a..a0d2f3c 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_auth_attempt_unittest.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_auth_attempt_unittest.cc
@@ -92,7 +92,7 @@ void ShowUserPodCustomIcon( const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon) + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& icon_info) override { ADD_FAILURE() << "Should not be reached."; }
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.cc index f5d620ca..58331a54 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.cc
@@ -173,29 +173,29 @@ return; } - proximity_auth::ScreenlockBridge::UserPodCustomIconOptions icon_options; - icon_options.SetIcon(icon); + proximity_auth::ScreenlockBridge::UserPodCustomIconInfo icon_info; + icon_info.SetIcon(icon); if (HardlockOnClick(state_)) - icon_options.SetHardlockOnClick(); + icon_info.SetHardlockOnClick(); - UpdateTooltipOptions(&icon_options); + UpdateTooltipOptions(&icon_info); // For states without tooltips, we still need to set an accessibility label. if (state_ == ScreenlockState::BLUETOOTH_CONNECTING) { - icon_options.SetAriaLabel( + icon_info.SetAriaLabel( l10n_util::GetStringUTF16(IDS_SMART_LOCK_SPINNER_ACCESSIBILITY_LABEL)); } // Accessibility users may not be able to see the green icon which indicates // the phone is authenticated. Provide message to that effect. if (state_ == ScreenlockState::AUTHENTICATED) { - icon_options.SetAriaLabel(l10n_util::GetStringUTF16( + icon_info.SetAriaLabel(l10n_util::GetStringUTF16( IDS_SMART_LOCK_SCREENLOCK_AUTHENTICATED_LABEL)); } screenlock_bridge_->lock_handler()->ShowUserPodCustomIcon(account_id_, - icon_options); + icon_info); } void EasyUnlockScreenlockStateHandler::SetHardlockState( @@ -278,16 +278,16 @@ if (hardlock_ui_shown_) return; - proximity_auth::ScreenlockBridge::UserPodCustomIconOptions icon_options; + proximity_auth::ScreenlockBridge::UserPodCustomIconInfo icon_info; if (hardlock_state_ == LOGIN_FAILED) { - icon_options.SetIcon( + icon_info.SetIcon( proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED); } else if (hardlock_state_ == PAIRING_CHANGED || hardlock_state_ == PAIRING_ADDED) { - icon_options.SetIcon(proximity_auth::ScreenlockBridge:: - USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED); + icon_info.SetIcon(proximity_auth::ScreenlockBridge:: + USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED); } else { - icon_options.SetIcon( + icon_info.SetIcon( proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_HARDLOCKED); } @@ -332,15 +332,15 @@ pref_manager_->SetHasShownLoginDisabledMessage(true); } - icon_options.SetTooltip(tooltip, autoshow); + icon_info.SetTooltip(tooltip, autoshow); screenlock_bridge_->lock_handler()->ShowUserPodCustomIcon(account_id_, - icon_options); + icon_info); hardlock_ui_shown_ = true; } void EasyUnlockScreenlockStateHandler::UpdateTooltipOptions( - proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options) { + proximity_auth::ScreenlockBridge::UserPodCustomIconInfo* icon_info) { size_t resource_id = 0; std::u16string device_name; resource_id = GetTooltipResourceId(state_); @@ -361,7 +361,7 @@ return; bool autoshow_tooltip = state_ != ScreenlockState::AUTHENTICATED; - icon_options->SetTooltip(tooltip, autoshow_tooltip); + icon_info->SetTooltip(tooltip, autoshow_tooltip); } std::u16string EasyUnlockScreenlockStateHandler::GetDeviceName() {
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.h b/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.h index b1b6fbf..6ad695b 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.h +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler.h
@@ -87,7 +87,7 @@ // Updates icon's tooltip options. void UpdateTooltipOptions( - proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options); + proximity_auth::ScreenlockBridge::UserPodCustomIconInfo* icon_info); // Gets the name to be used for the device. The name depends on the device // type (example values: Chromebook and Chromebox).
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler_unittest.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler_unittest.cc index 0eec7e18..d49c4cb 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler_unittest.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_screenlock_state_handler_unittest.cc
@@ -104,13 +104,13 @@ void ShowUserPodCustomIcon( const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon) + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& icon_info) override { ASSERT_TRUE(account_id_ == account_id) << "account_id_=" << account_id_.Serialize() << " != account_id=" << account_id.Serialize(); ++show_icon_count_; - last_custom_icon_ = icon.ToDictionaryValue(); + last_custom_icon_ = icon_info.ToDictionaryValue(); ValidateCustomIcon(); }
diff --git a/chrome/browser/ash/login/enrollment/enrollment_screen.h b/chrome/browser/ash/login/enrollment/enrollment_screen.h index 3aab32ab..b074a81 100644 --- a/chrome/browser/ash/login/enrollment/enrollment_screen.h +++ b/chrome/browser/ash/login/enrollment/enrollment_screen.h
@@ -21,7 +21,7 @@ #include "chrome/browser/ash/login/screen_manager.h" #include "chrome/browser/ash/login/screens/base_screen.h" #include "chrome/browser/ash/login/wizard_context.h" -#include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_join_delegate.h" #include "chrome/browser/chromeos/policy/enrollment_config.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/policy/core/common/cloud/enterprise_metrics.h"
diff --git a/chrome/browser/ash/login/enrollment/enterprise_enrollment_helper.h b/chrome/browser/ash/login/enrollment/enterprise_enrollment_helper.h index 8d399ac..c92744f 100644 --- a/chrome/browser/ash/login/enrollment/enterprise_enrollment_helper.h +++ b/chrome/browser/ash/login/enrollment/enterprise_enrollment_helper.h
@@ -12,7 +12,7 @@ #include "base/callback_forward.h" #include "base/macros.h" // TODO(https://crbug.com/1164001): move to forward declaration -#include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_join_delegate.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h"
diff --git a/chrome/browser/ash/login/existing_user_controller_browsertest.cc b/chrome/browser/ash/login/existing_user_controller_browsertest.cc index 2c81382..3013c778 100644 --- a/chrome/browser/ash/login/existing_user_controller_browsertest.cc +++ b/chrome/browser/ash/login/existing_user_controller_browsertest.cc
@@ -1368,7 +1368,7 @@ // Set the lock screen so that the managed warning can be queried. screen_locker_tester_.Lock(); - EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( managed_user_.account_id)); // Verify that the lock screen text uses the prefs value for its construction. @@ -1392,7 +1392,7 @@ // Set the lock screen so that the managed warning can be queried. screen_locker_tester_.Lock(); - EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( managed_user_.account_id)); // Verify that the lock screen text uses the prefs value for its construction. @@ -1414,7 +1414,7 @@ screen_locker_tester_.Lock(); // Verify that no managed warning is shown for an unmanaged user. - EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( not_managed_user_.account_id)); }
diff --git a/chrome/browser/ash/login/login_ui_browsertest.cc b/chrome/browser/ash/login/login_ui_browsertest.cc index 5ff9e5a..1ba0efb 100644 --- a/chrome/browser/ash/login/login_ui_browsertest.cc +++ b/chrome/browser/ash/login/login_ui_browsertest.cc
@@ -359,7 +359,7 @@ LoginAndLock(not_managed_user, nullptr); EXPECT_FALSE( ash::LoginScreenTestApi::IsManagedIconShown(not_managed_user.account_id)); - EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( not_managed_user.account_id)); } @@ -369,7 +369,7 @@ EnterpriseIconInvisibleNotManagedUser) { EXPECT_FALSE( ash::LoginScreenTestApi::IsManagedIconShown(not_managed_user.account_id)); - EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( not_managed_user.account_id)); } @@ -380,7 +380,7 @@ LoginAndLock(managed_user, &managed_user_policy_mixin_); EXPECT_TRUE( ash::LoginScreenTestApi::IsManagedIconShown(managed_user.account_id)); - EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( managed_user.account_id)); } @@ -390,7 +390,7 @@ EnterpriseIconVisibleManagedUser) { EXPECT_TRUE( ash::LoginScreenTestApi::IsManagedIconShown(managed_user.account_id)); - EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_TRUE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( managed_user.account_id)); } @@ -414,7 +414,7 @@ screen_locker_tester.Lock(); EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedIconShown( logged_in_user_mixin_.GetAccountId())); - EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( logged_in_user_mixin_.GetAccountId())); } @@ -424,7 +424,7 @@ EnterpriseIconVisibleChildUser) { EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedIconShown( logged_in_user_mixin_.GetAccountId())); - EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInMenuShown( + EXPECT_FALSE(ash::LoginScreenTestApi::IsManagedMessageInDialogShown( logged_in_user_mixin_.GetAccountId())); }
diff --git a/chrome/browser/ash/login/saml/in_session_password_sync_manager.h b/chrome/browser/ash/login/saml/in_session_password_sync_manager.h index 5264c49..89e976b 100644 --- a/chrome/browser/ash/login/saml/in_session_password_sync_manager.h +++ b/chrome/browser/ash/login/saml/in_session_password_sync_manager.h
@@ -113,6 +113,10 @@ // Reset lockscreen re-authentication dialog. void ResetDialog(); + LockScreenStartReauthDialog* get_reauth_dialog_for_testing() { + return lock_screen_start_reauth_dialog_.get(); + } + private: void UpdateOnlineAuth(); void OnCookiesTransfered();
diff --git a/chrome/browser/ash/login/saml/mock_lock_handler.h b/chrome/browser/ash/login/saml/mock_lock_handler.h index 8f7fddb..d13030a 100644 --- a/chrome/browser/ash/login/saml/mock_lock_handler.h +++ b/chrome/browser/ash/login/saml/mock_lock_handler.h
@@ -23,11 +23,11 @@ MOCK_METHOD(void, ShowBannerMessage, (const std::u16string& message, bool is_warning)); - MOCK_METHOD( - void, - ShowUserPodCustomIcon, - (const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon)); + MOCK_METHOD(void, + ShowUserPodCustomIcon, + (const AccountId& account_id, + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& + icon_info)); MOCK_METHOD(void, HideUserPodCustomIcon, (const AccountId& account_id)); MOCK_METHOD(void, EnableInput, ()); MOCK_METHOD(void,
diff --git a/chrome/browser/ash/login/saml/saml_lockscreen_browsertest.cc b/chrome/browser/ash/login/saml/saml_lockscreen_browsertest.cc new file mode 100644 index 0000000..310b24a --- /dev/null +++ b/chrome/browser/ash/login/saml/saml_lockscreen_browsertest.cc
@@ -0,0 +1,220 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/constants/ash_features.h" +#include "ash/constants/ash_switches.h" +#include "base/run_loop.h" +#include "base/test/scoped_feature_list.h" +#include "chrome/browser/ash/login/lock/screen_locker_tester.h" +#include "chrome/browser/ash/login/saml/fake_saml_idp_mixin.h" +#include "chrome/browser/ash/login/saml/in_session_password_sync_manager.h" +#include "chrome/browser/ash/login/saml/in_session_password_sync_manager_factory.h" +#include "chrome/browser/ash/login/session/user_session_manager_test_api.h" +#include "chrome/browser/ash/profiles/profile_helper.h" +#include "chrome/browser/ash/login/login_pref_names.h" +#include "chrome/browser/ash/login/test/js_checker.h" +#include "chrome/browser/ash/login/test/logged_in_user_mixin.h" +#include "chrome/browser/ash/login/test/test_condition_waiter.h" +#include "chrome/browser/ash/login/users/test_users.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h" +#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h" +#include "chrome/browser/ui/webui/signin/signin_utils.h" +#include "chrome/test/base/mixin_based_in_process_browser_test.h" +#include "chromeos/dbus/shill/fake_shill_manager_client.h" +#include "components/account_id/account_id.h" +#include "components/network_session_configurator/common/network_switches.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/test_utils.h" +#include "net/dns/mock_host_resolver.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace chromeos { + +namespace { +const test::UIPath kSamlContainer = {"main-element", "body"}; +const test::UIPath kMainVerifyButton = {"main-element", + "nextButtonVerifyScreen"}; +const test::UIPath kMainScreen = {"main-element", "verifyAccountScreen"}; +const std::string kSigninFrame = "signin-frame"; + +constexpr char kTestAuthSIDCookie1[] = "fake-auth-SID-cookie-1"; +constexpr char kTestAuthLSIDCookie1[] = "fake-auth-LSID-cookie-1"; +constexpr char kTestRefreshToken[] = "fake-refresh-token"; +} // namespace + +class LockscreenWebUiTest : public MixinBasedInProcessBrowserTest { + public: + LockscreenWebUiTest() { + feature_list_.InitAndEnableFeature( + features::kEnableSamlReauthenticationOnLockscreen); + } + + LockscreenWebUiTest(const LockscreenWebUiTest&) = delete; + LockscreenWebUiTest& operator=(const LockscreenWebUiTest&) = delete; + + ~LockscreenWebUiTest() override = default; + + void SetUpCommandLine(base::CommandLine* command_line) override { + command_line->AppendSwitch( + chromeos::switches::kAllowFailedPolicyFetchForTest); + // TODO(crbug.com/1177416) - Fix this with a proper SSL solution. + command_line->AppendSwitch(::switches::kIgnoreCertificateErrors); + + MixinBasedInProcessBrowserTest::SetUpCommandLine(command_line); + } + + void SetUpOnMainThread() override { + ShillManagerClient::Get()->GetTestInterface()->SetupDefaultEnvironment(); + + host_resolver()->AddRule("*", "127.0.0.1"); + + test::UserSessionManagerTestApi session_manager_test_api( + UserSessionManager::GetInstance()); + session_manager_test_api.SetShouldObtainTokenHandleInTests(false); + + fake_gaia_mixin()->fake_gaia()->RegisterSamlUser( + chromeos::FakeGaiaMixin::kEnterpriseUser1, + fake_saml_idp_.GetSamlPageUrl()); + + fake_gaia_mixin()->set_initialize_fake_merge_session(false); + fake_gaia_mixin()->fake_gaia()->SetFakeMergeSessionParams( + chromeos::FakeGaiaMixin::kEnterpriseUser1, kTestAuthSIDCookie1, + kTestAuthLSIDCookie1); + fake_gaia_mixin()->SetupFakeGaiaForLogin( + chromeos::FakeGaiaMixin::kEnterpriseUser1, "", kTestRefreshToken); + + MixinBasedInProcessBrowserTest::SetUpOnMainThread(); + } + + void Login() { logged_in_user_mixin_.LogInUser(); } + + void ShowDialogAndWait() { + password_sync_manager_ = + InSessionPasswordSyncManagerFactory::GetForProfile( + ProfileManager::GetActiveUserProfile()); + ProfileManager::GetActiveUserProfile()->GetPrefs()->SetBoolean( + prefs::kLockScreenReauthenticationEnabled, true); + ASSERT_TRUE(password_sync_manager_); + password_sync_manager_->CreateAndShowDialog(); + base::RunLoop().RunUntilIdle(); + + // Fetch the dialog, WebUi controller and main message handler. + reauth_dialog_ = password_sync_manager_->get_reauth_dialog_for_testing(); + ASSERT_TRUE(reauth_dialog_); + reauth_webui_controller_ = static_cast<LockScreenStartReauthUI*>( + reauth_dialog_->GetWebUIForTest()->GetController()); + ASSERT_TRUE(reauth_webui_controller_); + main_handler_ = reauth_webui_controller_->GetMainHandlerForTests(); + ASSERT_TRUE(main_handler_); + main_handler_->force_saml_redirect_for_testing(); + + WaitForWebUi(); + } + + void LockscreenAndShowDialog() { + Login(); + ScreenLockerTester().Lock(); + base::RunLoop().RunUntilIdle(); + ShowDialogAndWait(); + } + + void WaitForWebUi() { + base::RunLoop run_loop; + if (!main_handler_->IsJsReadyForTesting(run_loop.QuitClosure())) { + run_loop.Run(); + } + } + + void WaitForAuthenticatorToLoad() { + base::RunLoop run_loop; + if (!main_handler_->IsAuthenticatorLoaded(run_loop.QuitClosure())) { + run_loop.Run(); + }; + } + + void WaitForIdpPageLoad() { + content::DOMMessageQueue message_queue; + content::ExecuteScriptAsync( + reauth_dialog_->GetWebUIForTest()->GetWebContents(), + R"($('main-element').authenticator_.addEventListener('authFlowChange', + function f() { + $('main-element').authenticator_.removeEventListener( + 'authFlowChange', f); + window.domAutomationController.send('Loaded'); + });)"); + std::string message; + do { + ASSERT_TRUE(message_queue.WaitForMessage(&message)); + } while (message != "\"Loaded\""); + } + + test::JSChecker JS() { + return test::JSChecker(reauth_dialog_->GetWebUIForTest()->GetWebContents()); + } + + test::JSChecker SigninFrameJS() { + content::RenderFrameHost* frame = signin::GetAuthFrame( + reauth_dialog_->GetWebUIForTest()->GetWebContents(), kSigninFrame); + CHECK(frame && frame->IsDOMContentLoaded()); + test::JSChecker result = test::JSChecker(frame); + return result; + } + + FakeSamlIdpMixin* fake_saml_idp() { return &fake_saml_idp_; } + + FakeGaiaMixin* fake_gaia_mixin() { + return logged_in_user_mixin_.GetFakeGaiaMixin(); + } + + protected: + base::test::ScopedFeatureList feature_list_; + + private: + chromeos::InSessionPasswordSyncManager* password_sync_manager_ = nullptr; + chromeos::LockScreenStartReauthDialog* reauth_dialog_ = nullptr; + LockScreenStartReauthUI* reauth_webui_controller_ = nullptr; + LockScreenReauthHandler* main_handler_ = nullptr; + + chromeos::LoggedInUserMixin logged_in_user_mixin_{ + &mixin_host_, + LoggedInUserMixin::LogInType::kRegular, + embedded_test_server(), + /*test_base=*/this, + true /*should_launch_browser*/, + AccountId::FromUserEmailGaiaId( + chromeos::FakeGaiaMixin::kEnterpriseUser1, + chromeos::FakeGaiaMixin::kEnterpriseUser1GaiaId), + true /*include_initial_user*/}; + + FakeSamlIdpMixin fake_saml_idp_{&mixin_host_, fake_gaia_mixin()}; +}; + +IN_PROC_BROWSER_TEST_F(LockscreenWebUiTest, Login) { + fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); + + LockscreenAndShowDialog(); + + // Expect the main screen to be visible and proceed to the SAML page. + JS().ExpectVisiblePath(kMainScreen); + JS().TapOnPath(kMainVerifyButton); + WaitForAuthenticatorToLoad(); + + JS().ExpectVisiblePath(kSamlContainer); + JS().ExpectHiddenPath(kMainScreen); + base::RunLoop().RunUntilIdle(); + + WaitForIdpPageLoad(); + + // Fill-in the SAML IdP form and submit. + SigninFrameJS().CreateVisibilityWaiter(true, {"Email"})->Wait(); + SigninFrameJS().TypeIntoPath(chromeos::FakeGaiaMixin::kEnterpriseUser1, {"Email"}); + SigninFrameJS().TypeIntoPath("actual_password", {"Password"}); + SigninFrameJS().TapOn("Submit"); + + ScreenLockerTester().WaitForUnlock(); +} + +} // namespace chromeos
diff --git a/chrome/browser/ash/login/screens/os_install_screen.cc b/chrome/browser/ash/login/screens/os_install_screen.cc index 5ec9032..14a64ff 100644 --- a/chrome/browser/ash/login/screens/os_install_screen.cc +++ b/chrome/browser/ash/login/screens/os_install_screen.cc
@@ -8,6 +8,14 @@ namespace chromeos { +namespace { + +constexpr const char kUserActionIntroNextClicked[] = "os-install-intro-next"; +constexpr const char kUserActionConfirmNextClicked[] = + "os-install-confirm-next"; + +} // namespace + OsInstallScreen::OsInstallScreen(OsInstallScreenView* view) : BaseScreen(OsInstallScreenView::kScreenId, OobeScreenPriority::DEFAULT), view_(view) { @@ -34,4 +42,14 @@ void OsInstallScreen::HideImpl() {} +void OsInstallScreen::OnUserAction(const std::string& action_id) { + if (action_id == kUserActionIntroNextClicked) { + view_->ShowConfirmStep(); + } else if (action_id == kUserActionConfirmNextClicked) { + view_->StartInstall(); + } else { + BaseScreen::OnUserAction(action_id); + } +} + } // namespace chromeos
diff --git a/chrome/browser/ash/login/screens/os_install_screen.h b/chrome/browser/ash/login/screens/os_install_screen.h index 239e477..7210887 100644 --- a/chrome/browser/ash/login/screens/os_install_screen.h +++ b/chrome/browser/ash/login/screens/os_install_screen.h
@@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_SCREENS_OS_INSTALL_SCREEN_H_ #define CHROME_BROWSER_ASH_LOGIN_SCREENS_OS_INSTALL_SCREEN_H_ +#include <string> + #include "chrome/browser/ash/login/screens/base_screen.h" namespace chromeos { @@ -24,6 +26,7 @@ // BaseScreen: void ShowImpl() override; void HideImpl() override; + void OnUserAction(const std::string& action_id) override; OsInstallScreenView* view_ = nullptr; };
diff --git a/chrome/browser/ash/login/screens/os_install_screen_browsertest.cc b/chrome/browser/ash/login/screens/os_install_screen_browsertest.cc index 390257bf..bad7cc70 100644 --- a/chrome/browser/ash/login/screens/os_install_screen_browsertest.cc +++ b/chrome/browser/ash/login/screens/os_install_screen_browsertest.cc
@@ -18,6 +18,11 @@ const test::UIPath kWelcomeScreen = {"connect", "welcomeScreen"}; const test::UIPath kOsInstallButton = {"connect", "welcomeScreen", "osInstall"}; +const test::UIPath kOsInstallIntroNextButton = {"os-install", + "osInstallIntroNextButton"}; +const test::UIPath kOsInstallConfirmNextButton = {"os-install", + "osInstallConfirmNextButton"}; + } // namespace class OsInstallScreenTest : public OobeBaseTest { @@ -26,6 +31,12 @@ OobeBaseTest::SetUpCommandLine(command_line); command_line->AppendSwitch(switches::kAllowOsInstall); } + + void AdvanceToOsInstallScreen() { + OobeScreenWaiter(WelcomeView::kScreenId).Wait(); + test::OobeJS().TapOnPath(kOsInstallButton); + OobeScreenWaiter(OsInstallScreenView::kScreenId).Wait(); + } }; // If the kAllowOsInstall switch is not set, the welcome screen should @@ -46,14 +57,19 @@ test::OobeJS().ExpectVisiblePath(kOsInstallButton); } -// Clicking the OS install button should exit the welcome screen and -// start the OS install flow. -IN_PROC_BROWSER_TEST_F(OsInstallScreenTest, StartOsInstallFlow) { - OobeScreenWaiter(WelcomeView::kScreenId).Wait(); +// Clicking the next buttons should advance from the intro step to the +// confirm step, then to the in-progress step. +IN_PROC_BROWSER_TEST_F(OsInstallScreenTest, OsInstallSteps) { + const std::string current_step = "login.OsInstallScreen.currentUIStep()"; - test::OobeJS().TapOnPath(kOsInstallButton); + AdvanceToOsInstallScreen(); + test::OobeJS().ExpectEQ(current_step, std::string("intro")); - OobeScreenWaiter(OsInstallScreenView::kScreenId).Wait(); + test::OobeJS().TapOnPath(kOsInstallIntroNextButton); + test::OobeJS().ExpectEQ(current_step, std::string("confirm")); + + test::OobeJS().TapOnPath(kOsInstallConfirmNextButton); + test::OobeJS().ExpectEQ(current_step, std::string("in_progress")); } } // namespace chromeos
diff --git a/chrome/browser/ash/login/screens/user_selection_screen.cc b/chrome/browser/ash/login/screens/user_selection_screen.cc index cf76b029..5fbad2c1 100644 --- a/chrome/browser/ash/login/screens/user_selection_screen.cc +++ b/chrome/browser/ash/login/screens/user_selection_screen.cc
@@ -767,9 +767,8 @@ void UserSelectionScreen::ShowUserPodCustomIcon( const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& - icon_options) { - view_->ShowUserPodCustomIcon(account_id, icon_options); + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& icon_info) { + view_->ShowUserPodCustomIcon(account_id, icon_info); } void UserSelectionScreen::HideUserPodCustomIcon(const AccountId& account_id) {
diff --git a/chrome/browser/ash/login/screens/user_selection_screen.h b/chrome/browser/ash/login/screens/user_selection_screen.h index 7b0a32b..84fa141 100644 --- a/chrome/browser/ash/login/screens/user_selection_screen.h +++ b/chrome/browser/ash/login/screens/user_selection_screen.h
@@ -78,7 +78,7 @@ bool is_warning) override; void ShowUserPodCustomIcon( const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon) + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& icon_info) override; void HideUserPodCustomIcon(const AccountId& account_id) override;
diff --git a/chrome/browser/ash/login/test/enrollment_helper_mixin.cc b/chrome/browser/ash/login/test/enrollment_helper_mixin.cc index 8e74706..224031e 100644 --- a/chrome/browser/ash/login/test/enrollment_helper_mixin.cc +++ b/chrome/browser/ash/login/test/enrollment_helper_mixin.cc
@@ -9,7 +9,7 @@ #include "chrome/browser/ash/login/enrollment/enterprise_enrollment_helper.h" #include "chrome/browser/ash/login/enrollment/enterprise_enrollment_helper_mock.h" #include "chrome/browser/ash/login/wizard_controller.h" -#include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_join_delegate.h" using testing::_; using testing::AtLeast;
diff --git a/chrome/browser/ash/login/ui/views/user_board_view.h b/chrome/browser/ash/login/ui/views/user_board_view.h index b8ea522e..c653045 100644 --- a/chrome/browser/ash/login/ui/views/user_board_view.h +++ b/chrome/browser/ash/login/ui/views/user_board_view.h
@@ -45,8 +45,8 @@ bool is_warning) = 0; virtual void ShowUserPodCustomIcon( const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& - icon) = 0; + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& + icon_info) = 0; virtual void HideUserPodCustomIcon(const AccountId& account_id) = 0; virtual void SetAuthType(const AccountId& account_id, proximity_auth::mojom::AuthType auth_type,
diff --git a/chrome/browser/ash/login/user_board_view_mojo.cc b/chrome/browser/ash/login/user_board_view_mojo.cc index f2834f1..3bde322 100644 --- a/chrome/browser/ash/login/user_board_view_mojo.cc +++ b/chrome/browser/ash/login/user_board_view_mojo.cc
@@ -16,49 +16,50 @@ namespace { -ash::EasyUnlockIconId GetEasyUnlockIconIdFromUserPodCustomIconId( +ash::EasyUnlockIconState GetEasyUnlockIconStateFromUserPodCustomIconId( proximity_auth::ScreenlockBridge::UserPodCustomIcon icon) { switch (icon) { case proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE: - return ash::EasyUnlockIconId::NONE; + return ash::EasyUnlockIconState::NONE; case proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_HARDLOCKED: - return ash::EasyUnlockIconId::HARDLOCKED; + return ash::EasyUnlockIconState::HARDLOCKED; case proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED: - return ash::EasyUnlockIconId::LOCKED; + return ash::EasyUnlockIconState::LOCKED; case proximity_auth::ScreenlockBridge:: USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED: - return ash::EasyUnlockIconId::LOCKED_TO_BE_ACTIVATED; + return ash::EasyUnlockIconState::LOCKED_TO_BE_ACTIVATED; case proximity_auth::ScreenlockBridge:: USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT: - return ash::EasyUnlockIconId::LOCKED_WITH_PROXIMITY_HINT; + return ash::EasyUnlockIconState::LOCKED_WITH_PROXIMITY_HINT; case proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED: - return ash::EasyUnlockIconId::UNLOCKED; + return ash::EasyUnlockIconState::UNLOCKED; case proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER: - return ash::EasyUnlockIconId::SPINNER; + return ash::EasyUnlockIconState::SPINNER; } } // Converts parameters to a mojo struct that can be sent to the // screenlock view-based UI. -ash::EasyUnlockIconOptions ToEasyUnlockIconOptions( - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& - icon_options) { - ash::EasyUnlockIconOptions options; - options.icon = - GetEasyUnlockIconIdFromUserPodCustomIconId(icon_options.icon()); +ash::EasyUnlockIconInfo ToEasyUnlockIconInfo( + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& + user_pod_icon_info) { + ash::EasyUnlockIconInfo easy_unlock_icon_info; + easy_unlock_icon_info.icon_state = + GetEasyUnlockIconStateFromUserPodCustomIconId(user_pod_icon_info.icon()); - if (!icon_options.tooltip().empty()) { - options.tooltip = icon_options.tooltip(); - options.autoshow_tooltip = icon_options.autoshow_tooltip(); + if (!user_pod_icon_info.tooltip().empty()) { + easy_unlock_icon_info.tooltip = user_pod_icon_info.tooltip(); + easy_unlock_icon_info.autoshow_tooltip = + user_pod_icon_info.autoshow_tooltip(); } - if (!icon_options.aria_label().empty()) - options.aria_label = icon_options.aria_label(); + if (!user_pod_icon_info.aria_label().empty()) + easy_unlock_icon_info.aria_label = user_pod_icon_info.aria_label(); - if (icon_options.hardlock_on_click()) - options.hardlock_on_click = true; + if (user_pod_icon_info.hardlock_on_click()) + easy_unlock_icon_info.hardlock_on_click = true; - return options; + return easy_unlock_icon_info; } } // namespace @@ -109,10 +110,9 @@ void UserBoardViewMojo::ShowUserPodCustomIcon( const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& - icon_options) { + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& icon_info) { ash::LoginScreen::Get()->GetModel()->ShowEasyUnlockIcon( - account_id, ToEasyUnlockIconOptions(icon_options)); + account_id, ToEasyUnlockIconInfo(icon_info)); } void UserBoardViewMojo::HideUserPodCustomIcon(const AccountId& account_id) {
diff --git a/chrome/browser/ash/login/user_board_view_mojo.h b/chrome/browser/ash/login/user_board_view_mojo.h index aabc5fa..749f1ab8 100644 --- a/chrome/browser/ash/login/user_board_view_mojo.h +++ b/chrome/browser/ash/login/user_board_view_mojo.h
@@ -30,7 +30,7 @@ bool is_warning) override; void ShowUserPodCustomIcon( const AccountId& account_id, - const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon) + const proximity_auth::ScreenlockBridge::UserPodCustomIconInfo& icon_info) override; void HideUserPodCustomIcon(const AccountId& account_id) override; void SetAuthType(const AccountId& account_id,
diff --git a/chrome/browser/cart/commerce_hint_service.cc b/chrome/browser/cart/commerce_hint_service.cc index fb18e7b31..a259ae22 100644 --- a/chrome/browser/cart/commerce_hint_service.cc +++ b/chrome/browser/cart/commerce_hint_service.cc
@@ -16,7 +16,7 @@ #include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "components/search/ntp_features.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_user_data.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h" @@ -82,13 +82,13 @@ // Implementation of the Mojo CommerceHintObserver. This is called by the // renderer to notify the browser that a commerce hint happens. class CommerceHintObserverImpl - : public content::FrameServiceBase<mojom::CommerceHintObserver> { + : public content::DocumentServiceBase<mojom::CommerceHintObserver> { public: explicit CommerceHintObserverImpl( content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<mojom::CommerceHintObserver> receiver, base::WeakPtr<CommerceHintService> service) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), binding_url_(render_frame_host->GetLastCommittedURL()), service_(std::move(service)) {} @@ -166,7 +166,7 @@ content::RenderFrameHost* host, mojo::PendingReceiver<mojom::CommerceHintObserver> receiver) { // The object is bound to the lifetime of |host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new CommerceHintObserverImpl(host, std::move(receiver), weak_factory_.GetWeakPtr()); }
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index 86e4886..406bdea1 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -2563,9 +2563,13 @@ "platform_keys/platform_keys_service_factory.cc", "platform_keys/platform_keys_service_factory.h", "platform_keys/platform_keys_service_nss.cc", - "policy/active_directory_join_delegate.h", - "policy/active_directory_policy_manager.cc", - "policy/active_directory_policy_manager.h", + "policy/active_directory/active_directory_join_delegate.h", + "policy/active_directory/active_directory_policy_manager.cc", + "policy/active_directory/active_directory_policy_manager.h", + "policy/active_directory/component_active_directory_policy_retriever.cc", + "policy/active_directory/component_active_directory_policy_retriever.h", + "policy/active_directory/component_active_directory_policy_service.cc", + "policy/active_directory/component_active_directory_policy_service.h", "policy/adb_sideloading_allowance_mode_policy_handler.cc", "policy/adb_sideloading_allowance_mode_policy_handler.h", "policy/affiliated_cloud_policy_invalidator.cc", @@ -2585,10 +2589,6 @@ "policy/browser_policy_connector_chromeos.h", "policy/cached_policy_key_loader_chromeos.cc", "policy/cached_policy_key_loader_chromeos.h", - "policy/component_active_directory_policy_retriever.cc", - "policy/component_active_directory_policy_retriever.h", - "policy/component_active_directory_policy_service.cc", - "policy/component_active_directory_policy_service.h", "policy/configuration_policy_handler_chromeos.cc", "policy/configuration_policy_handler_chromeos.h", "policy/device_cloud_policy_initializer.cc", @@ -2707,8 +2707,12 @@ "policy/lacros_availability_policy_handler.h", "policy/lock_to_single_user_manager.cc", "policy/lock_to_single_user_manager.h", - "policy/login_profile_policy_provider.cc", - "policy/login_profile_policy_provider.h", + "policy/login/login_profile_policy_provider.cc", + "policy/login/login_profile_policy_provider.h", + "policy/login/secondary_google_account_signin_policy_handler.cc", + "policy/login/secondary_google_account_signin_policy_handler.h", + "policy/login/wildcard_login_checker.cc", + "policy/login/wildcard_login_checker.h", "policy/minimum_version_policy_handler.cc", "policy/minimum_version_policy_handler.h", "policy/minimum_version_policy_handler_delegate_impl.cc", @@ -2820,8 +2824,6 @@ "policy/scheduled_update_checker/scoped_wake_lock.h", "policy/scheduled_update_checker/task_executor_with_retries.cc", "policy/scheduled_update_checker/task_executor_with_retries.h", - "policy/secondary_google_account_signin_policy_handler.cc", - "policy/secondary_google_account_signin_policy_handler.h", "policy/server_backed_state/device_cloud_state_keys_uploader.cc", "policy/server_backed_state/device_cloud_state_keys_uploader.h", "policy/server_backed_state/server_backed_device_state.cc", @@ -2877,8 +2879,6 @@ "policy/value_validation/onc_policy_value_validator_base.h", "policy/value_validation/onc_user_policy_value_validator.cc", "policy/value_validation/onc_user_policy_value_validator.h", - "policy/wildcard_login_checker.cc", - "policy/wildcard_login_checker.h", "preferences.cc", "preferences.h", "printing/automatic_usb_printer_configurer.cc", @@ -4068,7 +4068,9 @@ "phonehub/browser_tabs_model_provider_impl_unittest.cc", "platform_keys/key_permissions/arc_key_permissions_manager_delegate_unittest.cc", "platform_keys/key_permissions/key_permissions_service_impl_unittest.cc", - "policy/active_directory_policy_manager_unittest.cc", + "policy/active_directory/active_directory_policy_manager_unittest.cc", + "policy/active_directory/component_active_directory_policy_retriever_unittest.cc", + "policy/active_directory/component_active_directory_policy_service_unittest.cc", "policy/adb_sideloading_allowance_mode_policy_handler_unittest.cc", "policy/affiliated_cloud_policy_invalidator_unittest.cc", "policy/affiliated_invalidation_service_provider_impl_unittest.cc", @@ -4076,8 +4078,6 @@ "policy/auto_enrollment_client_impl_unittest.cc", "policy/bluetooth_policy_handler_unittest.cc", "policy/cached_policy_key_loader_chromeos_unittest.cc", - "policy/component_active_directory_policy_retriever_unittest.cc", - "policy/component_active_directory_policy_service_unittest.cc", "policy/configuration_policy_handler_chromeos_unittest.cc", "policy/device_cloud_policy_initializer_unittest.cc", "policy/device_cloud_policy_manager_chromeos_unittest.cc", @@ -4112,6 +4112,7 @@ "policy/heartbeat_scheduler_unittest.cc", "policy/hostname_handler_unittest.cc", "policy/lock_to_single_user_manager_unittest.cc", + "policy/login/secondary_google_account_signin_policy_handler_unittest.cc", "policy/minimum_version_policy_handler_unittest.cc", "policy/networking/network_configuration_updater_unittest.cc", "policy/off_hours/device_off_hours_controller_unittest.cc", @@ -4144,7 +4145,6 @@ "policy/reporting/single_arc_app_install_event_log_unittest.cc", "policy/rsu/lookup_key_uploader_unittest.cc", "policy/scheduled_update_checker/device_scheduled_update_checker_unittest.cc", - "policy/secondary_google_account_signin_policy_handler_unittest.cc", "policy/server_backed_state/device_cloud_state_keys_uploader_unittest.cc", "policy/server_backed_state/server_backed_state_keys_broker_unittest.cc", "policy/status_collector/activity_storage_unittest.cc", @@ -4574,18 +4574,21 @@ sources = [ "policy/fuzzer/policy_fuzzer.proto" ] import_dirs = [ + # Add the fuzzable (full-protobuf) .pb.h files into include directories. + # This item should come first, so that regular (lite-protobuf) .pb.h + # analogs don't get included, as this would cause compilation issues due + # to missing symbols. + "//components/policy/proto/fuzzer", + + # For imports of proto files from the source tree. "//components/policy/proto", + + # For imports of autogenerated proto files. "$root_gen_dir/components/policy/proto", ] - proto_deps = [ - "//components/policy:cloud_policy_full_runtime_proto", - "//components/policy/proto:chrome_device_policy_full_runtime_proto", - ] + proto_deps = [ "//components/policy/proto/fuzzer" ] - link_deps = [ - "//components/policy:cloud_policy_full_runtime_proto", - "//components/policy/proto:chrome_device_policy_full_runtime_proto", - ] + link_deps = [ "//components/policy/proto/fuzzer" ] } }
diff --git a/chrome/browser/chromeos/extensions/login_screen/login_screen_apitest_base.h b/chrome/browser/chromeos/extensions/login_screen/login_screen_apitest_base.h index f778d54a0..bf591f9 100644 --- a/chrome/browser/chromeos/extensions/login_screen/login_screen_apitest_base.h +++ b/chrome/browser/chromeos/extensions/login_screen/login_screen_apitest_base.h
@@ -9,7 +9,7 @@ #include <string> #include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h" #include "components/version_info/version_info.h" class ExtensionTestMessageListener;
diff --git a/chrome/browser/chromeos/extensions/login_screen/login_screen_ui/login_screen_ui_apitest.cc b/chrome/browser/chromeos/extensions/login_screen/login_screen_ui/login_screen_ui_apitest.cc index b8045055..48ef635 100644 --- a/chrome/browser/chromeos/extensions/login_screen/login_screen_ui/login_screen_ui_apitest.cc +++ b/chrome/browser/chromeos/extensions/login_screen/login_screen_ui/login_screen_ui_apitest.cc
@@ -9,7 +9,7 @@ #include "chrome/browser/ash/login/ui/login_screen_extension_ui/window.h" #include "chrome/browser/chromeos/extensions/login_screen/login_screen_apitest_base.h" #include "chrome/browser/chromeos/extensions/login_screen/login_screen_ui/ui_handler.h" -#include "chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h" #include "components/version_info/version_info.h" #include "content/public/test/browser_test.h" #include "ui/views/widget/widget.h"
diff --git a/chrome/browser/chromeos/policy/active_directory_join_delegate.h b/chrome/browser/chromeos/policy/active_directory/active_directory_join_delegate.h similarity index 84% rename from chrome/browser/chromeos/policy/active_directory_join_delegate.h rename to chrome/browser/chromeos/policy/active_directory/active_directory_join_delegate.h index 648e041..41cbb468 100644 --- a/chrome/browser/chromeos/policy/active_directory_join_delegate.h +++ b/chrome/browser/chromeos/policy/active_directory/active_directory_join_delegate.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_JOIN_DELEGATE_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_JOIN_DELEGATE_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_ACTIVE_DIRECTORY_JOIN_DELEGATE_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_ACTIVE_DIRECTORY_JOIN_DELEGATE_H_ #include <string> @@ -46,4 +46,4 @@ using ::chromeos::OnDomainJoinedCallback; } // namespace ash -#endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_JOIN_DELEGATE_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_ACTIVE_DIRECTORY_JOIN_DELEGATE_H_
diff --git a/chrome/browser/chromeos/policy/active_directory_policy_manager.cc b/chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.cc similarity index 99% rename from chrome/browser/chromeos/policy/active_directory_policy_manager.cc rename to chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.cc index 8ed5329..1702cb6 100644 --- a/chrome/browser/chromeos/policy/active_directory_policy_manager.cc +++ b/chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include <string> #include <utility>
diff --git a/chrome/browser/chromeos/policy/active_directory_policy_manager.h b/chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h similarity index 95% rename from chrome/browser/chromeos/policy/active_directory_policy_manager.h rename to chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h index 392bf891..c76ee9b6 100644 --- a/chrome/browser/chromeos/policy/active_directory_policy_manager.h +++ b/chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ #include <memory> @@ -12,7 +12,7 @@ #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "base/timer/timer.h" -#include "chrome/browser/chromeos/policy/component_active_directory_policy_service.h" +#include "chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.h" #include "components/account_id/account_id.h" #include "components/policy/core/common/cloud/cloud_policy_store.h" #include "components/policy/core/common/configuration_policy_provider.h" @@ -240,4 +240,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_
diff --git a/chrome/browser/chromeos/policy/active_directory_policy_manager_unittest.cc b/chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager_unittest.cc similarity index 99% rename from chrome/browser/chromeos/policy/active_directory_policy_manager_unittest.cc rename to chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager_unittest.cc index beab1c1b..51a3f26 100644 --- a/chrome/browser/chromeos/policy/active_directory_policy_manager_unittest.cc +++ b/chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include <memory> #include <string>
diff --git a/chrome/browser/chromeos/policy/component_active_directory_policy_browsertest.cc b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_browsertest.cc similarity index 100% rename from chrome/browser/chromeos/policy/component_active_directory_policy_browsertest.cc rename to chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_browsertest.cc
diff --git a/chrome/browser/chromeos/policy/component_active_directory_policy_retriever.cc b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.cc similarity index 96% rename from chrome/browser/chromeos/policy/component_active_directory_policy_retriever.cc rename to chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.cc index 1483a2e5..b66ab68c 100644 --- a/chrome/browser/chromeos/policy/component_active_directory_policy_retriever.cc +++ b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/component_active_directory_policy_retriever.h" +#include "chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.h" #include "base/bind.h" #include "base/logging.h"
diff --git a/chrome/browser/chromeos/policy/component_active_directory_policy_retriever.h b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.h similarity index 91% rename from chrome/browser/chromeos/policy/component_active_directory_policy_retriever.h rename to chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.h index f06da7c..1e51c5bc 100644 --- a/chrome/browser/chromeos/policy/component_active_directory_policy_retriever.h +++ b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_COMPONENT_ACTIVE_DIRECTORY_POLICY_RETRIEVER_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_COMPONENT_ACTIVE_DIRECTORY_POLICY_RETRIEVER_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_COMPONENT_ACTIVE_DIRECTORY_POLICY_RETRIEVER_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_COMPONENT_ACTIVE_DIRECTORY_POLICY_RETRIEVER_H_ #include <string> #include <vector> @@ -91,4 +91,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_COMPONENT_ACTIVE_DIRECTORY_POLICY_RETRIEVER_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_COMPONENT_ACTIVE_DIRECTORY_POLICY_RETRIEVER_H_
diff --git a/chrome/browser/chromeos/policy/component_active_directory_policy_retriever_unittest.cc b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever_unittest.cc similarity index 97% rename from chrome/browser/chromeos/policy/component_active_directory_policy_retriever_unittest.cc rename to chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever_unittest.cc index b651555..42398a0f 100644 --- a/chrome/browser/chromeos/policy/component_active_directory_policy_retriever_unittest.cc +++ b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/component_active_directory_policy_retriever.h" +#include "chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.h" #include "base/bind.h" #include "base/test/task_environment.h"
diff --git a/chrome/browser/chromeos/policy/component_active_directory_policy_service.cc b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.cc similarity index 98% rename from chrome/browser/chromeos/policy/component_active_directory_policy_service.cc rename to chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.cc index 92c1364..217fe34 100644 --- a/chrome/browser/chromeos/policy/component_active_directory_policy_service.cc +++ b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/component_active_directory_policy_service.h" +#include "chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.h" #include <iterator>
diff --git a/chrome/browser/chromeos/policy/component_active_directory_policy_service.h b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.h similarity index 91% rename from chrome/browser/chromeos/policy/component_active_directory_policy_service.h rename to chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.h index 2075d67..1cd3aaa 100644 --- a/chrome/browser/chromeos/policy/component_active_directory_policy_service.h +++ b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_COMPONENT_ACTIVE_DIRECTORY_POLICY_SERVICE_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_COMPONENT_ACTIVE_DIRECTORY_POLICY_SERVICE_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_COMPONENT_ACTIVE_DIRECTORY_POLICY_SERVICE_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_COMPONENT_ACTIVE_DIRECTORY_POLICY_SERVICE_H_ #include <memory> #include <string> @@ -13,7 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" -#include "chrome/browser/chromeos/policy/component_active_directory_policy_retriever.h" +#include "chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_retriever.h" #include "components/policy/core/common/policy_namespace.h" #include "components/policy/core/common/policy_types.h" #include "components/policy/core/common/schema_registry.h" @@ -129,4 +129,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_COMPONENT_ACTIVE_DIRECTORY_POLICY_SERVICE_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_COMPONENT_ACTIVE_DIRECTORY_POLICY_SERVICE_H_
diff --git a/chrome/browser/chromeos/policy/component_active_directory_policy_service_unittest.cc b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service_unittest.cc similarity index 99% rename from chrome/browser/chromeos/policy/component_active_directory_policy_service_unittest.cc rename to chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service_unittest.cc index 889ae9b0..ab119f9 100644 --- a/chrome/browser/chromeos/policy/component_active_directory_policy_service_unittest.cc +++ b/chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/component_active_directory_policy_service.h" +#include "chrome/browser/chromeos/policy/active_directory/component_active_directory_policy_service.h" #include "base/bind.h" #include "base/test/task_environment.h"
diff --git a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc index 02d404cd..d977787 100644 --- a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc +++ b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc
@@ -29,7 +29,7 @@ #include "chrome/browser/ash/settings/cros_settings.h" #include "chrome/browser/ash/settings/device_settings_service.h" #include "chrome/browser/ash/system/timezone_util.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/adb_sideloading_allowance_mode_policy_handler.h" #include "chrome/browser/chromeos/policy/affiliated_cloud_policy_invalidator.h" #include "chrome/browser/chromeos/policy/affiliated_invalidation_service_provider.h"
diff --git a/chrome/browser/chromeos/policy/dlp/data_transfer_dlp_controller_browsertest.cc b/chrome/browser/chromeos/policy/dlp/data_transfer_dlp_controller_browsertest.cc index 18ddc13b..eb3b8ed 100644 --- a/chrome/browser/chromeos/policy/dlp/data_transfer_dlp_controller_browsertest.cc +++ b/chrome/browser/chromeos/policy/dlp/data_transfer_dlp_controller_browsertest.cc
@@ -19,7 +19,7 @@ #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_factory.h" #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_impl.h" #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_test_utils.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/test/base/ui_test_utils.h"
diff --git a/chrome/browser/chromeos/policy/dlp/dlp_content_manager_browsertest.cc b/chrome/browser/chromeos/policy/dlp/dlp_content_manager_browsertest.cc index 6ac444b..0889d858 100644 --- a/chrome/browser/chromeos/policy/dlp/dlp_content_manager_browsertest.cc +++ b/chrome/browser/chromeos/policy/dlp/dlp_content_manager_browsertest.cc
@@ -21,7 +21,7 @@ #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_factory.h" #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_test_utils.h" #include "chrome/browser/chromeos/policy/dlp/mock_dlp_rules_manager.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" #include "chrome/browser/notifications/notification_display_service_tester.h" #include "chrome/browser/policy/messaging_layer/public/report_queue_impl.h"
diff --git a/chrome/browser/chromeos/policy/dlp/dlp_rules_manager_impl_browsertest.cc b/chrome/browser/chromeos/policy/dlp/dlp_rules_manager_impl_browsertest.cc index c6bfc7f..e94f94e 100644 --- a/chrome/browser/chromeos/policy/dlp/dlp_rules_manager_impl_browsertest.cc +++ b/chrome/browser/chromeos/policy/dlp/dlp_rules_manager_impl_browsertest.cc
@@ -7,7 +7,7 @@ #include "chrome/browser/chromeos/policy/dlp/dlp_policy_constants.h" #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_factory.h" #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_test_utils.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" #include "chrome/browser/profiles/profile_manager.h" #include "components/policy/core/common/policy_map.h"
diff --git a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc index dca6777..1a4eb91 100644 --- a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc +++ b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
@@ -21,7 +21,7 @@ #include "chrome/browser/ash/login/enrollment/auto_enrollment_controller.h" #include "chrome/browser/ash/ownership/owner_settings_service_ash.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_join_delegate.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" #include "chrome/browser/chromeos/policy/dm_token_storage.h" #include "chrome/browser/chromeos/policy/server_backed_state/server_backed_state_keys_broker.h"
diff --git a/chrome/browser/chromeos/policy/external_data/user_cloud_external_data_manager_browsertest.cc b/chrome/browser/chromeos/policy/external_data/user_cloud_external_data_manager_browsertest.cc index f59b7f8..af0c9ea9 100644 --- a/chrome/browser/chromeos/policy/external_data/user_cloud_external_data_manager_browsertest.cc +++ b/chrome/browser/chromeos/policy/external_data/user_cloud_external_data_manager_browsertest.cc
@@ -16,7 +16,7 @@ #include "build/build_config.h" #include "chrome/browser/chromeos/policy/external_data/cloud_external_data_manager_base.h" #include "chrome/browser/chromeos/policy/external_data/cloud_external_data_manager_base_test_util.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" #include "chrome/browser/policy/profile_policy_connector.h"
diff --git a/chrome/browser/chromeos/policy/blocking_login_browsertest.cc b/chrome/browser/chromeos/policy/login/blocking_login_browsertest.cc similarity index 98% rename from chrome/browser/chromeos/policy/blocking_login_browsertest.cc rename to chrome/browser/chromeos/policy/login/blocking_login_browsertest.cc index 51cda8d9..0e160287 100644 --- a/chrome/browser/chromeos/policy/blocking_login_browsertest.cc +++ b/chrome/browser/chromeos/policy/login/blocking_login_browsertest.cc
@@ -92,8 +92,7 @@ public content::NotificationObserver, public testing::WithParamInterface<BlockingLoginTestParam> { public: - BlockingLoginTest() : profile_added_(NULL) { - } + BlockingLoginTest() : profile_added_(NULL) {} void SetUpCommandLine(base::CommandLine* command_line) override { OobeBaseTest::SetUpCommandLine(command_line); @@ -104,8 +103,7 @@ } void SetUpOnMainThread() override { - registrar_.Add(this, - chrome::NOTIFICATION_PROFILE_ADDED, + registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, content::NotificationService::AllSources()); OobeBaseTest::SetUpOnMainThread(); @@ -129,9 +127,7 @@ profile_added_ = content::Source<Profile>(source).ptr(); } - void RunUntilIdle() { - base::RunLoop().RunUntilIdle(); - } + void RunUntilIdle() { base::RunLoop().RunUntilIdle(); } void EnrollDevice(const std::string& domain) { base::RunLoop loop;
diff --git a/chrome/browser/chromeos/policy/device_login_screen_policy_browsertest.cc b/chrome/browser/chromeos/policy/login/device_login_screen_policy_browsertest.cc similarity index 100% rename from chrome/browser/chromeos/policy/device_login_screen_policy_browsertest.cc rename to chrome/browser/chromeos/policy/login/device_login_screen_policy_browsertest.cc
diff --git a/chrome/browser/chromeos/policy/force_maximize_on_first_run_chromeos_browsertest.cc b/chrome/browser/chromeos/policy/login/force_maximize_on_first_run_chromeos_browsertest.cc similarity index 98% rename from chrome/browser/chromeos/policy/force_maximize_on_first_run_chromeos_browsertest.cc rename to chrome/browser/chromeos/policy/login/force_maximize_on_first_run_chromeos_browsertest.cc index 230200b4..9e4cb17 100644 --- a/chrome/browser/chromeos/policy/force_maximize_on_first_run_chromeos_browsertest.cc +++ b/chrome/browser/chromeos/policy/login/force_maximize_on_first_run_chromeos_browsertest.cc
@@ -12,7 +12,7 @@ #include "chrome/browser/ash/login/test/session_manager_state_waiter.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h"
diff --git a/chrome/browser/chromeos/policy/login_policy_test_base.cc b/chrome/browser/chromeos/policy/login/login_policy_test_base.cc similarity index 96% rename from chrome/browser/chromeos/policy/login_policy_test_base.cc rename to chrome/browser/chromeos/policy/login/login_policy_test_base.cc index d9b83c0..c3d9ec38 100644 --- a/chrome/browser/chromeos/policy/login_policy_test_base.cc +++ b/chrome/browser/chromeos/policy/login/login_policy_test_base.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include <memory> @@ -83,12 +83,10 @@ } void LoginPolicyTestBase::GetMandatoryPoliciesValue( - base::DictionaryValue* policy) const { -} + base::DictionaryValue* policy) const {} void LoginPolicyTestBase::GetRecommendedPoliciesValue( - base::DictionaryValue* policy) const { -} + base::DictionaryValue* policy) const {} void LoginPolicyTestBase::SetMergeSessionParams() { FakeGaia::MergeSessionParams params;
diff --git a/chrome/browser/chromeos/policy/login_policy_test_base.h b/chrome/browser/chromeos/policy/login/login_policy_test_base.h similarity index 90% rename from chrome/browser/chromeos/policy/login_policy_test_base.h rename to chrome/browser/chromeos/policy/login/login_policy_test_base.h index 134b6b7a..ca55dc9 100644 --- a/chrome/browser/chromeos/policy/login_policy_test_base.h +++ b/chrome/browser/chromeos/policy/login/login_policy_test_base.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_LOGIN_POLICY_TEST_BASE_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_LOGIN_POLICY_TEST_BASE_H_ #include <memory> #include <string> @@ -74,4 +74,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_LOGIN_POLICY_TEST_BASE_H_
diff --git a/chrome/browser/chromeos/policy/login_profile_policy_provider.cc b/chrome/browser/chromeos/policy/login/login_profile_policy_provider.cc similarity index 98% rename from chrome/browser/chromeos/policy/login_profile_policy_provider.cc rename to chrome/browser/chromeos/policy/login/login_profile_policy_provider.cc index b6e3912..a47e571 100644 --- a/chrome/browser/chromeos/policy/login_profile_policy_provider.cc +++ b/chrome/browser/chromeos/policy/login/login_profile_policy_provider.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" +#include "chrome/browser/chromeos/policy/login/login_profile_policy_provider.h" #include <memory> #include <string>
diff --git a/chrome/browser/chromeos/policy/login_profile_policy_provider.h b/chrome/browser/chromeos/policy/login/login_profile_policy_provider.h similarity index 87% rename from chrome/browser/chromeos/policy/login_profile_policy_provider.h rename to chrome/browser/chromeos/policy/login/login_profile_policy_provider.h index 6dfe263..3869ae4 100644 --- a/chrome/browser/chromeos/policy/login_profile_policy_provider.h +++ b/chrome/browser/chromeos/policy/login/login_profile_policy_provider.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_PROFILE_POLICY_PROVIDER_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_PROFILE_POLICY_PROVIDER_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_LOGIN_PROFILE_POLICY_PROVIDER_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_LOGIN_PROFILE_POLICY_PROVIDER_H_ #include "base/compiler_specific.h" #include "base/macros.h" @@ -50,4 +50,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_PROFILE_POLICY_PROVIDER_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_LOGIN_PROFILE_POLICY_PROVIDER_H_
diff --git a/chrome/browser/chromeos/policy/login_screen_accessibility_policy_browsertest.cc b/chrome/browser/chromeos/policy/login/login_screen_accessibility_policy_browsertest.cc similarity index 100% rename from chrome/browser/chromeos/policy/login_screen_accessibility_policy_browsertest.cc rename to chrome/browser/chromeos/policy/login/login_screen_accessibility_policy_browsertest.cc
diff --git a/chrome/browser/chromeos/policy/login_screen_default_policy_browsertest.cc b/chrome/browser/chromeos/policy/login/login_screen_default_policy_browsertest.cc similarity index 91% rename from chrome/browser/chromeos/policy/login_screen_default_policy_browsertest.cc rename to chrome/browser/chromeos/policy/login/login_screen_default_policy_browsertest.cc index 914f4308..ae60cff 100644 --- a/chrome/browser/chromeos/policy/login_screen_default_policy_browsertest.cc +++ b/chrome/browser/chromeos/policy/login/login_screen_default_policy_browsertest.cc
@@ -59,8 +59,7 @@ DISALLOW_COPY_AND_ASSIGN(PrefChangeWatcher); }; -PrefChangeWatcher::PrefChangeWatcher(const char* pref_name, - PrefService* prefs) +PrefChangeWatcher::PrefChangeWatcher(const char* pref_name, PrefService* prefs) : pref_changed_(false) { registrar_.Init(prefs); registrar_.Add(pref_name, @@ -131,12 +130,11 @@ }; LoginScreenDefaultPolicyBrowsertestBase:: - LoginScreenDefaultPolicyBrowsertestBase() : login_profile_(NULL) { -} + LoginScreenDefaultPolicyBrowsertestBase() + : login_profile_(NULL) {} LoginScreenDefaultPolicyBrowsertestBase:: - ~LoginScreenDefaultPolicyBrowsertestBase() { -} + ~LoginScreenDefaultPolicyBrowsertestBase() {} void LoginScreenDefaultPolicyBrowsertestBase::SetUpOnMainThread() { DevicePolicyCrosBrowserTest::SetUpOnMainThread(); @@ -152,12 +150,10 @@ } LoginScreenDefaultPolicyLoginScreenBrowsertest:: - LoginScreenDefaultPolicyLoginScreenBrowsertest() { -} + LoginScreenDefaultPolicyLoginScreenBrowsertest() {} LoginScreenDefaultPolicyLoginScreenBrowsertest:: - ~LoginScreenDefaultPolicyLoginScreenBrowsertest() { -} + ~LoginScreenDefaultPolicyLoginScreenBrowsertest() {} void LoginScreenDefaultPolicyLoginScreenBrowsertest::SetUpCommandLine( base::CommandLine* command_line) { @@ -201,12 +197,10 @@ } LoginScreenDefaultPolicyInSessionBrowsertest:: - LoginScreenDefaultPolicyInSessionBrowsertest() { -} + LoginScreenDefaultPolicyInSessionBrowsertest() {} LoginScreenDefaultPolicyInSessionBrowsertest:: - ~LoginScreenDefaultPolicyInSessionBrowsertest() { -} + ~LoginScreenDefaultPolicyInSessionBrowsertest() {} void LoginScreenDefaultPolicyInSessionBrowsertest::SetUpOnMainThread() { LoginScreenDefaultPolicyBrowsertestBase::SetUpOnMainThread(); @@ -232,8 +226,8 @@ // Enable the large cursor through device policy and wait for the change to // take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_large_cursor_enabled(true); + proto.mutable_accessibility_settings() + ->set_login_screen_default_large_cursor_enabled(true); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilityLargeCursorEnabled); @@ -256,8 +250,8 @@ // Enable spoken feedback through device policy and wait for the change to // take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_spoken_feedback_enabled(true); + proto.mutable_accessibility_settings() + ->set_login_screen_default_spoken_feedback_enabled(true); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilitySpokenFeedbackEnabled); @@ -280,8 +274,8 @@ // Enable high contrast mode through device policy and wait for the change to // take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_high_contrast_enabled(true); + proto.mutable_accessibility_settings() + ->set_login_screen_default_high_contrast_enabled(true); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilityHighContrastEnabled); @@ -304,8 +298,8 @@ // Set the screen magnifier through device policy and wait for the change // to take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_screen_magnifier_type(kFullScreenMagnifier); + proto.mutable_accessibility_settings() + ->set_login_screen_default_screen_magnifier_type(kFullScreenMagnifier); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilityScreenMagnifierEnabled); @@ -329,8 +323,8 @@ // Enable the large cursor through device policy and wait for the change to // take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_large_cursor_enabled(true); + proto.mutable_accessibility_settings() + ->set_login_screen_default_large_cursor_enabled(true); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilityLargeCursorEnabled); @@ -353,8 +347,8 @@ // Enable spoken feedback through device policy and wait for the change to // take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_spoken_feedback_enabled(true); + proto.mutable_accessibility_settings() + ->set_login_screen_default_spoken_feedback_enabled(true); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilitySpokenFeedbackEnabled); @@ -377,8 +371,8 @@ // Enable high contrast mode through device policy and wait for the change to // take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_high_contrast_enabled(true); + proto.mutable_accessibility_settings() + ->set_login_screen_default_high_contrast_enabled(true); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilityHighContrastEnabled); @@ -400,8 +394,8 @@ // Set the screen magnifier through device policy and wait for the change // to take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_screen_magnifier_type(kFullScreenMagnifier); + proto.mutable_accessibility_settings() + ->set_login_screen_default_screen_magnifier_type(kFullScreenMagnifier); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilityScreenMagnifierEnabled); @@ -423,8 +417,8 @@ // Enable the on-screen keyboard through device policy and wait for the change // to take effect. em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_virtual_keyboard_enabled(true); + proto.mutable_accessibility_settings() + ->set_login_screen_default_virtual_keyboard_enabled(true); RefreshDevicePolicyAndWaitForPrefChange( ash::prefs::kAccessibilityVirtualKeyboardEnabled);
diff --git a/chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.cc b/chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.cc similarity index 93% rename from chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.cc rename to chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.cc index e021f58..5e300b7 100644 --- a/chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.cc +++ b/chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.h" +#include "chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.h" #include "ash/constants/ash_pref_names.h" #include "components/policy/core/common/policy_map.h"
diff --git a/chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.h b/chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.h similarity index 76% rename from chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.h rename to chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.h index 10d6fbc..1a598c7 100644 --- a/chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.h +++ b/chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_SECONDARY_GOOGLE_ACCOUNT_SIGNIN_POLICY_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_SECONDARY_GOOGLE_ACCOUNT_SIGNIN_POLICY_HANDLER_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_SECONDARY_GOOGLE_ACCOUNT_SIGNIN_POLICY_HANDLER_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_SECONDARY_GOOGLE_ACCOUNT_SIGNIN_POLICY_HANDLER_H_ #include "base/macros.h" #include "components/policy/core/browser/configuration_policy_handler.h" @@ -32,4 +32,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_SECONDARY_GOOGLE_ACCOUNT_SIGNIN_POLICY_HANDLER_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_SECONDARY_GOOGLE_ACCOUNT_SIGNIN_POLICY_HANDLER_H_
diff --git a/chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler_unittest.cc b/chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler_unittest.cc similarity index 96% rename from chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler_unittest.cc rename to chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler_unittest.cc index 69abe83..9f14fc4 100644 --- a/chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler_unittest.cc +++ b/chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler_unittest.cc
@@ -8,7 +8,7 @@ #include "ash/constants/ash_pref_names.h" #include "base/macros.h" -#include "chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.h" +#include "chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.h" #include "components/policy/core/common/policy_map.h" #include "components/policy/core/common/policy_pref_names.h" #include "components/policy/policy_constants.h"
diff --git a/chrome/browser/chromeos/policy/signin_profile_extensions_policy_browsertest.cc b/chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_browsertest.cc similarity index 99% rename from chrome/browser/chromeos/policy/signin_profile_extensions_policy_browsertest.cc rename to chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_browsertest.cc index 12b69b2c..4779d48 100644 --- a/chrome/browser/chromeos/policy/signin_profile_extensions_policy_browsertest.cc +++ b/chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_browsertest.cc
@@ -16,7 +16,7 @@ #include "base/strings/stringprintf.h" #include "base/threading/thread_restrictions.h" #include "base/version.h" -#include "chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/policy/extension_force_install_mixin.h"
diff --git a/chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.cc b/chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.cc similarity index 96% rename from chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.cc rename to chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.cc index c42cace1..8763b6d 100644 --- a/chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.cc +++ b/chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h" #include "ash/constants/ash_switches.h" #include "base/bind.h"
diff --git a/chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h b/chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h similarity index 84% rename from chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h rename to chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h index dc9a5fb0..3bb03b4 100644 --- a/chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h +++ b/chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_SIGNIN_PROFILE_EXTENSIONS_POLICY_TEST_BASE_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_SIGNIN_PROFILE_EXTENSIONS_POLICY_TEST_BASE_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_SIGNIN_PROFILE_EXTENSIONS_POLICY_TEST_BASE_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_SIGNIN_PROFILE_EXTENSIONS_POLICY_TEST_BASE_H_ #include <memory> #include <string> @@ -46,4 +46,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_SIGNIN_PROFILE_EXTENSIONS_POLICY_TEST_BASE_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_SIGNIN_PROFILE_EXTENSIONS_POLICY_TEST_BASE_H_
diff --git a/chrome/browser/chromeos/policy/wildcard_login_checker.cc b/chrome/browser/chromeos/policy/login/wildcard_login_checker.cc similarity index 97% rename from chrome/browser/chromeos/policy/wildcard_login_checker.cc rename to chrome/browser/chromeos/policy/login/wildcard_login_checker.cc index ab8849c..2da5d84e 100644 --- a/chrome/browser/chromeos/policy/wildcard_login_checker.cc +++ b/chrome/browser/chromeos/policy/login/wildcard_login_checker.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/policy/wildcard_login_checker.h" +#include "chrome/browser/chromeos/policy/login/wildcard_login_checker.h" #include <memory>
diff --git a/chrome/browser/chromeos/policy/wildcard_login_checker.h b/chrome/browser/chromeos/policy/login/wildcard_login_checker.h similarity index 91% rename from chrome/browser/chromeos/policy/wildcard_login_checker.h rename to chrome/browser/chromeos/policy/login/wildcard_login_checker.h index f08dace..728481d 100644 --- a/chrome/browser/chromeos/policy/wildcard_login_checker.h +++ b/chrome/browser/chromeos/policy/login/wildcard_login_checker.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_WILDCARD_LOGIN_CHECKER_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_WILDCARD_LOGIN_CHECKER_H_ #include <memory> @@ -67,4 +67,4 @@ } // namespace policy -#endif // CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_ +#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_WILDCARD_LOGIN_CHECKER_H_
diff --git a/chrome/browser/chromeos/policy/networking/policy_certs_browsertest.cc b/chrome/browser/chromeos/policy/networking/policy_certs_browsertest.cc index 9a0018a5..1d0c788 100644 --- a/chrome/browser/chromeos/policy/networking/policy_certs_browsertest.cc +++ b/chrome/browser/chromeos/policy/networking/policy_certs_browsertest.cc
@@ -31,10 +31,10 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chromeos/policy/device_local_account.h" #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h" #include "chrome/browser/chromeos/policy/networking/user_network_configuration_updater.h" #include "chrome/browser/chromeos/policy/networking/user_network_configuration_updater_factory.h" -#include "chrome/browser/chromeos/policy/signin_profile_extensions_policy_test_base.h" #include "chrome/browser/net/nss_context.h" #include "chrome/browser/policy/profile_policy_connector_builder.h" #include "chrome/browser/profiles/profile.h"
diff --git a/chrome/browser/chromeos/policy/restore_on_startup_browsertest_chromeos.cc b/chrome/browser/chromeos/policy/restore_on_startup_browsertest_chromeos.cc index 6392480..216e3bc9 100644 --- a/chrome/browser/chromeos/policy/restore_on_startup_browsertest_chromeos.cc +++ b/chrome/browser/chromeos/policy/restore_on_startup_browsertest_chromeos.cc
@@ -10,7 +10,7 @@ #include "base/values.h" #include "chrome/browser/ash/login/test/session_manager_state_waiter.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h"
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc index 9935697..922fac1 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc +++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
@@ -28,11 +28,11 @@ #include "chrome/browser/ash/login/users/chrome_user_manager_impl.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" +#include "chrome/browser/chromeos/policy/login/wildcard_login_checker.h" #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" #include "chrome/browser/chromeos/policy/remote_commands/user_commands_factory_chromeos.h" #include "chrome/browser/chromeos/policy/reporting/arc_app_install_event_log_uploader.h" #include "chrome/browser/chromeos/policy/reporting/extension_install_event_log_uploader.h" -#include "chrome/browser/chromeos/policy/wildcard_login_checker.h" #include "chrome/browser/enterprise/reporting/report_scheduler_desktop.h" #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h" #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h index 9c3f33e9..de7e4da9 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h +++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h
@@ -16,7 +16,7 @@ #include "base/scoped_observation.h" #include "base/time/time.h" #include "base/timer/timer.h" -#include "chrome/browser/chromeos/policy/wildcard_login_checker.h" +#include "chrome/browser/chromeos/policy/login/wildcard_login_checker.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager_observer.h" #include "components/account_id/account_id.h"
diff --git a/chrome/browser/chromeos/policy/user_policy_manager_builder_chromeos.cc b/chrome/browser/chromeos/policy/user_policy_manager_builder_chromeos.cc index bcdd9c76..c20c3e2 100644 --- a/chrome/browser/chromeos/policy/user_policy_manager_builder_chromeos.cc +++ b/chrome/browser/chromeos/policy/user_policy_manager_builder_chromeos.cc
@@ -23,7 +23,7 @@ #include "chrome/browser/ash/settings/cros_settings.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/external_data/user_cloud_external_data_manager.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
diff --git a/chrome/browser/content_creation/notes/internal/android/java/src/org/chromium/chrome/browser/content_creation/notes/NoteCreationDialog.java b/chrome/browser/content_creation/notes/internal/android/java/src/org/chromium/chrome/browser/content_creation/notes/NoteCreationDialog.java index fcbc8bb..7062bcd4 100644 --- a/chrome/browser/content_creation/notes/internal/android/java/src/org/chromium/chrome/browser/content_creation/notes/NoteCreationDialog.java +++ b/chrome/browser/content_creation/notes/internal/android/java/src/org/chromium/chrome/browser/content_creation/notes/NoteCreationDialog.java
@@ -19,7 +19,6 @@ import org.chromium.chrome.browser.content_creation.internal.R; import org.chromium.components.content_creation.notes.models.NoteTemplate; -import org.chromium.components.content_creation.notes.models.TextAlignment; import org.chromium.ui.modelutil.LayoutViewBuilder; import org.chromium.ui.modelutil.MVCListAdapter.ModelList; import org.chromium.ui.modelutil.PropertyKey; @@ -92,18 +91,18 @@ private void bindCarouselItem(PropertyModel model, ViewGroup parent, PropertyKey propertyKey) { NoteTemplate template = model.get(NoteProperties.TEMPLATE); - Typeface typeface = model.get(NoteProperties.TYPEFACE); View background = parent.findViewById(R.id.background); template.mainBackground.apply(background); background.setClipToOutline(true); + ((TextView) parent.findViewById(R.id.title)).setText(template.localizedName); + + Typeface typeface = model.get(NoteProperties.TYPEFACE); TextView noteText = (TextView) parent.findViewById(R.id.text); - noteText.setText(mSelectedText); - noteText.setTextColor(template.textStyle.fontColor); - noteText.setAllCaps(template.textStyle.allCaps); - noteText.setGravity(TextAlignment.toGravity(template.textStyle.alignment)); noteText.setTypeface(typeface); + template.textStyle.apply(noteText, mSelectedText); + setLeftPadding(model.get(NoteProperties.IS_FIRST), parent.findViewById(R.id.item)); } @@ -111,11 +110,11 @@ // following item is slightlight peaking from the right. For that, set left padding exactly // what is needed to push the first item to the center, but set a smaller padding for the // following items. - private void setLeftPadding(boolean is_first, View itemView) { + private void setLeftPadding(boolean isFirst, View itemView) { int dialogWidth = mContentView.getWidth(); int templateWidth = getActivity().getResources().getDimensionPixelSize(R.dimen.note_width); int paddingLeft = (int) ((dialogWidth - templateWidth) - * (is_first ? FIRST_NOTE_PADDING_RATIO : NOTE_PADDING_RATIO) + * (isFirst ? FIRST_NOTE_PADDING_RATIO : NOTE_PADDING_RATIO) + 0.5f); itemView.setPadding(paddingLeft, itemView.getPaddingTop(), itemView.getPaddingRight(), itemView.getPaddingBottom());
diff --git a/chrome/browser/device_api/device_service_impl.cc b/chrome/browser/device_api/device_service_impl.cc index cd20f91..10e7cd1b 100644 --- a/chrome/browser/device_api/device_service_impl.cc +++ b/chrome/browser/device_api/device_service_impl.cc
@@ -43,7 +43,7 @@ DeviceServiceImpl::DeviceServiceImpl( content::RenderFrameHost* host, mojo::PendingReceiver<blink::mojom::DeviceAPIService> receiver) - : FrameServiceBase(host, std::move(receiver)), host_(host) { + : DocumentServiceBase(host, std::move(receiver)), host_(host) { pref_change_registrar_.Init( Profile::FromBrowserContext(host->GetBrowserContext())->GetPrefs()); pref_change_registrar_.Add( @@ -67,7 +67,7 @@ return; } // The object is bound to the lifetime of |host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new DeviceServiceImpl(host, std::move(receiver)); }
diff --git a/chrome/browser/device_api/device_service_impl.h b/chrome/browser/device_api/device_service_impl.h index d3b1715..29905a6 100644 --- a/chrome/browser/device_api/device_service_impl.h +++ b/chrome/browser/device_api/device_service_impl.h
@@ -6,7 +6,7 @@ #define CHROME_BROWSER_DEVICE_API_DEVICE_SERVICE_IMPL_H_ #include "components/prefs/pref_change_registrar.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "third_party/blink/public/mojom/device/device.mojom.h" namespace content { @@ -16,7 +16,7 @@ // A browser-side mojo service, which corresponds to the navigator.managed Web // API. Available only to trusted web applications. class DeviceServiceImpl final - : public content::FrameServiceBase<blink::mojom::DeviceAPIService> { + : public content::DocumentServiceBase<blink::mojom::DeviceAPIService> { public: // Tries to attach this mojo service to |host| for trusted web applications. // Will dynamically disconnect if the trustness status is revoked.
diff --git a/chrome/browser/device_api/managed_configuration_service.cc b/chrome/browser/device_api/managed_configuration_service.cc index 97a631e..40fa968 100644 --- a/chrome/browser/device_api/managed_configuration_service.cc +++ b/chrome/browser/device_api/managed_configuration_service.cc
@@ -21,14 +21,14 @@ } // The object is bound to the lifetime of |host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new ManagedConfigurationServiceImpl(host, std::move(receiver)); } ManagedConfigurationServiceImpl::ManagedConfigurationServiceImpl( content::RenderFrameHost* host, mojo::PendingReceiver<blink::mojom::ManagedConfigurationService> receiver) - : FrameServiceBase(host, std::move(receiver)), host_(host) { + : DocumentServiceBase(host, std::move(receiver)), host_(host) { managed_configuration_api()->AddObserver(this); }
diff --git a/chrome/browser/device_api/managed_configuration_service.h b/chrome/browser/device_api/managed_configuration_service.h index aeb58786..cc4477b8 100644 --- a/chrome/browser/device_api/managed_configuration_service.h +++ b/chrome/browser/device_api/managed_configuration_service.h
@@ -6,11 +6,11 @@ #define CHROME_BROWSER_DEVICE_API_MANAGED_CONFIGURATION_SERVICE_H_ #include "chrome/browser/device_api/managed_configuration_api.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "third_party/blink/public/mojom/device/device.mojom.h" class ManagedConfigurationServiceImpl - : public content::FrameServiceBase< + : public content::DocumentServiceBase< blink::mojom::ManagedConfigurationService>, public ManagedConfigurationAPI::Observer { public:
diff --git a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.cc b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.cc index 1dc37f92..0696052 100644 --- a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.cc +++ b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.cc
@@ -80,8 +80,8 @@ } }; -SkColor GetBackgroundColor(const views::Widget* widget) { - return widget->GetNativeTheme()->GetSystemColor( +SkColor GetBackgroundColor(const views::View* view) { + return view->GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_DialogBackground); } @@ -207,10 +207,12 @@ std::unique_ptr<ContentAnalysisDelegateBase> delegate, content::WebContents* web_contents, safe_browsing::DeepScanAccessPoint access_point, - int files_count) + int files_count, + ContentAnalysisDelegateBase::FinalResult final_result) : content::WebContentsObserver(web_contents), delegate_(std::move(delegate)), web_contents_(web_contents), + final_result_(final_result), access_point_(std::move(access_point)), files_count_(files_count) { SetOwnedByWidget(true); @@ -218,6 +220,9 @@ if (observer_for_testing) observer_for_testing->ConstructorCalled(this, base::TimeTicks::Now()); + if (final_result_ != ContentAnalysisDelegateBase::FinalResult::SUCCESS) + UpdateStateFromFinalResult(final_result_); + SetupButtons(); first_shown_timestamp_ = base::TimeTicks::Now(); @@ -341,6 +346,11 @@ // Add padding to distance the message from the button(s). layout->AddPaddingRow(views::GridLayout::kFixedSize, 10); + + // If the dialog was started in a state other than pending, setup the views + // accordingly. + if (!is_pending()) + UpdateViews(); } return contents_view_; @@ -370,23 +380,10 @@ const std::u16string& custom_message, const GURL& learn_more_url) { DCHECK(is_pending()); - final_result_ = result; final_custom_message_ = custom_message; final_learn_more_url_ = learn_more_url; - switch (final_result_) { - case ContentAnalysisDelegateBase::FinalResult::ENCRYPTED_FILES: - case ContentAnalysisDelegateBase::FinalResult::LARGE_FILES: - case ContentAnalysisDelegateBase::FinalResult::FAILURE: - dialog_status_ = DeepScanningDialogStatus::FAILURE; - break; - case ContentAnalysisDelegateBase::FinalResult::SUCCESS: - dialog_status_ = DeepScanningDialogStatus::SUCCESS; - break; - case ContentAnalysisDelegateBase::FinalResult::WARNING: - dialog_status_ = DeepScanningDialogStatus::WARNING; - break; - } + UpdateStateFromFinalResult(result); // Update the pending dialog only after it has been shown for a minimum amount // of time. @@ -407,19 +404,37 @@ observer_for_testing->DestructorCalled(this); } -void ContentAnalysisDialog::UpdateDialog() { - views::Widget* widget = GetWidget(); - DCHECK(widget); - DCHECK(is_result()); +void ContentAnalysisDialog::UpdateStateFromFinalResult( + ContentAnalysisDelegateBase::FinalResult final_result) { + final_result_ = final_result; + switch (final_result_) { + case ContentAnalysisDelegateBase::FinalResult::ENCRYPTED_FILES: + case ContentAnalysisDelegateBase::FinalResult::LARGE_FILES: + case ContentAnalysisDelegateBase::FinalResult::FAILURE: + dialog_state_ = State::FAILURE; + break; + case ContentAnalysisDelegateBase::FinalResult::SUCCESS: + dialog_state_ = State::SUCCESS; + break; + case ContentAnalysisDelegateBase::FinalResult::WARNING: + dialog_state_ = State::WARNING; + break; + } +} - auto height_before = contents_view_->GetPreferredSize().height(); +void ContentAnalysisDialog::UpdateViews() { + DCHECK(contents_view_); // Update the style of the dialog to reflect the new state. message_->Update(); image_->Update(); side_icon_image_->Update(); - side_icon_spinner_->Update(); - side_icon_spinner_ = nullptr; + // There isn't always a spinner, for instance when the dialog is started in a + // state other than the "pending" state. + if (side_icon_spinner_) { + side_icon_spinner_->Update(); + side_icon_spinner_ = nullptr; + } // Update the buttons. SetupButtons(); @@ -436,10 +451,18 @@ learn_more_link_->SetVisible( (is_failure() || is_warning()) && (final_learn_more_url_.is_valid() && !final_learn_more_url_.is_empty())); +} + +void ContentAnalysisDialog::UpdateDialog() { + DCHECK(contents_view_); + DCHECK(is_result()); + + auto height_before = contents_view_->GetPreferredSize().height(); + + UpdateViews(); // Resize the dialog's height. This is needed since the text might take more // lines after changing. - auto height_after = contents_view_->GetPreferredSize().height(); int height_to_add = std::max(height_after - height_before, 0); if (height_to_add > 0) @@ -447,7 +470,7 @@ // Update the dialog. DialogDelegate::DialogModelChanged(); - widget->ScheduleLayout(); + contents_view_->InvalidateLayout(); // Schedule the dialog to close itself in the success case. if (is_success()) { @@ -545,31 +568,31 @@ } std::u16string ContentAnalysisDialog::GetDialogMessage() const { - switch (dialog_status_) { - case DeepScanningDialogStatus::PENDING: + switch (dialog_state_) { + case State::PENDING: return GetPendingMessage(); - case DeepScanningDialogStatus::FAILURE: + case State::FAILURE: return GetFailureMessage(); - case DeepScanningDialogStatus::SUCCESS: + case State::SUCCESS: return GetSuccessMessage(); - case DeepScanningDialogStatus::WARNING: + case State::WARNING: return GetWarningMessage(); } } std::u16string ContentAnalysisDialog::GetCancelButtonText() const { int text_id; - switch (dialog_status_) { - case DeepScanningDialogStatus::SUCCESS: + switch (dialog_state_) { + case State::SUCCESS: NOTREACHED(); FALLTHROUGH; - case DeepScanningDialogStatus::PENDING: + case State::PENDING: text_id = IDS_DEEP_SCANNING_DIALOG_CANCEL_UPLOAD_BUTTON; break; - case DeepScanningDialogStatus::FAILURE: + case State::FAILURE: text_id = IDS_CLOSE; break; - case DeepScanningDialogStatus::WARNING: + case State::WARNING: text_id = IDS_DEEP_SCANNING_DIALOG_CANCEL_WARNING_BUTTON; break; } @@ -610,12 +633,12 @@ SkColor ContentAnalysisDialog::GetSideImageBackgroundColor() const { DCHECK(is_result()); - const views::Widget* widget = GetWidget(); - DCHECK(widget); + DCHECK(contents_view_); + ui::NativeTheme::ColorId color_id = is_success() ? ui::NativeTheme::kColorId_AlertSeverityLow : ui::NativeTheme::kColorId_AlertSeverityHigh; - return widget->GetNativeTheme()->GetSystemColor(color_id); + return contents_view_->GetNativeTheme()->GetSystemColor(color_id); } int ContentAnalysisDialog::GetPasteImageId(bool use_dark) const { @@ -689,7 +712,7 @@ } const gfx::ImageSkia* ContentAnalysisDialog::GetTopImage() const { - const bool use_dark = color_utils::IsDark(GetBackgroundColor(GetWidget())); + const bool use_dark = color_utils::IsDark(GetBackgroundColor(contents_view_)); const bool treat_as_text_paste = access_point_ == safe_browsing::DeepScanAccessPoint::PASTE || (access_point_ == safe_browsing::DeepScanAccessPoint::DRAG_AND_DROP && @@ -702,19 +725,19 @@ } SkColor ContentAnalysisDialog::GetSideImageLogoColor() const { - const views::Widget* widget = GetWidget(); - DCHECK(widget); - switch (dialog_status_) { - case DeepScanningDialogStatus::PENDING: + DCHECK(contents_view_); + + switch (dialog_state_) { + case State::PENDING: // Match the spinner in the pending state. - return widget->GetNativeTheme()->GetSystemColor( + return contents_view_->GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_ThrobberSpinningColor); - case DeepScanningDialogStatus::SUCCESS: - case DeepScanningDialogStatus::FAILURE: - case DeepScanningDialogStatus::WARNING: + case State::SUCCESS: + case State::FAILURE: + case State::WARNING: // In a result state the background will have the result's color, so the // logo should have the same color as the background. - return GetBackgroundColor(widget); + return GetBackgroundColor(contents_view_); } }
diff --git a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.h b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.h index 7fd5cba..224acd8c 100644 --- a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.h +++ b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.h
@@ -43,28 +43,6 @@ class ContentAnalysisDialog : public views::DialogDelegate, public content::WebContentsObserver { public: - // Enum used to represent what the dialog is currently showing. - enum class DeepScanningDialogStatus { - // The dialog is shown with an explanation that the scan is being performed - // and that the result is pending. - PENDING, - - // The dialog is shown with a short message indicating that the scan was a - // success and that the user may proceed with their upload, drag-and-drop or - // paste. - SUCCESS, - - // The dialog is shown with a message indicating that the scan was a failure - // and that the user may not proceed with their upload, drag-and-drop or - // paste. - FAILURE, - - // The dialog is shown with a message indicating that the scan was a - // failure, but that the user may proceed with their upload, drag-and-drop - // or paste if they want to. - WARNING, - }; - // TestObserver should be implemented by tests that need to track when certain // ContentAnalysisDialog functions are called. The test can add itself as an // observer by using SetObserverForTesting. @@ -110,7 +88,9 @@ ContentAnalysisDialog(std::unique_ptr<ContentAnalysisDelegateBase> delegate, content::WebContents* web_contents, safe_browsing::DeepScanAccessPoint access_point, - int files_count); + int files_count, + ContentAnalysisDelegateBase::FinalResult final_result = + ContentAnalysisDelegateBase::FinalResult::SUCCESS); // views::DialogDelegate: std::u16string GetWindowTitle() const override; @@ -129,24 +109,16 @@ const std::u16string& custom_message, const GURL& learn_more_url); - // Accessors to simplify |dialog_status_| checking. - inline bool is_success() const { - return dialog_status_ == DeepScanningDialogStatus::SUCCESS; - } + // Accessors to simplify |dialog_state_| checking. + inline bool is_success() const { return dialog_state_ == State::SUCCESS; } - inline bool is_failure() const { - return dialog_status_ == DeepScanningDialogStatus::FAILURE; - } + inline bool is_failure() const { return dialog_state_ == State::FAILURE; } - inline bool is_warning() const { - return dialog_status_ == DeepScanningDialogStatus::WARNING; - } + inline bool is_warning() const { return dialog_state_ == State::WARNING; } inline bool is_result() const { return !is_pending(); } - inline bool is_pending() const { - return dialog_status_ == DeepScanningDialogStatus::PENDING; - } + inline bool is_pending() const { return dialog_state_ == State::PENDING; } bool has_custom_message() const { return !final_custom_message_.empty(); } @@ -155,14 +127,14 @@ final_learn_more_url_.is_valid(); } - // Returns the side image's logo color depending on |dialog_status_|. + // Returns the side image's logo color depending on |dialog_state_|. SkColor GetSideImageLogoColor() const; // Returns the side image's background circle color depending on - // |dialog_status_|. + // |dialog_state_|. SkColor GetSideImageBackgroundColor() const; - // Returns the appropriate top image depending on |dialog_status_|. + // Returns the appropriate top image depending on |dialog_state_|. const gfx::ImageSkia* GetTopImage() const; // Accessors used to validate the views in tests. @@ -174,33 +146,66 @@ // Friend the unit test class for this so it can call the private dtor. friend class ContentAnalysisDialogPlainTest; + // Enum used to represent what the dialog is currently showing. + enum class State { + // The dialog is shown with an explanation that the scan is being performed + // and that the result is pending. + PENDING, + + // The dialog is shown with a short message indicating that the scan was a + // success and that the user may proceed with their upload, drag-and-drop or + // paste. + SUCCESS, + + // The dialog is shown with a message indicating that the scan was a failure + // and that the user may not proceed with their upload, drag-and-drop or + // paste. + FAILURE, + + // The dialog is shown with a message indicating that the scan was a + // failure, but that the user may proceed with their upload, drag-and-drop + // or paste if they want to. + WARNING, + }; + ~ContentAnalysisDialog() override; - // Update the UI depending on |dialog_status_|. + void UpdateStateFromFinalResult( + ContentAnalysisDelegateBase::FinalResult final_result); + + // Updates the views in the dialog to put them in the correct state for + // |dialog_state_|. This doesn't trigger the same events/resizes as + // UpdateDialog(), and doesn't require the presence of a widget. This is safe + // to use in the first GetContentsView() call, before the dialog is shown. + void UpdateViews(); + + // Update the UI depending on |dialog_state_|. This also triggers resizes and + // fires some events. It's meant to be called to update the entire dialog when + // it's already showing. void UpdateDialog(); // Resizes the already shown dialog to accommodate changes in its content. void Resize(int height_to_add); - // Setup the appropriate buttons depending on |dialog_status_|. + // Setup the appropriate buttons depending on |dialog_state_|. void SetupButtons(); // Returns a newly created side icon. std::unique_ptr<views::View> CreateSideIcon(); - // Returns the appropriate dialog message depending on |dialog_status_|. + // Returns the appropriate dialog message depending on |dialog_state_|. std::u16string GetDialogMessage() const; - // Returns the text for the Cancel button depending on |dialog_status_|. + // Returns the text for the Cancel button depending on |dialog_state_|. std::u16string GetCancelButtonText() const; // Returns the text for the Ok button for the warning case. std::u16string GetBypassWarningButtonText() const; - // Returns the appropriate paste top image ID depending on |dialog_status_|. + // Returns the appropriate paste top image ID depending on |dialog_state_|. int GetPasteImageId(bool use_dark) const; - // Returns the appropriate upload top image ID depending on |dialog_status_|. + // Returns the appropriate upload top image ID depending on |dialog_state_|. int GetUploadImageId(bool use_dark) const; // Returns the appropriate pending message depending on |files_count_|. @@ -241,11 +246,10 @@ base::TimeTicks first_shown_timestamp_; // Used to show the appropriate dialog depending on the scan's status. - DeepScanningDialogStatus dialog_status_ = DeepScanningDialogStatus::PENDING; + State dialog_state_ = State::PENDING; // Used to show the appropriate message. - ContentAnalysisDelegateBase::FinalResult final_result_ = - ContentAnalysisDelegateBase::FinalResult::SUCCESS; + ContentAnalysisDelegateBase::FinalResult final_result_; std::u16string final_custom_message_; GURL final_learn_more_url_;
diff --git a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc index addef5d..3466069d 100644 --- a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc +++ b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc
@@ -746,13 +746,15 @@ protected: ContentAnalysisDialog* dialog() { return dialog_; } - ContentAnalysisDialog* CreateContentAnalysisDialog() { + ContentAnalysisDialog* CreateContentAnalysisDialog( + ContentAnalysisDelegateBase::FinalResult result = + ContentAnalysisDelegateBase::FinalResult::SUCCESS) { // This ctor ends up calling into constrained_window to show itself, in a // way that relinquishes its ownership. Because of this, new it here and // let it be deleted by the constrained_window code. dialog_ = new ContentAnalysisDialog( nullptr, browser()->tab_strip_model()->GetActiveWebContents(), - safe_browsing::DeepScanAccessPoint::DOWNLOAD, 0); + safe_browsing::DeepScanAccessPoint::DOWNLOAD, 0, result); return dialog_; } @@ -774,4 +776,50 @@ u"Your administrator says \"Test\"."); } +IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, + TestOpenInDefaultPendingState) { + ContentAnalysisDialog* dialog = CreateContentAnalysisDialog(); + EXPECT_TRUE(dialog->GetSideIconSpinnerForTesting()); + EXPECT_EQ( + dialog->GetMessageForTesting()->GetText(), + u"Checking this data with your organization's security policies..."); +} + +IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, + TestOpenInWarningState) { + ContentAnalysisDialog* dialog = CreateContentAnalysisDialog( + ContentAnalysisDelegateBase::FinalResult::WARNING); + EXPECT_EQ(nullptr, dialog->GetSideIconSpinnerForTesting()); + EXPECT_EQ(dialog->GetMessageForTesting()->GetText(), + u"This data has sensitive or dangerous content"); +} + +IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, TestOpenInBlockState) { + ContentAnalysisDialog* dialog = CreateContentAnalysisDialog( + ContentAnalysisDelegateBase::FinalResult::FAILURE); + EXPECT_EQ(nullptr, dialog->GetSideIconSpinnerForTesting()); + EXPECT_EQ(dialog->GetMessageForTesting()->GetText(), + u"This data has sensitive or dangerous content. Remove this " + u"content and try again."); +} + +IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, + TestOpenInLargeFilesState) { + ContentAnalysisDialog* dialog = CreateContentAnalysisDialog( + ContentAnalysisDelegateBase::FinalResult::LARGE_FILES); + EXPECT_EQ(nullptr, dialog->GetSideIconSpinnerForTesting()); + EXPECT_EQ(dialog->GetMessageForTesting()->GetText(), + u"Some of these files are too big for a security check. You can " + u"upload files up to 50 MB."); +} + +IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, + TestOpenInEncryptedFilesState) { + ContentAnalysisDialog* dialog = CreateContentAnalysisDialog( + ContentAnalysisDelegateBase::FinalResult::ENCRYPTED_FILES); + EXPECT_EQ(nullptr, dialog->GetSideIconSpinnerForTesting()); + EXPECT_EQ(dialog->GetMessageForTesting()->GetText(), + u"Some of these files are encrypted. Ask their owner to decrypt."); +} + } // namespace enterprise_connectors
diff --git a/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc index 544073d..186789a 100644 --- a/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc +++ b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc
@@ -207,7 +207,7 @@ return; case RetrieveDeviceDataStatus::kDataRecordNotFound: VLOG(1) << "The Endpoint Verification data is not present."; - Respond(NoArguments()); + Respond(OneArgument(base::Value(base::Value::BlobStorage()))); return; default: VLOG(1) << "Endpoint Verification data retrieval error: "
diff --git a/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_apitest.cc b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_apitest.cc new file mode 100644 index 0000000..bfb7962 --- /dev/null +++ b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_apitest.cc
@@ -0,0 +1,289 @@ +// 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 "build/build_config.h" +#include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "components/version_info/version_info.h" +#include "content/public/test/browser_test.h" +#include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" +#include "extensions/test/test_extension_dir.h" + +#if !BUILDFLAG(IS_CHROMEOS_ASH) +#include "components/enterprise/browser/controller/fake_browser_dm_token_storage.h" +#endif + +namespace extensions { +namespace { + +// Manifest key for the Endpoint Verification extension found at +// chrome.google.com/webstore/detail/callobklhcbilhphinckomhgkigmfocg +// This extension is authorized to use the enterprise.reportingPrivate API. +constexpr char kAuthorizedManifestKey[] = + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjXwWSZq5RLuM5ZbmRWn4gXwpMOb52a" + "oOhtzIsmbXUWPQeA6/D2p1uaPxIHh6EusxAhXMrBgNaJv1QFxCxiU1aGDlmCR9mOsA7rK5kmVC" + "i0TYLbQa+C38UDmyhRACrvHO26Jt8qC8oM8yiSuzgb+16rgCCcek9dP7IaHaoJMsBMAEf3VEno" + "4xt+kCAAsFsyFCB4plWid54avqpgg6+OsR3ZtUAMWooVziJHVmBTiyl82QR5ZURYr+TjkiljkP" + "EBLaMTKC2g7tUl2h0Q1UmMTMc2qxLIVVREhr4q9iOegNxfNy78BaxZxI1Hjp0EVYMZunIEI9r1" + "k0vyyaH13TvdeqNwIDAQAB"; + +// Manifest key for the Google Translate extension found at +// chrome.google.com/webstore/detail/aapbdbdomjkkjkaonfhkkikfgjllcleb +// This extension is unauthorized to use the enterprise.reportingPrivate API. +constexpr char kUnauthorizedManifestKey[] = + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfHy1M+jghaHyaVAILzx/c/Dy+RXtcaP9/5p" + "C7EY8JlNEI/G4DIIng9IzlrH8UWStpMWMyGUsdyusn2PkYFrqfVzhc2azVF3PX9D0KHG3FLN3m" + "Noz1YTBHvO5QSXJf292qW0tTYuoGqeTfXtF9odLdg20Xd0YrLmtS4TQkpSYGDwIDAQAB"; + +constexpr char kManifestTemplate[] = R"( + { + "key": "%s", + "name": "Enterprise Private Reporting API Test", + "version": "0.1", + "manifest_version": 2, + "permissions": [ + "enterprise.reportingPrivate" + ], + "background": { "scripts": ["background.js"] } + })"; + +} // namespace + +// This test class is to validate that the API is correctly unavailable on +// unsupported extensions and unsupported platforms. It also does basic +// validation that fields are present in the values the API returns, but it +// doesn't make strong assumption on what those values are to minimize the kind +// of mocking that is already done in unit/browser tests covering this API. +class EnterpriseReportingPrivateApiTest : public extensions::ExtensionApiTest { + public: + EnterpriseReportingPrivateApiTest() { +#if !BUILDFLAG(IS_CHROMEOS_ASH) + browser_dm_token_storage_.SetClientId("client_id"); +#endif + } + + ~EnterpriseReportingPrivateApiTest() override = default; + + void RunTest(const std::string& background_js, + bool authorized_manifest_key = true) { + ResultCatcher result_catcher; + TestExtensionDir test_dir; + test_dir.WriteManifest(base::StringPrintf( + kManifestTemplate, authorized_manifest_key ? kAuthorizedManifestKey + : kUnauthorizedManifestKey)); + + // Since the API functions use async callbacks, this wrapper code is + // necessary for assertions to work properly. + constexpr char kTestWrapper[] = R"( + chrome.test.runTests([ + async function asyncAssertions() { + %s + } + ]);)"; + test_dir.WriteFile(FILE_PATH_LITERAL("background.js"), + base::StringPrintf(kTestWrapper, background_js.c_str())); + + const Extension* extension = LoadExtension( + test_dir.UnpackedPath(), {.ignore_manifest_warnings = true}); + ASSERT_TRUE(extension); + ASSERT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); + } + + protected: +#if !BUILDFLAG(IS_CHROMEOS_ASH) + policy::FakeBrowserDMTokenStorage browser_dm_token_storage_; +#endif +}; + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, + ExtensionAvailability) { + constexpr char kBackgroundJs[] = R"( + chrome.test.assertEq(undefined, chrome.enterprise); + chrome.test.notifyPass(); + )"; + RunTest(kBackgroundJs, /*authorized_manifest_key*/ false); +} + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, GetDeviceId) { + constexpr char kAssertions[] = +#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) + "chrome.test.assertNoLastError();" + "chrome.test.assertEq(id, 'client_id');"; +#else + "chrome.test.assertLastError('Access to extension API denied.');"; +#endif + constexpr char kTest[] = R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.getDeviceId); + chrome.enterprise.reportingPrivate.getDeviceId((id) => { + %s + chrome.test.notifyPass(); + }); + )"; + RunTest(base::StringPrintf(kTest, kAssertions)); +} + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, GetPersistentSecret) { + constexpr char kAssertions[] = +#if defined(OS_WIN) || defined(OS_MAC) + "chrome.test.assertNoLastError();" + "chrome.test.assertTrue(secret instanceof ArrayBuffer);"; +#elif defined(OS_LINUX) + "chrome.test.assertLastError('-1');"; +#else + "chrome.test.assertLastError('Access to extension API denied.');"; +#endif + constexpr char kTest[] = R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.getPersistentSecret); + chrome.enterprise.reportingPrivate.getPersistentSecret((secret) => { + %s + chrome.test.notifyPass(); + }); + )"; + RunTest(base::StringPrintf(kTest, kAssertions)); +} + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, GetDeviceData) { + constexpr char kAssertions[] = +#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) + "chrome.test.assertNoLastError();" + "chrome.test.assertTrue(data instanceof ArrayBuffer);"; +#else + "chrome.test.assertLastError('Access to extension API denied.');"; +#endif + constexpr char kTest[] = R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.getDeviceData); + chrome.enterprise.reportingPrivate.getDeviceData('id', (data) => { + %s + chrome.test.notifyPass(); + }); + )"; + RunTest(base::StringPrintf(kTest, kAssertions)); +} + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, SetDeviceData) { + constexpr char kAssertions[] = +#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) + "chrome.test.assertNoLastError();" + "chrome.enterprise.reportingPrivate.getDeviceData('id', (data) => {" + " let view = new Int8Array(data);" + " chrome.test.assertEq(3, view.length);" + " chrome.test.assertEq(2, view[0]);" + " chrome.test.assertEq(1, view[1]);" + " chrome.test.assertEq(0, view[2]);" + " chrome.test.notifyPass();" + "});"; +#else + "chrome.test.assertLastError('Access to extension API denied.');" + "chrome.test.notifyPass();"; +#endif + constexpr char kTest[] = R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.setDeviceData); + let array = new Int8Array(3); + array[0] = 2; + array[1] = 1; + array[2] = 0; + chrome.enterprise.reportingPrivate.setDeviceData('id', array, () => { + %s + }); + )"; + RunTest(base::StringPrintf(kTest, kAssertions)); +} + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, GetDeviceInfo) { +#if defined(OS_WIN) + constexpr char kOSName[] = "windows"; +#elif defined(OS_MAC) + constexpr char kOSName[] = "macOS"; +#elif defined(OS_LINUX) + constexpr char kOSName[] = "linux"; +#endif + +#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) + constexpr char kTest[] = R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.getDeviceInfo); + + chrome.enterprise.reportingPrivate.getDeviceInfo((deviceInfo) => { + chrome.test.assertNoLastError(); + + chrome.test.assertEq(8, Object.keys(deviceInfo).length); + chrome.test.assertEq('%s', deviceInfo.osName); + chrome.test.assertEq(typeof deviceInfo.osVersion, 'string'); + chrome.test.assertEq(typeof deviceInfo.deviceHostName, 'string'); + chrome.test.assertEq(typeof deviceInfo.deviceModel, 'string'); + chrome.test.assertEq(typeof deviceInfo.serialNumber, 'string'); + chrome.test.assertEq(typeof deviceInfo.screenLockSecured, 'string'); + chrome.test.assertEq(typeof deviceInfo.diskEncrypted, 'string'); + chrome.test.assertTrue(deviceInfo.macAddresses instanceof Array); + + chrome.test.notifyPass(); + });)"; + RunTest(base::StringPrintf(kTest, kOSName)); +#else + RunTest(R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.getDeviceInfo); + + chrome.enterprise.reportingPrivate.getDeviceInfo((deviceInfo) => { + chrome.test.assertLastError('Access to extension API denied.'); + chrome.test.notifyPass(); + }); + )"); +#endif +} + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, GetContextInfo) { + RunTest(R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.getContextInfo); + chrome.enterprise.reportingPrivate.getContextInfo((info) => { + chrome.test.assertNoLastError(); + + chrome.test.assertEq(9, Object.keys(info).length); + chrome.test.assertTrue(info.browserAffiliationIds instanceof Array); + chrome.test.assertTrue(info.profileAffiliationIds instanceof Array); + chrome.test.assertTrue(info.onFileAttachedProviders instanceof Array); + chrome.test.assertTrue(info.onFileDownloadedProviders instanceof Array); + chrome.test.assertTrue(info.onBulkDataEntryProviders instanceof Array); + chrome.test.assertEq(typeof info.realtimeUrlCheckMode, 'string'); + chrome.test.assertTrue(info.onSecurityEventProviders instanceof Array); + chrome.test.assertEq(typeof info.browserVersion, 'string'); + chrome.test.assertEq(typeof info.safeBrowsingProtectionLevel, 'string'); + + chrome.test.notifyPass(); + });)"); +} + +IN_PROC_BROWSER_TEST_F(EnterpriseReportingPrivateApiTest, GetCertificate) { + // The encodedCertificate attribute should always be empty when the + // AutoSelectCertificateForUrls policy is unset. + RunTest(R"( + chrome.test.assertEq( + 'function', + typeof chrome.enterprise.reportingPrivate.getCertificate); + chrome.enterprise.reportingPrivate.getCertificate( + 'https://foo.com', (certificate) => { + chrome.test.assertNoLastError(); + + chrome.test.assertEq(1, Object.keys(certificate).length); + chrome.test.assertEq(typeof certificate.status, 'string'); + chrome.test.assertEq(certificate.encodedCertificate, undefined); + + chrome.test.notifyPass(); + });)"); +} + +} // namespace extensions
diff --git a/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc index 29fccd9..4658fff8 100644 --- a/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc +++ b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc
@@ -118,8 +118,14 @@ browser(), extensions::api_test_utils::NONE); ASSERT_TRUE(function->GetResultList()); - EXPECT_EQ(0u, function->GetResultList()->GetSize()); + EXPECT_EQ(1u, function->GetResultList()->GetSize()); EXPECT_TRUE(function->GetError().empty()); + + const base::Value* single_result = nullptr; + EXPECT_TRUE(function->GetResultList()->Get(0, &single_result)); + ASSERT_TRUE(single_result); + ASSERT_TRUE(single_result->is_blob()); + EXPECT_EQ(base::Value::BlobStorage(), single_result->GetBlob()); } TEST_F(EnterpriseReportingPrivateDeviceDataFunctionsTest, DeviceBadId) { @@ -196,8 +202,13 @@ std::move(values2), browser(), extensions::api_test_utils::NONE); ASSERT_TRUE(get_function2->GetResultList()); - EXPECT_EQ(0u, get_function2->GetResultList()->GetSize()); + EXPECT_EQ(1u, get_function2->GetResultList()->GetSize()); EXPECT_TRUE(get_function2->GetError().empty()); + + EXPECT_TRUE(get_function2->GetResultList()->Get(0, &single_result)); + ASSERT_TRUE(single_result); + ASSERT_TRUE(single_result->is_blob()); + EXPECT_EQ(base::Value::BlobStorage(), single_result->GetBlob()); } // TODO(pastarmovj): Remove once implementation for the other platform exists.
diff --git a/chrome/browser/extensions/back_forward_cache_browsertest.cc b/chrome/browser/extensions/back_forward_cache_browsertest.cc index 4fba49a..448e00e0 100644 --- a/chrome/browser/extensions/back_forward_cache_browsertest.cc +++ b/chrome/browser/extensions/back_forward_cache_browsertest.cc
@@ -20,7 +20,8 @@ public: explicit ExtensionBackForwardCacheBrowserTest( bool all_extensions_allowed = true, - bool allow_content_scripts = true) { + bool allow_content_scripts = true, + std::string blocked_extensions = "") { // If `allow_content_scripts` is true then `all_extensions_allowed` must // also be true. DCHECK(!(allow_content_scripts && !all_extensions_allowed)); @@ -30,7 +31,8 @@ allow_content_scripts ? "true" : "false"}, {"TimeToLiveInBackForwardCacheInSeconds", "3600"}, {"all_extensions_allowed", - all_extensions_allowed ? "true" : "false"}}}}, + all_extensions_allowed ? "true" : "false"}, + {"blocked_extensions", blocked_extensions}}}}, {features::kBackForwardCacheMemoryControls}); } @@ -513,4 +515,46 @@ blink::mojom::RendererEvictionReason::kJavaScriptExecution)); } +// Test that allows all extensions but disables bfcache in the presence of a few +// blocked ones. +class ExtensionBackForwardCacheBlockedExtensionBrowserTest + : public ExtensionBackForwardCacheBrowserTest { + public: + ExtensionBackForwardCacheBlockedExtensionBrowserTest() + : ExtensionBackForwardCacheBrowserTest( + /*all_extensions_allowed*/ true, + /*allow_content_scripts=*/true, + /*blocked_extensions=*/ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,mockepjebcnmhmhcahfddgfcdgkdifnc," + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") {} +}; + +// Tests that a blocked extension that is installed prevents back forward +// cache. +IN_PROC_BROWSER_TEST_F(ExtensionBackForwardCacheBlockedExtensionBrowserTest, + ScriptDisallowed) { + const Extension* extension = + LoadExtension(test_data_dir_.AppendASCII("trivial_extension") + .AppendASCII("extension.crx")); + ASSERT_TRUE(extension); + ASSERT_EQ(extension->id(), "mockepjebcnmhmhcahfddgfcdgkdifnc"); + + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); + GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); + + // 1) Navigate to A. + content::RenderFrameHost* rfh_a = + ui_test_utils::NavigateToURL(browser(), url_a); + content::RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); + + // 2) Navigate to B. + ui_test_utils::NavigateToURL(browser(), url_b); + + // Expect that `rfh_a` is destroyed as it wouldn't be placed in the cache + // since there is a blocked feature flag with id + // 'mockepjebcnmhmhcahfddgfcdgkdifnc'. + delete_observer_rfh_a.WaitUntilDeleted(); +} + } // namespace extensions
diff --git a/chrome/browser/extensions/extension_security_exploit_browsertest.cc b/chrome/browser/extensions/extension_security_exploit_browsertest.cc index 09c08b8..0860d8e7 100644 --- a/chrome/browser/extensions/extension_security_exploit_browsertest.cc +++ b/chrome/browser/extensions/extension_security_exploit_browsertest.cc
@@ -353,15 +353,10 @@ // Inject the malformed/mutated IPC and verify that the renderer is terminated // as expected. - content::RenderProcessHost* main_frame_process = - web_contents->GetMainFrame()->GetProcess(); - RenderProcessHostBadIpcMessageWaiter kill_waiter(main_frame_process); - IPC::IpcSecurityTestUtil::PwnMessageReceived( - main_frame_process->GetChannel(), - ExtensionHostMsg_OpenChannelToExtension(source_context, info, - channel_name, port_id)); - EXPECT_EQ(bad_message::EMF_INVALID_EXTENSION_ID_FOR_CONTENT_SCRIPT, - kill_waiter.Wait()); + // + // TODO(https://crbug.com/1212918: Once the bug is fixed, re-enable the test + // assertion that verifies that `kill_waiter.Wait()` returns + // EMF_INVALID_EXTENSION_ID_FOR_CONTENT_SCRIPT. } IN_PROC_BROWSER_TEST_F(OpenChannelToExtensionExploitTest,
diff --git a/chrome/browser/extensions/tab_helper.cc b/chrome/browser/extensions/tab_helper.cc index 6fe783e..626cd777 100644 --- a/chrome/browser/extensions/tab_helper.cc +++ b/chrome/browser/extensions/tab_helper.cc
@@ -164,19 +164,40 @@ return all_extensions_allowed.Get(); } +std::string BlockedExtensionListForBFCache() { + // If back forward cache is disabled, indicate nothing is blocked. + if (!content::BackForwardCache::IsBackForwardCacheFeatureEnabled()) + return std::string(); + + static base::FeatureParam<std::string> extensions_blocked( + &features::kBackForwardCache, "blocked_extensions", ""); + return extensions_blocked.Get(); +} + void DisableBackForwardCacheIfNecessary( const ExtensionSet& enabled_extensions, content::BrowserContext* context, content::NavigationHandle* navigation_handle) { - // If we allow all extensions for bfcache then just return. - if (AreAllExtensionsAllowedForBFCache()) + bool all_allowed = AreAllExtensionsAllowedForBFCache(); + std::string blocked_extensions = BlockedExtensionListForBFCache(); + + // If we allow all extensions for bfcache and there aren't any blocked, then + // just return. + if (all_allowed && blocked_extensions.empty()) return; + // We shouldn't have blocked extensions if `all_allowed` is false. + DCHECK(blocked_extensions.empty() || all_allowed); + bool disable_bfcache = false; // If the user data exists we know we are disabled. if (context->GetUserData(kIsBFCacheDisabledKey)) { disable_bfcache = true; } else { + std::vector<std::string> blocked_extensions_list = + base::SplitString(blocked_extensions, ",", base::TRIM_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); + // Compute whether we need to disable it. for (const auto& extension : enabled_extensions) { // Skip component extensions, apps, themes, shared modules and the google @@ -188,6 +209,13 @@ continue; } if (util::IsExtensionVisibleToContext(*extension, context)) { + // If we are allowing all extensions with a block filter set, and this + // extension is not in it then continue. + if (all_allowed && + !base::Contains(blocked_extensions_list, extension->id())) { + continue; + } + VLOG(1) << "Disabled bfcache due to " << extension->short_name() << "," << extension->id(); if (!disable_bfcache) {
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index b54e6b1..6a0e1b5 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -241,7 +241,7 @@ { "name": "ash-enable-pip-rounded-corners", "owners": [ "edcourtney" ], - "expiry_milestone": 90 + "expiry_milestone": 96 }, { "name": "ash-enable-unified-desktop", @@ -2207,6 +2207,16 @@ "expiry_milestone": 80 }, { + "name" : "enable-projector-feature", + "owners" : [ "cros-families-eng@google.com" ], + "expiry_milestone": 100 + }, + { + "name" : "enable-projector-feature-pod", + "owners" : [ "cros-families-eng@google.com" ], + "expiry_milestone": 100 + }, + { "name": "enable-quic", "owners": [ "//net/quic/OWNERS" ], // This flag is used by network administrators to debug @@ -2631,6 +2641,11 @@ "expiry_milestone": -1 }, { + "name": "enable-webrtc-analog-agc-clipping-control", + "owners": [ "alessiob", "silen", "minyue" ], + "expiry_milestone": 103 + }, + { "name": "enable-webrtc-capture-multi-channel-audio-processing", "owners": [ "saza" ], "expiry_milestone": 123 @@ -4146,16 +4161,6 @@ "expiry_milestone": 95 }, { - "name": "pdf-viewer-document-properties", - "owners": [ "dhoss", "dpapad" ], - "expiry_milestone": 92 - }, - { - "name": "pdf-viewer-presentation-mode", - "owners": [ "dpapad" ], - "expiry_milestone": 92 - }, - { "name": "pdf-xfa-forms", "owners": [ "carlosil", "tsepez" ], "expiry_milestone": 94 @@ -4226,11 +4231,6 @@ "expiry_milestone": 96 }, { - "name": "prefetch-notification-scheduling-integration", - "owners": [ "hesen" ], - "expiry_milestone": 88 - }, - { "name": "print-with-reduced-rasterization", "owners": [ "thestig" ], "expiry_milestone": 96
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index ceb37133..299e08c 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -2635,6 +2635,11 @@ const char kWebrtcHybridAgcDescription[] = "WebRTC Agc2 digital adaptation with Agc1 analog adaptation."; +const char kWebrtcAnalogAgcClippingControlName[] = + "WebRTC Agc1 analog clipping control."; +const char kWebrtcAnalogAgcClippingControlDescription[] = + "WebRTC Agc1 analog clipping controller to reduce saturation."; + const char kWebrtcHwDecodingName[] = "WebRTC hardware video decoding"; const char kWebrtcHwDecodingDescription[] = "Support in WebRTC for decoding video streams using platform hardware."; @@ -3389,12 +3394,6 @@ const char kUserMediaScreenCapturingDescription[] = "Allows sites to request a video stream of your screen."; -const char kPrefetchNotificationSchedulingIntegrationName[] = - "Enable prefetch notification using notification scheduling system"; -const char kPrefetchNotificationSchedulingIntegrationDescription[] = - "if enable prefetch notification service and background task will hook up " - "to notification scheduling system in native side"; - const char kVideoTutorialsName[] = "Enable video tutorials"; const char kVideoTutorialsDescription[] = "Show video tutorials in Chrome"; const char kVideoTutorialsInstantFetchName[] = @@ -4577,6 +4576,14 @@ const char kListAllDisplayModesDescription[] = "Enables listing all external displays' modes in the display settings."; +const char kProjectorFeaturePodName[] = "Show Projector In System Tray"; +const char kProjectorFeaturePodDescription[] = + "Enables showing the projector feature pod in system stray"; + +const char kProjectorName[] = "Enable the Projector feature"; +const char kProjectorDescription[] = + "Enables projector feature flag to be used"; + const char kEnableHardwareMirrorModeName[] = "Enable Hardware Mirror Mode"; const char kEnableHardwareMirrorModeDescription[] = "Enables hardware support when multiple displays are set to mirror mode."; @@ -5055,20 +5062,6 @@ "instead."; #endif // ENABLE_PAINT_PREVIEW && defined(OS_ANDROID) -#if BUILDFLAG(ENABLE_PLUGINS) - -const char kPdfViewerDocumentPropertiesName[] = - "PDF Viewer Document Properties"; -const char kPdfViewerDocumentPropertiesDescription[] = - "When enabled, the PDF viewer will include an option in the toolbar's " - "overflow menu to open a dialog containing document properties."; - -const char kPdfViewerPresentationModeName[] = "PDF Viewer Presentation Mode"; -const char kPdfViewerPresentationModeDescription[] = - "When enabled, the PDF viewer will include an option in the toolbar's " - "overflow menu to enter Presentation (full screen) Mode."; -#endif // BUILDFLAG(ENABLE_PLUGINS) - #if BUILDFLAG(ENABLE_WEBUI_TAB_STRIP) const char kWebUITabStripName[] = "WebUI tab strip"; const char kWebUITabStripDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index 1880da9..38e7bbbb 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -1512,6 +1512,9 @@ extern const char kWebrtcHybridAgcName[]; extern const char kWebrtcHybridAgcDescription[]; +extern const char kWebrtcAnalogAgcClippingControlName[]; +extern const char kWebrtcAnalogAgcClippingControlDescription[]; + extern const char kWebrtcHwDecodingName[]; extern const char kWebrtcHwDecodingDescription[]; @@ -1956,9 +1959,6 @@ extern const char kVoiceButtonInTopToolbarName[]; extern const char kVoiceButtonInTopToolbarDescription[]; -extern const char kPrefetchNotificationSchedulingIntegrationName[]; -extern const char kPrefetchNotificationSchedulingIntegrationDescription[]; - extern const char kInlineUpdateFlowName[]; extern const char kInlineUpdateFlowDescription[]; @@ -2659,6 +2659,12 @@ extern const char kListAllDisplayModesName[]; extern const char kListAllDisplayModesDescription[]; +extern const char kProjectorFeaturePodName[]; +extern const char kProjectorFeaturePodDescription[]; + +extern const char kProjectorName[]; +extern const char kProjectorDescription[]; + extern const char kEnableHardwareMirrorModeName[]; extern const char kEnableHardwareMirrorModeDescription[]; @@ -2964,14 +2970,6 @@ extern const char kPaintPreviewStartupDescription[]; #endif // ENABLE_PAINT_PREVIEW && defined(OS_ANDROID) -#if BUILDFLAG(ENABLE_PLUGINS) -extern const char kPdfViewerDocumentPropertiesName[]; -extern const char kPdfViewerDocumentPropertiesDescription[]; - -extern const char kPdfViewerPresentationModeName[]; -extern const char kPdfViewerPresentationModeDescription[]; -#endif // BUILDFLAG(ENABLE_PLUGINS) - #if BUILDFLAG(ENABLE_WEBUI_TAB_STRIP) extern const char kWebUITabStripName[]; extern const char kWebUITabStripDescription[];
diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc index 435cd37..8717a6b 100644 --- a/chrome/browser/flags/android/chrome_feature_list.cc +++ b/chrome/browser/flags/android/chrome_feature_list.cc
@@ -126,6 +126,7 @@ &feed::kInterestFeedV2, &feed::kInterestFeedV2Autoplay, &feed::kInterestFeedV2Hearts, + &feed::kReliabilityLogging, &feed::kWebFeed, &feed::kXsurfaceMetricsReporting, &history::kHideFromApi3Transitions,
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java index 050c56d..8021d5f8 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java
@@ -336,6 +336,7 @@ public static final String EXPERIMENTS_FOR_AGSA = "ExperimentsForAgsa"; public static final String EXPLICIT_LANGUAGE_ASK = "ExplicitLanguageAsk"; public static final String EXPLORE_SITES = "ExploreSites"; + public static final String FEED_RELIABILITY_LOGGING = "FeedReliabilityLogging"; public static final String FILLING_PASSWORDS_FROM_ANY_ORIGIN = "FillingPasswordsFromAnyOrigin"; public static final String FOCUS_OMNIBOX_IN_INCOGNITO_TAB_INTENTS = "FocusOmniboxInIncognitoTabIntents";
diff --git a/chrome/browser/media/android/cdm/media_drm_storage_factory.cc b/chrome/browser/media/android/cdm/media_drm_storage_factory.cc index a16e1510..68fec4c 100644 --- a/chrome/browser/media/android/cdm/media_drm_storage_factory.cc +++ b/chrome/browser/media/android/cdm/media_drm_storage_factory.cc
@@ -151,7 +151,7 @@ : base::BindRepeating(&CreateOriginId); // The object will be deleted on connection error, or when the frame navigates - // away. See FrameServiceBase for details. + // away. See DocumentServiceBase for details. new cdm::MediaDrmStorageImpl( render_frame_host, pref_service, get_origin_id_cb, base::BindRepeating(&AllowEmptyOriginId, render_frame_host),
diff --git a/chrome/browser/media/cdm_pref_service_impl.cc b/chrome/browser/media/cdm_pref_service_impl.cc index 3af7bc0..01bf2e4 100644 --- a/chrome/browser/media/cdm_pref_service_impl.cc +++ b/chrome/browser/media/cdm_pref_service_impl.cc
@@ -93,14 +93,14 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // The object is bound to the lifetime of `render_frame_host` and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new CdmPrefServiceImpl(render_frame_host, std::move(receiver)); } CdmPrefServiceImpl::CdmPrefServiceImpl( content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<media::mojom::CdmPrefService> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)) {} + : DocumentServiceBase(render_frame_host, std::move(receiver)) {} CdmPrefServiceImpl::~CdmPrefServiceImpl() = default;
diff --git a/chrome/browser/media/cdm_pref_service_impl.h b/chrome/browser/media/cdm_pref_service_impl.h index 3632224..599cba1f 100644 --- a/chrome/browser/media/cdm_pref_service_impl.h +++ b/chrome/browser/media/cdm_pref_service_impl.h
@@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_MEDIA_CDM_PREF_SERVICE_IMPL_H_ #define CHROME_BROWSER_MEDIA_CDM_PREF_SERVICE_IMPL_H_ -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "media/mojo/mojom/cdm_pref_service.mojom.h" #include "url/origin.h" @@ -17,7 +17,7 @@ // for origins serving hardware security protected contents and as such the size // of the CDM Origin ID dictionary should only contain a handful of items. class CdmPrefServiceImpl final - : public content::FrameServiceBase<media::mojom::CdmPrefService> { + : public content::DocumentServiceBase<media::mojom::CdmPrefService> { public: static void Create( content::RenderFrameHost* render_frame_host, @@ -35,7 +35,7 @@ CdmPrefServiceImpl( content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<media::mojom::CdmPrefService> receiver); - // `this` can only be destructed as a FrameServiceBase + // `this` can only be destructed as a DocumentServiceBase ~CdmPrefServiceImpl() final; };
diff --git a/chrome/browser/media/output_protection_impl.cc b/chrome/browser/media/output_protection_impl.cc index 0e49144ca9..ba42f2a 100644 --- a/chrome/browser/media/output_protection_impl.cc +++ b/chrome/browser/media/output_protection_impl.cc
@@ -24,14 +24,14 @@ DCHECK(render_frame_host); // The object is bound to the lifetime of |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new OutputProtectionImpl(render_frame_host, std::move(receiver)); } OutputProtectionImpl::OutputProtectionImpl( content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<media::mojom::OutputProtection> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), render_process_id_(render_frame_host->GetProcess()->GetID()), render_frame_id_(render_frame_host->GetRoutingID()) {}
diff --git a/chrome/browser/media/output_protection_impl.h b/chrome/browser/media/output_protection_impl.h index a094834a..e87db5b 100644 --- a/chrome/browser/media/output_protection_impl.h +++ b/chrome/browser/media/output_protection_impl.h
@@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_MEDIA_OUTPUT_PROTECTION_IMPL_H_ #define CHROME_BROWSER_MEDIA_OUTPUT_PROTECTION_IMPL_H_ -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "media/mojo/mojom/output_protection.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" @@ -19,7 +19,7 @@ // their statuses. On all platforms we'll check the network links. On ChromeOS // we'll also check the hardware links. Can only be used on the UI thread. class OutputProtectionImpl final - : public content::FrameServiceBase<media::mojom::OutputProtection> { + : public content::DocumentServiceBase<media::mojom::OutputProtection> { public: static void Create( content::RenderFrameHost* render_frame_host, @@ -35,7 +35,7 @@ EnableProtectionCallback callback) final; private: - // |this| can only be destructed as a FrameServiceBase. + // |this| can only be destructed as a DocumentServiceBase. ~OutputProtectionImpl() final; // Callbacks for QueryStatus and EnableProtection results.
diff --git a/chrome/browser/media/platform_verification_impl.cc b/chrome/browser/media/platform_verification_impl.cc index 056a548..e1c0d0ed 100644 --- a/chrome/browser/media/platform_verification_impl.cc +++ b/chrome/browser/media/platform_verification_impl.cc
@@ -61,14 +61,14 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // The object is bound to the lifetime of |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new PlatformVerificationImpl(render_frame_host, std::move(receiver)); } PlatformVerificationImpl::PlatformVerificationImpl( content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<media::mojom::PlatformVerification> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), render_frame_host_(render_frame_host) {} PlatformVerificationImpl::~PlatformVerificationImpl() {
diff --git a/chrome/browser/media/platform_verification_impl.h b/chrome/browser/media/platform_verification_impl.h index ff09e02..0efe796 100644 --- a/chrome/browser/media/platform_verification_impl.h +++ b/chrome/browser/media/platform_verification_impl.h
@@ -10,7 +10,7 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" #include "build/chromeos_buildflags.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "media/mojo/mojom/platform_verification.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" @@ -21,7 +21,7 @@ // Implements media::mojom::PlatformVerification. Can only be used on the // UI thread because PlatformVerificationFlow lives on the UI thread. class PlatformVerificationImpl final - : public content::FrameServiceBase<media::mojom::PlatformVerification> { + : public content::DocumentServiceBase<media::mojom::PlatformVerification> { public: static void Create( content::RenderFrameHost* render_frame_host, @@ -41,7 +41,7 @@ #endif // BUILDFLAG(IS_CHROMEOS_ASH) private: - // |this| can only be destructed as a FrameServiceBase. + // |this| can only be destructed as a DocumentServiceBase. ~PlatformVerificationImpl() final; #if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/navigation_predictor/navigation_predictor.cc b/chrome/browser/navigation_predictor/navigation_predictor.cc index 1c23d85c7..fe7a5e6 100644 --- a/chrome/browser/navigation_predictor/navigation_predictor.cc +++ b/chrome/browser/navigation_predictor/navigation_predictor.cc
@@ -42,7 +42,7 @@ NavigationPredictor::NavigationPredictor( content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<AnchorElementMetricsHost> receiver) - : content::FrameServiceBase<blink::mojom::AnchorElementMetricsHost>( + : content::DocumentServiceBase<blink::mojom::AnchorElementMetricsHost>( render_frame_host, std::move(receiver)) { DETACH_FROM_SEQUENCE(sequence_checker_); @@ -75,7 +75,7 @@ } // The object is bound to the lifetime of the |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new NavigationPredictor(render_frame_host, std::move(receiver)); }
diff --git a/chrome/browser/navigation_predictor/navigation_predictor.h b/chrome/browser/navigation_predictor/navigation_predictor.h index 0e056e20..26cc788 100644 --- a/chrome/browser/navigation_predictor/navigation_predictor.h +++ b/chrome/browser/navigation_predictor/navigation_predictor.h
@@ -12,7 +12,7 @@ #include "base/macros.h" #include "base/sequence_checker.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/visibility.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "services/metrics/public/cpp/ukm_recorder.h" @@ -32,8 +32,8 @@ // // This class derives from WebContentsObserver so that it can keep track of when // WebContents is being destroyed via web_contents(). -class NavigationPredictor - : public content::FrameServiceBase<blink::mojom::AnchorElementMetricsHost> { +class NavigationPredictor : public content::DocumentServiceBase< + blink::mojom::AnchorElementMetricsHost> { public: NavigationPredictor(content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<AnchorElementMetricsHost> receiver);
diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc index cb67a0cd..a1bfc2a 100644 --- a/chrome/browser/pdf/pdf_extension_test.cc +++ b/chrome/browser/pdf/pdf_extension_test.cc
@@ -402,33 +402,13 @@ protected: // Hooks to set up feature flags. virtual const std::vector<base::Feature> GetEnabledFeatures() const { - std::vector<base::Feature> enabled; - if (ShouldEnablePdfViewerPresentationMode()) { - enabled.push_back(chrome_pdf::features::kPdfViewerPresentationMode); - } - if (ShouldEnablePdfViewerDocumentProperties()) { - enabled.push_back(chrome_pdf::features::kPdfViewerDocumentProperties); - } - return enabled; + return {}; } virtual const std::vector<base::Feature> GetDisabledFeatures() const { - std::vector<base::Feature> disabled; - if (!ShouldEnablePdfViewerPresentationMode()) { - disabled.push_back(chrome_pdf::features::kPdfViewerPresentationMode); - } - if (!ShouldEnablePdfViewerDocumentProperties()) { - disabled.push_back(chrome_pdf::features::kPdfViewerDocumentProperties); - } - return disabled; + return {}; } - // Hook to set up whether the PdfViewerPresentationMode feature is enabled. - virtual bool ShouldEnablePdfViewerPresentationMode() const { return false; } - - // Hook to set up whether the PdfViewerDocumentProperties feature is enabled. - virtual bool ShouldEnablePdfViewerDocumentProperties() const { return false; } - private: WebContents* LoadPdfGetGuestContentsHelper(const GURL& url, bool new_tab) { if (new_tab) { @@ -898,39 +878,6 @@ } }; -class PDFExtensionDocumentPropertiesEnabledTest - : public PDFExtensionJSTestBase { - public: - ~PDFExtensionDocumentPropertiesEnabledTest() override = default; - - protected: - bool ShouldEnablePdfViewerDocumentProperties() const override { return true; } -}; - -IN_PROC_BROWSER_TEST_F(PDFExtensionDocumentPropertiesEnabledTest, - ViewerPropertiesDialog) { - // The properties dialog formats some values based on locale. - base::test::ScopedRestoreICUDefaultLocale scoped_locale{"en_US"}; - // This will apply to the new processes spawned within RunTestsInJsModule(), - // thus consistently running the test in a well known time zone. - content::ScopedTimeZone scoped_time_zone{"America/Los_Angeles"}; - RunTestsInJsModule("viewer_properties_dialog_test.js", "document_info.pdf"); -} - -class PDFExtensionPresentationModeEnabledTest : public PDFExtensionJSTestBase { - public: - ~PDFExtensionPresentationModeEnabledTest() override = default; - - protected: - bool ShouldEnablePdfViewerPresentationMode() const override { return true; } -}; - -IN_PROC_BROWSER_TEST_F(PDFExtensionPresentationModeEnabledTest, Fullscreen) { - // Use a PDF document with multiple pages, to exercise navigating between - // pages. - RunTestsInJsModule("fullscreen_test.js", "test-bookmarks.pdf"); -} - class PDFExtensionJSTest : public PDFExtensionJSTestBase { public: ~PDFExtensionJSTest() override = default; @@ -1029,7 +976,7 @@ RunTestsInJsModule("redirects_fail_test.js", "test.pdf"); } -IN_PROC_BROWSER_TEST_F(PDFExtensionJSTest, ViewerPdfToolbar) { +IN_PROC_BROWSER_TEST_F(PDFExtensionJSTest, ViewerToolbar) { // Although this test file does not require a PDF to be loaded, loading the // elements without loading a PDF is difficult. RunTestsInJsModule("viewer_toolbar_test.js", "test.pdf"); @@ -1053,6 +1000,21 @@ RunTestsInJsModule("viewer_thumbnail_test.js", "test.pdf"); } +IN_PROC_BROWSER_TEST_F(PDFExtensionJSTest, Fullscreen) { + // Use a PDF document with multiple pages, to exercise navigating between + // pages. + RunTestsInJsModule("fullscreen_test.js", "test-bookmarks.pdf"); +} + +IN_PROC_BROWSER_TEST_F(PDFExtensionJSTest, ViewerPropertiesDialog) { + // The properties dialog formats some values based on locale. + base::test::ScopedRestoreICUDefaultLocale scoped_locale{"en_US"}; + // This will apply to the new processes spawned within RunTestsInJsModule(), + // thus consistently running the test in a well known time zone. + content::ScopedTimeZone scoped_time_zone{"America/Los_Angeles"}; + RunTestsInJsModule("viewer_properties_dialog_test.js", "document_info.pdf"); +} + #if BUILDFLAG(IS_CHROMEOS_ASH) IN_PROC_BROWSER_TEST_F(PDFExtensionJSTest, Printing) { RunTestsInJsModule("printing_icon_test.js", "test.pdf");
diff --git a/chrome/browser/pdf/pdf_extension_util.cc b/chrome/browser/pdf/pdf_extension_util.cc index 6f304559..f5fcfe6 100644 --- a/chrome/browser/pdf/pdf_extension_util.cc +++ b/chrome/browser/pdf/pdf_extension_util.cc
@@ -187,13 +187,6 @@ } void AddAdditionalData(bool enable_annotations, base::Value* dict) { - dict->SetKey("documentPropertiesEnabled", - base::Value(base::FeatureList::IsEnabled( - chrome_pdf::features::kPdfViewerDocumentProperties))); - dict->SetKey("presentationModeEnabled", - base::Value(base::FeatureList::IsEnabled( - chrome_pdf::features::kPdfViewerPresentationMode))); - bool printing_enabled = true; bool annotations_enabled = false; #if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/policy/chrome_policy_conversions_client.cc b/chrome/browser/policy/chrome_policy_conversions_client.cc index dce5472..5a68b87 100644 --- a/chrome/browser/policy/chrome_policy_conversions_client.cc +++ b/chrome/browser/policy/chrome_policy_conversions_client.cc
@@ -37,7 +37,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ash/settings/cros_settings.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc index a2a8e7d..b066c11 100644 --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -132,7 +132,7 @@ #include "chrome/browser/chromeos/platform_keys/key_permissions/key_permissions_policy_handler.h" #include "chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.h" #include "chrome/browser/chromeos/policy/lacros_availability_policy_handler.h" -#include "chrome/browser/chromeos/policy/secondary_google_account_signin_policy_handler.h" +#include "chrome/browser/chromeos/policy/login/secondary_google_account_signin_policy_handler.h" #include "chrome/browser/chromeos/policy/system_features_disable_list_policy_handler.h" #include "chrome/browser/nearby_sharing/common/nearby_share_prefs.h" #include "chrome/browser/policy/default_geolocation_policy_handler.h"
diff --git a/chrome/browser/policy/login_policy_test_base_browsertest.cc b/chrome/browser/policy/login_policy_test_base_browsertest.cc index 0d25007e..bee89e56 100644 --- a/chrome/browser/policy/login_policy_test_base_browsertest.cc +++ b/chrome/browser/policy/login_policy_test_base_browsertest.cc
@@ -12,7 +12,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" -#include "chrome/browser/chromeos/policy/login_policy_test_base.h" +#include "chrome/browser/chromeos/policy/login/login_policy_test_base.h" #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/policy/messaging_layer/public/report_client.cc b/chrome/browser/policy/messaging_layer/public/report_client.cc index 76e6714..1bd6cc0 100644 --- a/chrome/browser/policy/messaging_layer/public/report_client.cc +++ b/chrome/browser/policy/messaging_layer/public/report_client.cc
@@ -55,18 +55,13 @@ } // namespace ReportingClient::AsyncStartUploaderRequest::AsyncStartUploaderRequest( - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb) - : priority_(priority), - need_encryption_key_(need_encryption_key), + : need_encryption_key_(need_encryption_key), start_uploader_cb_(std::move(start_uploader_cb)) {} ReportingClient::AsyncStartUploaderRequest::~AsyncStartUploaderRequest() = default; -Priority ReportingClient::AsyncStartUploaderRequest::priority() const { - return priority_; -} bool ReportingClient::AsyncStartUploaderRequest::need_encryption_key() const { return need_encryption_key_; } @@ -381,23 +376,21 @@ // static void ReportingClient::AsyncStartUploader( - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb) { ReportingClient* const instance = static_cast<ReportingClient*>(GetInstance()); - instance->DeliverAsyncStartUploader(priority, need_encryption_key, + instance->DeliverAsyncStartUploader(need_encryption_key, std::move(start_uploader_cb)); } void ReportingClient::DeliverAsyncStartUploader( - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb) { uploaders_queue_task_runner_->PostTask( FROM_HERE, base::BindOnce( - [](Priority priority, bool need_encryption_key, + [](bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb, ReportingClient* instance) { DCHECK_CALLED_ON_VALID_SEQUENCE( @@ -413,9 +406,9 @@ } // Not set yet. Enqueue it. instance->async_start_uploaders_queue_.emplace( - priority, need_encryption_key, std::move(start_uploader_cb)); + need_encryption_key, std::move(start_uploader_cb)); }, - priority, need_encryption_key, std::move(start_uploader_cb), + need_encryption_key, std::move(start_uploader_cb), base::Unretained(this))); }
diff --git a/chrome/browser/policy/messaging_layer/public/report_client.h b/chrome/browser/policy/messaging_layer/public/report_client.h index c086ac5..44f447a 100644 --- a/chrome/browser/policy/messaging_layer/public/report_client.h +++ b/chrome/browser/policy/messaging_layer/public/report_client.h
@@ -115,7 +115,6 @@ class AsyncStartUploaderRequest { public: AsyncStartUploaderRequest( - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb); AsyncStartUploaderRequest(const AsyncStartUploaderRequest& other) = delete; @@ -123,12 +122,10 @@ const AsyncStartUploaderRequest& other) = delete; ~AsyncStartUploaderRequest(); - Priority priority() const; bool need_encryption_key() const; UploaderInterface::UploaderInterfaceResultCb& start_uploader_cb(); private: - const Priority priority_; const bool need_encryption_key_; UploaderInterface::UploaderInterfaceResultCb start_uploader_cb_; }; @@ -149,14 +146,11 @@ void OnInitState(bool reporting_client_configured); void OnInitializationComplete(Status init_status); - // TODO(b/183666933) Priority is used only for testing, remove it if possible. static void AsyncStartUploader( - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb); void DeliverAsyncStartUploader( - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb);
diff --git a/chrome/browser/policy/profile_policy_connector.cc b/chrome/browser/policy/profile_policy_connector.cc index 524baf4..558683033 100644 --- a/chrome/browser/policy/profile_policy_connector.cc +++ b/chrome/browser/policy/profile_policy_connector.cc
@@ -33,12 +33,12 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/browser_process_platform_part.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/device_local_account.h" #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" -#include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" +#include "chrome/browser/chromeos/policy/login/login_profile_policy_provider.h" #include "components/policy/core/common/proxy_policy_provider.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h"
diff --git a/chrome/browser/policy/profile_policy_connector_builder.cc b/chrome/browser/policy/profile_policy_connector_builder.cc index 2a35f2d..f2dd76af 100644 --- a/chrome/browser/policy/profile_policy_connector_builder.cc +++ b/chrome/browser/policy/profile_policy_connector_builder.cc
@@ -18,7 +18,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ash/profiles/profile_helper.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" #else // Non-ChromeOS. #include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
diff --git a/chrome/browser/policy/schema_registry_service_builder.cc b/chrome/browser/policy/schema_registry_service_builder.cc index 60b00d7..2cef2c1 100644 --- a/chrome/browser/policy/schema_registry_service_builder.cc +++ b/chrome/browser/policy/schema_registry_service_builder.cc
@@ -19,7 +19,7 @@ #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part_chromeos.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
diff --git a/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.h b/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.h index 86617dc..c703623 100644 --- a/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.h +++ b/chrome/browser/prefetch/prefetch_proxy/chrome_speculation_host_delegate.h
@@ -35,7 +35,7 @@ std::vector<blink::mojom::SpeculationCandidatePtr>& candidates) override; private: - // content::SpeculationHostImpl, which inherits content::FrameServiceBase, + // content::SpeculationHostImpl, which inherits content::DocumentServiceBase, // owns `this`, so `this` can access `render_frame_host_` safely. content::RenderFrameHost& render_frame_host_;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 0f051ffa..3fd507a 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc
@@ -180,7 +180,7 @@ #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ash/settings/device_settings_service.h" #include "chrome/browser/chromeos/locale_change_guard.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/user_policy_manager_builder_chromeos.h" #include "chrome/browser/chromeos/preferences.h"
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/classic_background.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/classic_background.js index 86676db..e217156 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/classic_background.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/classic_background.js
@@ -188,23 +188,18 @@ * A helper function which executes code. * @param {string} code The code to execute. */ - const executeScript = goog.bind(function(code) { - chrome.tabs.executeScript( - tab.id, {code, 'allFrames': true}, goog.bind(function() { - if (!chrome.extension.lastError) { - return; - } - if (sawError) { - return; - } - sawError = true; - console.error('Could not inject into tab', tab); - this.tts.speak( - 'Error starting ChromeVox for ' + tab.title + ', ' + - tab.url, - QueueMode.QUEUE); - }, this)); - }, this); + const executeScript = (code) => { + chrome.tabs.executeScript(tab.id, {code, 'allFrames': true}, () => { + if (!chrome.extension.lastError) { + return; + } + if (sawError) { + return; + } + sawError = true; + console.error('Could not inject into tab', tab); + }); + }; // There is a scenario where two copies of the content script can get // loaded into the same tab on browser startup - one automatically and @@ -288,7 +283,7 @@ * messages to the proper destination. */ addBridgeListener() { - ExtensionBridge.addMessageListener(goog.bind(function(msg, port) { + ExtensionBridge.addMessageListener((msg, port) => { const target = msg['target']; const action = msg['action']; @@ -319,7 +314,7 @@ } break; } - }, this)); + }); } /** @@ -350,7 +345,7 @@ const background = new ChromeVoxBackground(); // TODO: this needs to be cleaned up (move to init?). - window['speak'] = goog.bind(background.tts.speak, background.tts); + window['speak'] = background.tts.speak.bind(background.tts); ChromeVoxState.backgroundTts = background.backgroundTts_; // Export the prefs object for access by the options page. window['prefs'] = ChromeVoxPrefs.instance;
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_display_manager.js b/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_display_manager.js index 6db1f9c..2a1c0df 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_display_manager.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_display_manager.js
@@ -89,15 +89,14 @@ this.updatePanStrategy_(items.brailleWordWrap); }.bind(this)); - BrailleCaptionsBackground.init( - goog.bind(this.onCaptionsStateChanged_, this)); + BrailleCaptionsBackground.init(this.onCaptionsStateChanged_.bind(this)); if (goog.isDef(chrome.brailleDisplayPrivate)) { - const onDisplayStateChanged = goog.bind(this.refreshDisplayState_, this); + const onDisplayStateChanged = this.refreshDisplayState_.bind(this); chrome.brailleDisplayPrivate.getDisplayState(onDisplayStateChanged); chrome.brailleDisplayPrivate.onDisplayStateChanged.addListener( onDisplayStateChanged); chrome.brailleDisplayPrivate.onKeyEvent.addListener( - goog.bind(this.onKeyEvent_, this)); + this.onKeyEvent_.bind(this)); } else { // Get the initial captions state since we won't refresh the display // state in an API callback in this case.
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_input_handler_test.js b/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_input_handler_test.js index 654a02c..c8c3e74 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_input_handler_test.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/braille/braille_input_handler_test.js
@@ -47,7 +47,7 @@ this.uncommittedText_ = ''; /** @private {?Array<number>} */ this.extraCells_ = []; - port.postMessage = goog.bind(this.handleMessage_, this); + port.postMessage = this.handleMessage_.bind(this); } /**
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/braille/liblouis.js b/chrome/browser/resources/chromeos/accessibility/chromevox/braille/liblouis.js index 6ef13b2d..3c6d5e9 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/braille/liblouis.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/braille/liblouis.js
@@ -158,11 +158,9 @@ loadOrReload_(opt_loadCallback) { this.worker_ = new Worker(this.wasmPath_); this.worker_.addEventListener( - 'message', goog.bind(this.onInstanceMessage_, this), - false /* useCapture */); + 'message', this.onInstanceMessage_.bind(this), false /* useCapture */); this.worker_.addEventListener( - 'error', goog.bind(this.onInstanceError_, this), - false /* useCapture */); + 'error', this.onInstanceError_.bind(this), false /* useCapture */); this.rpc_('load', {}, () => { this.isLoaded_ = true; opt_loadCallback && opt_loadCallback(this);
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/common/tts_background.js b/chrome/browser/resources/chromeos/accessibility/chromevox/common/tts_background.js index 28d06867..a1c4b61 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/common/tts_background.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/common/tts_background.js
@@ -415,9 +415,9 @@ const utterance = this.currentUtterance_; const utteranceId = utterance.id; - utterance.properties['onEvent'] = goog.bind(function(event) { + utterance.properties['onEvent'] = (event) => { this.onTtsEvent_(event, utteranceId); - }, this); + }; const validatedProperties = /** @type {!chrome.tts.TtsOptions} */ ({}); for (let i = 0; i < TtsBackground.ALLOWED_PROPERTIES_.length; i++) { @@ -741,7 +741,7 @@ * @private */ createPunctuationReplace_(clear) { - return goog.bind(function(match) { + return (match) => { const retain = this.retainPunctuation_.indexOf(match) !== -1 ? match : ' '; return clear ? retain : @@ -750,7 +750,7 @@ Msgs.getMsg(AbstractTts.CHARACTER_DICTIONARY[match]))) .format({'COUNT': 1}) + retain + ' '; - }, this); + }; } /** @@ -807,21 +807,21 @@ * @private */ updateVoice_(voiceName, opt_callback) { - chrome.tts.getVoices(goog.bind(function(voices) { + chrome.tts.getVoices((voices) => { const systemVoice = {voiceName: constants.SYSTEM_VOICE}; voices.unshift(systemVoice); const newVoice = voices.find((v) => { return v.voiceName === voiceName; }) || systemVoice; - if (newVoice) { + if (newVoice && newVoice.voiceName) { this.currentVoice = newVoice.voiceName; this.startSpeakingNextItemInQueue_(); } if (opt_callback) { opt_callback(this.currentVoice); } - }, this)); + }); } /**
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js b/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js index f125f4a..de46fe1 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js
@@ -341,7 +341,7 @@ // Make a copy of the key bindings, get the localized title of each // command, and then sort them. const sortedBindings = keymap.bindings().slice(); - sortedBindings.forEach(goog.bind(function(binding) { + sortedBindings.forEach((binding) => { const command = binding.command; const keySeq = binding.sequence; binding.keySeq = KeyUtil.keySequenceToString(keySeq, true); @@ -357,7 +357,7 @@ return word.charAt(0).toUpperCase() + word.substr(1); }); binding.title = title; - }, this)); + }); sortedBindings.sort(function(binding1, binding2) { return binding1.title.localeCompare(binding2.title); }); @@ -365,7 +365,7 @@ // Insert items from the bindings into the menus. const sawBindingSet = {}; const gestures = Object.keys(GestureCommandData.GESTURE_COMMAND_MAP); - sortedBindings.forEach(goog.bind(function(binding) { + sortedBindings.forEach((binding) => { const command = binding.command; if (sawBindingSet[command]) { return; @@ -399,7 +399,7 @@ CommandHandler['onCommand'](binding.command); }, binding.command); } - }, this)); + }); // Add all open tabs to the Tabs menu. bkgnd.chrome.windows.getLastFocused(function(lastFocusedWindow) {
diff --git a/chrome/browser/resources/chromeos/login/os_install.html b/chrome/browser/resources/chromeos/login/os_install.html index e0a183c..3e2cfb6 100644 --- a/chrome/browser/resources/chromeos/login/os_install.html +++ b/chrome/browser/resources/chromeos/login/os_install.html
@@ -4,22 +4,64 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://oobe/custom_elements.html"> <link rel="import" href="/components/common_styles.html"> <link rel="import" href="/components/login_screen_behavior.html"> +<link rel="import" href="/components/multi_step_behavior.html"> <link rel="import" href="/components/oobe_adaptive_dialog.html"> <link rel="import" href="/components/oobe_dialog_host_behavior/oobe_dialog_host_behavior.html"> <link rel="import" href="/components/oobe_i18n_behavior/oobe_i18n_behavior.html"> +<link rel="import" href="/components/oobe_icons.html"> <dom-module id="os-install-element"> <template> <style include="oobe-dialog-host"></style> - <oobe-adaptive-dialog id="osInstallDialog" role="dialog"> - <h1 slot="title"> - [[i18nDynamic(locale, 'osInstallDialogIntroTitle')]] - </h1> + <oobe-adaptive-dialog id="osInstallDialog" role="dialog" for-step="intro" + aria-label$="[[i18nDynamic(locale, 'osInstallDialogIntroTitle')]]"> + <iron-icon slot="icon" icon="oobe-32:googleg"></iron-icon> + <h1 slot="title">[[i18nDynamic(locale, 'osInstallDialogIntroTitle')]]</h1> + <div slot="subtitle"> + <strong> + [[i18nDynamic(locale, 'osInstallDialogIntroSubtitle')]] + </strong> + </div> + + <div slot="content" class="flex layout vertical center center-justified"> + <html-echo content="[[getIntroBodyHtml_(locale)]]"></html-echo> + </div> + + <div slot="bottom-buttons"> + <oobe-next-button + text-key="osInstallDialogIntroNextButton" class="focus-on-show" + id="osInstallIntroNextButton" + inverse on-click="onIntroNextButtonPressed_"></oobe-next-button> + </div> </oobe-adaptive-dialog> + + <oobe-adaptive-dialog id="osInstallDialog" role="dialog" for-step="confirm" + aria-label$="[[i18nDynamic(locale, 'osInstallDialogConfirmTitle')]]"> + <iron-icon slot="icon" icon="oobe-32:googleg"></iron-icon> + <h1 slot="title">[[i18nDynamic(locale, 'osInstallDialogConfirmTitle')]] + </h1> + <div slot="subtitle"> + <html-echo content="[[getConfirmBodyHtml_(locale)]]"></html-echo> + </div> + + <div slot="bottom-buttons"> + <oobe-next-button + text-key="osInstallDialogConfirmNextButton" class="focus-on-show" + id="osInstallConfirmNextButton" + inverse on-click="onConfirmNextButtonPressed_"></oobe-next-button> + </div> + </oobe-adaptive-dialog> + + <oobe-loading-dialog id="osInstallDialog" for-step="in_progress" + text-key="osInstallDialogInProgressTitle" + aria-label$="[[i18nDynamic(locale, 'enableDebuggingScreenTitle')]]"> + <iron-icon slot="icon" icon="oobe-32:googleg"></iron-icon> + </oobe-loading-dialog> </template> </dom-module>
diff --git a/chrome/browser/resources/chromeos/login/os_install.js b/chrome/browser/resources/chromeos/login/os_install.js index 3fa5db7..9e18989 100644 --- a/chrome/browser/resources/chromeos/login/os_install.js +++ b/chrome/browser/resources/chromeos/login/os_install.js
@@ -5,14 +5,85 @@ /** * @fileoverview Polymer element for OS install screen. */ + +(function() { +const UIState = { + INTRO: 'intro', + CONFIRM: 'confirm', + IN_PROGRESS: 'in_progress', +}; + Polymer({ is: 'os-install-element', - behaviors: [OobeI18nBehavior, OobeDialogHostBehavior, LoginScreenBehavior], + behaviors: [ + OobeI18nBehavior, + OobeDialogHostBehavior, + LoginScreenBehavior, + MultiStepBehavior, + ], + + EXTERNAL_API: [ + 'currentUIStep', + 'showConfirmStep', + 'showInProgressStep', + ], + + UI_STEPS: UIState, + + /** + * @return {string} + */ + defaultUIStep() { + return UIState.INTRO; + }, + + /** + * @return {string} + */ + currentUIStep() { + return this.uiStep; + }, ready() { this.initializeLoginScreen('OsInstallScreen', { resetAllowed: true, }); }, + + showConfirmStep() { + this.setUIStep(UIState.CONFIRM); + }, + + showInProgressStep() { + this.setUIStep(UIState.IN_PROGRESS); + }, + + onIntroNextButtonPressed_() { + this.userActed('os-install-intro-next'); + }, + + onConfirmNextButtonPressed_() { + this.userActed('os-install-confirm-next'); + }, + + /** + * @param {string} locale + * @return {string} + * @private + */ + getIntroBodyHtml_(locale) { + return this.i18nAdvanced('osInstallDialogIntroBody'); + }, + + /** + * @param {string} locale + * @return {string} + * @private + */ + getConfirmBodyHtml_(locale) { + return this.i18nAdvanced( + 'osInstallDialogConfirmBody', {tags: ['p', 'ul', 'li']}); + }, }); +})();
diff --git a/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.html b/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.html index 19702242..fab17081 100644 --- a/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.html +++ b/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.html
@@ -156,7 +156,7 @@ } </style> <div class="content-wrapper" hidden="[[!isVerifyUser_]]" role="dialog" - aria-modal="true" + aria-modal="true" id="verifyAccountScreen" aria-label="$i18n{loginWelcomeMessage}"> <div class="header"> <iron-icon class="title-icon" icon="oobe-32:avatar"></iron-icon> @@ -176,7 +176,7 @@ <cr-button id="cancelButton" class="cancel-button" on-click="onCloseTap_"> $i18n{lockScreenCancelButton} </cr-button> - <cr-button id="nextButton" class="action-button" on-click="onVerify_"> + <cr-button id="nextButtonVerifyScreen" class="action-button" on-click="onVerify_"> $i18n{lockScreenVerifyButton} </cr-button> </div>
diff --git a/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.js b/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.js index f13f70a..1291b40 100644 --- a/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.js +++ b/chrome/browser/resources/chromeos/password_change/lock_screen_reauth.js
@@ -7,7 +7,6 @@ * the lock screen. */ - import {assert} from 'chrome://resources/js/assert.m.js'; import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
diff --git a/chrome/browser/resources/new_tab_page/customize_dialog.js b/chrome/browser/resources/new_tab_page/customize_dialog.js index a256816..779e516 100644 --- a/chrome/browser/resources/new_tab_page/customize_dialog.js +++ b/chrome/browser/resources/new_tab_page/customize_dialog.js
@@ -223,6 +223,7 @@ this.selectedCollection_ = null; this.pageHandler_.onCustomizeDialogAction( newTabPage.mojom.CustomizeDialogAction.kBackgroundsBackClicked); + this.$.pages.scrollTop = 0; } /** @private */
diff --git a/chrome/browser/resources/pdf/elements/BUILD.gn b/chrome/browser/resources/pdf/elements/BUILD.gn index 63fec12..d660b37 100644 --- a/chrome/browser/resources/pdf/elements/BUILD.gn +++ b/chrome/browser/resources/pdf/elements/BUILD.gn
@@ -155,7 +155,6 @@ ":viewer-page-selector", "..:metrics", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", - "//ui/webui/resources/js:assert.m", ] }
diff --git a/chrome/browser/resources/pdf/elements/viewer-toolbar.html b/chrome/browser/resources/pdf/elements/viewer-toolbar.html index 325cad1..e6d49e2 100644 --- a/chrome/browser/resources/pdf/elements/viewer-toolbar.html +++ b/chrome/browser/resources/pdf/elements/viewer-toolbar.html
@@ -293,23 +293,18 @@ $i18n{annotationsShowToggle} </button> - <template is="dom-if" if="[[presentationModeEnabled]]"> - <hr> - <button id="present-button" class="dropdown-item" - on-click="onPresentClick_"> - <span class="check-container" aria-hidden="true"></span> - $i18n{present} - </button> - </template> + <hr> - <template is="dom-if" if="[[documentPropertiesEnabled]]"> - <hr hidden="[[presentationModeEnabled]]"> - <button id="properties-button" class="dropdown-item" - on-click="onPropertiesClick_"> - <span class="check-container" aria-hidden="true"></span> - $i18n{propertiesDialogTitle} - </button> - </template> + <button id="present-button" class="dropdown-item" on-click="onPresentClick_"> + <span class="check-container" aria-hidden="true"></span> + $i18n{present} + </button> + + <button id="properties-button" class="dropdown-item" + on-click="onPropertiesClick_"> + <span class="check-container" aria-hidden="true"></span> + $i18n{propertiesDialogTitle} + </button> </cr-action-menu> <if expr="enable_ink">
diff --git a/chrome/browser/resources/pdf/elements/viewer-toolbar.js b/chrome/browser/resources/pdf/elements/viewer-toolbar.js index a8451469..ff8bc97 100644 --- a/chrome/browser/resources/pdf/elements/viewer-toolbar.js +++ b/chrome/browser/resources/pdf/elements/viewer-toolbar.js
@@ -17,7 +17,6 @@ import './shared-vars.js'; import {AnchorAlignment} from 'chrome://resources/cr_elements/cr_action_menu/cr_action_menu.m.js'; -import {assert} from 'chrome://resources/js/assert.m.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {FittingType} from '../constants.js'; @@ -47,7 +46,6 @@ // </if> docTitle: String, docLength: Number, - documentPropertiesEnabled: Boolean, hasEdits: Boolean, hasEnteredAnnotationMode: Boolean, isFormFieldFocused: Boolean, @@ -64,7 +62,6 @@ pageNo: Number, pdfAnnotationsEnabled: Boolean, - presentationModeEnabled: Boolean, printingEnabled: Boolean, rotated: Boolean, viewportZoom: Number, @@ -220,7 +217,6 @@ /** @private */ onPresentClick_() { - assert(this.presentationModeEnabled); record(UserAction.PRESENT); this.getMenu_().close(); this.dispatchEvent(new CustomEvent('present-click')); @@ -228,7 +224,6 @@ /** @private */ onPropertiesClick_() { - assert(this.documentPropertiesEnabled); record(UserAction.PROPERTIES); this.getMenu_().close(); this.dispatchEvent(new CustomEvent('properties-click'));
diff --git a/chrome/browser/resources/pdf/pdf_viewer.html b/chrome/browser/resources/pdf/pdf_viewer.html index 2b4e275..1e02ae6b 100644 --- a/chrome/browser/resources/pdf/pdf_viewer.html +++ b/chrome/browser/resources/pdf/pdf_viewer.html
@@ -132,8 +132,6 @@ doc-title="[[title_]]" doc-length="[[docLength_]]" page-no="[[pageNo_]]" load-progress="[[loadProgress_]]" has-edits="[[hasEdits_]]" has-entered-annotation-mode="[[hasEnteredAnnotationMode_]]" - document-properties-enabled="[[documentPropertiesEnabled_]]" - presentation-mode-enabled="[[presentationModeEnabled_]]" printing-enabled="[[printingEnabled_]]" rotated="[[isRotated_(clockwiseRotations_)]]" is-form-field-focused="[[isFormFieldFocused_]]"
diff --git a/chrome/browser/resources/pdf/pdf_viewer.js b/chrome/browser/resources/pdf/pdf_viewer.js index 36d3635..60c4a63 100644 --- a/chrome/browser/resources/pdf/pdf_viewer.js +++ b/chrome/browser/resources/pdf/pdf_viewer.js
@@ -177,12 +177,6 @@ }, /** @private */ - documentPropertiesEnabled_: { - type: Boolean, - value: false, - }, - - /** @private */ fileName_: String, /** @private */ @@ -228,12 +222,6 @@ }, /** @private */ - presentationModeEnabled_: { - type: Boolean, - value: false, - }, - - /** @private */ printingEnabled_: { type: Boolean, value: false, @@ -600,8 +588,6 @@ /** @private */ onPresentClick_() { - assert(this.presentationModeEnabled_); - const onWheel = e => { e.deltaY > 0 ? this.viewport.goToNextPage() : this.viewport.goToPreviousPage(); @@ -641,7 +627,6 @@ /** @private */ onPropertiesClick_() { - assert(this.documentPropertiesEnabled_); assert(!this.showPropertiesDialog_); this.showPropertiesDialog_ = true; } @@ -755,12 +740,8 @@ handleStrings(strings) { super.handleStrings(strings); - this.documentPropertiesEnabled_ = - loadTimeData.getBoolean('documentPropertiesEnabled'); this.pdfAnnotationsEnabled_ = loadTimeData.getBoolean('pdfAnnotationsEnabled'); - this.presentationModeEnabled_ = - loadTimeData.getBoolean('presentationModeEnabled'); this.printingEnabled_ = loadTimeData.getBoolean('printingEnabled'); const presetZoomFactors = this.viewport.presetZoomFactors; this.zoomBounds_.min = Math.round(presetZoomFactors[0] * 100);
diff --git a/chrome/browser/sharesheet/sharesheet_service.cc b/chrome/browser/sharesheet/sharesheet_service.cc index f318523..6ae2629 100644 --- a/chrome/browser/sharesheet/sharesheet_service.cc +++ b/chrome/browser/sharesheet/sharesheet_service.cc
@@ -80,7 +80,8 @@ content::WebContents* web_contents, apps::mojom::IntentPtr intent, SharesheetMetrics::LaunchSource source, - sharesheet::DeliveredCallback delivered_callback) { + sharesheet::DeliveredCallback delivered_callback, + sharesheet::CloseCallback close_callback) { DCHECK(intent->action == apps_util::kIntentActionSend || intent->action == apps_util::kIntentActionSendMultiple); @@ -95,7 +96,8 @@ auto* sharesheet_service_delegate = GetOrCreateDelegate(web_contents->GetTopLevelNativeWindow()); sharesheet_service_delegate->ShowNearbyShareBubble( - std::move(intent), std::move(delivered_callback)); + std::move(intent), std::move(delivered_callback), + std::move(close_callback)); } #endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/sharesheet/sharesheet_service.h b/chrome/browser/sharesheet/sharesheet_service.h index 49c9a5b..2d1c689 100644 --- a/chrome/browser/sharesheet/sharesheet_service.h +++ b/chrome/browser/sharesheet/sharesheet_service.h
@@ -75,7 +75,8 @@ void ShowNearbyShareBubble(content::WebContents* web_contents, apps::mojom::IntentPtr intent, SharesheetMetrics::LaunchSource source, - sharesheet::DeliveredCallback delivered_callback); + sharesheet::DeliveredCallback delivered_callback, + sharesheet::CloseCallback close_callback); #endif // BUILDFLAG(IS_CHROMEOS_ASH) void OnBubbleClosed(gfx::NativeWindow native_window, const std::u16string& active_action);
diff --git a/chrome/browser/sharesheet/sharesheet_service_delegate.cc b/chrome/browser/sharesheet/sharesheet_service_delegate.cc index f250b1b..3956dfa 100644 --- a/chrome/browser/sharesheet/sharesheet_service_delegate.cc +++ b/chrome/browser/sharesheet/sharesheet_service_delegate.cc
@@ -44,16 +44,21 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) void SharesheetServiceDelegate::ShowNearbyShareBubble( apps::mojom::IntentPtr intent, - sharesheet::DeliveredCallback delivered_callback) { + sharesheet::DeliveredCallback delivered_callback, + sharesheet::CloseCallback close_callback) { if (is_bubble_open_) { if (delivered_callback) { std::move(delivered_callback) .Run(sharesheet::SharesheetResult::kErrorAlreadyOpen); } + if (close_callback) { + std::move(close_callback).Run(); + } return; } sharesheet_bubble_view_->ShowNearbyShareBubble(std::move(intent), - std::move(delivered_callback)); + std::move(delivered_callback), + std::move(close_callback)); is_bubble_open_ = true; } #endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/sharesheet/sharesheet_service_delegate.h b/chrome/browser/sharesheet/sharesheet_service_delegate.h index 24dc55a..d7594de 100644 --- a/chrome/browser/sharesheet/sharesheet_service_delegate.h +++ b/chrome/browser/sharesheet/sharesheet_service_delegate.h
@@ -50,7 +50,8 @@ sharesheet::DeliveredCallback delivered_callback); #if BUILDFLAG(IS_CHROMEOS_ASH) void ShowNearbyShareBubble(apps::mojom::IntentPtr intent, - sharesheet::DeliveredCallback delivered_callback); + sharesheet::DeliveredCallback delivered_callback, + sharesheet::CloseCallback close_callback); #endif // BUILDFLAG(IS_CHROMEOS_ASH) void OnBubbleClosed(const std::u16string& active_action); void OnTargetSelected(const std::u16string& target_name,
diff --git a/chrome/browser/sharesheet/sharesheet_types.h b/chrome/browser/sharesheet/sharesheet_types.h index 12b6071..a2ef406 100644 --- a/chrome/browser/sharesheet/sharesheet_types.h +++ b/chrome/browser/sharesheet/sharesheet_types.h
@@ -74,6 +74,7 @@ }; using DeliveredCallback = base::OnceCallback<void(SharesheetResult success)>; +using CloseCallback = base::OnceCallback<void()>; } // namespace sharesheet
diff --git a/chrome/browser/ui/ash/chrome_capture_mode_delegate.cc b/chrome/browser/ui/ash/chrome_capture_mode_delegate.cc index b0c7ea1..edd5233b 100644 --- a/chrome/browser/ui/ash/chrome_capture_mode_delegate.cc +++ b/chrome/browser/ui/ash/chrome_capture_mode_delegate.cc
@@ -173,3 +173,5 @@ void ChromeCaptureModeDelegate::OnSessionStateChanged(bool started) { is_session_active_ = started; } + +void ChromeCaptureModeDelegate::OnServiceRemoteReset() {}
diff --git a/chrome/browser/ui/ash/chrome_capture_mode_delegate.h b/chrome/browser/ui/ash/chrome_capture_mode_delegate.h index d5bb70d..2b8054b 100644 --- a/chrome/browser/ui/ash/chrome_capture_mode_delegate.h +++ b/chrome/browser/ui/ash/chrome_capture_mode_delegate.h
@@ -51,6 +51,7 @@ mojo::PendingReceiver<media::mojom::AudioStreamFactory> receiver) override; void OnSessionStateChanged(bool started) override; + void OnServiceRemoteReset() override; private: // Used to temporarily disable capture mode in certain cases for which neither
diff --git a/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc b/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc index ad05b18..6b97492b 100644 --- a/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc +++ b/chrome/browser/ui/ash/holding_space/holding_space_downloads_delegate.cc
@@ -381,17 +381,13 @@ } // Update. - // TODO(crbug.com/1213274): Perform a single atomic update of all attributes. - model()->UpdateBackingFileForItem( - in_progress_download->GetHoldingSpaceItem()->id(), - in_progress_download->GetFilePath(), - holding_space_util::ResolveFileSystemUrl( - profile(), in_progress_download->GetFilePath())); - model()->UpdatePauseForItem(in_progress_download->GetHoldingSpaceItem()->id(), - in_progress_download->IsPaused()); - model()->UpdateProgressForItem( - in_progress_download->GetHoldingSpaceItem()->id(), - in_progress_download->GetProgress()); + model() + ->UpdateItem(in_progress_download->GetHoldingSpaceItem()->id()) + ->SetBackingFile(in_progress_download->GetFilePath(), + holding_space_util::ResolveFileSystemUrl( + profile(), in_progress_download->GetFilePath())) + .SetPaused(in_progress_download->IsPaused()) + .SetProgress(in_progress_download->GetProgress()); } } // namespace ash
diff --git a/chrome/browser/ui/ash/holding_space/holding_space_file_system_delegate.cc b/chrome/browser/ui/ash/holding_space/holding_space_file_system_delegate.cc index 501ea42..f3cf466 100644 --- a/chrome/browser/ui/ash/holding_space/holding_space_file_system_delegate.cc +++ b/chrome/browser/ui/ash/holding_space/holding_space_file_system_delegate.cc
@@ -473,9 +473,11 @@ if (item_ids_to_remove.count(to_move.first)) continue; - model()->UpdateBackingFileForItem( - to_move.first, to_move.second, - holding_space_util::ResolveFileSystemUrl(profile(), to_move.second)); + model() + ->UpdateItem(/*id=*/to_move.first) + ->SetBackingFile(/*file_path=*/to_move.second, + holding_space_util::ResolveFileSystemUrl( + profile(), /*file_path=*/to_move.second)); } // If a backing file update occurred, it's possible that there are no longer
diff --git a/chrome/browser/ui/ash/holding_space/holding_space_keyed_service_unittest.cc b/chrome/browser/ui/ash/holding_space/holding_space_keyed_service_unittest.cc index 081a7070..93855e6 100644 --- a/chrome/browser/ui/ash/holding_space/holding_space_keyed_service_unittest.cc +++ b/chrome/browser/ui/ash/holding_space/holding_space_keyed_service_unittest.cc
@@ -695,9 +695,8 @@ // Update the file path for a finalized item. Because the item is finalized, // it should be updated immediately in persistent storage. file_path = downloads_mount->CreateArbitraryFile(); - holding_space_model->UpdateBackingFileForItem( - finalized_holding_space_item_ptr->id(), file_path, - GetFileSystemUrl(GetProfile(), file_path)); + holding_space_model->UpdateItem(finalized_holding_space_item_ptr->id()) + ->SetBackingFile(file_path, GetFileSystemUrl(GetProfile(), file_path)); ASSERT_EQ(persisted_holding_space_items.GetList().size(), 2u); persisted_holding_space_items.GetList()[1u] = @@ -710,9 +709,8 @@ // Update the file path for the in-progress item. Because the item is still in // progress, it should not be added/updated to/in persistent storage. file_path = downloads_mount->CreateArbitraryFile(); - holding_space_model->UpdateBackingFileForItem( - in_progress_holding_space_item_ptr->id(), file_path, - GetFileSystemUrl(GetProfile(), file_path)); + holding_space_model->UpdateItem(in_progress_holding_space_item_ptr->id()) + ->SetBackingFile(file_path, GetFileSystemUrl(GetProfile(), file_path)); EXPECT_EQ(*GetProfile()->GetPrefs()->GetList( HoldingSpacePersistenceDelegate::kPersistencePath), @@ -720,8 +718,8 @@ // Update the progress for the in-progress item. Because the item is still in // progress it should not be added/updated to/in persistent storage. - holding_space_model->UpdateProgressForItem( - in_progress_holding_space_item_ptr->id(), 0.75f); + holding_space_model->UpdateItem(in_progress_holding_space_item_ptr->id()) + ->SetProgress(0.75f); EXPECT_EQ(*GetProfile()->GetPrefs()->GetList( HoldingSpacePersistenceDelegate::kPersistencePath), @@ -729,8 +727,8 @@ // Mark the in-progress item as finalized. Because the item is finalized, it // should be added to persistent storage at the appropriate index. - holding_space_model->UpdateProgressForItem( - in_progress_holding_space_item_ptr->id(), 1.f); + holding_space_model->UpdateItem(in_progress_holding_space_item_ptr->id()) + ->SetProgress(1.f); ASSERT_EQ(persisted_holding_space_items.GetList().size(), 2u); persisted_holding_space_items.Insert(
diff --git a/chrome/browser/ui/ash/holding_space/holding_space_ui_browsertest.cc b/chrome/browser/ui/ash/holding_space/holding_space_ui_browsertest.cc index c4c7ecb..156ac88e 100644 --- a/chrome/browser/ui/ash/holding_space/holding_space_ui_browsertest.cc +++ b/chrome/browser/ui/ash/holding_space/holding_space_ui_browsertest.cc
@@ -1549,7 +1549,7 @@ ASSERT_EQ(download_chips.size(), 2u); // The two download chips present should still be the original chips for the - // completed download and the (now paused) in-progress download. + // completed download and the (now paused or resumed) in-progress download. EXPECT_EQ(download_chips.at(0), completed_download_chip); EXPECT_EQ(download_chips.at(1), in_progress_download_chip); }
diff --git a/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.cc b/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.cc index 56bee2c..e8b5ccda 100644 --- a/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.cc +++ b/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.cc
@@ -255,7 +255,9 @@ void SharesheetBubbleView::ShowNearbyShareBubble( apps::mojom::IntentPtr intent, - ::sharesheet::DeliveredCallback delivered_callback) { + ::sharesheet::DeliveredCallback delivered_callback, + ::sharesheet::CloseCallback close_callback) { + close_callback_ = std::move(close_callback); ShowBubble({}, std::move(intent), std::move(delivered_callback)); if (delivered_callback_) { std::move(delivered_callback_) @@ -703,6 +705,9 @@ base::TimeDelta::FromMilliseconds(80); is_bubble_closing_ = true; + if (close_callback_) { + std::move(close_callback_).Run(); + } ui::Layer* layer = View::GetWidget()->GetLayer(); auto scoped_settings =
diff --git a/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.h b/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.h index 8e3f834..30b133c 100644 --- a/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.h +++ b/chrome/browser/ui/ash/sharesheet/sharesheet_bubble_view.h
@@ -40,12 +40,13 @@ // |delivered_callback| is run to inform the caller whether something failed, // or the intent has been delivered to a target selected by the user. + // |close_callback| is run to inform the caller when the bubble is closed. void ShowBubble(std::vector<TargetInfo> targets, apps::mojom::IntentPtr intent, ::sharesheet::DeliveredCallback delivered_callback); - void ShowNearbyShareBubble( - apps::mojom::IntentPtr intent, - ::sharesheet::DeliveredCallback delivered_callback); + void ShowNearbyShareBubble(apps::mojom::IntentPtr intent, + ::sharesheet::DeliveredCallback delivered_callback, + ::sharesheet::CloseCallback close_callback); void ShowActionView(); void ResizeBubble(const int& width, const int& height); void CloseBubble(); @@ -90,6 +91,7 @@ std::u16string active_target_; apps::mojom::IntentPtr intent_; ::sharesheet::DeliveredCallback delivered_callback_; + ::sharesheet::CloseCallback close_callback_; int width_ = 0; int height_ = 0;
diff --git a/chrome/browser/ui/ash/test_login_screen_model.cc b/chrome/browser/ui/ash/test_login_screen_model.cc index 465628b..f889dc50 100644 --- a/chrome/browser/ui/ash/test_login_screen_model.cc +++ b/chrome/browser/ui/ash/test_login_screen_model.cc
@@ -32,7 +32,7 @@ const AccountId& account_id) {} void TestLoginScreenModel::ShowEasyUnlockIcon( const AccountId& account_id, - const ash::EasyUnlockIconOptions& icon) {} + const ash::EasyUnlockIconInfo& icon_info) {} void TestLoginScreenModel::SetChallengeResponseAuthEnabledForUser( const AccountId& user, bool enabled) {}
diff --git a/chrome/browser/ui/ash/test_login_screen_model.h b/chrome/browser/ui/ash/test_login_screen_model.h index d6f07173..dec73fb7 100644 --- a/chrome/browser/ui/ash/test_login_screen_model.h +++ b/chrome/browser/ui/ash/test_login_screen_model.h
@@ -34,7 +34,7 @@ bool enabled) override; void ForceOnlineSignInForUser(const AccountId& account_id) override; void ShowEasyUnlockIcon(const AccountId& user, - const ash::EasyUnlockIconOptions& icon) override; + const ash::EasyUnlockIconInfo& icon_info) override; void SetChallengeResponseAuthEnabledForUser(const AccountId& user, bool enabled) override;
diff --git a/chrome/browser/ui/global_media_controls/media_notification_service.cc b/chrome/browser/ui/global_media_controls/media_notification_service.cc index fe700b2..d5a44b3 100644 --- a/chrome/browser/ui/global_media_controls/media_notification_service.cc +++ b/chrome/browser/ui/global_media_controls/media_notification_service.cc
@@ -316,8 +316,8 @@ return nullptr; auto ui = std::make_unique<media_router::MediaRouterUI>(web_contents); - if (presentation_request_notification_producer_->GetNotificationItem() - ->context()) { + if (!presentation_request_notification_producer_->GetNotificationItem() + ->is_default_presentation_request()) { ui->InitWithStartPresentationContext( presentation_request_notification_producer_->GetNotificationItem() ->PassContext());
diff --git a/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc b/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc index 38d97ee..cc32623 100644 --- a/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc +++ b/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc
@@ -454,7 +454,7 @@ EXPECT_TRUE(item); auto* pr_item = static_cast<PresentationRequestNotificationItem*>(item.get()); - EXPECT_EQ(pr_item->context()->presentation_request(), presentation_request); + EXPECT_EQ(pr_item->request(), presentation_request); return notification_id; }
diff --git a/chrome/browser/ui/global_media_controls/presentation_request_notification_item.cc b/chrome/browser/ui/global_media_controls/presentation_request_notification_item.cc index 288daec4..755574f 100644 --- a/chrome/browser/ui/global_media_controls/presentation_request_notification_item.cc +++ b/chrome/browser/ui/global_media_controls/presentation_request_notification_item.cc
@@ -27,6 +27,7 @@ std::unique_ptr<media_router::StartPresentationContext> context) : id_(base::UnguessableToken::Create().ToString()), notification_service_(notification_service), + is_default_presentation_request_(context == nullptr), context_(std::move(context)), request_(request) { DCHECK(!context || request == context->presentation_request());
diff --git a/chrome/browser/ui/global_media_controls/presentation_request_notification_item.h b/chrome/browser/ui/global_media_controls/presentation_request_notification_item.h index b410fee6..4cda236d 100644 --- a/chrome/browser/ui/global_media_controls/presentation_request_notification_item.h +++ b/chrome/browser/ui/global_media_controls/presentation_request_notification_item.h
@@ -37,9 +37,10 @@ } const std::string& id() const { return id_; } - media_router::StartPresentationContext* context() const { - return context_.get(); + bool is_default_presentation_request() const { + return is_default_presentation_request_; } + std::unique_ptr<media_router::StartPresentationContext> PassContext() { return std::move(context_); } @@ -55,10 +56,15 @@ const std::string id_; MediaNotificationService* const notification_service_; + + // True if the item is created from a default PresentationRequest, which means + // |context_| is set to nullptr in the constructor. + const bool is_default_presentation_request_; + // |context_| is nullptr if: - // (1) It is created for a default presentation request; + // (1) It is created for a default PresentationRequest; // (2) MediaNotificationService has passed |context_| to initialize a - // CastDialogController + // CastDialogController. std::unique_ptr<media_router::StartPresentationContext> context_; const content::PresentationRequest request_;
diff --git a/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.cc b/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.cc index 592ee9af..29edb1f2 100644 --- a/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.cc +++ b/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.cc
@@ -59,16 +59,16 @@ private: void WebContentsDestroyed() override { - notification_producer_->DeleteItemForPresentationRequest("closed"); + notification_producer_->DeleteItemForPresentationRequest("Dialog closed."); } void NavigationEntryCommitted( const content::LoadCommittedDetails& load_details) override { - notification_producer_->DeleteItemForPresentationRequest("closed"); + notification_producer_->DeleteItemForPresentationRequest("Dialog closed."); } void RenderProcessGone(base::TerminationStatus status) override { - notification_producer_->DeleteItemForPresentationRequest("closed"); + notification_producer_->DeleteItemForPresentationRequest("Dialog closed."); } PresentationRequestNotificationProducer* const notification_producer_; @@ -141,11 +141,10 @@ void PresentationRequestNotificationProducer::OnNotificationListChanged() { ShowOrHideItem(); } -void PresentationRequestNotificationProducer::SetPresentationManagerForTesting( +void PresentationRequestNotificationProducer::SetTestPresentationManager( base::WeakPtr<media_router::WebContentsPresentationManager> presentation_manager) { - presentation_manager_ = presentation_manager; - presentation_manager_->AddObserver(this); + test_presentation_manager_ = presentation_manager; } void PresentationRequestNotificationProducer::OnMediaDialogOpened() { @@ -157,7 +156,9 @@ base::BindOnce( &PresentationRequestNotificationProducer::AfterMediaDialogOpened, weak_factory_.GetWeakPtr(), - GetActiveWebContentsPresentationManager())); + test_presentation_manager_ + ? test_presentation_manager_ + : GetActiveWebContentsPresentationManager())); } void PresentationRequestNotificationProducer::OnMediaDialogClosed() { @@ -240,11 +241,6 @@ const std::string& message) { if (!item_) return; - if (item_->context()) { - item_->context()->InvokeErrorCallback(blink::mojom::PresentationError( - blink::mojom::PresentationErrorType::PRESENTATION_REQUEST_CANCELLED, - message)); - } const auto id{item_->id()}; item_.reset(); presentation_request_observer_.reset();
diff --git a/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.h b/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.h index 69986260..aa38a9c 100644 --- a/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.h +++ b/chrome/browser/ui/global_media_controls/presentation_request_notification_producer.h
@@ -72,7 +72,7 @@ content::WebContents* GetWebContents(); base::WeakPtr<PresentationRequestNotificationItem> GetNotificationItem(); - void SetPresentationManagerForTesting( + void SetTestPresentationManager( base::WeakPtr<media_router::WebContentsPresentationManager> presentation_manager); @@ -108,7 +108,9 @@ // Returns true if there is an item, and the item is for a non-default // presentation request. - bool HasItemForNonDefaultRequest() const { return item_ && item_->context(); } + bool HasItemForNonDefaultRequest() const { + return item_ && !item_->is_default_presentation_request(); + } // Queries |notification_service_| for active sessions associated with the // WebContents that |this| manages and stores the value in |should_hide_|. @@ -122,7 +124,10 @@ // dialog is closed. // It is used to remove |this| from |presentation_manager_|'s observers. base::WeakPtr<media_router::WebContentsPresentationManager> - presentation_manager_ = nullptr; + presentation_manager_; + // A copy of the WebContentsPresentationManager used for testing. + base::WeakPtr<media_router::WebContentsPresentationManager> + test_presentation_manager_; // The notification managed by this producer, if there is one. absl::optional<PresentationRequestNotificationItem> item_;
diff --git a/chrome/browser/ui/global_media_controls/presentation_request_notification_producer_unittest.cc b/chrome/browser/ui/global_media_controls/presentation_request_notification_producer_unittest.cc index 1c80912..eb15cf1 100644 --- a/chrome/browser/ui/global_media_controls/presentation_request_notification_producer_unittest.cc +++ b/chrome/browser/ui/global_media_controls/presentation_request_notification_producer_unittest.cc
@@ -8,6 +8,7 @@ #include "chrome/browser/media/router/chrome_media_router_factory.h" #include "chrome/browser/media/router/media_router_feature.h" #include "chrome/browser/ui/global_media_controls/media_notification_service.h" +#include "chrome/browser/ui/global_media_controls/test_helper.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "components/media_router/browser/presentation/start_presentation_context.h" @@ -19,6 +20,44 @@ using testing::_; namespace { +class MockWebContentsPresentationManager + : public media_router::WebContentsPresentationManager { + public: + bool HasDefaultPresentationRequest() const override { + return default_presentation_request_.has_value(); + } + + const content::PresentationRequest& GetDefaultPresentationRequest() + const override { + return *default_presentation_request_; + } + + void SetDefaultPresentationRequest( + const content::PresentationRequest& request) { + default_presentation_request_ = request; + } + + MOCK_METHOD1( + AddObserver, + void(media_router::WebContentsPresentationManager::Observer* observer)); + MOCK_METHOD1( + RemoveObserver, + void(media_router::WebContentsPresentationManager::Observer* observer)); + MOCK_METHOD3(OnPresentationResponse, + void(const content::PresentationRequest&, + media_router::mojom::RoutePresentationConnectionPtr, + const media_router::RouteRequestResult&)); + MOCK_METHOD0(GetMediaRoutes, std::vector<media_router::MediaRoute>()); + + base::WeakPtr<WebContentsPresentationManager> GetWeakPtr() override { + return weak_factory_.GetWeakPtr(); + } + + private: + absl::optional<content::PresentationRequest> default_presentation_request_; + base::WeakPtrFactory<MockWebContentsPresentationManager> weak_factory_{this}; +}; + media_router::MediaRoute CreateMediaRoute( media_router::MediaRoute::Id route_id) { media_router::MediaRoute media_route(route_id, @@ -50,25 +89,39 @@ notification_producer_ = notification_service_->presentation_request_notification_producer_ .get(); + + presentation_manager_ = + std::make_unique<MockWebContentsPresentationManager>(); + notification_producer_->SetTestPresentationManager( + presentation_manager_->GetWeakPtr()); } void TearDown() override { notification_service_.reset(); + media_router::WebContentsPresentationManager::SetTestInstance(nullptr); ChromeRenderViewHostTestHarness::TearDown(); } + void SimulateDialogOpenedAndWait(MockMediaDialogDelegate* delegate) { + delegate->Open(notification_service_.get()); + task_environment()->RunUntilIdle(); + } + + void SimulateDialogClosedAndWait(MockMediaDialogDelegate* delegate) { + delegate->Close(); + task_environment()->RunUntilIdle(); + } + + content::PresentationRequest CreatePresentationRequest() { + return content::PresentationRequest( + main_rfh()->GetGlobalFrameRoutingId(), + {GURL("http://example.com"), GURL("http://example2.com")}, + url::Origin::Create(GURL("http://google.com"))); + } + void SimulateStartPresentationContextCreated() { auto context = std::make_unique<media_router::StartPresentationContext>( - content::PresentationRequest( - main_rfh()->GetGlobalFrameRoutingId(), - {GURL("http://example.com"), GURL("http://example2.com")}, - url::Origin::Create(GURL("http://google.com"))), - base::BindOnce( - &PresentationRequestNotificationProducerTest::RequestSuccess, - base::Unretained(this)), - base::BindOnce( - &PresentationRequestNotificationProducerTest::RequestError, - base::Unretained(this))); + CreatePresentationRequest(), base::DoNothing(), base::DoNothing()); notification_producer_->OnStartPresentationContextCreated( std::move(context)); } @@ -78,16 +131,11 @@ notification_producer_->OnMediaRoutesChanged(routes); } - MOCK_METHOD3(RequestSuccess, - void(const blink::mojom::PresentationInfo&, - media_router::mojom::RoutePresentationConnectionPtr, - const media_router::MediaRoute&)); - MOCK_METHOD1(RequestError, - void(const blink::mojom::PresentationError& error)); protected: std::unique_ptr<MediaNotificationService> notification_service_; PresentationRequestNotificationProducer* notification_producer_ = nullptr; + std::unique_ptr<MockWebContentsPresentationManager> presentation_manager_; base::test::ScopedFeatureList feature_list_; }; @@ -107,3 +155,37 @@ notification_producer_->OnContainerDismissed(item->id()); EXPECT_FALSE(notification_producer_->GetNotificationItem()); } + +TEST_F(PresentationRequestNotificationProducerTest, OnMediaDialogOpened) { + MockMediaDialogDelegate delegate; + // Open the dialog on a page without a default presentation request. + SimulateDialogOpenedAndWait(&delegate); + EXPECT_FALSE(notification_producer_->GetNotificationItem()); + SimulateDialogClosedAndWait(&delegate); + + // Open the dialog on a page with default presentation request and there does + // not exist a notification for non-default presentation request. A dummy + // notification should be created. + presentation_manager_->SetDefaultPresentationRequest( + CreatePresentationRequest()); + SimulateDialogOpenedAndWait(&delegate); + EXPECT_TRUE(notification_producer_->GetNotificationItem()); + SimulateDialogClosedAndWait(&delegate); +} + +TEST_F(PresentationRequestNotificationProducerTest, + OnMediaDialogOpenedWithExistingItem) { + MockMediaDialogDelegate delegate; + + // Open the dialog on a page with default presentation request and there + // exists a notification for non-default presentation request. The existing + // notification should not be replaced. + SimulateStartPresentationContextCreated(); + auto id = notification_producer_->GetNotificationItem()->id(); + presentation_manager_->SetDefaultPresentationRequest( + CreatePresentationRequest()); + SimulateDialogOpenedAndWait(&delegate); + EXPECT_TRUE(notification_producer_->GetNotificationItem()); + EXPECT_EQ(id, notification_producer_->GetNotificationItem()->id()); + SimulateDialogClosedAndWait(&delegate); +}
diff --git a/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc b/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc index a007de2f..a9da9493 100644 --- a/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc +++ b/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc
@@ -7,6 +7,7 @@ #include <utility> #include "base/command_line.h" +#include "base/path_service.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/browser_process.h" @@ -18,6 +19,7 @@ #include "chrome/browser/ui/views/devtools_process_observer.h" #include "chrome/browser/ui/views/media_router/media_router_dialog_controller_views.h" #include "chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.h" +#include "chrome/common/chrome_paths.h" #include "components/constrained_window/constrained_window_views.h" #include "components/media_router/browser/media_router_dialog_controller.h" #include "components/ui_devtools/connector_delegate.h" @@ -190,9 +192,12 @@ // Starts the UI Devtools server for browser UI (and Ash UI on Chrome OS). auto connector = std::make_unique<UiDevtoolsConnector>(); + base::FilePath output_dir; + bool result = base::PathService::Get(chrome::DIR_USER_DATA, &output_dir); + DCHECK(result); devtools_server_ = ui_devtools::CreateUiDevToolsServerForViews( g_browser_process->system_network_context_manager()->GetContext(), - std::move(connector)); + std::move(connector), output_dir); devtools_process_observer_ = std::make_unique<DevtoolsProcessObserver>( devtools_server_->tracing_agent()); }
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h index 32764a9..8bcbda12 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h
@@ -50,6 +50,7 @@ void UpdateWindowTitle() override; void SizeConstraintsChanged() override; void UpdateMinimumSize() override; + void WindowControlsOverlayEnabledChanged() override; // views::View: gfx::Size GetMinimumSize() const override; @@ -97,6 +98,8 @@ void UpdateCaptionButtonPlaceholderContainerBackground(); + void AddRoutingForWindowControlsOverlayViews(); + // Used to keep track of the update of kShowFullscreenToolbar preference. BooleanPrefMember show_fullscreen_toolbar_;
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm index 8f38ecb..872884d 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm
@@ -82,17 +82,8 @@ if (browser_view->IsWindowControlsOverlayEnabled()) { caption_button_placeholder_container_ = AddChildView(std::make_unique<CaptionButtonPlaceholderContainer>()); - caption_buttons_overlay_input_routing_view_ = - std::make_unique<WindowControlsOverlayInputRoutingMac>( - this, caption_button_placeholder_container_, - remote_cocoa::mojom::WindowControlsOverlayNSViewType:: - kCaptionButtonContainer); - web_app_frame_toolbar_overlay_routing_view_ = - std::make_unique<WindowControlsOverlayInputRoutingMac>( - this, web_app_frame_toolbar(), - remote_cocoa::mojom::WindowControlsOverlayNSViewType:: - kWebAppFrameToolbar); + AddRoutingForWindowControlsOverlayViews(); } } @@ -323,6 +314,30 @@ GetWidget()->OnSizeConstraintsChanged(); } +void BrowserNonClientFrameViewMac::WindowControlsOverlayEnabledChanged() { + if (browser_view()->IsWindowControlsOverlayEnabled()) { + caption_button_placeholder_container_ = + AddChildView(std::make_unique<CaptionButtonPlaceholderContainer>()); + UpdateCaptionButtonPlaceholderContainerBackground(); + + AddRoutingForWindowControlsOverlayViews(); + + caption_buttons_overlay_input_routing_view_->Enable(); + web_app_frame_toolbar_overlay_routing_view_->Enable(); + } else { + caption_buttons_overlay_input_routing_view_->Disable(); + web_app_frame_toolbar_overlay_routing_view_->Disable(); + + RemoveChildView(caption_button_placeholder_container_); + caption_button_placeholder_container_ = nullptr; + + caption_buttons_overlay_input_routing_view_ = nullptr; + web_app_frame_toolbar_overlay_routing_view_ = nullptr; + } + + web_app_frame_toolbar()->OnWindowControlsOverlayEnabledChanged(); + frame()->client_view()->InvalidateLayout(); +} /////////////////////////////////////////////////////////////////////////////// // BrowserNonClientFrameViewMac, views::View implementation: @@ -549,3 +564,17 @@ views::CreateSolidBackground(GetFrameColor())); } } + +void BrowserNonClientFrameViewMac::AddRoutingForWindowControlsOverlayViews() { + caption_buttons_overlay_input_routing_view_ = + std::make_unique<WindowControlsOverlayInputRoutingMac>( + this, caption_button_placeholder_container_, + remote_cocoa::mojom::WindowControlsOverlayNSViewType:: + kCaptionButtonContainer); + + web_app_frame_toolbar_overlay_routing_view_ = + std::make_unique<WindowControlsOverlayInputRoutingMac>( + this, web_app_frame_toolbar(), + remote_cocoa::mojom::WindowControlsOverlayNSViewType:: + kWebAppFrameToolbar); +}
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.cc deleted file mode 100644 index 388c6fe..0000000 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.cc +++ /dev/null
@@ -1,161 +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 "base/run_loop.h" -#include "base/strings/utf_string_conversions.h" -#include "build/build_config.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/ui/view_ids.h" -#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/browser/ui/web_applications/web_app_controller_browsertest.h" -#include "chrome/common/pref_names.h" -#include "chrome/test/base/ui_test_utils.h" -#include "components/prefs/pref_service.h" -#include "content/public/test/browser_test.h" -#include "content/public/test/browser_test_utils.h" -#include "net/test/embedded_test_server/embedded_test_server.h" -#include "ui/base/test/scoped_fake_nswindow_fullscreen.h" -#include "ui/views/controls/label.h" -#include "ui/views/view.h" -#include "ui/views/view_test_api.h" -#include "ui/views/widget/widget.h" -#include "ui/views/window/non_client_view.h" -#include "url/gurl.h" - -namespace { - -class TextChangeWaiter { - public: - explicit TextChangeWaiter(views::Label* label) - : subscription_(label->AddTextChangedCallback( - base::BindRepeating(&TextChangeWaiter::OnTextChanged, - base::Unretained(this)))) {} - - TextChangeWaiter(const TextChangeWaiter&) = delete; - TextChangeWaiter& operator=(const TextChangeWaiter&) = delete; - - // Runs a loop until a text change is observed (unless one has - // already been observed, in which case it returns immediately). - void Wait() { - if (observed_change_) - return; - - run_loop_.Run(); - } - - private: - void OnTextChanged() { - observed_change_ = true; - if (run_loop_.running()) - run_loop_.Quit(); - } - - bool observed_change_ = false; - base::RunLoop run_loop_; - base::CallbackListSubscription subscription_; -}; - -} // anonymous namespace - -class BrowserNonClientFrameViewMacBrowserTest - : public web_app::WebAppControllerBrowserTest { - public: - BrowserNonClientFrameViewMacBrowserTest() = default; - BrowserNonClientFrameViewMacBrowserTest( - const BrowserNonClientFrameViewMacBrowserTest&) = delete; - BrowserNonClientFrameViewMacBrowserTest& operator=( - const BrowserNonClientFrameViewMacBrowserTest&) = delete; - ~BrowserNonClientFrameViewMacBrowserTest() override = default; -}; - -IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewMacBrowserTest, TitleUpdates) { - ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; - - const GURL start_url = GetInstallableAppURL(); - const web_app::AppId app_id = InstallPWA(start_url); - Browser* const browser = LaunchWebAppBrowser(app_id); - content::WebContents* const web_contents = - browser->tab_strip_model()->GetActiveWebContents(); - // Ensure the main page has loaded and is ready for ExecJs DOM manipulation. - ASSERT_TRUE(content::NavigateToURL(web_contents, start_url)); - - BrowserView* const browser_view = - BrowserView::GetBrowserViewForBrowser(browser); - views::NonClientFrameView* const frame_view = - browser_view->GetWidget()->non_client_view()->frame_view(); - auto* const title = - static_cast<views::Label*>(frame_view->GetViewByID(VIEW_ID_WINDOW_TITLE)); - - { - chrome::ToggleFullscreenMode(browser); - EXPECT_TRUE(browser_view->GetWidget()->IsFullscreen()); - TextChangeWaiter waiter(title); - const std::u16string expected_title(u"Full Screen"); - ASSERT_TRUE(content::ExecJs( - web_contents, - "document.querySelector('title').textContent = 'Full Screen'")); - waiter.Wait(); - EXPECT_EQ(expected_title, title->GetText()); - } - - { - chrome::ToggleFullscreenMode(browser); - EXPECT_FALSE(browser_view->GetWidget()->IsFullscreen()); - TextChangeWaiter waiter(title); - const std::u16string expected_title(u"Not Full Screen"); - ASSERT_TRUE(content::ExecJs( - web_contents, - "document.querySelector('title').textContent = 'Not Full Screen'")); - waiter.Wait(); - EXPECT_EQ(expected_title, title->GetText()); - } -} - -// Test to make sure the WebAppToolbarFrame triggers an InvalidateLayout() when -// toggled in fullscreen mode. -// TODO(crbug.com/1156050): Flaky on Mac. -#if defined(OS_MAC) -#define MAYBE_ToolbarLayoutFullscreenTransition \ - DISABLED_ToolbarLayoutFullscreenTransition -#else -#define MAYBE_ToolbarLayoutFullscreenTransition \ - ToolbarLayoutFullscreenTransition -#endif -IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewMacBrowserTest, - MAYBE_ToolbarLayoutFullscreenTransition) { - ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; - - const GURL start_url = GetInstallableAppURL(); - const web_app::AppId app_id = InstallPWA(start_url); - Browser* const browser = LaunchWebAppBrowser(app_id); - - BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); - BrowserNonClientFrameView* const frame_view = - static_cast<BrowserNonClientFrameView*>( - browser_view->GetWidget()->non_client_view()->frame_view()); - - // Trigger a layout on the view tree to address any invalid layouts waiting - // for a re-layout. - views::ViewTestApi frame_view_test_api(frame_view); - browser_view->GetWidget()->LayoutRootViewIfNecessary(); - - // Assert that the layout of the frame view is in a valid state. - EXPECT_FALSE(frame_view_test_api.needs_layout()); - - PrefService* prefs = browser->profile()->GetPrefs(); - prefs->SetBoolean(prefs::kShowFullscreenToolbar, false); - - chrome::ToggleFullscreenMode(browser); - fake_fullscreen.FinishTransition(); - EXPECT_FALSE(frame_view_test_api.needs_layout()); - - prefs->SetBoolean(prefs::kShowFullscreenToolbar, true); - - // Showing the toolbar in fullscreen mode should trigger a layout - // invalidation. - EXPECT_TRUE(frame_view_test_api.needs_layout()); -}
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.mm b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.mm new file mode 100644 index 0000000..986fe8d --- /dev/null +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.mm
@@ -0,0 +1,376 @@ +// 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 "base/files/file_util.h" +#include "base/run_loop.h" +#include "base/strings/utf_string_conversions.h" +#include "build/build_config.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_commands.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/view_ids.h" +#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" +#include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h" +#include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_view.h" +#include "chrome/browser/ui/views/web_apps/frame_toolbar/web_app_toolbar_button_container.h" +#include "chrome/browser/ui/web_applications/app_browser_controller.h" +#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h" +#include "chrome/browser/ui/web_applications/web_app_controller_browsertest.h" +#include "chrome/browser/web_applications/components/web_application_info.h" +#include "chrome/browser/web_applications/test/web_app_install_test_utils.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/common/content_features.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/browser_test_utils.h" +#include "content/public/test/test_navigation_observer.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "ui/base/hit_test.h" +#include "ui/base/test/scoped_fake_nswindow_fullscreen.h" +#include "ui/views/controls/label.h" +#include "ui/views/view.h" +#include "ui/views/view_test_api.h" +#include "ui/views/widget/widget.h" +#include "ui/views/window/non_client_view.h" +#include "url/gurl.h" + +namespace { + +class TextChangeWaiter { + public: + explicit TextChangeWaiter(views::Label* label) + : subscription_(label->AddTextChangedCallback( + base::BindRepeating(&TextChangeWaiter::OnTextChanged, + base::Unretained(this)))) {} + + TextChangeWaiter(const TextChangeWaiter&) = delete; + TextChangeWaiter& operator=(const TextChangeWaiter&) = delete; + + // Runs a loop until a text change is observed (unless one has + // already been observed, in which case it returns immediately). + void Wait() { + if (observed_change_) + return; + + run_loop_.Run(); + } + + private: + void OnTextChanged() { + observed_change_ = true; + if (run_loop_.running()) + run_loop_.Quit(); + } + + bool observed_change_ = false; + base::RunLoop run_loop_; + base::CallbackListSubscription subscription_; +}; + +} // anonymous namespace + +class BrowserNonClientFrameViewMacBrowserTest + : public web_app::WebAppControllerBrowserTest { + public: + BrowserNonClientFrameViewMacBrowserTest() = default; + BrowserNonClientFrameViewMacBrowserTest( + const BrowserNonClientFrameViewMacBrowserTest&) = delete; + BrowserNonClientFrameViewMacBrowserTest& operator=( + const BrowserNonClientFrameViewMacBrowserTest&) = delete; + ~BrowserNonClientFrameViewMacBrowserTest() override = default; +}; + +IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewMacBrowserTest, TitleUpdates) { + ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; + + const GURL start_url = GetInstallableAppURL(); + const web_app::AppId app_id = InstallPWA(start_url); + Browser* const browser = LaunchWebAppBrowser(app_id); + content::WebContents* const web_contents = + browser->tab_strip_model()->GetActiveWebContents(); + // Ensure the main page has loaded and is ready for ExecJs DOM manipulation. + ASSERT_TRUE(content::NavigateToURL(web_contents, start_url)); + + BrowserView* const browser_view = + BrowserView::GetBrowserViewForBrowser(browser); + views::NonClientFrameView* const frame_view = + browser_view->GetWidget()->non_client_view()->frame_view(); + auto* const title = + static_cast<views::Label*>(frame_view->GetViewByID(VIEW_ID_WINDOW_TITLE)); + + { + chrome::ToggleFullscreenMode(browser); + EXPECT_TRUE(browser_view->GetWidget()->IsFullscreen()); + TextChangeWaiter waiter(title); + const std::u16string expected_title(u"Full Screen"); + ASSERT_TRUE(content::ExecJs( + web_contents, + "document.querySelector('title').textContent = 'Full Screen'")); + waiter.Wait(); + EXPECT_EQ(expected_title, title->GetText()); + } + + { + chrome::ToggleFullscreenMode(browser); + EXPECT_FALSE(browser_view->GetWidget()->IsFullscreen()); + TextChangeWaiter waiter(title); + const std::u16string expected_title(u"Not Full Screen"); + ASSERT_TRUE(content::ExecJs( + web_contents, + "document.querySelector('title').textContent = 'Not Full Screen'")); + waiter.Wait(); + EXPECT_EQ(expected_title, title->GetText()); + } +} + +// Test to make sure the WebAppToolbarFrame triggers an InvalidateLayout() when +// toggled in fullscreen mode. +// TODO(crbug.com/1156050): Flaky on Mac. +#if defined(OS_MAC) +#define MAYBE_ToolbarLayoutFullscreenTransition \ + DISABLED_ToolbarLayoutFullscreenTransition +#else +#define MAYBE_ToolbarLayoutFullscreenTransition \ + ToolbarLayoutFullscreenTransition +#endif +IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewMacBrowserTest, + MAYBE_ToolbarLayoutFullscreenTransition) { + ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; + + const GURL start_url = GetInstallableAppURL(); + const web_app::AppId app_id = InstallPWA(start_url); + Browser* const browser = LaunchWebAppBrowser(app_id); + + BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); + BrowserNonClientFrameView* const frame_view = + static_cast<BrowserNonClientFrameView*>( + browser_view->GetWidget()->non_client_view()->frame_view()); + + // Trigger a layout on the view tree to address any invalid layouts waiting + // for a re-layout. + views::ViewTestApi frame_view_test_api(frame_view); + browser_view->GetWidget()->LayoutRootViewIfNecessary(); + + // Assert that the layout of the frame view is in a valid state. + EXPECT_FALSE(frame_view_test_api.needs_layout()); + + PrefService* prefs = browser->profile()->GetPrefs(); + prefs->SetBoolean(prefs::kShowFullscreenToolbar, false); + + chrome::ToggleFullscreenMode(browser); + fake_fullscreen.FinishTransition(); + EXPECT_FALSE(frame_view_test_api.needs_layout()); + + prefs->SetBoolean(prefs::kShowFullscreenToolbar, true); + + // Showing the toolbar in fullscreen mode should trigger a layout + // invalidation. + EXPECT_TRUE(frame_view_test_api.needs_layout()); +} + +class WebAppBrowserFrameViewMacWindowControlsOverlayTest + : public InProcessBrowserTest { + public: + WebAppBrowserFrameViewMacWindowControlsOverlayTest() { + scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>(); + scoped_feature_list_->InitAndEnableFeature( + features::kWebAppWindowControlsOverlay); + } + WebAppBrowserFrameViewMacWindowControlsOverlayTest( + const WebAppBrowserFrameViewMacWindowControlsOverlayTest&) = delete; + WebAppBrowserFrameViewMacWindowControlsOverlayTest& operator=( + const WebAppBrowserFrameViewMacWindowControlsOverlayTest&) = delete; + + ~WebAppBrowserFrameViewMacWindowControlsOverlayTest() override = default; + + void SetUp() override { + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + + embedded_test_server()->ServeFilesFromDirectory(temp_dir_.GetPath()); + ASSERT_TRUE(embedded_test_server()->Start()); + + InProcessBrowserTest::SetUp(); + } + + GURL LoadTestPageWithDataAndGetURL() { + // Write |data| to a temporary file that can be later reached at + // http://127.0.0.1/test_file_*.html. + static int s_test_file_number = 1; + + const char kTestHTML[] = "<!DOCTYPE html>" + "<style>" + " #target {" + " -webkit-app-region: drag;" + " height: 100px;" + " width: 100px;" + " }" + "</style>" + "<div id=target></div>"; + + base::FilePath file_path = temp_dir_.GetPath().AppendASCII( + base::StringPrintf("test_file_%d.html", s_test_file_number++)); + + base::ScopedAllowBlockingForTesting allow_temp_file_writing; + base::WriteFile(file_path, kTestHTML); + + GURL url = embedded_test_server()->GetURL( + "/" + file_path.BaseName().AsUTF8Unsafe()); + + return url; + } + + void InstallAndLaunchWebAppWithWindowControlsOverlay() { + GURL start_url = LoadTestPageWithDataAndGetURL(); + + std::vector<blink::mojom::DisplayMode> display_overrides; + display_overrides.emplace_back( + blink::mojom::DisplayMode::kWindowControlsOverlay); + auto web_app_info = std::make_unique<WebApplicationInfo>(); + web_app_info->start_url = start_url; + web_app_info->scope = start_url.GetWithoutFilename(); + web_app_info->display_mode = blink::mojom::DisplayMode::kStandalone; + web_app_info->open_as_window = true; + web_app_info->title = u"A Web App"; + web_app_info->display_override = display_overrides; + + web_app::AppId app_id = web_app::test::InstallWebApp( + browser()->profile(), std::move(web_app_info)); + + content::TestNavigationObserver navigation_observer(start_url); + base::RunLoop loop; + navigation_observer.StartWatchingNewWebContents(); + app_browser_ = web_app::LaunchWebAppBrowser(browser()->profile(), app_id); + + // TODO(crbug.com/1191186): Register binder for BrowserInterfaceBroker + // during testing. + app_browser_->app_controller()->SetOnUpdateDraggableRegionForTesting( + loop.QuitClosure()); + web_app::NavigateToURLAndWait(app_browser_, start_url); + loop.Run(); + navigation_observer.WaitForNavigationFinished(); + + browser_view_ = BrowserView::GetBrowserViewForBrowser(app_browser_); + views::NonClientFrameView* frame_view = + browser_view_->GetWidget()->non_client_view()->frame_view(); + + frame_view_ = static_cast<BrowserNonClientFrameViewMac*>(frame_view); + web_app_frame_toolbar_ = frame_view_->web_app_frame_toolbar_for_testing(); + + DCHECK(web_app_frame_toolbar_); + DCHECK(web_app_frame_toolbar_->GetVisible()); + } + + Browser* app_browser_ = nullptr; + BrowserView* browser_view_ = nullptr; + BrowserNonClientFrameViewMac* frame_view_ = nullptr; + WebAppFrameToolbarView* web_app_frame_toolbar_ = nullptr; + + private: + std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; + base::ScopedTempDir temp_dir_; +}; + +IN_PROC_BROWSER_TEST_F(WebAppBrowserFrameViewMacWindowControlsOverlayTest, + WindowControlsOverlay) { + InstallAndLaunchWebAppWithWindowControlsOverlay(); + + browser_view_->ToggleWindowControlsOverlayEnabled(); + static_cast<views::View*>(frame_view_)->Layout(); + auto* web_contents = frame_view_->browser_view()->GetActiveWebContents(); + + // window controls overlay should be not be an empty rect and visible as this + // a web app. + + EXPECT_EQ(true, EvalJs(web_contents, + "window.navigator.windowControlsOverlay.visible")); + + EXPECT_NE( + 0, EvalJs(web_contents, + "navigator.windowControlsOverlay.getBoundingClientRect().x")); + EXPECT_EQ( + 0, EvalJs(web_contents, + "navigator.windowControlsOverlay.getBoundingClientRect().y")); + EXPECT_NE( + 0, + EvalJs(web_contents, + "navigator.windowControlsOverlay.getBoundingClientRect().width")); + EXPECT_NE( + 0, + EvalJs(web_contents, + "navigator.windowControlsOverlay.getBoundingClientRect().height")); +} + +IN_PROC_BROWSER_TEST_F(WebAppBrowserFrameViewMacWindowControlsOverlayTest, + GeometryChangeEvent) { + InstallAndLaunchWebAppWithWindowControlsOverlay(); + + browser_view_->ToggleWindowControlsOverlayEnabled(); + auto* web_contents = frame_view_->browser_view()->GetActiveWebContents(); + + EXPECT_TRUE(ExecuteScript( + web_contents->GetMainFrame(), + "geometrychangeCount = 0;" + "navigator.windowControlsOverlay.ongeometrychange = (e) => {" + " geometrychangeCount++;" + " rect = e.boundingRect;" + " visible = e.visible;" + "}")); + + // Change size of widget to trigger a "geometrychange" event. + gfx::Rect bounds = browser_view_->GetLocalBounds(); + bounds.set_width(bounds.width() - 1); + browser_view_->GetWidget()->SetBounds(bounds); + + // Window controls overlay should be not be an empty rect and visible as this + // is a web app. + + // expect the "geometrychange" event to have fired. + EXPECT_NE(0, EvalJs(web_contents, "geometrychangeCount")); + + // Validate event payload. + EXPECT_EQ(true, EvalJs(web_contents, "visible")); + EXPECT_NE(0, EvalJs(web_contents, "rect.width")); + EXPECT_NE(0, EvalJs(web_contents, "rect.height")); +} + +IN_PROC_BROWSER_TEST_F(WebAppBrowserFrameViewMacWindowControlsOverlayTest, + WindowControlsOverlayDraggableRegions) { + InstallAndLaunchWebAppWithWindowControlsOverlay(); + + browser_view_->ToggleWindowControlsOverlayEnabled(); + static_cast<views::View*>(frame_view_)->Layout(); + + constexpr gfx::Point kPoint(50, 50); + EXPECT_EQ(frame_view_->NonClientHitTest(kPoint), HTCAPTION); + EXPECT_FALSE(browser_view_->ShouldDescendIntoChildForEventHandling( + browser_view_->GetWidget()->GetNativeView(), kPoint)); +} + +IN_PROC_BROWSER_TEST_F(WebAppBrowserFrameViewMacWindowControlsOverlayTest, + ToggleWindowControlsOverlay) { + InstallAndLaunchWebAppWithWindowControlsOverlay(); + + // Make sure it launches in standalone mode by default. + EXPECT_FALSE(browser_view_->IsWindowControlsOverlayEnabled()); + EXPECT_TRUE(browser_view_->browser() + ->app_controller() + ->AppUsesWindowControlsOverlay()); + + // Toggle WCO on, and verify that the UI updates accordingly. + browser_view_->ToggleWindowControlsOverlayEnabled(); + EXPECT_TRUE(browser_view_->IsWindowControlsOverlayEnabled()); + EXPECT_TRUE(browser_view_->browser() + ->app_controller() + ->AppUsesWindowControlsOverlay()); + + // Toggle WCO off, and verify that the app returns to 'standalone' mode + browser_view_->ToggleWindowControlsOverlayEnabled(); + EXPECT_FALSE(browser_view_->IsWindowControlsOverlayEnabled()); + EXPECT_TRUE(browser_view_->browser() + ->app_controller() + ->AppUsesWindowControlsOverlay()); +}
diff --git a/chrome/browser/ui/views/frame/window_controls_overlay_input_routing_mac.mm b/chrome/browser/ui/views/frame/window_controls_overlay_input_routing_mac.mm index e8bf333f..d8d845e 100644 --- a/chrome/browser/ui/views/frame/window_controls_overlay_input_routing_mac.mm +++ b/chrome/browser/ui/views/frame/window_controls_overlay_input_routing_mac.mm
@@ -42,7 +42,7 @@ void WindowControlsOverlayInputRoutingMac::Disable() { if (!host_) return; - // TODO(crbug.com/937121): Implement when toggle button is added. + host_->RemoveRemoteWindowControlsOverlayView(overlay_type_); } void WindowControlsOverlayInputRoutingMac::UpdateNSViewPosition() {
diff --git a/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_toolbar_button_container.cc b/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_toolbar_button_container.cc index d99dbe37..ee82832 100644 --- a/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_toolbar_button_container.cc +++ b/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_toolbar_button_container.cc
@@ -83,6 +83,8 @@ if (app_controller->AppUsesWindowControlsOverlay()) { window_controls_overlay_toggle_button_ = AddChildView( std::make_unique<WindowControlsOverlayToggleButton>(browser_view_)); + views::SetHitTestComponent(window_controls_overlay_toggle_button_, + static_cast<int>(HTCLIENT)); } if (app_controller->HasTitlebarContentSettings()) {
diff --git a/chrome/browser/ui/web_applications/draggable_region_host_impl.cc b/chrome/browser/ui/web_applications/draggable_region_host_impl.cc index 37a6019..b0953ef 100644 --- a/chrome/browser/ui/web_applications/draggable_region_host_impl.cc +++ b/chrome/browser/ui/web_applications/draggable_region_host_impl.cc
@@ -14,7 +14,7 @@ DraggableRegionsHostImpl::DraggableRegionsHostImpl( content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<chrome::mojom::DraggableRegions> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)) {} + : DocumentServiceBase(render_frame_host, std::move(receiver)) {} DraggableRegionsHostImpl::~DraggableRegionsHostImpl() = default; @@ -31,7 +31,7 @@ return; // The object is bound to the lifetime of |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new DraggableRegionsHostImpl(render_frame_host, std::move(receiver)); }
diff --git a/chrome/browser/ui/web_applications/draggable_region_host_impl.h b/chrome/browser/ui/web_applications/draggable_region_host_impl.h index 5df2841b..9ed4d69 100644 --- a/chrome/browser/ui/web_applications/draggable_region_host_impl.h +++ b/chrome/browser/ui/web_applications/draggable_region_host_impl.h
@@ -6,14 +6,14 @@ #define CHROME_BROWSER_UI_WEB_APPLICATIONS_DRAGGABLE_REGION_HOST_IMPL_H_ #include "chrome/common/draggable_regions.mojom.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" namespace content { class RenderFrameHost; } class DraggableRegionsHostImpl - : public content::FrameServiceBase<chrome::mojom::DraggableRegions> { + : public content::DocumentServiceBase<chrome::mojom::DraggableRegions> { public: DraggableRegionsHostImpl(const DraggableRegionsHostImpl&) = delete; DraggableRegionsHostImpl& operator=(const DraggableRegionsHostImpl&) = delete;
diff --git a/chrome/browser/ui/web_applications/web_app_browser_controller.cc b/chrome/browser/ui/web_applications/web_app_browser_controller.cc index 8f95eea..3fb425d 100644 --- a/chrome/browser/ui/web_applications/web_app_browser_controller.cc +++ b/chrome/browser/ui/web_applications/web_app_browser_controller.cc
@@ -74,14 +74,8 @@ } bool WebAppBrowserController::IsWindowControlsOverlayEnabled() const { - // TODO(crbug.com/937121): Remove special casing for Mac once toggle is - // supported for BrowserNonClientFrameViewMac. -#if defined(OS_MAC) - return AppUsesWindowControlsOverlay(); -#else return AppUsesWindowControlsOverlay() && registrar().GetWindowControlsOverlayEnabled(GetAppId()); -#endif } void WebAppBrowserController::ToggleWindowControlsOverlayEnabled() {
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 4a2a142..8be0714 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -179,6 +179,8 @@ #include "chrome/browser/chromeos/secure_channel/secure_channel_client_provider.h" #include "chrome/browser/feedback/feedback_dialog_utils.h" #include "chrome/browser/nearby_sharing/nearby_sharing_service_factory.h" +#include "chrome/browser/ui/ash/holding_space/holding_space_keyed_service.h" +#include "chrome/browser/ui/ash/holding_space/holding_space_keyed_service_factory.h" #include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.h" #include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.h" #include "chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.h" @@ -453,8 +455,12 @@ template <> WebUIController* NewWebUI<chromeos::DiagnosticsDialogUI>(WebUI* web_ui, const GURL& url) { + ash::HoldingSpaceKeyedService* holding_space_keyed_service = + ash::HoldingSpaceKeyedServiceFactory::GetInstance()->GetService( + web_ui->GetWebContents()->GetBrowserContext()); return new chromeos::DiagnosticsDialogUI( - web_ui, base::BindRepeating(&CreateChromeSelectFilePolicy)); + web_ui, base::BindRepeating(&CreateChromeSelectFilePolicy), + holding_space_keyed_service->client()); } void BindMultiDeviceSetup(
diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc index 7c8113f..a5ee1477 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc
@@ -67,13 +67,20 @@ LockScreenReauthHandler::~LockScreenReauthHandler() = default; void LockScreenReauthHandler::HandleInitialize(const base::ListValue* value) { + AllowJavascript(); + OnJsReadyForTesting(); LoadAuthenticatorParam(); } void LockScreenReauthHandler::HandleAuthenticatorLoaded( const base::ListValue* value) { VLOG(1) << "Authenticator finished loading"; - authenticator_being_loaded_ = false; + authenticator_state_ = AuthenticatorState::LOADED; + + if (waiting_caller_) { + std::move(waiting_caller_).Run(); + } + // Recreate the client cert usage observer, in order to track only the certs // used during the current sign-in attempt. extension_provided_client_cert_usage_observer_ = @@ -81,12 +88,12 @@ } void LockScreenReauthHandler::LoadAuthenticatorParam() { - if (authenticator_being_loaded_) { + if (authenticator_state_ == AuthenticatorState::LOADING) { VLOG(1) << "Skip loading the Authenticator as it's already being loaded "; return; } - authenticator_being_loaded_ = true; + authenticator_state_ = AuthenticatorState::LOADING; login::GaiaContext context; context.force_reload = true; context.email = email_; @@ -174,11 +181,11 @@ params.SetString("gaiaId", context.gaia_id); params.SetBoolean("extractSamlPasswordAttributes", login::ExtractSamlPasswordAttributesEnabled()); - params.SetBoolean("doSamlRedirect", ShouldDoSamlRedirect(context.email)); + params.SetBoolean("doSamlRedirect", force_saml_redirect_for_testing_ ? + true : ShouldDoSamlRedirect(context.email)); params.SetString("clientVersion", version_info::GetVersionNumber()); params.SetBoolean("readOnlyEmail", true); - AllowJavascript(); CallJavascriptFunction("$(\'main-element\').loadAuthenticator", params); } @@ -247,6 +254,11 @@ password_sync_manager->DismissDialog(); } +void LockScreenReauthHandler::OnJsReadyForTesting() { + js_ready_ = true; + std::move(initialization_callback_for_testing_).Run(); +} + void LockScreenReauthHandler::CheckCredentials( const UserContext& user_context) { Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByAccountId( @@ -296,4 +308,24 @@ weak_factory_.GetWeakPtr())); } +bool LockScreenReauthHandler::IsAuthenticatorLoaded( + base::OnceClosure callback) { + if (authenticator_state_ == AuthenticatorState::LOADED) + return true; + + waiting_caller_ = std::move(callback); + return false; +} + +bool LockScreenReauthHandler::IsJsReadyForTesting( + base::OnceClosure js_ready_callback) { + if (js_ready_) + return true; + + DCHECK(initialization_callback_for_testing_.is_null()); + initialization_callback_for_testing_ = std::move(js_ready_callback); + return false; +} + + } // namespace chromeos
diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h index 23c17c8..9677df41 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h
@@ -29,7 +29,20 @@ void HandleAuthenticatorLoaded(const base::ListValue*); void HandleUpdateUserPassword(const base::ListValue*); + bool IsAuthenticatorLoaded(base::OnceClosure callback); + bool IsJsReadyForTesting(base::OnceClosure js_ready_callback); + + void force_saml_redirect_for_testing() { + force_saml_redirect_for_testing_ = true; + } + private: + enum class AuthenticatorState { + NOT_LOADED, + LOADING, + LOADED + }; + void LoadAuthenticatorParam(); void LoadGaia(const login::GaiaContext& context); @@ -46,10 +59,14 @@ void OnCookieWaitTimeout(); + void OnJsReadyForTesting(); + void CheckCredentials(const UserContext& user_context); - // True if the authenticator is still loading. - bool authenticator_being_loaded_ = false; + AuthenticatorState authenticator_state_ = AuthenticatorState::NOT_LOADED; + + // For testing only. Forces SAML redirect regardless of email. + bool force_saml_redirect_for_testing_ = false; // User non-canonicalized email for display std::string email_; @@ -65,6 +82,13 @@ std::unique_ptr<OnlineLoginHelper> online_login_helper_; + // A test may be waiting for the authenticator to load. + base::OnceClosure waiting_caller_; + + // Tests need to wait until the renderer is ready to execute JavaScript. + bool js_ready_ = false; + base::OnceClosure initialization_callback_for_testing_; + base::WeakPtrFactory<LockScreenReauthHandler> weak_factory_{this}; };
diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc index b61eac5..d8c4619 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc
@@ -9,6 +9,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" #include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h" +#include "chrome/browser/ui/webui/metrics_handler.h" #include "chrome/common/webui_url_constants.h" #include "chrome/grit/browser_resources.h" #include "chrome/grit/generated_resources.h" @@ -31,7 +32,10 @@ content::WebUIDataSource* source = content::WebUIDataSource::Create( chrome::kChromeUILockScreenStartReauthHost); - web_ui->AddMessageHandler(std::make_unique<LockScreenReauthHandler>(email)); + auto main_handler = std::make_unique<LockScreenReauthHandler>(email); + main_handler_ = main_handler.get(); + web_ui->AddMessageHandler(std::move(main_handler)); + web_ui->AddMessageHandler(std::make_unique<MetricsHandler>()); // TODO(crbug.com/1098690): Trusted Type Polymer source->DisableTrustedTypesCSP();
diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h index 99dfba9e..2e0049ab 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h
@@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_START_REAUTH_UI_H_ #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_START_REAUTH_UI_H_ +#include "base/callback_list.h" +#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h" #include "ui/web_dialogs/web_dialog_ui.h" namespace chromeos { @@ -14,6 +16,14 @@ public: explicit LockScreenStartReauthUI(content::WebUI* web_ui); ~LockScreenStartReauthUI() override; + + LockScreenReauthHandler* GetMainHandlerForTests() { return main_handler_; } + + private: + // The main message handler. + LockScreenReauthHandler* main_handler_; + + base::WeakPtrFactory<LockScreenStartReauthUI> weak_factory_{this}; }; } // namespace chromeos
diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h b/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h index e74afbe..a7d2f3d 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h
@@ -7,7 +7,6 @@ #include "base/memory/weak_ptr.h" #include "base/values.h" -#include "chromeos/login/auth/cryptohome_authenticator.h" #include "content/public/browser/web_ui_message_handler.h" namespace chromeos { @@ -25,7 +24,6 @@ private: const std::string password_change_url_; - scoped_refptr<CryptohomeAuthenticator> authenticator_; base::WeakPtrFactory<PasswordChangeHandler> weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(PasswordChangeHandler);
diff --git a/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.cc index 774280f..64fbde5 100644 --- a/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.h" +#include "base/notreached.h" #include "chrome/browser/ash/login/screens/os_install_screen.h" #include "chrome/browser/ui/webui/chromeos/login/js_calls_container.h" #include "chrome/grit/chromium_strings.h" @@ -18,7 +19,9 @@ OsInstallScreenHandler::OsInstallScreenHandler( JSCallsContainer* js_calls_container) - : BaseScreenHandler(kScreenId, js_calls_container) {} + : BaseScreenHandler(kScreenId, js_calls_container) { + set_user_acted_method_path("login.OsInstallScreen.userActed"); +} OsInstallScreenHandler::~OsInstallScreenHandler() { if (screen_) @@ -28,12 +31,25 @@ void OsInstallScreenHandler::DeclareLocalizedValues( ::login::LocalizedValuesBuilder* builder) { builder->Add("osInstallDialogIntroTitle", IDS_OS_INSTALL_SCREEN_INTRO_TITLE); + builder->Add("osInstallDialogIntroSubtitle", + IDS_OS_INSTALL_SCREEN_INTRO_SUBTITLE); + builder->Add("osInstallDialogIntroBody", IDS_OS_INSTALL_SCREEN_INTRO_BODY); + builder->Add("osInstallDialogIntroNextButton", + IDS_OS_INSTALL_SCREEN_INTRO_NEXT_BUTTON); + + builder->Add("osInstallDialogConfirmTitle", + IDS_OS_INSTALL_SCREEN_CONFIRM_TITLE); + builder->Add("osInstallDialogConfirmBody", + IDS_OS_INSTALL_SCREEN_CONFIRM_BODY); + builder->Add("osInstallDialogConfirmNextButton", + IDS_OS_INSTALL_SCREEN_CONFIRM_NEXT_BUTTON); + + builder->Add("osInstallDialogInProgressTitle", + IDS_OS_INSTALL_SCREEN_IN_PROGRESS_TITLE); } void OsInstallScreenHandler::Initialize() {} -void OsInstallScreenHandler::RegisterMessages() {} - void OsInstallScreenHandler::Show() { ShowScreen(kScreenId); } @@ -48,4 +64,12 @@ BaseScreenHandler::SetBaseScreen(nullptr); } +void OsInstallScreenHandler::ShowConfirmStep() { + CallJS("login.OsInstallScreen.showConfirmStep"); +} + +void OsInstallScreenHandler::StartInstall() { + CallJS("login.OsInstallScreen.showInProgressStep"); +} + } // namespace chromeos
diff --git a/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.h index 9d6e433c..3734ea56 100644 --- a/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/os_install_screen_handler.h
@@ -32,6 +32,9 @@ // Unbinds the screen from the view. virtual void Unbind() = 0; + + virtual void ShowConfirmStep() = 0; + virtual void StartInstall() = 0; }; class OsInstallScreenHandler : public BaseScreenHandler, @@ -49,12 +52,13 @@ void DeclareLocalizedValues( ::login::LocalizedValuesBuilder* builder) override; void Initialize() override; - void RegisterMessages() override; // OsInstallScreenView: void Show() override; void Bind(OsInstallScreen* screen) override; void Unbind() override; + void ShowConfirmStep() override; + void StartInstall() override; OsInstallScreen* screen_ = nullptr; };
diff --git a/chrome/browser/ui/webui/policy/policy_ui_handler.cc b/chrome/browser/ui/webui/policy/policy_ui_handler.cc index 6dfa259..77efcf9 100644 --- a/chrome/browser/ui/webui/policy/policy_ui_handler.cc +++ b/chrome/browser/ui/webui/policy/policy_ui_handler.cc
@@ -91,7 +91,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/browser_process_platform_part.h" -#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h" +#include "chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
diff --git a/chrome/browser/visibility_timer_tab_helper.cc b/chrome/browser/visibility_timer_tab_helper.cc index fe9be91..f4241a9 100644 --- a/chrome/browser/visibility_timer_tab_helper.cc +++ b/chrome/browser/visibility_timer_tab_helper.cc
@@ -14,6 +14,12 @@ WEB_CONTENTS_USER_DATA_KEY_IMPL(VisibilityTimerTabHelper) +struct VisibilityTimerTabHelper::Task { + base::TimeDelta visible_delay; + base::Location from_here; + base::OnceClosure task; +}; + VisibilityTimerTabHelper::~VisibilityTimerTabHelper() = default; void VisibilityTimerTabHelper::PostTaskAfterVisibleDelay( @@ -23,20 +29,11 @@ if (web_contents()->IsBeingDestroyed()) return; - // Safe to use Unretained, as destroying |this| will destroy task_queue_, - // hence cancelling all timers. - // RetainingOneShotTimer is used which needs a RepeatingCallback, but we - // only have it run this callback a single time, and destroy it after. - task_queue_.push_back(std::make_unique<base::RetainingOneShotTimer>( - from_here, visible_delay, - base::AdaptCallbackForRepeating( - base::BindOnce(&VisibilityTimerTabHelper::RunTask, - base::Unretained(this), std::move(task))))); - DCHECK(!task_queue_.back()->IsRunning()); + task_queue_.push_back({visible_delay, from_here, std::move(task)}); if (web_contents()->GetVisibility() == content::Visibility::VISIBLE && task_queue_.size() == 1) { - task_queue_.front()->Reset(); + StartNextTaskTimer(); } } @@ -44,9 +41,9 @@ content::Visibility visibility) { if (!task_queue_.empty()) { if (visibility == content::Visibility::VISIBLE) - task_queue_.front()->Reset(); + StartNextTaskTimer(); else - task_queue_.front()->Stop(); + timer_.Stop(); } } @@ -59,7 +56,24 @@ task_queue_.pop_front(); if (!task_queue_.empty()) - task_queue_.front()->Reset(); + StartNextTaskTimer(); std::move(task).Run(); } + +void VisibilityTimerTabHelper::StartNextTaskTimer() { + Task& task = task_queue_.front(); + DCHECK(task.task); + + // Split the callback, as we might need to use it again if the timer is + // stopped. + auto callback_pair = base::SplitOnceCallback(std::move(task.task)); + task.task = std::move(callback_pair.first); + + // Safe to use Unretained, as destroying |this| will destroy timer_, + // hence cancelling the callback. + timer_.Start( + task.from_here, task.visible_delay, + base::BindOnce(&VisibilityTimerTabHelper::RunTask, base::Unretained(this), + std::move(callback_pair.second))); +}
diff --git a/chrome/browser/visibility_timer_tab_helper.h b/chrome/browser/visibility_timer_tab_helper.h index 28ffbae..cb11266 100644 --- a/chrome/browser/visibility_timer_tab_helper.h +++ b/chrome/browser/visibility_timer_tab_helper.h
@@ -5,19 +5,17 @@ #ifndef CHROME_BROWSER_VISIBILITY_TIMER_TAB_HELPER_H_ #define CHROME_BROWSER_VISIBILITY_TIMER_TAB_HELPER_H_ -#include <memory> - +#include "base/callback_forward.h" #include "base/containers/circular_deque.h" +#include "base/timer/timer.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" -namespace base { -class RetainingOneShotTimer; -} - // At most one of these is attached to each WebContents. It allows posting // delayed tasks whose timer only counts down whilst the WebContents is visible // (and whose timer is reset whenever the WebContents stops being visible). +// If multiple tasks are added, they are queued in a dormant state -- their +// timer will not elapse until earlier tasks are completed. class VisibilityTimerTabHelper : public content::WebContentsObserver, public content::WebContentsUserData<VisibilityTimerTabHelper> { @@ -38,13 +36,15 @@ void OnVisibilityChanged(content::Visibility visibility) override; private: + struct Task; friend class content::WebContentsUserData<VisibilityTimerTabHelper>; explicit VisibilityTimerTabHelper(content::WebContents* contents); void RunTask(base::OnceClosure task); + void StartNextTaskTimer(); - base::circular_deque<std::unique_ptr<base::RetainingOneShotTimer>> - task_queue_; + base::OneShotTimer timer_; + base::circular_deque<Task> task_queue_; WEB_CONTENTS_USER_DATA_KEY_DECL(); };
diff --git a/chrome/browser/visibility_timer_tab_helper_unittest.cc b/chrome/browser/visibility_timer_tab_helper_unittest.cc index 79b98002..859844a 100644 --- a/chrome/browser/visibility_timer_tab_helper_unittest.cc +++ b/chrome/browser/visibility_timer_tab_helper_unittest.cc
@@ -62,3 +62,36 @@ EXPECT_TRUE(task_executed); } + +TEST_F(VisibilityTimerTabHelperTest, TasksAreQueuedInDormantState) { + std::string tasks_executed; + VisibilityTimerTabHelper::CreateForWebContents(web_contents()); + + VisibilityTimerTabHelper::FromWebContents(web_contents()) + ->PostTaskAfterVisibleDelay( + FROM_HERE, base::BindLambdaForTesting([&] { tasks_executed += "1"; }), + base::TimeDelta::FromSecondsD(1)); + web_contents()->WasShown(); + task_environment()->FastForwardBy(base::TimeDelta::FromMilliseconds(500)); + + // Add second task. Its timer does not advance until after the first task + // completes. + VisibilityTimerTabHelper::FromWebContents(web_contents()) + ->PostTaskAfterVisibleDelay( + FROM_HERE, base::BindLambdaForTesting([&] { tasks_executed += "2"; }), + base::TimeDelta::FromSecondsD(1)); + + web_contents()->WasHidden(); + web_contents()->WasShown(); + task_environment()->FastForwardBy(base::TimeDelta::FromMilliseconds(990)); + + EXPECT_EQ("", tasks_executed); + + task_environment()->FastForwardBy(base::TimeDelta::FromMilliseconds(11)); + + EXPECT_EQ("1", tasks_executed); + + task_environment()->FastForwardBy(base::TimeDelta::FromMilliseconds(1000)); + + EXPECT_EQ("12", tasks_executed); +}
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 0302b4e..b9baedd 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -690,9 +690,8 @@ #endif } -void ChromeContentRendererClient::RenderViewCreated( - content::RenderView* render_view) { - new prerender::NoStatePrefetchClient(render_view->GetWebView()); +void ChromeContentRendererClient::WebViewCreated(blink::WebView* web_view) { + new prerender::NoStatePrefetchClient(web_view); } SkBitmap* ChromeContentRendererClient::GetSadPluginBitmap() { @@ -988,8 +987,7 @@ if (GURL(frame->GetDocument().Url()).host_piece() == extension_misc::kPdfExtensionId) { if (!base::FeatureList::IsEnabled(features::kWebUIDarkMode)) { - auto* render_view = render_frame->GetRenderView(); - auto* web_view = render_view ? render_view->GetWebView() : nullptr; + auto* web_view = render_frame->GetWebView(); if (web_view) { web_view->GetSettings()->SetPreferredColorScheme( blink::mojom::PreferredColorScheme::kLight);
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h index b9b1841..0b9f4e64 100644 --- a/chrome/renderer/chrome_content_renderer_client.h +++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -88,7 +88,7 @@ void RenderThreadStarted() override; void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override; void RenderFrameCreated(content::RenderFrame* render_frame) override; - void RenderViewCreated(content::RenderView* render_view) override; + void WebViewCreated(blink::WebView* web_view) override; SkBitmap* GetSadPluginBitmap() override; SkBitmap* GetSadWebViewBitmap() override; bool IsPluginHandledExternally(content::RenderFrame* render_frame,
diff --git a/chrome/services/speech/soda/BUILD.gn b/chrome/services/speech/soda/BUILD.gn index f5770429..41aff36 100644 --- a/chrome/services/speech/soda/BUILD.gn +++ b/chrome/services/speech/soda/BUILD.gn
@@ -43,7 +43,7 @@ sources = [ "soda_client_unittest.cc" ] if (is_mac) { - data_deps = [ "//third_party/soda-mac:soda_resources" ] + data_deps = [ "//third_party/soda-mac64:soda_resources" ] } else if (is_win && target_cpu == "x86") { data_deps = [ "//third_party/soda-win32:soda_resources" ] } else if (is_win && target_cpu == "x64") {
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 3017152a..3a04686 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -2504,6 +2504,7 @@ "../browser/extensions/api/desktop_capture/desktop_capture_apitest.cc", "../browser/extensions/api/developer_private/developer_private_apitest.cc", "../browser/extensions/api/downloads/downloads_api_browsertest.cc", + "../browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_apitest.cc", "../browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_browsertest.cc", "../browser/extensions/api/extension_action/browser_action_apitest.cc", "../browser/extensions/api/extension_action/browser_action_browsertest.cc", @@ -3092,6 +3093,7 @@ "../browser/ash/login/saml/password_change_extension_browsertest.cc", "../browser/ash/login/saml/password_change_success_detection_browsertest.cc", "../browser/ash/login/saml/saml_browsertest.cc", + "../browser/ash/login/saml/saml_lockscreen_browsertest.cc", "../browser/ash/login/saml/security_token_saml_browsertest.cc", "../browser/ash/login/saml/test_client_cert_saml_idp_mixin.cc", "../browser/ash/login/saml/test_client_cert_saml_idp_mixin.h", @@ -3265,17 +3267,15 @@ "../browser/chromeos/platform_keys/platform_keys_service_browsertest.cc", "../browser/chromeos/platform_keys/platform_keys_service_test_util.cc", "../browser/chromeos/platform_keys/platform_keys_service_test_util.h", + "../browser/chromeos/policy/active_directory/component_active_directory_policy_browsertest.cc", "../browser/chromeos/policy/affiliation_mixin.cc", "../browser/chromeos/policy/affiliation_mixin.h", "../browser/chromeos/policy/affiliation_test_helper.cc", "../browser/chromeos/policy/affiliation_test_helper.h", "../browser/chromeos/policy/arc/unaffiliated_arc_allowed_browsertest.cc", - "../browser/chromeos/policy/blocking_login_browsertest.cc", "../browser/chromeos/policy/browser_policy_connector_chromeos_browsertest.cc", - "../browser/chromeos/policy/component_active_directory_policy_browsertest.cc", "../browser/chromeos/policy/device_cloud_policy_browsertest.cc", "../browser/chromeos/policy/device_local_account_browsertest.cc", - "../browser/chromeos/policy/device_login_screen_policy_browsertest.cc", "../browser/chromeos/policy/device_policy_cros_browser_test.cc", "../browser/chromeos/policy/device_policy_cros_browser_test.h", "../browser/chromeos/policy/device_quirks_policy_browsertest.cc", @@ -3301,19 +3301,21 @@ "../browser/chromeos/policy/external_data/device_policy_cloud_external_data_manager_browsertest.cc", "../browser/chromeos/policy/external_data/handlers/device_wilco_dtc_configuration_external_data_handler_browsertest.cc", "../browser/chromeos/policy/external_data/user_cloud_external_data_manager_browsertest.cc", - "../browser/chromeos/policy/force_maximize_on_first_run_chromeos_browsertest.cc", - "../browser/chromeos/policy/login_policy_test_base.cc", - "../browser/chromeos/policy/login_policy_test_base.h", - "../browser/chromeos/policy/login_screen_accessibility_policy_browsertest.cc", - "../browser/chromeos/policy/login_screen_default_policy_browsertest.cc", + "../browser/chromeos/policy/login/blocking_login_browsertest.cc", + "../browser/chromeos/policy/login/device_login_screen_policy_browsertest.cc", + "../browser/chromeos/policy/login/force_maximize_on_first_run_chromeos_browsertest.cc", + "../browser/chromeos/policy/login/login_policy_test_base.cc", + "../browser/chromeos/policy/login/login_policy_test_base.h", + "../browser/chromeos/policy/login/login_screen_accessibility_policy_browsertest.cc", + "../browser/chromeos/policy/login/login_screen_default_policy_browsertest.cc", + "../browser/chromeos/policy/login/signin_profile_extensions_policy_browsertest.cc", + "../browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.cc", + "../browser/chromeos/policy/login/signin_profile_extensions_policy_test_base.h", "../browser/chromeos/policy/minimum_version_policy_handler_browsertest.cc", "../browser/chromeos/policy/networking/network_policy_application_browsertest.cc", "../browser/chromeos/policy/networking/policy_certs_browsertest.cc", "../browser/chromeos/policy/power_policy_browsertest.cc", "../browser/chromeos/policy/restore_on_startup_browsertest_chromeos.cc", - "../browser/chromeos/policy/signin_profile_extensions_policy_browsertest.cc", - "../browser/chromeos/policy/signin_profile_extensions_policy_test_base.cc", - "../browser/chromeos/policy/signin_profile_extensions_policy_test_base.h", "../browser/chromeos/policy/site_isolation_flag_handling_browsertest.cc", "../browser/chromeos/policy/status_collector/child_status_collector_browsertest.cc", "../browser/chromeos/policy/status_collector/device_status_collector_browsertest.cc", @@ -3572,7 +3574,7 @@ "../browser/ui/cocoa/share_menu_controller_browsertest.mm", "../browser/ui/cocoa/task_manager_mac_browsertest.mm", "../browser/ui/cocoa/touchbar/browser_window_touch_bar_controller_browsertest.mm", - "../browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.cc", + "../browser/ui/views/frame/browser_non_client_frame_view_mac_browsertest.mm", "../common/profiler/thread_profiler_browsertest.cc", # TODO(crbug/845389): Re-Enable the following, which were temporarily
diff --git a/chrome/test/data/pdf/gesture_detector_test.js b/chrome/test/data/pdf/gesture_detector_test.js index e530e71..965e8bb 100644 --- a/chrome/test/data/pdf/gesture_detector_test.js +++ b/chrome/test/data/pdf/gesture_detector_test.js
@@ -165,7 +165,7 @@ chrome.test.succeed(); }, - function testZoomWithWheel() { + async function testZoomWithWheel() { stubElement = new EventTarget(); const gestureDetector = new GestureDetector(stubElement); const pinchListener = new PinchListener(gestureDetector); @@ -203,7 +203,9 @@ chrome.test.assertEq( {x: position.clientX, y: position.clientY}, detail.center); - pinchSequenceListener.endPromise.then(chrome.test.succeed); + await pinchSequenceListener.endPromise; + + chrome.test.succeed(); }, function testIgnoreTouchScrolling() {
diff --git a/chrome/test/data/pdf/viewer_thumbnail_bar_test.js b/chrome/test/data/pdf/viewer_thumbnail_bar_test.js index 50d6f1e..fe867390 100644 --- a/chrome/test/data/pdf/viewer_thumbnail_bar_test.js +++ b/chrome/test/data/pdf/viewer_thumbnail_bar_test.js
@@ -256,7 +256,7 @@ thumbnails[focusedIndex], thumbnailBar.shadowRoot.activeElement); chrome.test.succeed(); }, - function testThumbnailLeftRightSelect() { + async function testThumbnailLeftRightSelect() { const testDocLength = 2; const thumbnailBar = createThumbnailBar(); thumbnailBar.docLength = testDocLength; @@ -266,22 +266,20 @@ thumbnailBar.activePage = 1; let whenChanged = eventToPromise('change-page', thumbnailBar); keydown(thumbnailBar, 'ArrowRight'); - return whenChanged - .then(e => { - // The event contains the zero-based page index. - chrome.test.assertEq(1, e.detail.page); + let event = await whenChanged; - thumbnailBar.activePage = 2; - whenChanged = eventToPromise('change-page', thumbnailBar); - keydown(thumbnailBar, 'ArrowLeft'); - return whenChanged; - }) - .then(e => { - // The event contains the zero-based page index. - chrome.test.assertEq(0, e.detail.page); + // The event contains the zero-based page index. + chrome.test.assertEq(1, event.detail.page); - chrome.test.succeed(); - }); + thumbnailBar.activePage = 2; + whenChanged = eventToPromise('change-page', thumbnailBar); + keydown(thumbnailBar, 'ArrowLeft'); + event = await whenChanged; + + // The event contains the zero-based page index. + chrome.test.assertEq(0, event.detail.page); + + chrome.test.succeed(); }, async function testReactToNoPlugin() { const thumbnailBar = createThumbnailBar();
diff --git a/chrome/test/data/pdf/viewer_toolbar_test.js b/chrome/test/data/pdf/viewer_toolbar_test.js index 8e7551e..8bbe2199 100644 --- a/chrome/test/data/pdf/viewer_toolbar_test.js +++ b/chrome/test/data/pdf/viewer_toolbar_test.js
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {eventToPromise, flushTasks} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/_test_resources/webui/test_util.m.js'; +import {eventToPromise} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/_test_resources/webui/test_util.m.js'; import {FittingType, ViewerToolbarElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js'; /** @return {!ViewerToolbarElement} */ @@ -142,17 +142,18 @@ chrome.test.succeed(); }, - function testRotateButton() { + async function testRotateButton() { const toolbar = createToolbar(); const rotateButton = getCrIconButtons(toolbar, 'center')[3]; chrome.test.assertEq('pdf:rotate-left', rotateButton.ironIcon); - const promise = eventToPromise('rotate-left', toolbar); + const whenRotateLeft = eventToPromise('rotate-left', toolbar); rotateButton.click(); - promise.then(() => chrome.test.succeed()); + await whenRotateLeft; + chrome.test.succeed(); }, - function testZoomField() { + async function testZoomField() { const toolbar = createToolbar(); toolbar.viewportZoom = .8; toolbar.zoomBounds = {min: 25, max: 500}; @@ -172,41 +173,35 @@ const whenSent = eventToPromise('zoom-changed', toolbar); zoomField.value = '90000%'; zoomField.dispatchEvent(new CustomEvent('change')); - whenSent - .then(e => { - chrome.test.assertEq(500, e.detail); + let event = await whenSent; + chrome.test.assertEq(500, event.detail); - // This happens in the parent. - toolbar.viewportZoom = 5; - chrome.test.assertEq('500%', zoomField.value); + // This happens in the parent. + toolbar.viewportZoom = 5; + chrome.test.assertEq('500%', zoomField.value); - // Setting a value that is over the maximum again restores the max - // value, even though no event is sent. - zoomField.value = '80000%'; - zoomField.dispatchEvent(new CustomEvent('change')); - chrome.test.assertEq('500%', zoomField.value); + // Setting a value that is over the maximum again restores the max + // value, even though no event is sent. + zoomField.value = '80000%'; + zoomField.dispatchEvent(new CustomEvent('change')); + chrome.test.assertEq('500%', zoomField.value); - // Setting a new value sends the value in a zoom-changed event. - const whenSentNew = eventToPromise('zoom-changed', toolbar); - zoomField.value = '110%'; - zoomField.dispatchEvent(new CustomEvent('change')); - return whenSentNew; - }) - .then(e => { - chrome.test.assertEq(110, e.detail); + // Setting a new value sends the value in a zoom-changed event. + const whenSentNew = eventToPromise('zoom-changed', toolbar); + zoomField.value = '110%'; + zoomField.dispatchEvent(new CustomEvent('change')); + event = await whenSentNew; + chrome.test.assertEq(110, event.detail); - // Setting a new value and blurring sends the value in a zoom-changed - // event. If the value is below the minimum, this sends the minimum - // zoom. - const whenSentFromBlur = eventToPromise('zoom-changed', toolbar); - zoomField.value = '18%'; - zoomField.dispatchEvent(new CustomEvent('blur')); - return whenSentFromBlur; - }) - .then(e => { - chrome.test.assertEq(25, e.detail); - chrome.test.succeed(); - }); + // Setting a new value and blurring sends the value in a zoom-changed + // event. If the value is below the minimum, this sends the minimum + // zoom. + const whenSentFromBlur = eventToPromise('zoom-changed', toolbar); + zoomField.value = '18%'; + zoomField.dispatchEvent(new CustomEvent('blur')); + event = await whenSentFromBlur; + chrome.test.assertEq(25, event.detail); + chrome.test.succeed(); }, // Test that the overflow menu closes when an action is triggered. @@ -229,7 +224,7 @@ chrome.test.succeed(); }, - function testTwoPageViewToggle() { + async function testTwoPageViewToggle() { const toolbar = createToolbar(); toolbar.twoUpViewEnabled = false; const button = /** @type {!HTMLElement} */ ( @@ -238,26 +233,24 @@ let whenChanged = eventToPromise('two-up-view-changed', toolbar); button.click(); - whenChanged - .then(e => { - // Happens in the parent. - toolbar.twoUpViewEnabled = true; - chrome.test.assertEq(true, e.detail); - assertCheckboxMenuButton(button, true); - whenChanged = eventToPromise('two-up-view-changed', toolbar); - button.click(); - return whenChanged; - }) - .then(e => { - // Happens in the parent. - toolbar.twoUpViewEnabled = false; - chrome.test.assertEq(false, e.detail); - assertCheckboxMenuButton(button, false); - chrome.test.succeed(); - }); + let event = await whenChanged; + + // Happens in the parent. + toolbar.twoUpViewEnabled = true; + chrome.test.assertEq(true, event.detail); + assertCheckboxMenuButton(button, true); + whenChanged = eventToPromise('two-up-view-changed', toolbar); + button.click(); + event = await whenChanged; + + // Happens in the parent. + toolbar.twoUpViewEnabled = false; + chrome.test.assertEq(false, event.detail); + assertCheckboxMenuButton(button, false); + chrome.test.succeed(); }, - function testShowAnnotationsToggle() { + async function testShowAnnotationsToggle() { const toolbar = createToolbar(); const button = /** @type {!HTMLElement} */ ( toolbar.shadowRoot.querySelector('#show-annotations-button')); @@ -265,19 +258,17 @@ let whenChanged = eventToPromise('display-annotations-changed', toolbar); button.click(); - whenChanged - .then(e => { - chrome.test.assertEq(false, e.detail); - assertCheckboxMenuButton(button, false); - whenChanged = eventToPromise('display-annotations-changed', toolbar); - button.click(); - return whenChanged; - }) - .then(e => { - chrome.test.assertEq(true, e.detail); - assertCheckboxMenuButton(button, true); - chrome.test.succeed(); - }); + let event = await whenChanged; + + chrome.test.assertEq(false, event.detail); + assertCheckboxMenuButton(button, false); + whenChanged = eventToPromise('display-annotations-changed', toolbar); + button.click(); + event = await whenChanged; + + chrome.test.assertEq(true, event.detail); + assertCheckboxMenuButton(button, true); + chrome.test.succeed(); }, function testSidenavToggleButton() { @@ -299,27 +290,18 @@ async function testPresentButton() { const toolbar = createToolbar(); - let button = toolbar.shadowRoot.querySelector('#present-button'); - chrome.test.assertEq(null, button); - - toolbar.presentationModeEnabled = true; - await flushTasks(); - button = toolbar.shadowRoot.querySelector('#present-button'); - chrome.test.assertTrue(button !== null); + const button = toolbar.shadowRoot.querySelector('#present-button'); + chrome.test.assertTrue(!!button); const whenFired = eventToPromise('present-click', toolbar); button.click(); await whenFired; chrome.test.succeed(); }, + async function testPropertiesButton() { const toolbar = createToolbar(); - let button = toolbar.shadowRoot.querySelector('#properties-button'); - chrome.test.assertFalse(!!button); - - toolbar.documentPropertiesEnabled = true; - await flushTasks(); - button = toolbar.shadowRoot.querySelector('#properties-button'); + const button = toolbar.shadowRoot.querySelector('#properties-button'); chrome.test.assertTrue(!!button); const whenFired = eventToPromise('properties-click', toolbar);
diff --git a/chrome/test/data/pdf/zoom_manager_test.js b/chrome/test/data/pdf/zoom_manager_test.js index 6d5731e..97767ad 100644 --- a/chrome/test/data/pdf/zoom_manager_test.js +++ b/chrome/test/data/pdf/zoom_manager_test.js
@@ -160,7 +160,7 @@ chrome.test.succeed(); }, - function testMultiplePdfZoomChanges() { + async function testMultiplePdfZoomChanges() { const viewport = new MockViewport(); const browserZoomSetter = new MockBrowserZoomSetter(); const zoomManager = ZoomManager.create( @@ -174,12 +174,11 @@ chrome.test.assertTrue(browserZoomSetter.started); chrome.test.assertEq(2, browserZoomSetter.zoom); browserZoomSetter.complete(); - Promise.resolve().then(function() { - chrome.test.assertTrue(browserZoomSetter.started); - chrome.test.assertEq(3, browserZoomSetter.zoom); - viewport.removeListeners(); - chrome.test.succeed(); - }); + await Promise.resolve(); + chrome.test.assertTrue(browserZoomSetter.started); + chrome.test.assertEq(3, browserZoomSetter.zoom); + viewport.removeListeners(); + chrome.test.succeed(); }, function testMultipleBrowserZoomChanges() {
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index e1a007a..021bbb0 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json
@@ -930,6 +930,7 @@ "AlwaysOpenPdfExternally": { "os": ["win", "linux", "mac"], + "can_be_recommended": true, "policy_pref_mapping_tests": [ { "policies": { "AlwaysOpenPdfExternally": true },
diff --git a/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js b/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js index ffd62dda..04deb62 100644 --- a/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js +++ b/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js
@@ -377,16 +377,12 @@ }); }); - test('SetComponentsRepairStateOK', () => { + test('SetComponentListOk', () => { let components = [ { component: ComponentType.kKeyboard, state: ComponentRepairState.kOriginal }, - { - component: ComponentType.kTrackpad, - state: ComponentRepairState.kMissing - }, ]; let states = [ {state: RmaState.kSelectComponents, error: RmadErrorCode.kOk}, @@ -394,22 +390,18 @@ ]; service.setStates(states); - return service.setComponentsRepairState(components).then((state) => { + return service.setComponentList(components).then((state) => { assertEquals(state.state, RmaState.kUpdateChrome); assertEquals(state.error, RmadErrorCode.kOk); }); }); - test('SetComponentsRepairStateWrongStateFails', () => { + test('SetComponentListWrongStateFails', () => { let components = [ { component: ComponentType.kKeyboard, state: ComponentRepairState.kOriginal }, - { - component: ComponentType.kTrackpad, - state: ComponentRepairState.kMissing - }, ]; let states = [ {state: RmaState.kWelcomeScreen, error: RmadErrorCode.kOk}, @@ -417,7 +409,7 @@ ]; service.setStates(states); - return service.setComponentsRepairState(components).then((state) => { + return service.setComponentList(components).then((state) => { assertEquals(state.state, RmaState.kWelcomeScreen); assertEquals(state.error, RmadErrorCode.kRequestInvalid); }); @@ -735,16 +727,102 @@ }); }); - test('CutoffBatteryDefaultUndefined', () => { - return service.cutoffBattery().then((error) => { - assertEquals(error, undefined); + test('FinalizeAndRebootOk', () => { + let states = [ + {state: RmaState.kRepairComplete, error: RmadErrorCode.kOk}, + {state: RmaState.kChooseDestination, error: RmadErrorCode.kOk}, + ]; + service.setStates(states); + + return service.finalizeAndReboot().then((state) => { + assertEquals(state.state, RmaState.kChooseDestination); + assertEquals(state.error, RmadErrorCode.kOk); }); }); - test('SetCutoffBatteryUpdatesResult', () => { - service.setCutoffBatteryResult(RmadErrorCode.kRequestInvalid); - return service.cutoffBattery().then((error) => { - assertEquals(error.error, RmadErrorCode.kRequestInvalid); + test('FinalizeAndRebootWhenRmaNotRequired', () => { + return service.finalizeAndReboot().then((state) => { + assertEquals(state.state, RmaState.kUnknown); + assertEquals(state.error, RmadErrorCode.kRmaNotRequired); + }); + }); + + test('FinalizeAndRebootWrongStateFails', () => { + let states = [ + {state: RmaState.kWelcomeScreen, error: RmadErrorCode.kOk}, + {state: RmaState.kChooseDestination, error: RmadErrorCode.kOk}, + ]; + service.setStates(states); + + return service.finalizeAndReboot().then((state) => { + assertEquals(state.state, RmaState.kWelcomeScreen); + assertEquals(state.error, RmadErrorCode.kRequestInvalid); + }); + }); + + test('FinalizeAndShutdownOk', () => { + let states = [ + {state: RmaState.kRepairComplete, error: RmadErrorCode.kOk}, + {state: RmaState.kChooseDestination, error: RmadErrorCode.kOk}, + ]; + service.setStates(states); + + return service.finalizeAndShutdown().then((state) => { + assertEquals(state.state, RmaState.kChooseDestination); + assertEquals(state.error, RmadErrorCode.kOk); + }); + }); + + test('FinalizeAndShutdownWhenRmaNotRequired', () => { + return service.finalizeAndShutdown().then((state) => { + assertEquals(state.state, RmaState.kUnknown); + assertEquals(state.error, RmadErrorCode.kRmaNotRequired); + }); + }); + + test('FinalizeAndShutdownWrongStateFails', () => { + let states = [ + {state: RmaState.kWelcomeScreen, error: RmadErrorCode.kOk}, + {state: RmaState.kChooseDestination, error: RmadErrorCode.kOk}, + ]; + service.setStates(states); + + return service.finalizeAndShutdown().then((state) => { + assertEquals(state.state, RmaState.kWelcomeScreen); + assertEquals(state.error, RmadErrorCode.kRequestInvalid); + }); + }); + + test('CutoffBatteryOk', () => { + let states = [ + {state: RmaState.kRepairComplete, error: RmadErrorCode.kOk}, + {state: RmaState.kChooseDestination, error: RmadErrorCode.kOk}, + ]; + service.setStates(states); + + return service.cutoffBattery().then((state) => { + assertEquals(state.state, RmaState.kChooseDestination); + assertEquals(state.error, RmadErrorCode.kOk); + }); + }); + + test('CutoffBatteryWhenRmaNotRequired', () => { + return service.cutoffBattery().then((state) => { + assertEquals(state.state, RmaState.kUnknown); + assertEquals(state.error, RmadErrorCode.kRmaNotRequired); + }); + }); + + test('CutoffBatteryWrongStateFails', () => { + let states = [ + {state: RmaState.kWelcomeScreen, error: RmadErrorCode.kOk}, + {state: RmaState.kChooseDestination, error: RmadErrorCode.kOk}, + ]; + service.setStates(states); + + return service.cutoffBattery().then((state) => { + assertEquals(state.state, RmaState.kWelcomeScreen); + assertEquals(state.error, RmadErrorCode.kRequestInvalid); }); });
diff --git a/chrome/test/data/webui/js/parse_html_subset_test.js b/chrome/test/data/webui/js/parse_html_subset_test.js index 76f886c6..9ab3966 100644 --- a/chrome/test/data/webui/js/parse_html_subset_test.js +++ b/chrome/test/data/webui/js/parse_html_subset_test.js
@@ -79,6 +79,7 @@ test('supported optional tags', function() { parseHtmlSubset('<img>Some <b>bold</b> text', ['img']); + parseHtmlSubset('A list:<ul><li>An item</li></ul>', ['li', 'ul']); }); test('supported optional tags without the argument', function() {
diff --git a/chrome/test/data/webui/new_tab_page/customize_dialog_test.js b/chrome/test/data/webui/new_tab_page/customize_dialog_test.js index f219ba2b..2684dcb 100644 --- a/chrome/test/data/webui/new_tab_page/customize_dialog_test.js +++ b/chrome/test/data/webui/new_tab_page/customize_dialog_test.js
@@ -163,6 +163,13 @@ assertFalse(customizeDialog.$.refreshToggle.checked); }); + test('clicking back', () => { + customizeDialog.$.backgrounds.selectedCollection = {id: 'landscape'}; + customizeDialog.$.pages.scrollTop = 100; + customizeDialog.shadowRoot.querySelector('.icon-arrow-back').click(); + assertEquals(customizeDialog.$.pages.scrollTop, 0); + }); + test('clicking cancel', () => { customizeDialog.backgroundSelection = { type: BackgroundSelectionType.IMAGE,
diff --git a/chromecast/browser/application_media_info_manager.cc b/chromecast/browser/application_media_info_manager.cc index f353d23..23aadace 100644 --- a/chromecast/browser/application_media_info_manager.cc +++ b/chromecast/browser/application_media_info_manager.cc
@@ -21,7 +21,8 @@ mojo::PendingReceiver<::media::mojom::CastApplicationMediaInfoManager> receiver) { // The created ApplicationMediaInfoManager will be deleted on connection - // error, or when the frame navigates away. See FrameServiceBase for details. + // error, or when the frame navigates away. See DocumentServiceBase for + // details. new ApplicationMediaInfoManager(render_frame_host, std::move(receiver), std::move(application_session_id), mixer_audio_enabled); @@ -33,7 +34,7 @@ receiver, std::string application_session_id, bool mixer_audio_enabled) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), application_session_id_(std::move(application_session_id)), mixer_audio_enabled_(mixer_audio_enabled), renderer_blocked_(false) {
diff --git a/chromecast/browser/application_media_info_manager.h b/chromecast/browser/application_media_info_manager.h index 2252311..6000e29 100644 --- a/chromecast/browser/application_media_info_manager.h +++ b/chromecast/browser/application_media_info_manager.h
@@ -10,7 +10,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "media/mojo/mojom/cast_application_media_info_manager.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" @@ -24,7 +24,7 @@ class ApplicationMediaInfoManagerTest; class ApplicationMediaInfoManager - : public ::content::FrameServiceBase< + : public ::content::DocumentServiceBase< ::media::mojom::CastApplicationMediaInfoManager>, public base::SupportsWeakPtr<ApplicationMediaInfoManager> { public:
diff --git a/chromecast/renderer/cast_content_renderer_client.cc b/chromecast/renderer/cast_content_renderer_client.cc index dabd118..f24ae66 100644 --- a/chromecast/renderer/cast_content_renderer_client.cc +++ b/chromecast/renderer/cast_content_renderer_client.cc
@@ -162,9 +162,7 @@ #endif } -void CastContentRendererClient::RenderViewCreated( - content::RenderView* render_view) { - blink::WebView* webview = render_view->GetWebView(); +void CastContentRendererClient::WebViewCreated(blink::WebView* webview) { webview->SetBaseBackgroundColor(chromecast::GetSwitchValueColor( switches::kCastAppBackgroundColor, SK_ColorBLACK)); // Disable application cache as Chromecast doesn't support off-line
diff --git a/chromecast/renderer/cast_content_renderer_client.h b/chromecast/renderer/cast_content_renderer_client.h index dba39dc..57cc70a 100644 --- a/chromecast/renderer/cast_content_renderer_client.h +++ b/chromecast/renderer/cast_content_renderer_client.h
@@ -52,7 +52,7 @@ // ContentRendererClient implementation: void RenderThreadStarted() override; - void RenderViewCreated(content::RenderView* render_view) override; + void WebViewCreated(blink::WebView* web_view) override; void RenderFrameCreated(content::RenderFrame* render_frame) override; void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override; void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index f7337879..52dfe7d 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM
@@ -1 +1 @@ -14011.0.0 \ No newline at end of file +14012.0.0 \ No newline at end of file
diff --git a/chromeos/components/diagnostics_ui/backend/BUILD.gn b/chromeos/components/diagnostics_ui/backend/BUILD.gn index fe6299d..5478627 100644 --- a/chromeos/components/diagnostics_ui/backend/BUILD.gn +++ b/chromeos/components/diagnostics_ui/backend/BUILD.gn
@@ -80,6 +80,8 @@ deps = [ ":backend", + "//ash/public/cpp", + "//ash/public/cpp/holding_space:test_support", "//base", "//base/test:test_support", "//chromeos/components/diagnostics_ui/mojom",
diff --git a/chromeos/components/diagnostics_ui/backend/session_log_handler.cc b/chromeos/components/diagnostics_ui/backend/session_log_handler.cc index b030817..bc6e3683 100644 --- a/chromeos/components/diagnostics_ui/backend/session_log_handler.cc +++ b/chromeos/components/diagnostics_ui/backend/session_log_handler.cc
@@ -4,6 +4,7 @@ #include "chromeos/components/diagnostics_ui/backend/session_log_handler.h" +#include "ash/public/cpp/holding_space/holding_space_client.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/strings/strcat.h" @@ -30,19 +31,25 @@ } // namespace SessionLogHandler::SessionLogHandler( - const SelectFilePolicyCreator& select_file_policy_creator) + const SelectFilePolicyCreator& select_file_policy_creator, + ash::HoldingSpaceClient* holding_space_client) : SessionLogHandler( select_file_policy_creator, std::make_unique<TelemetryLog>(), - std::make_unique<RoutineLog>(base::FilePath(kRoutineLogPath))) {} + std::make_unique<RoutineLog>(base::FilePath(kRoutineLogPath)), + holding_space_client) {} SessionLogHandler::SessionLogHandler( const SelectFilePolicyCreator& select_file_policy_creator, std::unique_ptr<TelemetryLog> telemetry_log, - std::unique_ptr<RoutineLog> routine_log) + std::unique_ptr<RoutineLog> routine_log, + ash::HoldingSpaceClient* holding_space_client) : select_file_policy_creator_(select_file_policy_creator), telemetry_log_(std::move(telemetry_log)), - routine_log_(std::move(routine_log)) {} + routine_log_(std::move(routine_log)), + holding_space_client_(holding_space_client) { + DCHECK(holding_space_client_); +} SessionLogHandler::~SessionLogHandler() = default; @@ -62,15 +69,23 @@ base::ThreadPool::PostTaskAndReplyWithResult( FROM_HERE, {base::MayBlock()}, base::BindOnce(&SessionLogHandler::CreateSessionLog, - base::Unretained(this), std::move(path)), + base::Unretained(this), path), base::BindOnce(&SessionLogHandler::OnSessionLogCreated, - weak_factory_.GetWeakPtr())); + weak_factory_.GetWeakPtr(), path)); } -void SessionLogHandler::OnSessionLogCreated(const bool success) { +void SessionLogHandler::OnSessionLogCreated(const base::FilePath& file_path, + bool success) { + if (success) { + holding_space_client_->AddDiagnosticsLog(file_path); + } + ResolveJavascriptCallback(base::Value(save_session_log_callback_id_), base::Value(success)); save_session_log_callback_id_ = ""; + + if (log_created_closure_) + std::move(log_created_closure_).Run(); } void SessionLogHandler::FileSelectionCanceled(void* params) { @@ -91,6 +106,10 @@ set_web_ui(web_ui); } +void SessionLogHandler::SetLogCreatedClosureForTest(base::OnceClosure closure) { + log_created_closure_ = std::move(closure); +} + bool SessionLogHandler::CreateSessionLog(const base::FilePath& file_path) { // Fetch RoutineLog const std::string routine_log_contents = routine_log_->GetContents();
diff --git a/chromeos/components/diagnostics_ui/backend/session_log_handler.h b/chromeos/components/diagnostics_ui/backend/session_log_handler.h index 9bf5494e..a01e27e 100644 --- a/chromeos/components/diagnostics_ui/backend/session_log_handler.h +++ b/chromeos/components/diagnostics_ui/backend/session_log_handler.h
@@ -23,6 +23,10 @@ class FilePath; } // namespace base +namespace ash { +class HoldingSpaceClient; +} // namespace ash + namespace chromeos { namespace diagnostics { @@ -35,13 +39,14 @@ using SelectFilePolicyCreator = base::RepeatingCallback<std::unique_ptr<ui::SelectFilePolicy>( content::WebContents*)>; - explicit SessionLogHandler( - const SelectFilePolicyCreator& select_file_policy_creator); + SessionLogHandler(const SelectFilePolicyCreator& select_file_policy_creator, + ash::HoldingSpaceClient* holding_space_client); // Constructor for testing. Should not be called outside of tests. SessionLogHandler(const SelectFilePolicyCreator& select_file_policy_creator, std::unique_ptr<TelemetryLog> telemetry_log, - std::unique_ptr<RoutineLog> routine_log); + std::unique_ptr<RoutineLog> routine_log, + ash::HoldingSpaceClient* holding_space_client); ~SessionLogHandler() override; @@ -53,7 +58,7 @@ int index, void* params) override; - void OnSessionLogCreated(const bool success); + void OnSessionLogCreated(const base::FilePath& path, bool success); void FileSelectionCanceled(void* params) override; @@ -64,6 +69,7 @@ RoutineLog* GetRoutineLog() const; void SetWebUIForTest(content::WebUI* web_ui); + void SetLogCreatedClosureForTest(base::OnceClosure closure); private: // Creates a session log at `file_path`. The session log includes the contents @@ -80,8 +86,10 @@ SelectFilePolicyCreator select_file_policy_creator_; std::unique_ptr<TelemetryLog> telemetry_log_; std::unique_ptr<RoutineLog> routine_log_; + ash::HoldingSpaceClient* const holding_space_client_; std::string save_session_log_callback_id_; scoped_refptr<ui::SelectFileDialog> select_file_dialog_; + base::OnceClosure log_created_closure_; base::WeakPtrFactory<SessionLogHandler> weak_factory_{this}; };
diff --git a/chromeos/components/diagnostics_ui/backend/session_log_handler_unittest.cc b/chromeos/components/diagnostics_ui/backend/session_log_handler_unittest.cc index 628802a..ea42336e 100644 --- a/chromeos/components/diagnostics_ui/backend/session_log_handler_unittest.cc +++ b/chromeos/components/diagnostics_ui/backend/session_log_handler_unittest.cc
@@ -8,6 +8,7 @@ #include <string> #include <utility> +#include "ash/public/cpp/holding_space/mock_holding_space_client.h" #include "base/bind.h" #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -22,8 +23,8 @@ #include "chromeos/components/diagnostics_ui/backend/telemetry_log.h" #include "chromeos/components/diagnostics_ui/mojom/system_data_provider.mojom.h" #include "content/public/browser/web_contents.h" -#include "content/public/test/browser_task_environment.h" #include "content/public/test/test_web_ui.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/native_widget_types.h" #include "ui/shell_dialogs/select_file_dialog.h" @@ -147,9 +148,7 @@ class SessionLogHandlerTest : public testing::Test { public: SessionLogHandlerTest() - : task_environment_(content::BrowserTaskEnvironment::REAL_IO_THREAD), - web_ui_(), - session_log_handler_() { + : task_environment_(), web_ui_(), session_log_handler_() { EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); base::FilePath routine_log_path = temp_dir_.GetPath().AppendASCII(kRoutineLogFileName); @@ -159,7 +158,8 @@ routine_log_ = routine_log.get(); session_log_handler_ = std::make_unique<diagnostics::SessionLogHandler>( base::BindRepeating(&CreateTestSelectFilePolicy), - std::move(telemetry_log), std::move(routine_log)); + std::move(telemetry_log), std::move(routine_log), + &holding_space_client_); session_log_handler_->SetWebUIForTest(&web_ui_); session_log_handler_->RegisterMessages(); @@ -175,12 +175,17 @@ return *web_ui_.call_data()[index]; } + testing::NiceMock<ash::MockHoldingSpaceClient>& holding_space_client() { + return holding_space_client_; + } + protected: - content::BrowserTaskEnvironment task_environment_; + base::test::TaskEnvironment task_environment_; content::TestWebUI web_ui_; std::unique_ptr<diagnostics::SessionLogHandler> session_log_handler_; TelemetryLog* telemetry_log_; RoutineLog* routine_log_; + testing::NiceMock<ash::MockHoldingSpaceClient> holding_space_client_; base::ScopedTempDir temp_dir_; }; @@ -211,8 +216,10 @@ ui::SelectFileDialog::SetFactory(new TestSelectFileDialogFactory(log_path)); base::ListValue args; args.Append(kHandlerFunctionName); + base::RunLoop run_loop; + session_log_handler_->SetLogCreatedClosureForTest(run_loop.QuitClosure()); web_ui_.HandleReceivedMessage("saveSessionLog", &args); - task_environment_.RunUntilIdle(); + run_loop.Run(); const std::string expected_telemetry_log_header = "=== Telemetry Log ==="; const std::string expected_system_info_section_name = "--- System Info ---"; const std::string expected_snapshot_time_prefix = "Snapshot Time: "; @@ -258,8 +265,10 @@ const size_t call_data_count_before_call = web_ui_.call_data().size(); base::ListValue args; args.Append(kHandlerFunctionName); + base::RunLoop run_loop; + session_log_handler_->SetLogCreatedClosureForTest(run_loop.QuitClosure()); web_ui_.HandleReceivedMessage("saveSessionLog", &args); - task_environment_.RunUntilIdle(); + run_loop.Run(); EXPECT_EQ(call_data_count_before_call + 1u, web_ui_.call_data().size()); const content::TestWebUI::CallData& call_data = @@ -288,5 +297,20 @@ EXPECT_FALSE(/*success=*/call_data.arg2()->GetBool()); } +// Validates that saving a session log results in the session log file being +// added to the holding space. +TEST_F(SessionLogHandlerTest, AddToHoldingSpace) { + base::FilePath log_path = temp_dir_.GetPath().AppendASCII("test_path"); + ui::SelectFileDialog::SetFactory(new TestSelectFileDialogFactory(log_path)); + base::ListValue args; + args.Append(kHandlerFunctionName); + + EXPECT_CALL(holding_space_client(), AddDiagnosticsLog(testing::Eq(log_path))); + base::RunLoop run_loop; + session_log_handler_->SetLogCreatedClosureForTest(run_loop.QuitClosure()); + web_ui_.HandleReceivedMessage("saveSessionLog", &args); + run_loop.Run(); +} + } // namespace diagnostics } // namespace chromeos
diff --git a/chromeos/components/diagnostics_ui/diagnostics_ui.cc b/chromeos/components/diagnostics_ui/diagnostics_ui.cc index b33f607..eeaade4 100644 --- a/chromeos/components/diagnostics_ui/diagnostics_ui.cc +++ b/chromeos/components/diagnostics_ui/diagnostics_ui.cc
@@ -143,10 +143,12 @@ DiagnosticsDialogUI::DiagnosticsDialogUI( content::WebUI* web_ui, const chromeos::diagnostics::SessionLogHandler::SelectFilePolicyCreator& - select_file_policy_creator) + select_file_policy_creator, + ash::HoldingSpaceClient* holding_space_client) : ui::MojoWebDialogUI(web_ui), session_log_handler_(std::make_unique<diagnostics::SessionLogHandler>( - select_file_policy_creator)) { + select_file_policy_creator, + holding_space_client)) { diagnostics_manager_ = std::make_unique<diagnostics::DiagnosticsManager>( session_log_handler_.get()); @@ -163,7 +165,7 @@ IDR_DIAGNOSTICS_APP_INDEX_HTML); auto handler = std::make_unique<diagnostics::SessionLogHandler>( - select_file_policy_creator); + select_file_policy_creator, holding_space_client); diagnostics_manager_ = std::make_unique<diagnostics::DiagnosticsManager>(handler.get()); web_ui->AddMessageHandler(std::move(handler));
diff --git a/chromeos/components/diagnostics_ui/diagnostics_ui.h b/chromeos/components/diagnostics_ui/diagnostics_ui.h index 65b1799..989ae42 100644 --- a/chromeos/components/diagnostics_ui/diagnostics_ui.h +++ b/chromeos/components/diagnostics_ui/diagnostics_ui.h
@@ -15,6 +15,12 @@ #include "mojo/public/cpp/bindings/pending_receiver.h" #include "ui/web_dialogs/web_dialog_ui.h" +namespace ash { + +class HoldingSpaceClient; + +} // namespace ash + namespace chromeos { namespace diagnostics { @@ -28,7 +34,8 @@ explicit DiagnosticsDialogUI( content::WebUI* web_ui, const chromeos::diagnostics::SessionLogHandler::SelectFilePolicyCreator& - select_file_policy_creator); + select_file_policy_creator, + ash::HoldingSpaceClient* holding_space_client); ~DiagnosticsDialogUI() override; DiagnosticsDialogUI(const DiagnosticsDialogUI&) = delete;
diff --git a/chromeos/components/proximity_auth/fake_lock_handler.cc b/chromeos/components/proximity_auth/fake_lock_handler.cc index a5653a6..e60f900b 100644 --- a/chromeos/components/proximity_auth/fake_lock_handler.cc +++ b/chromeos/components/proximity_auth/fake_lock_handler.cc
@@ -15,7 +15,7 @@ void FakeLockHandler::ShowUserPodCustomIcon( const AccountId& account_id, - const ScreenlockBridge::UserPodCustomIconOptions& icon) {} + const ScreenlockBridge::UserPodCustomIconInfo& icon_info) {} void FakeLockHandler::HideUserPodCustomIcon(const AccountId& account_id) {}
diff --git a/chromeos/components/proximity_auth/fake_lock_handler.h b/chromeos/components/proximity_auth/fake_lock_handler.h index b5946cc..11493d3 100644 --- a/chromeos/components/proximity_auth/fake_lock_handler.h +++ b/chromeos/components/proximity_auth/fake_lock_handler.h
@@ -20,7 +20,7 @@ bool is_warning) override; void ShowUserPodCustomIcon( const AccountId& account_id, - const ScreenlockBridge::UserPodCustomIconOptions& icon) override; + const ScreenlockBridge::UserPodCustomIconInfo& icon_info) override; void HideUserPodCustomIcon(const AccountId& account_id) override; void EnableInput() override; void SetAuthType(const AccountId& account_id,
diff --git a/chromeos/components/proximity_auth/screenlock_bridge.cc b/chromeos/components/proximity_auth/screenlock_bridge.cc index a021506d..23f309c 100644 --- a/chromeos/components/proximity_auth/screenlock_bridge.cc +++ b/chromeos/components/proximity_auth/screenlock_bridge.cc
@@ -52,13 +52,13 @@ } // namespace -ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() +ScreenlockBridge::UserPodCustomIconInfo::UserPodCustomIconInfo() : autoshow_tooltip_(false), hardlock_on_click_(false) {} -ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {} +ScreenlockBridge::UserPodCustomIconInfo::~UserPodCustomIconInfo() {} std::unique_ptr<base::DictionaryValue> -ScreenlockBridge::UserPodCustomIconOptions::ToDictionaryValue() const { +ScreenlockBridge::UserPodCustomIconInfo::ToDictionaryValue() const { auto result = std::make_unique<base::DictionaryValue>(); result->SetString("id", GetIDString()); @@ -78,28 +78,28 @@ return result; } -void ScreenlockBridge::UserPodCustomIconOptions::SetIcon( +void ScreenlockBridge::UserPodCustomIconInfo::SetIcon( ScreenlockBridge::UserPodCustomIcon icon) { icon_ = icon; } -void ScreenlockBridge::UserPodCustomIconOptions::SetTooltip( +void ScreenlockBridge::UserPodCustomIconInfo::SetTooltip( const std::u16string& tooltip, bool autoshow) { tooltip_ = tooltip; autoshow_tooltip_ = autoshow; } -void ScreenlockBridge::UserPodCustomIconOptions::SetAriaLabel( +void ScreenlockBridge::UserPodCustomIconInfo::SetAriaLabel( const std::u16string& aria_label) { aria_label_ = aria_label; } -void ScreenlockBridge::UserPodCustomIconOptions::SetHardlockOnClick() { +void ScreenlockBridge::UserPodCustomIconInfo::SetHardlockOnClick() { hardlock_on_click_ = true; } -std::string ScreenlockBridge::UserPodCustomIconOptions::GetIDString() const { +std::string ScreenlockBridge::UserPodCustomIconInfo::GetIDString() const { return GetIdForIcon(icon_); }
diff --git a/chromeos/components/proximity_auth/screenlock_bridge.h b/chromeos/components/proximity_auth/screenlock_bridge.h index 7f8fafe3..bbc8a0a 100644 --- a/chromeos/components/proximity_auth/screenlock_bridge.h +++ b/chromeos/components/proximity_auth/screenlock_bridge.h
@@ -41,10 +41,12 @@ // Class containing parameters describing the custom icon that should be // shown on a user's screen lock pod next to the input field. - class UserPodCustomIconOptions { + class UserPodCustomIconInfo { public: - UserPodCustomIconOptions(); - ~UserPodCustomIconOptions(); + UserPodCustomIconInfo(); + UserPodCustomIconInfo(const UserPodCustomIconInfo&) = delete; + UserPodCustomIconInfo& operator=(const UserPodCustomIconInfo&) = delete; + ~UserPodCustomIconInfo(); // Converts parameters to a dictionary values that can be sent to the // screenlock web UI. @@ -86,8 +88,6 @@ std::u16string aria_label_; bool hardlock_on_click_; - - DISALLOW_COPY_AND_ASSIGN(UserPodCustomIconOptions); }; class LockHandler { @@ -101,7 +101,7 @@ // Shows a custom icon in the user pod on the lock screen. virtual void ShowUserPodCustomIcon( const AccountId& account_id, - const UserPodCustomIconOptions& icon) = 0; + const UserPodCustomIconInfo& icon_info) = 0; // Hides the custom icon in user pod for a user. virtual void HideUserPodCustomIcon(const AccountId& account_id) = 0;
diff --git a/chromeos/lacros/BUILD.gn b/chromeos/lacros/BUILD.gn index 7ad108b..f23d9d2 100644 --- a/chromeos/lacros/BUILD.gn +++ b/chromeos/lacros/BUILD.gn
@@ -62,9 +62,7 @@ "lacros.AppLauncherLaunch", "lacros.AudioPlay", "lacros.Basic", - - # TODO(crbug.com/1205526): Enable this test again. - #"lacros.ShelfLaunch", + "lacros.ShelfLaunch", ] }
diff --git a/chromeos/network/cellular_inhibitor.cc b/chromeos/network/cellular_inhibitor.cc index a7955be..807fc87 100644 --- a/chromeos/network/cellular_inhibitor.cc +++ b/chromeos/network/cellular_inhibitor.cc
@@ -27,6 +27,11 @@ constexpr base::TimeDelta kUninhibitRetryDelay = base::TimeDelta::FromSeconds(2); +// Timeout waiting for Cellular device scanning state to change +// to true and back to false. +constexpr base::TimeDelta kScanningChangeTimeout = + base::TimeDelta::FromSeconds(120); + } // namespace CellularInhibitor::InhibitRequest::InhibitRequest( @@ -184,6 +189,10 @@ return; } + scanning_change_timer_.Start( + FROM_HERE, kScanningChangeTimeout, + base::BindOnce(&CellularInhibitor::OnScanningChangeTimeout, + weak_ptr_factory_.GetWeakPtr())); TransitionToState(State::kWaitingForScanningToStart); CheckForScanningStarted(); } @@ -229,7 +238,15 @@ return !cellular_device->scanning(); } +void CellularInhibitor::OnScanningChangeTimeout() { + NET_LOG(ERROR) + << "Timeout waiting for cellular device scanning state to change."; + // Assume that inhibit has completed and continue processing other requests. + PopRequestAndProcessNext(); +} + void CellularInhibitor::PopRequestAndProcessNext() { + scanning_change_timer_.Stop(); inhibit_requests_.pop(); TransitionToState(State::kIdle); ProcessRequests(); @@ -312,7 +329,7 @@ } void CellularInhibitor::OnInhibitPropertyChangeTimeout() { - NET_LOG(EVENT) << "Timeout waiting for inhibit property change state_" + NET_LOG(EVENT) << "Timeout waiting for inhibit property change state " << state_; ReturnSetInhibitPropertyResult(/*success=*/false); }
diff --git a/chromeos/network/cellular_inhibitor.h b/chromeos/network/cellular_inhibitor.h index e6feaec..008b03ac 100644 --- a/chromeos/network/cellular_inhibitor.h +++ b/chromeos/network/cellular_inhibitor.h
@@ -136,6 +136,7 @@ bool HasScanningStarted(); void CheckForScanningStopped(); bool HasScanningStopped(); + void OnScanningChangeTimeout(); void CheckInhibitPropertyIfNeeded(); void CheckForInhibit(); @@ -160,6 +161,7 @@ size_t uninhibit_attempts_so_far_ = 0; base::OneShotTimer set_inhibit_timer_; + base::OneShotTimer scanning_change_timer_; base::ObserverList<Observer> observer_list_;
diff --git a/chromeos/network/cellular_inhibitor_unittest.cc b/chromeos/network/cellular_inhibitor_unittest.cc index d142908..759f349 100644 --- a/chromeos/network/cellular_inhibitor_unittest.cc +++ b/chromeos/network/cellular_inhibitor_unittest.cc
@@ -29,6 +29,9 @@ const char kDefaultCellularDevicePath[] = "stub_cellular_device"; +constexpr base::TimeDelta kScanningChangeTimeout = + base::TimeDelta::FromSeconds(120); + enum class GetInhibitedPropertyResult { kTrue, kFalse, kOperationFailed }; class TestObserver : public CellularInhibitor::Observer { @@ -143,6 +146,10 @@ CellularInhibitor::kInhibitPropertyChangeTimeout); } + void FastForwardScanningChangeTimeout() { + task_environment_.FastForwardBy(kScanningChangeTimeout); + } + size_t GetNumObserverEvents() const { return observer_.num_observer_events(); } @@ -285,4 +292,27 @@ EXPECT_FALSE(inhibit_lock); } +TEST_F(CellularInhibitorTest, FailureScanningChangeTimeout) { + AddCellularDevice(); + + std::unique_ptr<CellularInhibitor::InhibitLock> inhibit_lock = + InhibitCellularScanningSync( + CellularInhibitor::InhibitReason::kInstallingProfile); + // Ensure that a valid lock is returned and inhibit reason is returned. + EXPECT_TRUE(inhibit_lock); + EXPECT_EQ(CellularInhibitor::InhibitReason::kInstallingProfile, + GetInhibitReason()); + + // Delete lock to start uninhibiting and run till uninhibit is waiting for + // scanning state change. + inhibit_lock.reset(); + base::RunLoop().RunUntilIdle(); + + // Verify that no inhibit reason is returned after timeout. + EXPECT_EQ(CellularInhibitor::InhibitReason::kInstallingProfile, + GetInhibitReason()); + FastForwardScanningChangeTimeout(); + EXPECT_FALSE(GetInhibitReason().has_value()); +} + } // namespace chromeos
diff --git a/chromeos/network/device_state_unittest.cc b/chromeos/network/device_state_unittest.cc index 7a01b08..58fbbc8 100644 --- a/chromeos/network/device_state_unittest.cc +++ b/chromeos/network/device_state_unittest.cc
@@ -33,10 +33,10 @@ sim_slot_infos.push_back(std::move(psim_slot_info)); base::Value esim_slot_info(base::Value::Type::DICTIONARY); - psim_slot_info.SetStringKey(shill::kSIMSlotInfoICCID, kTestCellularESimIccid); - psim_slot_info.SetStringKey(shill::kSIMSlotInfoEID, kTestCellularEid); - psim_slot_info.SetBoolKey(shill::kSIMSlotInfoPrimary, false); - sim_slot_infos.push_back(std::move(psim_slot_info)); + esim_slot_info.SetStringKey(shill::kSIMSlotInfoICCID, kTestCellularESimIccid); + esim_slot_info.SetStringKey(shill::kSIMSlotInfoEID, kTestCellularEid); + esim_slot_info.SetBoolKey(shill::kSIMSlotInfoPrimary, false); + sim_slot_infos.push_back(std::move(esim_slot_info)); return base::Value(sim_slot_infos); }
diff --git a/components/cdm/browser/media_drm_storage_impl.cc b/components/cdm/browser/media_drm_storage_impl.cc index 1cf9f66..e351e88 100644 --- a/components/cdm/browser/media_drm_storage_impl.cc +++ b/components/cdm/browser/media_drm_storage_impl.cc
@@ -717,7 +717,7 @@ GetOriginIdCB get_origin_id_cb, AllowEmptyOriginIdCB allow_empty_origin_id_cb, mojo::PendingReceiver<media::mojom::MediaDrmStorage> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), pref_service_(pref_service), get_origin_id_cb_(get_origin_id_cb), allow_empty_origin_id_cb_(allow_empty_origin_id_cb) {
diff --git a/components/cdm/browser/media_drm_storage_impl.h b/components/cdm/browser/media_drm_storage_impl.h index 772f979..f9f4991 100644 --- a/components/cdm/browser/media_drm_storage_impl.h +++ b/components/cdm/browser/media_drm_storage_impl.h
@@ -15,7 +15,7 @@ #include "base/time/time.h" #include "base/unguessable_token.h" #include "build/build_config.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents_observer.h" #include "media/mojo/mojom/media_drm_storage.mojom.h" @@ -43,7 +43,7 @@ // This file is located under components/ so that it can be shared by multiple // content embedders (e.g. chrome and chromecast). class MediaDrmStorageImpl final - : public content::FrameServiceBase<media::mojom::MediaDrmStorage> { + : public content::DocumentServiceBase<media::mojom::MediaDrmStorage> { public: // When using per-origin provisioning, this is the ID for the origin. // If not specified, the device specific origin ID is to be used. @@ -125,7 +125,7 @@ RemovePersistentSessionCallback callback) final; private: - // |this| can only be destructed as a FrameServiceBase. + // |this| can only be destructed as a DocumentServiceBase. ~MediaDrmStorageImpl() final; // Called when |get_origin_id_cb_| asynchronously returns a origin ID as part
diff --git a/components/content_creation/notes/android/BUILD.gn b/components/content_creation/notes/android/BUILD.gn index 56caaff..11c6559 100644 --- a/components/content_creation/notes/android/BUILD.gn +++ b/components/content_creation/notes/android/BUILD.gn
@@ -12,12 +12,14 @@ "java/src/org/chromium/components/content_creation/notes/bridges/NoteTemplateConversionBridge.java", "java/src/org/chromium/components/content_creation/notes/models/Background.java", "java/src/org/chromium/components/content_creation/notes/models/FooterStyle.java", + "java/src/org/chromium/components/content_creation/notes/models/HighlightStyle.java", "java/src/org/chromium/components/content_creation/notes/models/LinearGradientBackground.java", "java/src/org/chromium/components/content_creation/notes/models/LinearGradientDirection.java", "java/src/org/chromium/components/content_creation/notes/models/NoteTemplate.java", "java/src/org/chromium/components/content_creation/notes/models/SolidBackground.java", "java/src/org/chromium/components/content_creation/notes/models/TextAlignment.java", "java/src/org/chromium/components/content_creation/notes/models/TextStyle.java", + "java/src/org/chromium/components/content_creation/notes/ui/TextHighlightSpan.java", ] deps = [
diff --git a/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/bridges/NoteTemplateConversionBridge.java b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/bridges/NoteTemplateConversionBridge.java index f2eda435..31360c1 100644 --- a/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/bridges/NoteTemplateConversionBridge.java +++ b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/bridges/NoteTemplateConversionBridge.java
@@ -11,6 +11,7 @@ import org.chromium.base.annotations.JNINamespace; import org.chromium.components.content_creation.notes.models.Background; import org.chromium.components.content_creation.notes.models.FooterStyle; +import org.chromium.components.content_creation.notes.models.HighlightStyle; import org.chromium.components.content_creation.notes.models.LinearGradientBackground; import org.chromium.components.content_creation.notes.models.LinearGradientDirection; import org.chromium.components.content_creation.notes.models.NoteTemplate; @@ -49,9 +50,10 @@ @CalledByNative private static TextStyle createTextStyle(String fontName, @ColorInt int fontColor, int weight, - boolean allCaps, int alignment, @ColorInt int highlightColor) { + boolean allCaps, int alignment, @ColorInt int highlightColor, int highlightStyle) { return new TextStyle(fontName, fontColor, weight, allCaps, - TextAlignment.fromInteger(alignment), highlightColor); + TextAlignment.fromInteger(alignment), highlightColor, + HighlightStyle.fromInteger(highlightStyle)); } @CalledByNative
diff --git a/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/models/HighlightStyle.java b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/models/HighlightStyle.java new file mode 100644 index 0000000..6061e1c --- /dev/null +++ b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/models/HighlightStyle.java
@@ -0,0 +1,26 @@ +// 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.components.content_creation.notes.models; + +/** + * Enum with values corresponding to the C++ HighlightStyle enum class. + */ +public enum HighlightStyle { + NONE, + FULL, + HALF; + + public static HighlightStyle fromInteger(int x) { + switch (x) { + case 0: + return NONE; + case 1: + return FULL; + case 2: + return HALF; + } + return NONE; + } +} \ No newline at end of file
diff --git a/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/models/TextStyle.java b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/models/TextStyle.java index 853be12..bd70bd6 100644 --- a/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/models/TextStyle.java +++ b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/models/TextStyle.java
@@ -4,40 +4,82 @@ package org.chromium.components.content_creation.notes.models; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.style.LeadingMarginSpan; +import android.view.View; +import android.widget.TextView; + import androidx.annotation.ColorInt; +import org.chromium.components.content_creation.notes.ui.TextHighlightSpan; + /** * Model class for a template's text style. */ public class TextStyle { + // Value in pixels of the leading padding when text has a highlight. + private static final int HIGHLIGHT_LEADING_PADDING = 10; + public final String fontName; - public final @ColorInt int fontColor; public final int weight; - public final boolean allCaps; - public final TextAlignment alignment; - public final @ColorInt int highlightColor; + + private final @ColorInt int mFontColor; + private final boolean mAllCaps; + private final TextAlignment mAlignment; + private final @ColorInt int mHighlightColor; + private final HighlightStyle mHighlightStyle; /** Constructor. */ public TextStyle(String fontName, @ColorInt int fontColor, int weight, boolean allCaps, - TextAlignment alignment, @ColorInt int highlightColor) { + TextAlignment alignment, @ColorInt int highlightColor, HighlightStyle highlightStyle) { this.fontName = fontName; - this.fontColor = fontColor; this.weight = weight; - this.allCaps = allCaps; - this.alignment = alignment; - if (highlightColor > 0) { - this.highlightColor = highlightColor; - } else { - this.highlightColor = 0; - } + this.mFontColor = fontColor; + this.mAllCaps = allCaps; + this.mAlignment = alignment; + this.mHighlightColor = highlightColor; + this.mHighlightStyle = highlightStyle; } /** * Returns true if this text style specifies a highlight color to draw behind the * text but on top of background colors. */ - public boolean hasHighlightColor() { - return this.highlightColor > 0; + public boolean hasHighlight() { + // Sometimes colors' integers overflow, so negative numbers are valid. + return this.mHighlightColor != 0 && this.mHighlightStyle != HighlightStyle.NONE; + } + + /** + * Applies the current styling to the |text| when setting it on |textView|. + */ + public void apply(TextView textView, String text) { + textView.setTextColor(this.mFontColor); + textView.setAllCaps(this.mAllCaps); + textView.setGravity(TextAlignment.toGravity(this.mAlignment)); + + if (this.hasHighlight()) { + int start = 0; + int end = text.length(); + + SpannableString spannableString = new SpannableString(text); + + boolean isRtl = textView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; + TextHighlightSpan highlightSpan = new TextHighlightSpan( + this.mHighlightStyle, this.mHighlightColor, this.mAlignment, isRtl); + spannableString.setSpan(highlightSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + + // Needs a small leading margin span otherwise the highlight appears as if it was + // clipped. + LeadingMarginSpan.Standard marginSpan = + new LeadingMarginSpan.Standard(HIGHLIGHT_LEADING_PADDING); + spannableString.setSpan(marginSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + + textView.setText(spannableString, TextView.BufferType.SPANNABLE); + } else { + textView.setText(text); + } } }
diff --git a/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/ui/TextHighlightSpan.java b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/ui/TextHighlightSpan.java new file mode 100644 index 0000000..b9525e3 --- /dev/null +++ b/components/content_creation/notes/android/java/src/org/chromium/components/content_creation/notes/ui/TextHighlightSpan.java
@@ -0,0 +1,76 @@ +// 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.components.content_creation.notes.ui; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.text.style.LineBackgroundSpan; + +import androidx.annotation.ColorInt; + +import org.chromium.components.content_creation.notes.models.HighlightStyle; +import org.chromium.components.content_creation.notes.models.TextAlignment; + +/** + * Class used to draw colored highlight behind text. + */ +public class TextHighlightSpan implements LineBackgroundSpan { + private static final int RIGHT_PADDING = 10; + + private final HighlightStyle mStyle; + private final @ColorInt int mColor; + private final boolean mIsCentered; + private final boolean mIsLeftAligned; + + /** Constructor. */ + public TextHighlightSpan( + HighlightStyle style, @ColorInt int color, TextAlignment alignment, boolean isRtl) { + assert style != HighlightStyle.NONE; + + this.mStyle = style; + this.mColor = color; + this.mIsCentered = alignment == TextAlignment.CENTER; + this.mIsLeftAligned = (!isRtl && alignment == TextAlignment.START) + || (isRtl && alignment == TextAlignment.END); + } + + @Override + public void drawBackground(Canvas canvas, Paint paint, int left, int right, int top, + int baseline, int bottom, CharSequence text, int start, int end, int lineNumber) { + CharSequence lineText = text.subSequence(start, end); + if (lineText.toString().trim().length() == 0) { + // No need to draw a background for lines with no characters. + return; + } + + final int textWidth = Math.round(paint.measureText(text, start, end)); + final int paintColor = paint.getColor(); + + paint.setColor(this.mColor); + + if (this.mIsCentered) { + int middle = ((right - left) / 2) + left; + int textWidthOffset = (textWidth / 2); + left = middle - textWidthOffset; + right = middle + textWidthOffset; + } else if (this.mIsLeftAligned) { + right = left + textWidth; + } else { + left = right - textWidth; + } + + if (this.mStyle == HighlightStyle.HALF) { + top = top + (bottom - top) / 2; + } + + // Add some padding to the right to prevent most of the clipping. It + // will still occur when the line takes the full width of the canvas, + // but it looks much better like this. + canvas.drawRect(left, top, right + RIGHT_PADDING, bottom, paint); + + // Reset initial paint color to ensure the text gets drawn properly. + paint.setColor(paintColor); + } +} \ No newline at end of file
diff --git a/components/content_creation/notes/android/note_template_conversion_bridge.cc b/components/content_creation/notes/android/note_template_conversion_bridge.cc index eeaaa2a..1eb96806 100644 --- a/components/content_creation/notes/android/note_template_conversion_bridge.cc +++ b/components/content_creation/notes/android/note_template_conversion_bridge.cc
@@ -37,7 +37,8 @@ env, ConvertUTF8ToJavaString(env, text_style.font_name()), text_style.font_color(), text_style.weight(), text_style.all_caps(), static_cast<uint16_t>(text_style.alignment()), - text_style.highlight_color()); + text_style.highlight_color(), + static_cast<uint16_t>(text_style.highlight_style())); } ScopedJavaLocalRef<jobject> CreateJavaFooterStyle(
diff --git a/components/content_creation/notes/core/templates/template_constants.cc b/components/content_creation/notes/core/templates/template_constants.cc index 881c009..74ace8d7 100644 --- a/components/content_creation/notes/core/templates/template_constants.cc +++ b/components/content_creation/notes/core/templates/template_constants.cc
@@ -27,6 +27,8 @@ const ARGBColor kRed500Color = 0xFFEA4335; const ARGBColor kYellow400Color = 0xFFFCC934; +const ARGBColor kLightYellowColor = 0xFFFCEF94; + const ARGBColor kWhiteColor = 0xFFFFFFFF; const ARGBColor kBlackColor = 0xFF000000; @@ -104,7 +106,6 @@ } NoteTemplate GetImpactfulTemplate() { - // TODO(crbug.com/1194168): Add offset text highlights support. return NoteTemplate( /*id=*/NoteTemplateIds::kImpactful, l10n_util::GetStringUTF8( @@ -112,7 +113,8 @@ Background(/*color=*/kGrey200Color), TextStyle(kBebasNeueFontName, /*font_color=*/kBlackColor, k400Weight, - /*all_caps=*/true, TextAlignment::kCenter), + /*all_caps=*/true, TextAlignment::kCenter, + /*highlight_color=*/kWhiteColor, HighlightStyle::kHalf), /*footer_style=*/CreateLightBackgroundFooterStyle()); } @@ -138,7 +140,7 @@ TextStyle(kBebasNeueFontName, /*font_color=*/kYellow400Color, k400Weight, /*all_caps=*/true, TextAlignment::kStart, - /*highlight_color=*/kBlue900Color), + /*highlight_color=*/kBlue900Color, HighlightStyle::kFull), /*footer_style=*/CreateDarkBackgroundFooterStyle()); } @@ -155,14 +157,14 @@ } NoteTemplate GetBoldTemplate() { - // TODO(crbug.com/1194168): Add offset text highlights support. return NoteTemplate( /*id=*/NoteTemplateIds::kBold, l10n_util::GetStringUTF8(IDS_CONTENT_CREATION_NOTE_TEMPLATE_NAME_BOLD), Background(/*color=*/kWhiteColor), TextStyle(kBebasNeueFontName, /*font_color=*/kBlackColor, k400Weight, - /*all_caps=*/true, TextAlignment::kCenter), + /*all_caps=*/true, TextAlignment::kCenter, + /*highlight_color=*/kLightYellowColor, HighlightStyle::kHalf), /*footer_style=*/CreateLightBackgroundFooterStyle()); }
diff --git a/components/content_creation/notes/core/templates/template_types.cc b/components/content_creation/notes/core/templates/template_types.cc index 182942b..aac1dd0 100644 --- a/components/content_creation/notes/core/templates/template_types.cc +++ b/components/content_creation/notes/core/templates/template_types.cc
@@ -47,20 +47,23 @@ weight_(weight), all_caps_(all_caps), alignment_(alignment), - highlight_color_(0U) {} + highlight_color_(0U), + highlight_style_(HighlightStyle::kNone) {} TextStyle::TextStyle(const std::string& font_name, ARGBColor font_color, uint16_t weight, bool all_caps, TextAlignment alignment, - ARGBColor highlight_color) + ARGBColor highlight_color, + HighlightStyle highlight_style) : font_name_(font_name), font_color_(font_color), weight_(weight), all_caps_(all_caps), alignment_(alignment), - highlight_color_(highlight_color) {} + highlight_color_(highlight_color), + highlight_style_(highlight_style) {} FooterStyle::FooterStyle(ARGBColor text_color, ARGBColor logo_color) : text_color_(text_color), logo_color_(logo_color) {}
diff --git a/components/content_creation/notes/core/templates/template_types.h b/components/content_creation/notes/core/templates/template_types.h index 6a2dfc1..5aec99c 100644 --- a/components/content_creation/notes/core/templates/template_types.h +++ b/components/content_creation/notes/core/templates/template_types.h
@@ -72,6 +72,10 @@ // counterpart of the same name. enum class TextAlignment { kInvalid = 0, kStart = 1, kCenter = 2, kEnd = 3 }; +// Represents the different supported text highlight styles. Keep this enum in +// sync with its Java counterpart of the same name. +enum class HighlightStyle { kNone = 0, kFull = 1, kHalf = 2 }; + // Parameters dictating how to display text. class TextStyle { public: @@ -86,7 +90,8 @@ uint16_t weight, bool all_caps, TextAlignment alignment, - ARGBColor highlight_color); + ARGBColor highlight_color, + HighlightStyle highlight_style); const std::string& font_name() const { return font_name_; } ARGBColor font_color() const { return font_color_; } @@ -94,6 +99,7 @@ bool all_caps() const { return all_caps_; } TextAlignment alignment() const { return alignment_; } ARGBColor highlight_color() const { return highlight_color_; } + HighlightStyle highlight_style() const { return highlight_style_; } private: std::string font_name_; @@ -102,6 +108,7 @@ bool all_caps_; TextAlignment alignment_; ARGBColor highlight_color_; + HighlightStyle highlight_style_; }; // Parameters to control the appearance of the elements in a note's footer.
diff --git a/components/exo/surface.cc b/components/exo/surface.cc index 34fd2515..f8eeb19 100644 --- a/components/exo/surface.cc +++ b/components/exo/surface.cc
@@ -47,6 +47,7 @@ #include "ui/events/event.h" #include "ui/gfx/buffer_format_util.h" #include "ui/gfx/geometry/dip_util.h" +#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/gpu_fence.h" @@ -1166,8 +1167,8 @@ damage_rect += origin.OffsetFromOrigin(); damage_rect.Intersect(output_rect); if (device_scale_factor <= 1) { - render_pass->damage_rect.Union(gfx::ToEnclosingRect( - gfx::ConvertRectToPixels(damage_rect, device_scale_factor))); + damage_rect = gfx::ToEnclosingRect( + gfx::ConvertRectToPixels(damage_rect, device_scale_factor)); } else { // The damage will eventually be rescaled by 1/device_scale_factor. Since // that scale factor is <1, taking the enclosed rect here means that that @@ -1175,7 +1176,7 @@ // which makes the enclosing rect equal to |damage_rect|. gfx::RectF scaled_damage(damage_rect); scaled_damage.Scale(device_scale_factor); - render_pass->damage_rect.Union(gfx::ToEnclosedRect(scaled_damage)); + damage_rect = gfx::ToEnclosedRect(scaled_damage); } } state_.damage.Clear(); @@ -1234,7 +1235,6 @@ gfx::MaskFilterInfo() /*mask_filter_info=*/, absl::nullopt /*clip_rect=*/, are_contents_opaque, state_.basic_state.alpha /*opacity=*/, SkBlendMode::kSrcOver /*blend_mode=*/, 0 /*sorting_context_id=*/); - quad_state->no_damage = damage_rect.IsEmpty(); if (current_resource_.id) { gfx::RectF uv_crop(gfx::SizeF(1, 1)); @@ -1299,7 +1299,15 @@ gfx::ProtectedVideoType::kClear); if (current_resource_.is_overlay_candidate) texture_quad->set_resource_size_in_pixels(current_resource_.size); + frame->resource_list.push_back(current_resource_); + + if (!damage_rect.IsEmpty()) { + texture_quad->damage_rect = damage_rect; + render_pass->has_per_quad_damage = true; + // Clear handled damage so it will not be added to the |render_pass|. + damage_rect = gfx::Rect(); + } } } else { viz::SolidColorDrawQuad* solid_quad = @@ -1307,6 +1315,8 @@ solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false /* force_anti_aliasing_off */); } + + render_pass->damage_rect.Union(damage_rect); } void Surface::UpdateContentSize() {
diff --git a/components/exo/surface_unittest.cc b/components/exo/surface_unittest.cc index dc34ffb..8c3677a 100644 --- a/components/exo/surface_unittest.cc +++ b/components/exo/surface_unittest.cc
@@ -89,9 +89,25 @@ gfx::ConvertRectToPixels(rect, device_scale_factor())); } - gfx::Rect ToTargetSpaceDamage(const gfx::Rect damage_rect) { + gfx::Rect GetCompleteDamage(const viz::CompositorFrame& frame) { + auto& root_pass = frame.render_pass_list.back(); + gfx::Rect complete_damage = root_pass->damage_rect; + + for (auto* quad : root_pass->quad_list) { + if (quad->material == viz::DrawQuad::Material::kTextureContent) { + auto* texture_quad = viz::TextureDrawQuad::MaterialCast(quad); + if (texture_quad->damage_rect.has_value()) { + complete_damage.Union(texture_quad->damage_rect.value()); + } + } + } + return complete_damage; + } + + gfx::Rect ToTargetSpaceDamage(const viz::CompositorFrame& frame) { // Map a frame's damage back to the coordinate space of its buffer. - return gfx::ScaleToEnclosingRect(damage_rect, 1 / device_scale_factor()); + return gfx::ScaleToEnclosingRect(GetCompleteDamage(frame), + 1 / device_scale_factor()); } const viz::CompositorFrame& GetFrameFromSurface(ShellSurface* shell_surface) { @@ -174,8 +190,7 @@ { const viz::CompositorFrame& frame = GetFrameFromSurface(shell_surface.get()); - EXPECT_EQ(ToPixel(gfx::Rect(buffer_size)), - frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(ToPixel(gfx::Rect(buffer_size)), GetCompleteDamage(frame)); } gfx::RectF buffer_damage(32, 64, 16, 32); @@ -193,8 +208,8 @@ { const viz::CompositorFrame& frame = GetFrameFromSurface(shell_surface.get()); - EXPECT_TRUE(ToTargetSpaceDamage(frame.render_pass_list.back()->damage_rect) - .Contains(gfx::ToNearestRect(buffer_damage))); + EXPECT_TRUE( + ToTargetSpaceDamage(frame).Contains(gfx::ToNearestRect(buffer_damage))); } } @@ -223,7 +238,7 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect(gfx::ScaleRect( gfx::RectF(gfx::Rect(buffer_size)), device_scale_factor())); - EXPECT_EQ(scaled_damage, frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(scaled_damage, GetCompleteDamage(frame)); } const gfx::RectF surface_damage(16, 16); @@ -241,8 +256,8 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect( gfx::ScaleRect(subsurface_damage, device_scale_factor())); - EXPECT_TRUE(scaled_damage.ApproximatelyEqual( - frame.render_pass_list.back()->damage_rect, margin)); + EXPECT_TRUE( + scaled_damage.ApproximatelyEqual(GetCompleteDamage(frame), margin)); } surface->Damage(gfx::ToNearestRect(surface_damage)); @@ -256,8 +271,8 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect( gfx::ScaleRect(surface_damage, device_scale_factor())); - EXPECT_TRUE(scaled_damage.ApproximatelyEqual( - frame.render_pass_list.back()->damage_rect, margin)); + EXPECT_TRUE( + scaled_damage.ApproximatelyEqual(GetCompleteDamage(frame), margin)); } } @@ -287,7 +302,7 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect(gfx::ScaleRect( gfx::RectF(gfx::Rect(buffer_size)), device_scale_factor())); - EXPECT_EQ(scaled_damage, frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(scaled_damage, GetCompleteDamage(frame)); } const gfx::RectF subsurface_damage(32, 32, 16, 16); @@ -309,7 +324,7 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect(gfx::ScaleRect( gfx::RectF(gfx::Rect(buffer_size)), device_scale_factor())); - EXPECT_EQ(scaled_damage, frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(scaled_damage, GetCompleteDamage(frame)); } // Damage but do not commit. @@ -326,8 +341,8 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect( gfx::ScaleRect(subsurface_damage, device_scale_factor())); - EXPECT_TRUE(scaled_damage.ApproximatelyEqual( - frame.render_pass_list.back()->damage_rect, margin)); + EXPECT_TRUE( + scaled_damage.ApproximatelyEqual(GetCompleteDamage(frame), margin)); } } @@ -357,7 +372,7 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect(gfx::ScaleRect( gfx::RectF(gfx::Rect(buffer_size)), device_scale_factor())); - EXPECT_EQ(scaled_damage, frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(scaled_damage, GetCompleteDamage(frame)); } const gfx::RectF subsurface_damage(32, 32, 16, 16); @@ -378,8 +393,8 @@ GetFrameFromSurface(shell_surface.get()); const gfx::Rect scaled_damage = gfx::ToNearestRect( gfx::ScaleRect(subsurface_damage, device_scale_factor())); - EXPECT_TRUE(scaled_damage.ApproximatelyEqual( - frame.render_pass_list.back()->damage_rect, margin)); + EXPECT_TRUE( + scaled_damage.ApproximatelyEqual(GetCompleteDamage(frame), margin)); } } @@ -434,8 +449,7 @@ EXPECT_FALSE(texture_draw_quad->ShouldDrawWithBlending()); EXPECT_EQ(SK_ColorBLACK, texture_draw_quad->background_color); - EXPECT_EQ(gfx::Rect(buffer_size), - ToTargetSpaceDamage(frame.render_pass_list.back()->damage_rect)); + EXPECT_EQ(gfx::Rect(buffer_size), ToTargetSpaceDamage(frame)); } // Setting an empty opaque region requires draw with blending. @@ -452,8 +466,7 @@ frame.render_pass_list.back()->quad_list.back()); EXPECT_TRUE(texture_draw_quad->ShouldDrawWithBlending()); EXPECT_EQ(SK_ColorTRANSPARENT, texture_draw_quad->background_color); - EXPECT_EQ(gfx::Rect(buffer_size), - ToTargetSpaceDamage(frame.render_pass_list.back()->damage_rect)); + EXPECT_EQ(gfx::Rect(buffer_size), ToTargetSpaceDamage(frame)); } std::unique_ptr<Buffer> buffer_without_alpha( @@ -474,8 +487,7 @@ EXPECT_FALSE(frame.render_pass_list.back() ->quad_list.back() ->ShouldDrawWithBlending()); - EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 0, 0)), - frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 0, 0)), GetCompleteDamage(frame)); } } @@ -594,8 +606,7 @@ const viz::CompositorFrame& frame = GetFrameFromSurface(shell_surface.get()); ASSERT_EQ(1u, frame.render_pass_list.size()); - EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 256, 256)), - frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 256, 256)), GetCompleteDamage(frame)); } // Disabled due to flakiness: crbug.com/856145 @@ -629,7 +640,7 @@ ASSERT_EQ(1u, frame.render_pass_list.size()); EXPECT_EQ( ToPixel(gfx::Rect(0, 0, buffer_size.height(), buffer_size.width())), - frame.render_pass_list.back()->damage_rect); + GetCompleteDamage(frame)); const auto& quad_list = frame.render_pass_list[0]->quad_list; ASSERT_EQ(1u, quad_list.size()); EXPECT_EQ( @@ -732,8 +743,7 @@ const viz::CompositorFrame& frame = GetFrameFromSurface(shell_surface.get()); ASSERT_EQ(1u, frame.render_pass_list.size()); - EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 512, 512)), - frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 512, 512)), GetCompleteDamage(frame)); } TEST_P(SurfaceTest, SetCrop) { @@ -755,8 +765,7 @@ const viz::CompositorFrame& frame = GetFrameFromSurface(shell_surface.get()); ASSERT_EQ(1u, frame.render_pass_list.size()); - EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 12, 12)), - frame.render_pass_list.back()->damage_rect); + EXPECT_EQ(ToPixel(gfx::Rect(0, 0, 12, 12)), GetCompleteDamage(frame)); } // Disabled due to flakiness: crbug.com/856145 @@ -1019,8 +1028,7 @@ ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size()); ASSERT_EQ(1u, frame.resource_list.size()); ASSERT_EQ(viz::ResourceId(1u), frame.resource_list.back().id); - EXPECT_EQ(gfx::Rect(buffer_size), - ToTargetSpaceDamage(frame.render_pass_list.back()->damage_rect)); + EXPECT_EQ(gfx::Rect(buffer_size), ToTargetSpaceDamage(frame)); } { @@ -1034,8 +1042,7 @@ // No quad if alpha is 0. ASSERT_EQ(0u, frame.render_pass_list.back()->quad_list.size()); ASSERT_EQ(0u, frame.resource_list.size()); - EXPECT_EQ(gfx::Rect(buffer_size), - ToTargetSpaceDamage(frame.render_pass_list.back()->damage_rect)); + EXPECT_EQ(gfx::Rect(buffer_size), ToTargetSpaceDamage(frame)); } { @@ -1050,8 +1057,7 @@ ASSERT_EQ(1u, frame.resource_list.size()); // The resource should be updated again, the id should be changed. ASSERT_EQ(viz::ResourceId(2u), frame.resource_list.back().id); - EXPECT_EQ(gfx::Rect(buffer_size), - ToTargetSpaceDamage(frame.render_pass_list.back()->damage_rect)); + EXPECT_EQ(gfx::Rect(buffer_size), ToTargetSpaceDamage(frame)); } }
diff --git a/components/feed/feed_feature_list.cc b/components/feed/feed_feature_list.cc index 29c096a..bfd82f8 100644 --- a/components/feed/feed_feature_list.cc +++ b/components/feed/feed_feature_list.cc
@@ -59,6 +59,8 @@ base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kXsurfaceMetricsReporting{ "XsurfaceMetricsReporting", base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kReliabilityLogging{"FeedReliabilityLogging", + base::FEATURE_DISABLED_BY_DEFAULT}; const char kDefaultReferrerUrl[] = "https://www.google.com/";
diff --git a/components/feed/feed_feature_list.h b/components/feed/feed_feature_list.h index 67b4525..9cad2a1 100644 --- a/components/feed/feed_feature_list.h +++ b/components/feed/feed_feature_list.h
@@ -53,6 +53,9 @@ // xsurface feed. extern const base::Feature kXsurfaceMetricsReporting; +// Whether to log reliability events. +extern const base::Feature kReliabilityLogging; + std::string GetFeedReferrerUrl(); } // namespace feed
diff --git a/components/omnibox/browser/android/OWNERS b/components/omnibox/browser/android/OWNERS index f326619a..9b9d6de 100644 --- a/components/omnibox/browser/android/OWNERS +++ b/components/omnibox/browser/android/OWNERS
@@ -1,3 +1,3 @@ +ender@google.com fgorski@chromium.org tedchoc@chromium.org -yusufo@chromium.org
diff --git a/components/policy/BUILD.gn b/components/policy/BUILD.gn index eec74421..7c3eba8e 100644 --- a/components/policy/BUILD.gn +++ b/components/policy/BUILD.gn
@@ -323,19 +323,6 @@ proto_deps = [ ":policy_code_generate" ] } -# This target generates the "full" protobuf library used by policy_fuzzer. -if (use_libfuzzer) { - fuzzable_proto_library("cloud_policy_full_runtime_proto") { - proto_out_dir = "components/policy/proto/fuzzer" - - sources = [ cloud_policy_proto_path ] - - import_dirs = [ "//components/policy/proto" ] - - proto_deps = [ ":policy_code_generate" ] - } -} - # This target builds the "full" protobuf, used for tests only. component("chrome_settings_proto_generated_compile") { testonly = true
diff --git a/components/policy/proto/BUILD.gn b/components/policy/proto/BUILD.gn index 4981800..541b453 100644 --- a/components/policy/proto/BUILD.gn +++ b/components/policy/proto/BUILD.gn
@@ -3,7 +3,6 @@ # found in the LICENSE file. import("//build/config/chromeos/ui_mode.gni") -import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni") import("//third_party/protobuf/proto_library.gni") # The proto files need to be a component to avoid duplicate symbols the way the @@ -65,14 +64,3 @@ component_build_force_source_set = true defines = [ "POLICY_PROTO_COMPILATION" ] } - -if (use_libfuzzer) { - fuzzable_proto_library("chrome_device_policy_full_runtime_proto") { - proto_out_dir = "components/policy/proto/fuzzer" - - sources = [ - "chrome_device_policy.proto", - "policy_common_definitions.proto", - ] - } -}
diff --git a/components/policy/proto/fuzzer/BUILD.gn b/components/policy/proto/fuzzer/BUILD.gn new file mode 100644 index 0000000..67aa773d1 --- /dev/null +++ b/components/policy/proto/fuzzer/BUILD.gn
@@ -0,0 +1,42 @@ +# 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. + +# Build rules for fuzzable (full-runtime) versions of the policy protobufs. + +import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni") + +assert(use_libfuzzer) + +group("fuzzer") { + deps = [ + ":chrome_device_policy_full_runtime_proto", + ":cloud_policy_full_runtime_proto", + ":policy_common_definitions_full_runtime_proto", + ] +} + +fuzzable_proto_library("policy_common_definitions_full_runtime_proto") { + proto_out_dir = "components/policy/proto/fuzzer" + + sources = [ "../policy_common_definitions.proto" ] +} + +fuzzable_proto_library("cloud_policy_full_runtime_proto") { + proto_out_dir = "components/policy/proto/fuzzer" + + sources = [ "$root_gen_dir/components/policy/proto/cloud_policy.proto" ] + + import_dirs = [ "//components/policy/proto" ] + + proto_deps = [ "//components/policy:policy_code_generate" ] + link_deps = [ ":policy_common_definitions_full_runtime_proto" ] +} + +fuzzable_proto_library("chrome_device_policy_full_runtime_proto") { + proto_out_dir = "components/policy/proto/fuzzer" + + sources = [ "../chrome_device_policy.proto" ] + + link_deps = [ ":policy_common_definitions_full_runtime_proto" ] +}
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 712b167c..29ac4d6 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -3588,6 +3588,7 @@ 'schema': { 'type': 'boolean' }, 'supported_on': ['chrome.*:55-'], 'features': { + 'can_be_recommended': True, 'dynamic_refresh': True, 'per_profile': True, }, @@ -3595,9 +3596,11 @@ 'id': 347, 'caption': '''Always Open PDF files externally''', 'tags': [], - 'desc': '''Setting the policy to True turns the internal PDF viewer off in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>, treats PDF files as a download, and lets users open PDFs with the default application. + 'desc': '''Setting the policy to Enabled turns the internal PDF viewer off in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>, treats PDF files as a download, and lets users open PDFs with the default application. - Setting the policy to False or leaving it unset means that unless users turns off the PDF plugin, it will open PDF files.''', + Setting the policy to Disabled means that unless users turns off the PDF plugin, it will open PDF files. + + If you set the policy, users can't change it in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>. If not set, users can choose whether to open PDF externally or not.''', }, { 'name': 'DisablePluginFinder',
diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h index b4655c1..18e632d 100644 --- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h +++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h
@@ -254,6 +254,8 @@ void UpdateWindowControlsOverlayNSView( const gfx::Rect& bounds, const mojom::WindowControlsOverlayNSViewType overlay_type) override; + void RemoveWindowControlsOverlayNSView( + const mojom::WindowControlsOverlayNSViewType overlay_type) override; // Return true if [NSApp updateWindows] needs to be called after updating the // TextInputClient.
diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm index def66d5..2ccec918 100644 --- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm +++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
@@ -1173,6 +1173,20 @@ } } +void NativeWidgetNSWindowBridge::RemoveWindowControlsOverlayNSView( + const mojom::WindowControlsOverlayNSViewType overlay_type) { + switch (overlay_type) { + case mojom::WindowControlsOverlayNSViewType::kCaptionButtonContainer: + [caption_buttons_overlay_nsview_ removeFromSuperview]; + caption_buttons_overlay_nsview_.reset(); + break; + case mojom::WindowControlsOverlayNSViewType::kWebAppFrameToolbar: + [web_app_frame_toolbar_overlay_nsview_ removeFromSuperview]; + web_app_frame_toolbar_overlay_nsview_.reset(); + break; + } +} + NSWindow* NativeWidgetNSWindowBridge::ns_window() { return window_.get(); }
diff --git a/components/remote_cocoa/common/native_widget_ns_window.mojom b/components/remote_cocoa/common/native_widget_ns_window.mojom index 8456bff..b82f559f 100644 --- a/components/remote_cocoa/common/native_widget_ns_window.mojom +++ b/components/remote_cocoa/common/native_widget_ns_window.mojom
@@ -235,4 +235,9 @@ // overlay display override for a |overlay_type|. UpdateWindowControlsOverlayNSView( gfx.mojom.Rect bounds, WindowControlsOverlayNSViewType overlay_type); + + // Remove the overlay NSView with |bounds| for a PWA with window controls + // overlay display override for a |overlay_type|. + RemoveWindowControlsOverlayNSView( + WindowControlsOverlayNSViewType overlay_type); };
diff --git a/components/reporting/storage/storage.cc b/components/reporting/storage/storage.cc index 3c6b9e80..0f460f81 100644 --- a/components/reporting/storage/storage.cc +++ b/components/reporting/storage/storage.cc
@@ -125,7 +125,6 @@ Storage* storage, UploaderInterfaceResultCb start_uploader_cb) { storage->async_start_upload_cb_.Run( - priority, /*need_encryption_key=*/EncryptionModuleInterface::is_enabled() && storage->encryption_module_->need_encryption_key(), base::BindOnce(&QueueUploaderInterface::WrapInstantiatedUploader, @@ -214,7 +213,6 @@ base::BindOnce(&KeyDelivery::EncryptionKeyReceiverReady, base::Unretained(this)); async_start_upload_cb_.Run( - /*priority=*/MANUAL_BATCH, // Any priority would do. /*need_encryption_key=*/true, base::BindOnce(&KeyDelivery::WrapInstantiatedKeyUploader, /*priority=*/MANUAL_BATCH,
diff --git a/components/reporting/storage/storage_unittest.cc b/components/reporting/storage/storage_unittest.cc index 7ca4ce23..e143c53 100644 --- a/components/reporting/storage/storage_unittest.cc +++ b/components/reporting/storage/storage_unittest.cc
@@ -501,7 +501,7 @@ ASSERT_TRUE(location_.CreateUniqueTempDir()); // Disallow uploads unless other expectation is set (any later EXPECT_CALL // will take precedence over this one). - EXPECT_CALL(set_mock_uploader_expectations_, Call(_, _, NotNull())) + EXPECT_CALL(set_mock_uploader_expectations_, Call(_, NotNull())) .WillRepeatedly(WithoutArgs(Invoke([]() { return Status(error::UNAVAILABLE, "Upload unavailable at this time"); }))); @@ -550,8 +550,8 @@ // Set uploader expectations for any queue; expect no records and need // key. Make sure no uploads happen, and key is requested. EXPECT_CALL(set_mock_uploader_expectations_, - Call(_, /*need_encryption_key=*/Eq(true), NotNull())) - .WillOnce(WithArg<2>(Invoke([](MockUploadClient* mock_upload_client) { + Call(/*need_encryption_key=*/Eq(true), NotNull())) + .WillOnce(WithArg<1>(Invoke([](MockUploadClient* mock_upload_client) { MockUploadClient::SetKeyDelivery client(mock_upload_client); return Status::StatusOK(); }))) @@ -617,7 +617,6 @@ } void AsyncStartMockUploader( - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb) { auto uploader = std::make_unique<MockUploadClient>( @@ -627,7 +626,7 @@ signed_encryption_key_), decryptor_); const auto status = set_mock_uploader_expectations_.Call( - priority, need_encryption_key, uploader.get()); + need_encryption_key, uploader.get()); if (!status.ok()) { std::move(start_uploader_cb).Run(status); return; @@ -637,7 +636,6 @@ void AsyncStartMockUploaderFailing( size_t failures_count, - Priority priority, bool need_encryption_key, UploaderInterface::UploaderInterfaceResultCb start_uploader_cb) { if (key_delivery_failure_count_.fetch_add(1) < failures_count) { @@ -645,8 +643,7 @@ .Run(Status(error::FAILED_PRECONDITION, "Test cannot start upload")); return; } - AsyncStartMockUploader(priority, need_encryption_key, - std::move(start_uploader_cb)); + AsyncStartMockUploader(need_encryption_key, std::move(start_uploader_cb)); } Status WriteString(Priority priority, base::StringPiece data) { @@ -744,7 +741,7 @@ base::ThreadPool::CreateSequencedTaskRunner(base::TaskTraits())}; ::testing::NiceMock<::testing::MockFunction< - Status(Priority, bool /*need_encryption_key*/, MockUploadClient*)>> + Status(bool /*need_encryption_key*/, MockUploadClient*)>> set_mock_uploader_expectations_; }; @@ -785,12 +782,11 @@ // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]); @@ -818,18 +814,17 @@ { test::TestCallbackAutoWaiter waiter; EXPECT_CALL(set_mock_uploader_expectations_, - Call(Ne(MANUAL_BATCH), /*need_encryption_key=*/_, NotNull())) - .WillRepeatedly(WithArgs<0, 2>( - Invoke([](Priority priority, MockUploadClient* mock_upload_client) { + Call(/*need_encryption_key=*/_, NotNull())) + .WillRepeatedly( + WithArgs<1>(Invoke([](MockUploadClient* mock_upload_client) { MockUploadClient::SetEmpty client(mock_upload_client); return Status::StatusOK(); }))); - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(MANUAL_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(MANUAL_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]); @@ -851,12 +846,11 @@ // Set uploader expectations with encryption key request. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(MANUAL_BATCH), /*need_encryption_key=*/Eq(true), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(true), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(MANUAL_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]) @@ -886,12 +880,11 @@ // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]) @@ -914,12 +907,11 @@ // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(MANUAL_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(MANUAL_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]); @@ -946,12 +938,11 @@ // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(MANUAL_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(MANUAL_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]) @@ -976,12 +967,11 @@ { // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]); @@ -998,12 +988,11 @@ { // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(1, kData[1]) .Required(2, kData[2]); return Status::StatusOK(); @@ -1018,12 +1007,11 @@ { test::TestCallbackAutoWaiter waiter; // Set uploader expectations. - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(2, kData[2]); return Status::StatusOK(); }))) @@ -1040,12 +1028,11 @@ { // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(2, kData[2]) .Required(3, kMoreData[0]) .Required(4, kMoreData[1]) @@ -1061,12 +1048,11 @@ { // Set uploader expectations. test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(3, kMoreData[0]) .Required(4, kMoreData[1]) .Required(5, kMoreData[2]); @@ -1085,12 +1071,11 @@ // records after the current one as |Possible|. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]); return Status::StatusOK(); }))) @@ -1101,12 +1086,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]); return Status::StatusOK(); @@ -1118,12 +1102,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]); @@ -1144,12 +1127,11 @@ // |Possible|. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]); return Status::StatusOK(); }))) @@ -1159,12 +1141,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]); return Status::StatusOK(); @@ -1175,12 +1156,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]); @@ -1199,12 +1179,11 @@ // data after the current one as |Possible|. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(2, kData[2]) .Required(3, kMoreData[0]); return Status::StatusOK(); @@ -1215,12 +1194,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(2, kData[2]) .Required(3, kMoreData[0]) .Required(4, kMoreData[1]); @@ -1232,12 +1210,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(2, kData[2]) .Required(3, kMoreData[0]) .Required(4, kMoreData[1]) @@ -1254,12 +1231,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]); return Status::StatusOK(); }))) @@ -1271,12 +1247,11 @@ { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]); return Status::StatusOK(); @@ -1290,20 +1265,11 @@ // Set uploader expectations for FAST_BATCH and SLOW_BATCH. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillRepeatedly(WithArgs<0, 2>( - Invoke([](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetEmpty client(mock_upload_client); - return Status::StatusOK(); - }))); - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(SLOW_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(SLOW_BATCH, mock_upload_client, &waiter) .Required(0, kMoreData[0]) .Required(1, kMoreData[1]); return Status::StatusOK(); @@ -1321,12 +1287,11 @@ // Add more data { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(IMMEDIATE), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(IMMEDIATE, mock_upload_client, &waiter) .Possible(1, kData[1]) .Required(2, kData[2]); return Status::StatusOK(); @@ -1339,19 +1304,10 @@ // Set uploader expectations for FAST_BATCH and SLOW_BATCH. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillRepeatedly(WithArgs<0, 2>( - Invoke([](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetEmpty client(mock_upload_client); - return Status::StatusOK(); - }))); - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(SLOW_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { MockUploadClient::SetUp(SLOW_BATCH, mock_upload_client, &waiter) .Required(1, kMoreData[1]) .Required(2, kMoreData[2]); @@ -1396,11 +1352,10 @@ // Set uploader expectations. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) @@ -1417,11 +1372,10 @@ // Set uploader expectations. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(2, kData[2]); return Status::StatusOK(); @@ -1436,11 +1390,10 @@ // Set uploader expectations: #0 and #1 could be returned as Gaps { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .RequiredSeqId(0) .RequiredSeqId(1) @@ -1464,11 +1417,10 @@ // Set uploader expectations: #0 and #1 could be returned as Gaps { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .RequiredSeqId(1) .RequiredSeqId(2) @@ -1516,8 +1468,8 @@ // Set uploader expectations for any queue; expect no records and need // key. Make sure no uploads happen, and key is requested. EXPECT_CALL(set_mock_uploader_expectations_, - Call(_, /*need_encryption_key=*/Eq(true), NotNull())) - .WillOnce(WithArg<2>(Invoke([](MockUploadClient* mock_upload_client) { + Call(/*need_encryption_key=*/Eq(true), NotNull())) + .WillOnce(WithArg<1>(Invoke([](MockUploadClient* mock_upload_client) { MockUploadClient::SetKeyDelivery client(mock_upload_client); return Status::StatusOK(); }))) @@ -1534,12 +1486,11 @@ // Set uploader expectations. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2]); @@ -1562,12 +1513,11 @@ // Set uploader expectations. { test::TestCallbackAutoWaiter waiter; - EXPECT_CALL( - set_mock_uploader_expectations_, - Call(Eq(FAST_BATCH), /*need_encryption_key=*/Eq(false), NotNull())) - .WillOnce(WithArgs<0, 2>(Invoke( - [&waiter](Priority priority, MockUploadClient* mock_upload_client) { - MockUploadClient::SetUp(priority, mock_upload_client, &waiter) + EXPECT_CALL(set_mock_uploader_expectations_, + Call(/*need_encryption_key=*/Eq(false), NotNull())) + .WillOnce( + WithArgs<1>(Invoke([&waiter](MockUploadClient* mock_upload_client) { + MockUploadClient::SetUp(FAST_BATCH, mock_upload_client, &waiter) .Required(0, kData[0]) .Required(1, kData[1]) .Required(2, kData[2])
diff --git a/components/reporting/storage/storage_uploader_interface.h b/components/reporting/storage/storage_uploader_interface.h index a672f37b..a4975c2 100644 --- a/components/reporting/storage/storage_uploader_interface.h +++ b/components/reporting/storage/storage_uploader_interface.h
@@ -26,7 +26,6 @@ public: // using AsyncStartUploaderCb = // base::RepeatingCallback<StatusOr<std::unique_ptr<UploaderInterface>>( - // Priority priority, // bool need_encryption_key)>; // Asynchronous callback that instantiates uploader. // To start upload, call |AsyncStartUploaderCb| on a thread pool. Once @@ -35,12 +34,9 @@ // key is needed (initially or periodically). using UploaderInterfaceResultCb = base::OnceCallback<void(StatusOr<std::unique_ptr<UploaderInterface>>)>; - // Callback type for asynchronous UploadInterface provider. |priority| - // identifies which queue is going to upload the data. - // TODO(b/183666933): |priority| is only used by tests, remove it if possible. + // Callback type for asynchronous UploadInterface provider. using AsyncStartUploaderCb = - base::RepeatingCallback<void(Priority priority, - bool need_encryption_key, + base::RepeatingCallback<void(bool need_encryption_key, UploaderInterfaceResultCb)>; UploaderInterface(const UploaderInterface& other) = delete;
diff --git a/components/segmentation_platform/components_unittests.filter b/components/segmentation_platform/components_unittests.filter index 08ac5b1..5be2f6df 100644 --- a/components/segmentation_platform/components_unittests.filter +++ b/components/segmentation_platform/components_unittests.filter
@@ -2,6 +2,7 @@ ModelExecutionSchedulerTest.* SegmentationModelExecutorTest.* SegmentationPlatformServiceImplTest.* +SegmentInfoDatabaseTest.* SegmentSelectorTest.* SignalFilterProcessorTest.* UserActionSignalHandlerTest.*
diff --git a/components/segmentation_platform/internal/BUILD.gn b/components/segmentation_platform/internal/BUILD.gn index b0da57d..e42332f 100644 --- a/components/segmentation_platform/internal/BUILD.gn +++ b/components/segmentation_platform/internal/BUILD.gn
@@ -17,6 +17,7 @@ sources = [ "database/metadata_utils.cc", "database/metadata_utils.h", + "database/segment_info_database.cc", "database/segment_info_database.h", "database/user_action_database.h", "execution/model_execution_status.h", @@ -73,6 +74,7 @@ # tests in //components/segmentation_platform/components_unittests.filter sources = [ "database/metadata_utils_unittest.cc", + "database/segment_info_database_unittest.cc", "database/test_segment_info_database.cc", "database/test_segment_info_database.h", "scheduler/model_execution_scheduler_unittest.cc",
diff --git a/components/segmentation_platform/internal/database/segment_info_database.cc b/components/segmentation_platform/internal/database/segment_info_database.cc new file mode 100644 index 0000000..072f7a6 --- /dev/null +++ b/components/segmentation_platform/internal/database/segment_info_database.cc
@@ -0,0 +1,130 @@ +// 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 "components/segmentation_platform/internal/database/segment_info_database.h" + +#include "base/callback_helpers.h" +#include "base/strings/string_number_conversions.h" + +namespace segmentation_platform { + +namespace { + +std::string ToString(OptimizationTarget segment_id) { + return base::NumberToString(static_cast<int>(segment_id)); +} + +} // namespace + +SegmentInfoDatabase::SegmentInfoDatabase( + std::unique_ptr<SegmentInfoProtoDb> database) + : database_(std::move(database)) {} + +SegmentInfoDatabase::~SegmentInfoDatabase() = default; + +void SegmentInfoDatabase::Initialize(SuccessCallback callback) { + database_->Init( + leveldb_proto::CreateSimpleOptions(), + base::BindOnce(&SegmentInfoDatabase::OnDatabaseInitialized, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); +} + +void SegmentInfoDatabase::GetAllSegmentInfo(AllSegmentInfoCallback callback) { + database_->LoadEntries( + base::BindOnce(&SegmentInfoDatabase::OnAllSegmentInfoLoaded, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); +} + +void SegmentInfoDatabase::OnAllSegmentInfoLoaded( + AllSegmentInfoCallback callback, + bool success, + std::unique_ptr<std::vector<proto::SegmentInfo>> all_infos) { + std::vector<std::pair<OptimizationTarget, proto::SegmentInfo>> pairs; + if (success && all_infos) { + for (auto& info : *all_infos.get()) { + DCHECK(info.has_segment_id()); + pairs.emplace_back(std::make_pair(info.segment_id(), std::move(info))); + } + } + + std::move(callback).Run(pairs); +} + +void SegmentInfoDatabase::GetSegmentInfo(OptimizationTarget segment_id, + SegmentInfoCallback callback) { + database_->GetEntry( + ToString(segment_id), + base::BindOnce(&SegmentInfoDatabase::OnGetSegmentInfo, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); +} + +void SegmentInfoDatabase::OnGetSegmentInfo( + SegmentInfoCallback callback, + bool success, + std::unique_ptr<proto::SegmentInfo> info) { + std::move(callback).Run(success && info ? absl::make_optional(*info) + : absl::nullopt); +} + +void SegmentInfoDatabase::UpdateSegment( + OptimizationTarget segment_id, + absl::optional<proto::SegmentInfo> segment_info, + SuccessCallback callback) { + auto entries_to_save = std::make_unique< + std::vector<std::pair<std::string, proto::SegmentInfo>>>(); + auto keys_to_delete = std::make_unique<std::vector<std::string>>(); + if (segment_info.has_value()) { + entries_to_save->emplace_back( + std::make_pair(ToString(segment_id), segment_info.value())); + } else { + keys_to_delete->emplace_back(ToString(segment_id)); + } + + database_->UpdateEntries(std::move(entries_to_save), + std::move(keys_to_delete), std::move(callback)); +} + +void SegmentInfoDatabase::SaveSegmentResult(OptimizationTarget segment_id, + proto::PredictionResult* result, + SuccessCallback callback) { + GetSegmentInfo( + segment_id, + base::BindOnce(&SegmentInfoDatabase::OnGetSegmentInfoForUpdatingResults, + weak_ptr_factory_.GetWeakPtr(), result, + std::move(callback))); +} + +void SegmentInfoDatabase::OnGetSegmentInfoForUpdatingResults( + proto::PredictionResult* result, + SuccessCallback callback, + absl::optional<proto::SegmentInfo> segment_info) { + // Ignore results if the metadata no longer exists. + if (!segment_info.has_value()) { + std::move(callback).Run(false); + return; + } + + // Update results. + if (result) { + segment_info->mutable_prediction_result()->CopyFrom(*result); + } else { + segment_info->clear_prediction_result(); + } + + auto entries_to_save = std::make_unique< + std::vector<std::pair<std::string, proto::SegmentInfo>>>(); + entries_to_save->emplace_back(std::make_pair( + ToString(segment_info->segment_id()), std::move(segment_info.value()))); + database_->UpdateEntries(std::move(entries_to_save), + std::make_unique<std::vector<std::string>>(), + std::move(callback)); +} + +void SegmentInfoDatabase::OnDatabaseInitialized( + SuccessCallback callback, + leveldb_proto::Enums::InitStatus status) { + std::move(callback).Run(status == leveldb_proto::Enums::InitStatus::kOK); +} + +} // namespace segmentation_platform
diff --git a/components/segmentation_platform/internal/database/segment_info_database.h b/components/segmentation_platform/internal/database/segment_info_database.h index 9151de9..ca3df62 100644 --- a/components/segmentation_platform/internal/database/segment_info_database.h +++ b/components/segmentation_platform/internal/database/segment_info_database.h
@@ -8,6 +8,7 @@ #include <vector> #include "base/callback.h" +#include "components/leveldb_proto/public/proto_database.h" #include "components/optimization_guide/proto/models.pb.h" #include "components/segmentation_platform/internal/proto/model_metadata.pb.h" #include "components/segmentation_platform/internal/proto/model_prediction.pb.h" @@ -31,20 +32,59 @@ using SuccessCallback = base::OnceCallback<void(bool)>; using AllSegmentInfoCallback = base::OnceCallback<void( std::vector<std::pair<OptimizationTarget, proto::SegmentInfo>>)>; + using SegmentInfoCallback = + base::OnceCallback<void(absl::optional<proto::SegmentInfo>)>; + using SegmentInfoProtoDb = leveldb_proto::ProtoDatabase<proto::SegmentInfo>; - virtual ~SegmentInfoDatabase() = default; + explicit SegmentInfoDatabase(std::unique_ptr<SegmentInfoProtoDb> database); + virtual ~SegmentInfoDatabase(); - // TODO(shaktisahu): Initialize DB before instantiating dependent classes. + // Disallow copy/assign. + SegmentInfoDatabase(const SegmentInfoDatabase&) = delete; + SegmentInfoDatabase& operator=(const SegmentInfoDatabase&) = delete; + + virtual void Initialize(SuccessCallback callback); // Convenient method to return combined info for all the segments in the // database. - virtual void GetAllSegmentInfo(AllSegmentInfoCallback callback) = 0; + virtual void GetAllSegmentInfo(AllSegmentInfoCallback callback); - // Called to write the model execution results for a given segment. If - // |result| is null, the existing results will be deleted. + // Called to get the metadata for a given segment. + virtual void GetSegmentInfo(OptimizationTarget segment_id, + SegmentInfoCallback callback); + + // Called to save or update metadata for a segment. The previous data is + // overwritten. If |segment_info| is empty, the segment will be deleted. + // TODO(shaktisahu): How does the client know if a segment is to be deleted? + virtual void UpdateSegment(OptimizationTarget segment_id, + absl::optional<proto::SegmentInfo> segment_info, + SuccessCallback callback); + + // Called to write the model execution results for a given segment. It will + // first read the currently stored result, and then overwrite it with + // |result|. If |result| is null, the existing result will be deleted. virtual void SaveSegmentResult(OptimizationTarget segment_id, proto::PredictionResult* result, - SuccessCallback callback) = 0; + SuccessCallback callback); + + private: + void OnDatabaseInitialized(SuccessCallback callback, + leveldb_proto::Enums::InitStatus status); + void OnAllSegmentInfoLoaded( + AllSegmentInfoCallback callback, + bool success, + std::unique_ptr<std::vector<proto::SegmentInfo>> all_infos); + void OnGetSegmentInfo(SegmentInfoCallback callback, + bool success, + std::unique_ptr<proto::SegmentInfo> info); + void OnGetSegmentInfoForUpdatingResults( + proto::PredictionResult* result, + SuccessCallback callback, + absl::optional<proto::SegmentInfo> segment_info); + + std::unique_ptr<SegmentInfoProtoDb> database_; + + base::WeakPtrFactory<SegmentInfoDatabase> weak_ptr_factory_{this}; }; } // namespace segmentation_platform
diff --git a/components/segmentation_platform/internal/database/segment_info_database_unittest.cc b/components/segmentation_platform/internal/database/segment_info_database_unittest.cc new file mode 100644 index 0000000..7f6ffa6 --- /dev/null +++ b/components/segmentation_platform/internal/database/segment_info_database_unittest.cc
@@ -0,0 +1,212 @@ +// 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 "components/segmentation_platform/internal/database/segment_info_database.h" + +#include "base/strings/string_number_conversions.h" +#include "base/test/task_environment.h" +#include "components/leveldb_proto/public/proto_database.h" +#include "components/leveldb_proto/testing/fake_db.h" +#include "testing/gtest/include/gtest/gtest.h" + +using InitStatus = leveldb_proto::Enums::InitStatus; + +namespace segmentation_platform { + +namespace { + +// Test Ids. +const OptimizationTarget kSegmentId = + OptimizationTarget::OPTIMIZATION_TARGET_SEGMENTATION_NEW_TAB; +const OptimizationTarget kSegmentId2 = + OptimizationTarget::OPTIMIZATION_TARGET_SEGMENTATION_SHARE; + +std::string ToString(OptimizationTarget segment_id) { + return base::NumberToString(static_cast<int>(segment_id)); +} + +proto::SegmentInfo CreateSegment(OptimizationTarget segment_id, + absl::optional<int> result = absl::nullopt) { + proto::SegmentInfo info; + info.set_segment_id(segment_id); + + if (result.has_value()) { + info.mutable_prediction_result()->set_result(result.value()); + } + return info; +} + +} // namespace + +class SegmentInfoDatabaseTest : public testing::Test { + public: + SegmentInfoDatabaseTest() = default; + ~SegmentInfoDatabaseTest() override = default; + + void OnGetAllSegments( + std::vector<std::pair<OptimizationTarget, proto::SegmentInfo>> entries) { + get_all_segment_result_ = entries; + } + + void OnGetSegment(absl::optional<proto::SegmentInfo> result) { + get_segment_result_ = result; + } + + protected: + void SetUpDB() { + DCHECK(!db_); + DCHECK(!segment_db_); + + auto db = std::make_unique<leveldb_proto::test::FakeDB<proto::SegmentInfo>>( + &db_entries_); + db_ = db.get(); + segment_db_ = std::make_unique<SegmentInfoDatabase>(std::move(db)); + } + + void TearDown() override { + db_entries_.clear(); + db_ = nullptr; + segment_db_.reset(); + } + + void VerifyDb(std::vector<OptimizationTarget> expected_ids) { + EXPECT_EQ(expected_ids.size(), db_entries_.size()); + for (auto segment_id : expected_ids) + EXPECT_TRUE(db_entries_.find(ToString(segment_id)) != db_entries_.end()); + } + + void WriteResult(OptimizationTarget segment_id, + absl::optional<float> result) { + proto::PredictionResult prediction_result; + if (result.has_value()) + prediction_result.set_result(result.value()); + + segment_db_->SaveSegmentResult( + segment_id, result.has_value() ? &prediction_result : nullptr, + base::DoNothing()); + db_->GetCallback(true); + db_->UpdateCallback(true); + } + + void VerifyResult(OptimizationTarget segment_id, + absl::optional<float> result) { + segment_db_->GetSegmentInfo( + segment_id, base::BindOnce(&SegmentInfoDatabaseTest::OnGetSegment, + base::Unretained(this))); + db_->GetCallback(true); + + EXPECT_EQ(segment_id, get_segment_result_->segment_id()); + EXPECT_EQ(result.has_value(), get_segment_result_->has_prediction_result()); + if (result.has_value()) { + EXPECT_EQ(result.value(), + get_segment_result_->prediction_result().result()); + } + } + + base::test::TaskEnvironment task_environment_; + std::vector<std::pair<OptimizationTarget, proto::SegmentInfo>> + get_all_segment_result_; + absl::optional<proto::SegmentInfo> get_segment_result_; + std::map<std::string, proto::SegmentInfo> db_entries_; + leveldb_proto::test::FakeDB<proto::SegmentInfo>* db_{nullptr}; + std::unique_ptr<SegmentInfoDatabase> segment_db_; +}; + +TEST_F(SegmentInfoDatabaseTest, Get) { + // Initialize DB with one entry. + db_entries_.insert( + std::make_pair(ToString(kSegmentId), CreateSegment(kSegmentId))); + SetUpDB(); + + segment_db_->Initialize(base::DoNothing()); + db_->InitStatusCallback(leveldb_proto::Enums::InitStatus::kOK); + VerifyDb({kSegmentId}); + + // Get all segments. + segment_db_->GetAllSegmentInfo(base::BindOnce( + &SegmentInfoDatabaseTest::OnGetAllSegments, base::Unretained(this))); + db_->LoadCallback(true); + EXPECT_EQ(1u, get_all_segment_result_.size()); + + // Get a single segment. + segment_db_->GetSegmentInfo( + kSegmentId, base::BindOnce(&SegmentInfoDatabaseTest::OnGetSegment, + base::Unretained(this))); + db_->GetCallback(true); + EXPECT_TRUE(get_segment_result_.has_value()); + EXPECT_EQ(kSegmentId, get_segment_result_->segment_id()); +} + +TEST_F(SegmentInfoDatabaseTest, Update) { + // Initialize DB with one entry. + db_entries_.insert( + std::make_pair(ToString(kSegmentId), CreateSegment(kSegmentId))); + SetUpDB(); + + segment_db_->Initialize(base::DoNothing()); + db_->InitStatusCallback(leveldb_proto::Enums::InitStatus::kOK); + + // Delete a segment. + segment_db_->UpdateSegment(kSegmentId, absl::nullopt, base::DoNothing()); + db_->UpdateCallback(true); + VerifyDb({}); + + // Insert a segment and verify. + segment_db_->UpdateSegment(kSegmentId, CreateSegment(kSegmentId), + base::DoNothing()); + db_->UpdateCallback(true); + VerifyDb({kSegmentId}); + + // Insert another segment and verify. + segment_db_->UpdateSegment(kSegmentId2, CreateSegment(kSegmentId), + base::DoNothing()); + db_->UpdateCallback(true); + VerifyDb({kSegmentId, kSegmentId2}); +} + +TEST_F(SegmentInfoDatabaseTest, WriteResult) { + // Initialize DB with one entry. + db_entries_.insert( + std::make_pair(ToString(kSegmentId), CreateSegment(kSegmentId))); + SetUpDB(); + + segment_db_->Initialize(base::DoNothing()); + db_->InitStatusCallback(leveldb_proto::Enums::InitStatus::kOK); + + // Update results and verify. + WriteResult(kSegmentId, 0.4f); + VerifyResult(kSegmentId, 0.4f); + + // Overwrite results and verify. + WriteResult(kSegmentId, 0.9f); + VerifyResult(kSegmentId, 0.9f); + + // Clear results and verify. + WriteResult(kSegmentId, absl::nullopt); + VerifyResult(kSegmentId, absl::nullopt); +} + +TEST_F(SegmentInfoDatabaseTest, WriteResultForTwoSegments) { + // Initialize DB with two entries. + db_entries_.insert( + std::make_pair(ToString(kSegmentId), CreateSegment(kSegmentId))); + db_entries_.insert( + std::make_pair(ToString(kSegmentId2), CreateSegment(kSegmentId2))); + SetUpDB(); + + segment_db_->Initialize(base::DoNothing()); + db_->InitStatusCallback(leveldb_proto::Enums::InitStatus::kOK); + + // Update results for first segment. + WriteResult(kSegmentId, 0.4f); + + // Update results for second segment. + WriteResult(kSegmentId2, 0.9f); + + // Verify results for both segments. + VerifyResult(kSegmentId, 0.4f); + VerifyResult(kSegmentId2, 0.9f); +} + +} // namespace segmentation_platform
diff --git a/components/segmentation_platform/internal/database/test_segment_info_database.cc b/components/segmentation_platform/internal/database/test_segment_info_database.cc index 31b5429..c7ff2e9 100644 --- a/components/segmentation_platform/internal/database/test_segment_info_database.cc +++ b/components/segmentation_platform/internal/database/test_segment_info_database.cc
@@ -11,15 +11,53 @@ namespace test { -TestSegmentInfoDatabase::TestSegmentInfoDatabase() = default; +TestSegmentInfoDatabase::TestSegmentInfoDatabase() + : SegmentInfoDatabase(nullptr) {} TestSegmentInfoDatabase::~TestSegmentInfoDatabase() = default; +void TestSegmentInfoDatabase::Initialize(SuccessCallback callback) { + std::move(callback).Run(true); +} + void TestSegmentInfoDatabase::GetAllSegmentInfo( AllSegmentInfoCallback callback) { std::move(callback).Run(segment_infos_); } +void TestSegmentInfoDatabase::GetSegmentInfo(OptimizationTarget segment_id, + SegmentInfoCallback callback) { + auto result = std::find_if( + segment_infos_.begin(), segment_infos_.end(), + [segment_id](std::pair<OptimizationTarget, proto::SegmentInfo> pair) { + return pair.first == segment_id; + }); + + std::move(callback).Run(result == segment_infos_.end() + ? absl::nullopt + : absl::make_optional(result->second)); +} + +void TestSegmentInfoDatabase::UpdateSegment( + OptimizationTarget segment_id, + absl::optional<proto::SegmentInfo> segment_info, + SuccessCallback callback) { + if (segment_info.has_value()) { + proto::SegmentInfo* info = FindOrCreateSegment(segment_id); + info->CopyFrom(segment_info.value()); + } else { + // Delete the segment. + auto new_end = std::remove_if( + segment_infos_.begin(), segment_infos_.end(), + [segment_id]( + const std::pair<OptimizationTarget, proto::SegmentInfo>& pair) { + return pair.first == segment_id; + }); + segment_infos_.erase(new_end, segment_infos_.end()); + } + std::move(callback).Run(true); +} + void TestSegmentInfoDatabase::SaveSegmentResult(OptimizationTarget segment_id, proto::PredictionResult* result, SuccessCallback callback) {
diff --git a/components/segmentation_platform/internal/database/test_segment_info_database.h b/components/segmentation_platform/internal/database/test_segment_info_database.h index 12252fb..3713d075 100644 --- a/components/segmentation_platform/internal/database/test_segment_info_database.h +++ b/components/segmentation_platform/internal/database/test_segment_info_database.h
@@ -18,7 +18,13 @@ ~TestSegmentInfoDatabase() override; // SegmentInfoDatabase overrides. + void Initialize(SuccessCallback callback) override; void GetAllSegmentInfo(AllSegmentInfoCallback callback) override; + void GetSegmentInfo(OptimizationTarget segment_id, + SegmentInfoCallback callback) override; + void UpdateSegment(OptimizationTarget segment_id, + absl::optional<proto::SegmentInfo> segment_info, + SuccessCallback callback) override; void SaveSegmentResult(OptimizationTarget segment_id, proto::PredictionResult* result, SuccessCallback callback) override;
diff --git a/components/sync_bookmarks/bookmark_local_changes_builder.cc b/components/sync_bookmarks/bookmark_local_changes_builder.cc index 18e6ebe..a0eb5a2e 100644 --- a/components/sync_bookmarks/bookmark_local_changes_builder.cc +++ b/components/sync_bookmarks/bookmark_local_changes_builder.cc
@@ -4,6 +4,7 @@ #include "components/sync_bookmarks/bookmark_local_changes_builder.h" +#include <limits> #include <memory> #include <string> #include <utility> @@ -31,14 +32,22 @@ syncer::CommitRequestDataList BookmarkLocalChangesBuilder::BuildCommitRequests( size_t max_entries) const { DCHECK(bookmark_tracker_); + const std::vector<const SyncedBookmarkTracker::Entity*> entities_with_local_changes = - bookmark_tracker_->GetEntitiesWithLocalChanges(max_entries); - DCHECK_LE(entities_with_local_changes.size(), max_entries); + bookmark_tracker_->GetEntitiesWithLocalChanges( + base::FeatureList::IsEnabled( + switches::kSyncBookmarksEnforceLateMaxEntriesToCommit) + ? std::numeric_limits<int>::max() + : max_entries); syncer::CommitRequestDataList commit_requests; for (const SyncedBookmarkTracker::Entity* entity : entities_with_local_changes) { + if (commit_requests.size() >= max_entries) { + break; + } + DCHECK(entity); DCHECK(entity->IsUnsynced()); const sync_pb::EntityMetadata* metadata = entity->metadata();
diff --git a/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc b/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc index 9eea19e3..5f8ca39 100644 --- a/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc +++ b/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc
@@ -12,6 +12,7 @@ #include "base/guid.h" #include "base/strings/utf_string_conversions.h" #include "base/test/bind.h" +#include "base/test/gmock_move_support.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/mock_callback.h" #include "base/test/scoped_feature_list.h" @@ -29,17 +30,20 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -using base::ASCIIToUTF16; -using testing::_; -using testing::Eq; -using testing::IsNull; -using testing::NiceMock; -using testing::NotNull; - namespace sync_bookmarks { namespace { +using base::ASCIIToUTF16; +using testing::_; +using testing::ElementsAre; +using testing::Eq; +using testing::IsEmpty; +using testing::IsNull; +using testing::NiceMock; +using testing::NotNull; +using testing::UnorderedElementsAre; + const char kBookmarkBarTag[] = "bookmark_bar"; const char kOtherBookmarksTag[] = "other_bookmarks"; const char kMobileBookmarksTag[] = "synced_bookmarks"; @@ -57,6 +61,17 @@ std::string server_tag; }; +MATCHER_P(CommitRequestDataMatchesGuid, guid, "") { + const syncer::CommitRequestData* data = arg.get(); + return data != nullptr && data->entity != nullptr && + data->entity->specifics.bookmark().guid() == guid.AsLowercaseString(); +} + +MATCHER_P(TrackedEntityCorrespondsToBookmarkNode, bookmark_node, "") { + const SyncedBookmarkTracker::Entity* entity = arg; + return entity->bookmark_node() == bookmark_node; +} + syncer::UpdateResponseData CreateUpdateResponseData( const BookmarkInfo& bookmark_info, const syncer::UniquePosition& unique_position, @@ -116,6 +131,37 @@ return bookmark_metadata; } +// Same as above but marks the node as unsynced (pending commit). |node| must +// not be nullptr. +sync_pb::BookmarkMetadata CreateUnsyncedNodeMetadata( + const bookmarks::BookmarkNode* node, + const std::string& server_id) { + sync_pb::BookmarkMetadata bookmark_metadata = + CreateNodeMetadata(node, server_id); + // Mark the entity as unsynced. + bookmark_metadata.mutable_metadata()->set_sequence_number(2); + bookmark_metadata.mutable_metadata()->set_acked_sequence_number(1); + return bookmark_metadata; +} + +sync_pb::BookmarkModelMetadata CreateMetadataForPermanentNodes( + const bookmarks::BookmarkModel* bookmark_model) { + sync_pb::BookmarkModelMetadata model_metadata; + *model_metadata.mutable_model_type_state() = CreateDummyModelTypeState(); + + *model_metadata.add_bookmarks_metadata() = + CreateNodeMetadata(bookmark_model->bookmark_bar_node(), + /*server_id=*/kBookmarkBarId); + *model_metadata.add_bookmarks_metadata() = + CreateNodeMetadata(bookmark_model->mobile_node(), + /*server_id=*/kMobileBookmarksId); + *model_metadata.add_bookmarks_metadata() = + CreateNodeMetadata(bookmark_model->other_node(), + /*server_id=*/kOtherBookmarksId); + + return model_metadata; +} + void AssertState(const BookmarkModelTypeProcessor* processor, const std::vector<BookmarkInfo>& bookmarks) { const SyncedBookmarkTracker* tracker = processor->GetTrackerForTest(); @@ -203,7 +249,10 @@ favicon_base::FaviconImageResult result; result.image = std::move(image); result.icon_url = std::move(icon_url); - std::move(favicon_image_callbacks_[task_id]).Run(result); + favicon_base::FaviconImageCallback cb = + std::move(favicon_image_callbacks_[task_id]); + favicon_image_callbacks_.erase(task_id); + std::move(cb).Run(result); } size_t GetTasksCount() const { return favicon_image_callbacks_.size(); } @@ -288,6 +337,17 @@ return model_metadata; } + syncer::CommitRequestDataList GetLocalChangesFromProcessor( + size_t max_entries) { + base::MockOnceCallback<void(syncer::CommitRequestDataList &&)> callback; + syncer::CommitRequestDataList local_changes; + // Destruction of the mock upon return will verify that Run() was indeed + // invoked. + EXPECT_CALL(callback, Run).WillOnce(MoveArg(&local_changes)); + processor_->GetLocalChanges(max_entries, callback.Get()); + return local_changes; + } + private: base::test::TaskEnvironment task_environment_; NiceMock<base::MockCallback<base::RepeatingClosure>> schedule_save_closure_; @@ -467,34 +527,9 @@ SimulateModelReadyToSync(); SimulateOnSyncStarting(); - // TODO(crbug.com/516866): Remove this after initial sync done is properly set - // within the processor. - sync_pb::BookmarkModelMetadata model_metadata; - model_metadata.mutable_model_type_state()->set_initial_sync_done(true); - // Add entries for the permanent nodes. TestBookmarkClient adds all of them. - sync_pb::BookmarkMetadata* bookmark_metadata = - model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(bookmark_bar_node->id()); - bookmark_metadata->mutable_metadata()->set_server_id(kBookmarkBarId); - bookmark_metadata->mutable_metadata()->set_client_tag_hash( - SyncedBookmarkTracker::GetClientTagHashFromGUID(bookmark_bar_node->guid()) - .value()); - bookmark_metadata = model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(bookmark_model()->other_node()->id()); - bookmark_metadata->mutable_metadata()->set_server_id(kOtherBookmarksId); - bookmark_metadata->mutable_metadata()->set_client_tag_hash( - SyncedBookmarkTracker::GetClientTagHashFromGUID( - bookmark_model()->other_node()->guid()) - .value()); - - bookmark_metadata = model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(bookmark_model()->mobile_node()->id()); - bookmark_metadata->mutable_metadata()->set_server_id(kMobileBookmarksId); - bookmark_metadata->mutable_metadata()->set_client_tag_hash( - SyncedBookmarkTracker::GetClientTagHashFromGUID( - bookmark_model()->mobile_node()->guid()) - .value()); + sync_pb::BookmarkModelMetadata model_metadata = + CreateMetadataForPermanentNodes(bookmark_model()); // Add an entry for the bookmark node. *model_metadata.add_bookmarks_metadata() = @@ -590,10 +625,9 @@ model_metadata.mutable_model_type_state()->set_initial_sync_done(true); // Add entries for only the bookmark bar. However, the TestBookmarkClient will // create all the 3 permanent nodes. - sync_pb::BookmarkMetadata* bookmark_metadata = - model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(bookmark_model()->bookmark_bar_node()->id()); - bookmark_metadata->mutable_metadata()->set_server_id(kBookmarkBarId); + *model_metadata.add_bookmarks_metadata() = + CreateNodeMetadata(bookmark_model()->bookmark_bar_node(), + /*server_id=*/kBookmarkBarId); // Create a new processor and init it with the metadata str. BookmarkModelTypeProcessor new_processor(bookmark_undo_service()); @@ -729,68 +763,95 @@ /*parent=*/bookmark_bar_node, /*index=*/0, base::UTF8ToUTF16(kTitle), GURL(kUrl)); - sync_pb::BookmarkModelMetadata model_metadata; - *model_metadata.mutable_model_type_state() = CreateDummyModelTypeState(); - - // Add entries for the permanent nodes. TestBookmarkClient adds all of them. - sync_pb::BookmarkMetadata* bookmark_metadata = - model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(bookmark_bar_node->id()); - bookmark_metadata->mutable_metadata()->set_server_id(kBookmarkBarId); - bookmark_metadata->mutable_metadata()->set_client_tag_hash( - SyncedBookmarkTracker::GetClientTagHashFromGUID(bookmark_bar_node->guid()) - .value()); - - bookmark_metadata = model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(bookmark_model()->other_node()->id()); - bookmark_metadata->mutable_metadata()->set_server_id(kOtherBookmarksId); - bookmark_metadata->mutable_metadata()->set_client_tag_hash( - SyncedBookmarkTracker::GetClientTagHashFromGUID( - bookmark_model()->other_node()->guid()) - .value()); - - bookmark_metadata = model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(bookmark_model()->mobile_node()->id()); - bookmark_metadata->mutable_metadata()->set_server_id(kMobileBookmarksId); - bookmark_metadata->mutable_metadata()->set_client_tag_hash( - SyncedBookmarkTracker::GetClientTagHashFromGUID( - bookmark_model()->mobile_node()->guid()) - .value()); - - // Add an entry for the bookmark node. - bookmark_metadata = model_metadata.add_bookmarks_metadata(); - *bookmark_metadata = CreateNodeMetadata(node, kNodeId); - // Mark the entity as unsynced. - bookmark_metadata->mutable_metadata()->set_sequence_number(2); - bookmark_metadata->mutable_metadata()->set_acked_sequence_number(1); + // Add an entry for the bookmark node that is unsynced. + sync_pb::BookmarkModelMetadata model_metadata = + CreateMetadataForPermanentNodes(bookmark_model()); + *model_metadata.add_bookmarks_metadata() = + CreateUnsyncedNodeMetadata(node, kNodeId); SimulateOnSyncStarting(); processor()->ModelReadyToSync(model_metadata.SerializeAsString(), schedule_save_closure()->Get(), bookmark_model()); - base::MockOnceCallback<void( - std::vector<std::unique_ptr<syncer::CommitRequestData>> &&)> - callback; - std::vector<std::unique_ptr<syncer::CommitRequestData>> callback_result; - ON_CALL(callback, Run) - .WillByDefault( - [&callback_result]( - std::vector<std::unique_ptr<syncer::CommitRequestData>>&& - commit_data) { callback_result = std::move(commit_data); }); - ASSERT_EQ(0u, bookmark_client()->GetTasksCount()); - EXPECT_CALL(callback, Run); - processor()->GetLocalChanges(/*max_entries=*/10, callback.Get()); - EXPECT_TRUE(callback_result.empty()); + EXPECT_THAT(GetLocalChangesFromProcessor(/*max_entries=*/10), IsEmpty()); EXPECT_TRUE(node->is_favicon_loading()); bookmark_client()->SimulateFaviconLoaded(GURL(kUrl), gfx::Image(), GURL(kIconUrl)); ASSERT_TRUE(node->is_favicon_loaded()); - EXPECT_CALL(callback, Run); - processor()->GetLocalChanges(/*max_entries=*/10, callback.Get()); - EXPECT_FALSE(callback_result.empty()); + EXPECT_THAT(GetLocalChangesFromProcessor(/*max_entries=*/10), + ElementsAre(CommitRequestDataMatchesGuid(node->guid()))); +} + +TEST_F(BookmarkModelTypeProcessorTest, + ShouldCommitEntitiesWhileOtherFaviconsLoading) { + base::test::ScopedFeatureList features; + features.InitAndEnableFeature( + switches::kSyncBookmarksEnforceLateMaxEntriesToCommit); + + const std::string kNodeId1 = "node_id1"; + const std::string kNodeId2 = "node_id2"; + const std::string kTitle = "title"; + const std::string kUrl1 = "http://www.url1.com"; + const std::string kUrl2 = "http://www.url2.com"; + const std::string kIconUrl = "http://www.url.com/favicon"; + + const bookmarks::BookmarkNode* bookmark_bar_node = + bookmark_model()->bookmark_bar_node(); + const bookmarks::BookmarkNode* node1 = bookmark_model()->AddURL( + /*parent=*/bookmark_bar_node, /*index=*/0, base::UTF8ToUTF16(kTitle), + GURL(kUrl1)); + const bookmarks::BookmarkNode* node2 = bookmark_model()->AddURL( + /*parent=*/bookmark_bar_node, /*index=*/1, base::UTF8ToUTF16(kTitle), + GURL(kUrl2)); + + // Add entries for the two bookmark nodes and mark them as unsynced. + sync_pb::BookmarkModelMetadata model_metadata = + CreateMetadataForPermanentNodes(bookmark_model()); + *model_metadata.add_bookmarks_metadata() = + CreateUnsyncedNodeMetadata(node1, kNodeId1); + *model_metadata.add_bookmarks_metadata() = + CreateUnsyncedNodeMetadata(node2, kNodeId2); + + SimulateOnSyncStarting(); + processor()->ModelReadyToSync(model_metadata.SerializeAsString(), + schedule_save_closure()->Get(), + bookmark_model()); + + // The goal of this test is to mimic the case where one bookmark (the first + // one listed by SyncedBookmarkTracker::GetEntitiesWithLocalChanges()) has no + // loaded favicon, while the second one does. The precise order is not known + // in advance (in the current implementation, it depends on the iteration + // order for raw pointers in an unordered_set) which means the test needs to + // pass for both cases. + const std::vector<const SyncedBookmarkTracker::Entity*> unsynced_entities = + processor()->GetTrackerForTest()->GetEntitiesWithLocalChanges( + /*max_entries=*/1000); + ASSERT_THAT( + unsynced_entities, + UnorderedElementsAre(TrackedEntityCorrespondsToBookmarkNode(node1), + TrackedEntityCorrespondsToBookmarkNode(node2))); + + // Force a favicon load for the second listed entity, but leave the first + // without loaded favicon. + bookmark_model()->GetFavicon(unsynced_entities[1]->bookmark_node()); + bookmark_client()->SimulateFaviconLoaded( + unsynced_entities[1]->bookmark_node()->url(), gfx::Image(), + GURL(kIconUrl)); + ASSERT_TRUE(unsynced_entities[1]->bookmark_node()->is_favicon_loaded()); + ASSERT_FALSE(unsynced_entities[0]->bookmark_node()->is_favicon_loaded()); + ASSERT_FALSE(unsynced_entities[0]->bookmark_node()->is_favicon_loading()); + + EXPECT_THAT(GetLocalChangesFromProcessor(/*max_entries=*/1), + ElementsAre(CommitRequestDataMatchesGuid( + unsynced_entities[1]->bookmark_node()->guid()))); + + // |unsynced_entities[0]| has been excluded from the result above because the + // favicon isn't loaded, but the loading process should have started now (see + // BookmarkLocalChangesBuilder::BuildCommitRequests()). + EXPECT_TRUE(unsynced_entities[0]->bookmark_node()->is_favicon_loading()); } TEST_F(BookmarkModelTypeProcessorTest, ShouldReuploadLegacyBookmarksOnStart) {
diff --git a/components/sync_bookmarks/switches.cc b/components/sync_bookmarks/switches.cc index 2c68c73..0fc9d150 100644 --- a/components/sync_bookmarks/switches.cc +++ b/components/sync_bookmarks/switches.cc
@@ -16,4 +16,8 @@ const base::Feature kSyncReuploadBookmarksUponMatchingData{ "SyncReuploadBookmarksUponMatchingData", base::FEATURE_ENABLED_BY_DEFAULT}; +const base::Feature kSyncBookmarksEnforceLateMaxEntriesToCommit{ + "SyncBookmarksEnforceLateMaxEntriesToCommit", + base::FEATURE_ENABLED_BY_DEFAULT}; + } // namespace switches
diff --git a/components/sync_bookmarks/switches.h b/components/sync_bookmarks/switches.h index c0e3009a..4bd99638 100644 --- a/components/sync_bookmarks/switches.h +++ b/components/sync_bookmarks/switches.h
@@ -19,6 +19,10 @@ // SyncReuploadBookmarkFullTitles is enabled. extern const base::Feature kSyncReuploadBookmarksUponMatchingData; +// TODO(crbug.com/1177798): remove this code after a quick verification that it +// doesn't cause issues. +extern const base::Feature kSyncBookmarksEnforceLateMaxEntriesToCommit; + } // namespace switches #endif // COMPONENTS_SYNC_BOOKMARKS_SWITCHES_H_
diff --git a/components/ui_devtools/devtools_server.cc b/components/ui_devtools/devtools_server.cc index 4675946..e7f5fec 100644 --- a/components/ui_devtools/devtools_server.cc +++ b/components/ui_devtools/devtools_server.cc
@@ -9,12 +9,15 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/command_line.h" +#include "base/files/file_util.h" #include "base/format_macros.h" #include "base/memory/ptr_util.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" +#include "base/path_service.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" +#include "base/task/thread_pool.h" #include "base/values.h" #include "components/ui_devtools/switches.h" #include "net/base/net_errors.h" @@ -27,6 +30,18 @@ namespace { const char kChromeDeveloperToolsPrefix[] = "devtools://devtools/bundled/devtools_app.html?uiDevTools=true&ws="; + +const base::FilePath::CharType kUIDevToolsActivePortFileName[] = + FILE_PATH_LITERAL("UIDevToolsActivePort"); + +void WriteUIDevtoolsPortToFile(base::FilePath output_dir, int port) { + base::FilePath path = output_dir.Append(kUIDevToolsActivePortFileName); + std::string port_target_string = base::StringPrintf("%d", port); + if (base::WriteFile(path, port_target_string.c_str(), + static_cast<int>(port_target_string.length())) < 0) { + LOG(ERROR) << "Error writing UIDevTools active port to file"; + } +} } // namespace UiDevToolsServer* UiDevToolsServer::devtools_server_ = nullptr; @@ -73,9 +88,13 @@ "Not implemented, only used in Devtools and is behind a switch." })"); -UiDevToolsServer::UiDevToolsServer(int port, - net::NetworkTrafficAnnotationTag tag) - : port_(port), tag_(tag) { +UiDevToolsServer::UiDevToolsServer( + int port, + net::NetworkTrafficAnnotationTag tag, + const base::FilePath& active_port_output_directory) + : port_(port), + active_port_output_directory_(active_port_output_directory), + tag_(tag) { DCHECK(!devtools_server_); devtools_server_ = this; } @@ -87,10 +106,11 @@ // static std::unique_ptr<UiDevToolsServer> UiDevToolsServer::CreateForViews( network::mojom::NetworkContext* network_context, - int port) { + int port, + const base::FilePath& active_port_output_directory) { // TODO(mhashmi): Change port if more than one inspectable clients - auto server = - base::WrapUnique(new UiDevToolsServer(port, kUIDevtoolsServerTag)); + auto server = base::WrapUnique(new UiDevToolsServer( + port, kUIDevtoolsServerTag, active_port_output_directory)); mojo::PendingRemote<network::mojom::TCPServerSocket> server_socket; auto receiver = server_socket.InitWithNewPipeAndPassReceiver(); CreateTCPServerSocket(std::move(receiver), network_context, port, @@ -105,8 +125,8 @@ std::unique_ptr<UiDevToolsServer> UiDevToolsServer::CreateForViz( mojo::PendingRemote<network::mojom::TCPServerSocket> server_socket, int port) { - auto server = - base::WrapUnique(new UiDevToolsServer(port, kVizDevtoolsServerTag)); + auto server = base::WrapUnique( + new UiDevToolsServer(port, kVizDevtoolsServerTag, base::FilePath())); server->MakeServer(std::move(server_socket), net::OK, absl::nullopt); return server; } @@ -190,6 +210,18 @@ if (result == net::OK) { server_ = std::make_unique<network::server::HttpServer>( std::move(server_socket), this); + // When --enable-ui-devtools=0, the browser will pick an available port and + // write to |kUIDevToolsActivePortFileName|. The file is useful for other + // programs such as Telemetry to know which port to listen to. + if (port_ == 0 && local_addr) { + port_ = local_addr->port(); + if (!active_port_output_directory_.empty()) { + base::ThreadPool::PostTask( + FROM_HERE, {base::MayBlock()}, + base::BindOnce(&WriteUIDevtoolsPortToFile, + active_port_output_directory_, port_)); + } + } } }
diff --git a/components/ui_devtools/devtools_server.h b/components/ui_devtools/devtools_server.h index 7a8b1ffd..2c06b4b 100644 --- a/components/ui_devtools/devtools_server.h +++ b/components/ui_devtools/devtools_server.h
@@ -36,13 +36,17 @@ ~UiDevToolsServer() override; // Returns an empty unique_ptr if ui devtools flag isn't enabled or if a - // server instance has already been created. + // server instance has already been created. If |port| is 0, the server will + // choose an available port. If |port| is 0 and |active_port_output_directory| + // is present, the server will write the chosen port to + // |kUIDevToolsActivePortFileName| on |active_port_output_directory|. static std::unique_ptr<UiDevToolsServer> CreateForViews( network::mojom::NetworkContext* network_context, - int port); + int port, + const base::FilePath& active_port_output_directory = base::FilePath()); // Assumes that the devtools flag is enabled, and was checked when the socket - // was created. + // was created. If |port| is 0, the server will choose an available port. static std::unique_ptr<UiDevToolsServer> CreateForViz( mojo::PendingRemote<network::mojom::TCPServerSocket> server_socket, int port); @@ -82,7 +86,9 @@ void SetOnSessionEnded(base::OnceClosure callback) const; private: - UiDevToolsServer(int port, const net::NetworkTrafficAnnotationTag tag); + UiDevToolsServer(int port, + const net::NetworkTrafficAnnotationTag tag, + const base::FilePath& active_port_output_directory); void MakeServer( mojo::PendingRemote<network::mojom::TCPServerSocket> server_socket, @@ -108,7 +114,11 @@ std::unique_ptr<network::server::HttpServer> server_; // The port the devtools server listens on - const int port_; + int port_; + + // Output directory for |kUIDevToolsActivePortFileName| when + // --enable-ui-devtools=0. + base::FilePath active_port_output_directory_; const net::NetworkTrafficAnnotationTag tag_;
diff --git a/components/ui_devtools/views/devtools_server_util.cc b/components/ui_devtools/views/devtools_server_util.cc index 36444f2..a50866e7 100644 --- a/components/ui_devtools/views/devtools_server_util.cc +++ b/components/ui_devtools/views/devtools_server_util.cc
@@ -20,11 +20,13 @@ std::unique_ptr<UiDevToolsServer> CreateUiDevToolsServerForViews( network::mojom::NetworkContext* network_context, - std::unique_ptr<ConnectorDelegate> connector) { + std::unique_ptr<ConnectorDelegate> connector, + const base::FilePath& active_port_output_directory) { constexpr int kUiDevToolsDefaultPort = 9223; int port = UiDevToolsServer::GetUiDevToolsPort(switches::kEnableUiDevTools, kUiDevToolsDefaultPort); - auto server = UiDevToolsServer::CreateForViews(network_context, port); + auto server = UiDevToolsServer::CreateForViews(network_context, port, + active_port_output_directory); DCHECK(server); auto client = std::make_unique<UiDevToolsClient>("UiDevToolsClient", server.get());
diff --git a/components/ui_devtools/views/devtools_server_util.h b/components/ui_devtools/views/devtools_server_util.h index fb8e07e2..025a664 100644 --- a/components/ui_devtools/views/devtools_server_util.h +++ b/components/ui_devtools/views/devtools_server_util.h
@@ -16,7 +16,8 @@ // The connector is used in TracingAgent to hook up with the tracing service. std::unique_ptr<UiDevToolsServer> CreateUiDevToolsServerForViews( network::mojom::NetworkContext* network_context, - std::unique_ptr<ConnectorDelegate> connector); + std::unique_ptr<ConnectorDelegate> connector, + const base::FilePath& active_port_output_directory); } // namespace ui_devtools
diff --git a/components/viz/common/quads/compositor_render_pass.cc b/components/viz/common/quads/compositor_render_pass.cc index b6b1bc0..8ff13b1c 100644 --- a/components/viz/common/quads/compositor_render_pass.cc +++ b/components/viz/common/quads/compositor_render_pass.cc
@@ -93,7 +93,8 @@ bool has_transparent_background, bool cache_render_pass, bool has_damage_from_contributing_content, - bool generate_mipmap) { + bool generate_mipmap, + bool has_per_quad_damage) { DCHECK(id); this->id = id; @@ -110,7 +111,7 @@ this->has_damage_from_contributing_content = has_damage_from_contributing_content; this->generate_mipmap = generate_mipmap; - + this->has_per_quad_damage = has_per_quad_damage; DCHECK(quad_list.empty()); DCHECK(shared_quad_state_list.empty()); } @@ -228,7 +229,8 @@ filters, backdrop_filters, backdrop_filter_bounds, subtree_capture_id, subtree_size, has_transparent_background, cache_render_pass, - has_damage_from_contributing_content, generate_mipmap); + has_damage_from_contributing_content, generate_mipmap, + has_per_quad_damage); if (shared_quad_state_list.empty()) { DCHECK(quad_list.empty());
diff --git a/components/viz/common/quads/compositor_render_pass.h b/components/viz/common/quads/compositor_render_pass.h index 273445e..cad9bca6 100644 --- a/components/viz/common/quads/compositor_render_pass.h +++ b/components/viz/common/quads/compositor_render_pass.h
@@ -75,7 +75,8 @@ bool has_transparent_background, bool cache_render_pass, bool has_damage_from_contributing_content, - bool generate_mipmap); + bool generate_mipmap, + bool has_per_quad_damage); void AsValueInto(base::trace_event::TracedValue* dict) const; @@ -100,6 +101,10 @@ // copied. gfx::Size subtree_size; + // Set to true if at least one of the quads in the |quad_list| contains damage + // that is not contained in |damage_rect|. + bool has_per_quad_damage = false; + // For testing functions. // TODO(vmpstr): See if we can clean these up by moving the tests to use // AggregatedRenderPasses where appropriate.
diff --git a/components/viz/common/quads/compositor_render_pass_unittest.cc b/components/viz/common/quads/compositor_render_pass_unittest.cc index cfca5f8..aa78932 100644 --- a/components/viz/common/quads/compositor_render_pass_unittest.cc +++ b/components/viz/common/quads/compositor_render_pass_unittest.cc
@@ -41,7 +41,7 @@ EXPECT_EQ(expected->has_transparent_background, actual->has_transparent_background); EXPECT_EQ(expected->generate_mipmap, actual->generate_mipmap); - + EXPECT_EQ(expected->has_per_quad_damage, actual->has_per_quad_damage); EXPECT_EQ(expected->shared_quad_state_list.size(), actual->shared_quad_state_list.size()); EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); @@ -135,13 +135,14 @@ bool cache_render_pass = false; bool has_damage_from_contributing_content = false; bool generate_mipmap = false; + bool has_per_quad_damage = false; auto pass = CompositorRenderPass::Create(); pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, backdrop_filters, backdrop_filter_bounds, SubtreeCaptureId{1u}, output_rect.size(), has_transparent_background, cache_render_pass, has_damage_from_contributing_content, - generate_mipmap); + generate_mipmap, has_per_quad_damage); // Two quads using one shared state. SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); @@ -191,6 +192,7 @@ bool contrib_cache_render_pass = false; bool contrib_has_damage_from_contributing_content = false; bool contrib_generate_mipmap = false; + bool contrib_has_per_quad_damage = false; auto contrib = CompositorRenderPass::Create(); contrib->SetAll(contrib_id, contrib_output_rect, contrib_damage_rect, @@ -199,7 +201,7 @@ SubtreeCaptureId{2u}, contrib_output_rect.size(), contrib_has_transparent_background, contrib_cache_render_pass, contrib_has_damage_from_contributing_content, - contrib_generate_mipmap); + contrib_generate_mipmap, contrib_has_per_quad_damage); SharedQuadState* contrib_shared_state = contrib->CreateAndAppendSharedQuadState(); @@ -247,13 +249,13 @@ bool cache_render_pass = false; bool has_damage_from_contributing_content = false; bool generate_mipmap = false; - + bool has_per_quad_damage = false; auto pass = CompositorRenderPass::Create(); pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, backdrop_filters, backdrop_filter_bounds, SubtreeCaptureId(), output_rect.size(), has_transparent_background, cache_render_pass, has_damage_from_contributing_content, - generate_mipmap); + generate_mipmap, has_per_quad_damage); // A shared state with a quad. SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState();
diff --git a/components/viz/common/quads/quad_list.cc b/components/viz/common/quads/quad_list.cc index 4aab9ad..8c9c46c 100644 --- a/components/viz/common/quads/quad_list.cc +++ b/components/viz/common/quads/quad_list.cc
@@ -19,20 +19,31 @@ #include "components/viz/common/quads/yuv_video_draw_quad.h" namespace { +// This rounding is required because 'LargestDrawQuadSize' and +// 'LargestDrawQuadAlignment' might not be the largest for the same quad type. +// For example |TextureDrawQuad| might be the largest quad but only have an +// alignment requirement of 8 bytes whereas |TileDrawQuad| might not be the +// largest quad but could have an alignment requirement of 16 bytes. +constexpr size_t RoundUp(size_t size, size_t align) { + return (size + align - 1u) & ~(align - 1u); +} + const size_t kDefaultNumQuadsToReserve = 128; } // namespace namespace viz { QuadList::QuadList() - : ListContainer<DrawQuad>(LargestDrawQuadAlignment(), - LargestDrawQuadSize(), - kDefaultNumQuadsToReserve) {} + : ListContainer<DrawQuad>( + LargestDrawQuadAlignment(), + RoundUp(LargestDrawQuadSize(), LargestDrawQuadAlignment()), + kDefaultNumQuadsToReserve) {} QuadList::QuadList(size_t default_size_to_reserve) - : ListContainer<DrawQuad>(LargestDrawQuadAlignment(), - LargestDrawQuadSize(), - default_size_to_reserve) {} + : ListContainer<DrawQuad>( + LargestDrawQuadAlignment(), + RoundUp(LargestDrawQuadSize(), LargestDrawQuadAlignment()), + default_size_to_reserve) {} QuadList::Iterator QuadList::InsertCopyBeforeDrawQuad(Iterator at, size_t count) {
diff --git a/components/viz/common/quads/render_pass_io.cc b/components/viz/common/quads/render_pass_io.cc index 148e0bc..94062a6 100644 --- a/components/viz/common/quads/render_pass_io.cc +++ b/components/viz/common/quads/render_pass_io.cc
@@ -27,6 +27,7 @@ #include "components/viz/common/quads/tile_draw_quad.h" #include "components/viz/common/quads/video_hole_draw_quad.h" #include "components/viz/common/quads/yuv_video_draw_quad.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace gl { struct HDRMetadata; @@ -52,6 +53,7 @@ kRenderPassCopyRequests = 1 << 12, kRenderPassQuadList = 1 << 13, kRenderPassSharedQuadStateList = 1 << 14, + kRenderPassHasPreQuadDamage = 1 << 15, kRenderPassAllFields = 0xFFFFFFFF, }; @@ -1202,6 +1204,9 @@ DCHECK_EQ(1u, draw_quad->resources.count); dict->SetKey("resource_size_in_pixels", SizeToDict(draw_quad->overlay_resources.size_in_pixels)); + if (draw_quad->damage_rect.has_value()) { + dict->SetKey("damage_rect", RectToDict(draw_quad->damage_rect.value())); + } } void TileDrawQuadToDict(const TileDrawQuad* draw_quad, base::Value* dict) { @@ -1228,6 +1233,9 @@ "protected_video_type", ProtectedVideoTypeToString(draw_quad->protected_video_type)); DCHECK(4u == draw_quad->resources.count || 3u == draw_quad->resources.count); + if (draw_quad->damage_rect.has_value()) { + dict->SetKey("damage_rect", RectToDict(draw_quad->damage_rect.value())); + } } void VideoHoleDrawQuadToDict(const VideoHoleDrawQuad* draw_quad, @@ -1437,6 +1445,7 @@ const base::Value* uv_bottom_right = dict.FindDictKey("uv_bottom_right"); absl::optional<int> background_color = dict.FindIntKey("background_color"); const base::Value* vertex_opacity = dict.FindListKey("vertex_opacity"); + const base::Value* damage_rect = dict.FindDictKey("damage_rect"); absl::optional<bool> y_flipped = dict.FindBoolKey("y_flipped"); absl::optional<bool> nearest_neighbor = dict.FindBoolKey("nearest_neighbor"); absl::optional<bool> secure_output_only = @@ -1475,6 +1484,12 @@ static_cast<SkColor>(background_color.value()), t_vertex_opacity, y_flipped.value(), nearest_neighbor.value(), secure_output_only.value(), static_cast<gfx::ProtectedVideoType>(protected_video_type_index)); + + gfx::Rect t_damage_rect; + if (damage_rect && RectFromDict(*damage_rect, &t_damage_rect)) { + draw_quad->damage_rect = t_damage_rect; + } + return true; } @@ -1516,6 +1531,7 @@ const base::Value* uv_tex_coord_rect = dict.FindDictKey("uv_tex_coord_rect"); const base::Value* ya_tex_size = dict.FindDictKey("ya_tex_size"); const base::Value* uv_tex_size = dict.FindDictKey("uv_tex_size"); + const base::Value* damage_rect = dict.FindDictKey("damage_rect"); absl::optional<double> resource_offset = dict.FindDoubleKey("resource_offset"); absl::optional<double> resource_multiplier = @@ -1568,6 +1584,12 @@ static_cast<uint32_t>(bits_per_channel.value()), static_cast<gfx::ProtectedVideoType>(protected_video_type_index), gfx::HDRMetadata()); + + gfx::Rect t_damage_rect; + if (damage_rect && RectFromDict(*damage_rect, &t_damage_rect)) { + draw_quad->damage_rect = t_damage_rect; + } + return true; } @@ -1904,6 +1926,11 @@ } if (ProcessRenderPassField(kRenderPassCacheRenderPass)) dict.SetBoolKey("cache_render_pass", render_pass.cache_render_pass); + if (ProcessRenderPassField(kRenderPassHasPreQuadDamage)) { + // Set the dict value only if it is not the non default value. + if (render_pass.has_per_quad_damage) + dict.SetBoolKey("has_per_quad_damage", render_pass.has_per_quad_damage); + } if (ProcessRenderPassField(kRenderPassHasDamageFromContributingContent)) { dict.SetBoolKey("has_damage_from_contributing_content", render_pass.has_damage_from_contributing_content); @@ -2025,6 +2052,13 @@ pass->cache_render_pass = cache_render_pass.value(); } + if (ProcessRenderPassField(kRenderPassHasPreQuadDamage)) { + const absl::optional<bool> has_per_quad_damage = + dict.FindBoolKey("has_per_quad_damage"); + if (has_per_quad_damage) + pass->has_per_quad_damage = has_per_quad_damage.value(); + } + if (ProcessRenderPassField(kRenderPassHasDamageFromContributingContent)) { const absl::optional<bool> has_damage_from_contributing_content = dict.FindBoolKey("has_damage_from_contributing_content");
diff --git a/components/viz/common/quads/shared_quad_state.h b/components/viz/common/quads/shared_quad_state.h index c16c0a2..cd63a699 100644 --- a/components/viz/common/quads/shared_quad_state.h +++ b/components/viz/common/quads/shared_quad_state.h
@@ -74,11 +74,6 @@ absl::optional<size_t> overlay_damage_index; // The amount to skew quads in this layer. For experimental de-jelly effect. float de_jelly_delta_y = 0.0f; - - // If true, indicates that the quads do not contribute damage to their - // render pass's damage; if false, whether or not the quads contribute - // damage is unknown. Only meaningful in root render passes. - bool no_damage = false; }; } // namespace viz
diff --git a/components/viz/common/quads/texture_draw_quad.cc b/components/viz/common/quads/texture_draw_quad.cc index b851c5f..8003773 100644 --- a/components/viz/common/quads/texture_draw_quad.cc +++ b/components/viz/common/quads/texture_draw_quad.cc
@@ -28,6 +28,8 @@ TextureDrawQuad::TextureDrawQuad(const TextureDrawQuad& other) = default; +TextureDrawQuad::~TextureDrawQuad() = default; + void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, const gfx::Rect& rect, const gfx::Rect& visible_rect,
diff --git a/components/viz/common/quads/texture_draw_quad.h b/components/viz/common/quads/texture_draw_quad.h index 3426ca94..25d1e9ac 100644 --- a/components/viz/common/quads/texture_draw_quad.h +++ b/components/viz/common/quads/texture_draw_quad.h
@@ -5,12 +5,12 @@ #ifndef COMPONENTS_VIZ_COMMON_QUADS_TEXTURE_DRAW_QUAD_H_ #define COMPONENTS_VIZ_COMMON_QUADS_TEXTURE_DRAW_QUAD_H_ -#include <stddef.h> - #include "components/viz/common/quads/draw_quad.h" #include "components/viz/common/resources/resource_id.h" #include "components/viz/common/viz_common_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkColor.h" +#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/video_types.h" @@ -23,6 +23,8 @@ TextureDrawQuad(); TextureDrawQuad(const TextureDrawQuad& other); + ~TextureDrawQuad() override; + void SetNew(const SharedQuadState* shared_quad_state, const gfx::Rect& rect, const gfx::Rect& visible_rect, @@ -75,6 +77,9 @@ // hardware overlay. gfx::ProtectedVideoType protected_video_type : 2; + // This optional damage is in target render pass coordinate space. + absl::optional<gfx::Rect> damage_rect; + // Identifier passed through by the video decoder that allows us to validate // if a protected surface can still be displayed. Non-zero when valid. uint32_t hw_protected_validation_id = 0;
diff --git a/components/viz/common/quads/yuv_video_draw_quad.h b/components/viz/common/quads/yuv_video_draw_quad.h index e052860..fd413d88 100644 --- a/components/viz/common/quads/yuv_video_draw_quad.h +++ b/components/viz/common/quads/yuv_video_draw_quad.h
@@ -5,11 +5,10 @@ #ifndef COMPONENTS_VIZ_COMMON_QUADS_YUV_VIDEO_DRAW_QUAD_H_ #define COMPONENTS_VIZ_COMMON_QUADS_YUV_VIDEO_DRAW_QUAD_H_ -#include <stddef.h> - #include "components/viz/common/quads/draw_quad.h" #include "components/viz/common/resources/resource_id.h" #include "components/viz/common/viz_common_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gfx/color_space.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/geometry/size.h" @@ -87,6 +86,9 @@ gfx::ProtectedVideoType::kClear; gfx::HDRMetadata hdr_metadata; + // This optional damage is in target render pass coordinate space. + absl::optional<gfx::Rect> damage_rect; + static const YUVVideoDrawQuad* MaterialCast(const DrawQuad*); ResourceId y_plane_resource_id() const {
diff --git a/components/viz/service/display/display_unittest.cc b/components/viz/service/display/display_unittest.cc index 3591b46..8b1c5c8 100644 --- a/components/viz/service/display/display_unittest.cc +++ b/components/viz/service/display/display_unittest.cc
@@ -748,7 +748,7 @@ render_pass_id_generator.GenerateNextId(), sub_surface_rect, no_damage, gfx::Transform(), cc::FilterOperations(), backdrop_filters, gfx::RRectF(gfx::RectF(sub_surface_rect), 0), SubtreeCaptureId(), - sub_surface_rect.size(), false, false, false, false); + sub_surface_rect.size(), false, false, false, false, false); pass_list.push_back(std::move(bd_pass)); CompositorFrame frame = CompositorFrameBuilder()
diff --git a/components/viz/service/display/overlay_candidate.cc b/components/viz/service/display/overlay_candidate.cc index 8996ed02..cb980331 100644 --- a/components/viz/service/display/overlay_candidate.cc +++ b/components/viz/service/display/overlay_candidate.cc
@@ -155,7 +155,6 @@ candidate->requires_overlay = OverlayCandidate::RequiresOverlay(quad); candidate->overlay_damage_index = sqs->overlay_damage_index.value_or(kInvalidDamageIndex); - candidate->assume_damaged = !sqs->no_damage; switch (quad->material) { case DrawQuad::Material::kTextureContent:
diff --git a/components/viz/service/display/overlay_candidate.h b/components/viz/service/display/overlay_candidate.h index d101c42..4649d4d 100644 --- a/components/viz/service/display/overlay_candidate.h +++ b/components/viz/service/display/overlay_candidate.h
@@ -137,11 +137,6 @@ // Is true if an HW overlay is required for the quad content. bool requires_overlay = false; - // Is true when quad is part of a |shared_quad_state| that has damage. - // This is a fallback case for when |overlay_damage_index| is unavailable and - // will be absent from the |SurfaceDamageRectList|. - bool assume_damaged = false; - // Identifier passed through by the video decoder that allows us to validate // if a protected surface can still be displayed. Non-zero when valid. uint32_t hw_protected_validation_id = 0;
diff --git a/components/viz/service/display/overlay_processor_using_strategy.cc b/components/viz/service/display/overlay_processor_using_strategy.cc index d29e9f6c..bab7cdfe 100644 --- a/components/viz/service/display/overlay_processor_using_strategy.cc +++ b/components/viz/service/display/overlay_processor_using_strategy.cc
@@ -383,8 +383,7 @@ static_cast<float>(it->candidate.damage_area_estimate) / display_area, it->candidate.resource_id, tracker_config_, it->candidate.overlay_damage_index != - OverlayCandidate::kInvalidDamageIndex || - it->candidate.assume_damaged); + OverlayCandidate::kInvalidDamageIndex); // Here a series of criteria are considered for wholesale rejection of a // candidate. The rational for rejection is usually power improvements but
diff --git a/components/viz/service/display/overlay_unittest.cc b/components/viz/service/display/overlay_unittest.cc index 5cb1608..351d450c 100644 --- a/components/viz/service/display/overlay_unittest.cc +++ b/components/viz/service/display/overlay_unittest.cc
@@ -1021,7 +1021,6 @@ SharedQuadState* damaged_shared_quad_state = pass->shared_quad_state_list.AllocateAndCopyFrom( pass->shared_quad_state_list.back()); - damaged_shared_quad_state->no_damage = false; auto* quad = CreateCandidateQuadAt( resource_provider_.get(), child_resource_provider_.get(), @@ -1075,7 +1074,6 @@ SharedQuadState* damaged_shared_quad_state = pass->shared_quad_state_list.AllocateAndCopyFrom( pass->shared_quad_state_list.back()); - damaged_shared_quad_state->no_damage = false; // Create surface damages corresponding to the in front damage, the overlay // damage, and finally the behind overlay damage. @@ -2037,11 +2035,9 @@ child_provider_.get(), pass->output_rect.size(), true /*is_overlay_candidate*/); previous_resource_id = resource_id; - pass->shared_quad_state_list.back()->no_damage = false; } else { // Starting the 3rd frame, they should have the same resource ID. resource_id = previous_resource_id; - pass->shared_quad_state_list.back()->no_damage = true; } // Create a quad with the resource ID selected above.
diff --git a/components/viz/service/display/surface_aggregator.cc b/components/viz/service/display/surface_aggregator.cc index 72613289b..b55b43b2 100644 --- a/components/viz/service/display/surface_aggregator.cc +++ b/components/viz/service/display/surface_aggregator.cc
@@ -30,6 +30,7 @@ #include "components/viz/common/quads/solid_color_draw_quad.h" #include "components/viz/common/quads/surface_draw_quad.h" #include "components/viz/common/quads/texture_draw_quad.h" +#include "components/viz/common/quads/yuv_video_draw_quad.h" #include "components/viz/common/surfaces/surface_range.h" #include "components/viz/service/display/aggregated_frame.h" #include "components/viz/service/display/display_resource_provider.h" @@ -94,6 +95,20 @@ shared_quad_state->quad_to_target_transform, expanded_rect); } +const absl::optional<gfx::Rect>& GetOptionalDamageRectFromQuad( + const DrawQuad* quad) { + if (quad->material == DrawQuad::Material::kTextureContent) { + auto* texture_quad = TextureDrawQuad::MaterialCast(quad); + return texture_quad->damage_rect; + } else if (quad->material == DrawQuad::Material::kYuvVideoContent) { + auto* yuv_video_quad = YUVVideoDrawQuad::MaterialCast(quad); + return yuv_video_quad->damage_rect; + } else { + static absl::optional<gfx::Rect> no_damage; + return no_damage; + } +} + } // namespace struct SurfaceAggregator::PrewalkResult { @@ -233,15 +248,17 @@ gfx::Rect SurfaceAggregator::DamageRectForSurface( const Surface* surface, - const CompositorRenderPass& source) const { - // If we have damage because of surface animation, return the source damage - // since we trust the source damage to have correctly computed damage, and we - // can't skip it. + const CompositorRenderPass& source, + bool include_per_quad_damage) const { + // The |damage_rect| set in |SurfaceAnimationManager| is the |output_rect|. + // However, we dont use |damage_rect| because when we transition from + // interpolated frame we would end up using the |damage_rect| from the + // original non interpolated frame. // TODO(vmpstr): This damage may be too large, but I think it's hard to figure // out a small bounds on the damage given an animation that happens in // SurfaceAnimationManager. if (surface->HasSurfaceAnimationDamage()) - return source.damage_rect; + return source.output_rect; if (IsSurfaceFrameIndexSameAsPrevious(surface)) return gfx::Rect(); @@ -254,8 +271,21 @@ } if (it != previous_contained_surfaces_.end()) { uint64_t previous_index = it->second; - if (previous_index == surface->GetActiveFrameIndex() - 1) - return source.damage_rect; + if (previous_index == surface->GetActiveFrameIndex() - 1) { + if (!source.has_per_quad_damage || !include_per_quad_damage) { + return source.damage_rect; + } else { + // TODO(crbug.com/1194082): Cache quad damage. + auto complete_damage = source.damage_rect; + for (auto* quad : source.quad_list) { + auto optional_damage = GetOptionalDamageRectFromQuad(quad); + if (optional_damage.has_value()) { + complete_damage.Union(optional_damage.value()); + } + } + return complete_damage; + } + } } return source.output_rect; @@ -320,7 +350,7 @@ dest_pass->cache_render_pass)) { damage_rect = source_pass->output_rect; } else { - damage_rect = DamageRectForSurface(surface, *source_pass); + damage_rect = DamageRectForSurface(surface, *source_pass, false); } } @@ -375,26 +405,23 @@ // can't be any damage above the quad within the surface, and the quad needs // its own SQS for the occluding_damage_rect metadata. const DrawQuad* target_quad = nullptr; - if (source_pass.quad_list.size() == 1) { - // If there's only one quad in the root render pass, then the conditions - // are clearly satisfied. - target_quad = source_pass.quad_list.back(); - } else { - // If there are multiple quads in the surface, if exactly one quad is - // marked as having damage, then we know that quad doesn't have damage - // above it, and we know that it has its own SQS (because its - // sqs->no_damage is unique). - for (auto* quad : source_pass.quad_list) { - if (quad->shared_quad_state->no_damage) { + for (auto* quad : source_pass.quad_list) { + // Quads with |per_quad_damage| do not contribute to the |damage_rect| in + // the |source_pass|. These quads are also assumed to have unique SQS + // objects. + if (source_pass.has_per_quad_damage) { + auto optional_damage = GetOptionalDamageRectFromQuad(quad); + if (optional_damage.has_value()) { continue; } + } - if (target_quad == nullptr) { - target_quad = quad; - } else { - target_quad = nullptr; - break; - } + if (target_quad == nullptr) { + target_quad = quad; + } else { + // More that one quad without per_quad_damage. + target_quad = nullptr; + break; } } @@ -462,7 +489,6 @@ gfx::Transform transform( target_transform, surface_quad->shared_quad_state->quad_to_target_transform); - AddSurfaceDamageToDamageList( /*default_damage_rect=*/surface_quad->rect, transform, clip_rect, /*source_pass =*/nullptr, dest_pass, /*surface=*/nullptr); @@ -701,7 +727,7 @@ // damage because HandleSurfaceQuad is a recursive call by calling // CopyQuadsToPass in it. dest_pass->has_damage_from_contributing_content |= - !DamageRectForSurface(surface, last_pass).IsEmpty(); + !DamageRectForSurface(surface, last_pass, true).IsEmpty(); if (merge_pass) { CopyQuadsToPass(last_pass, dest_pass, frame.device_scale_factor(), @@ -1004,7 +1030,6 @@ shared_quad_state->is_fast_rounded_corner = mask_filter_info_ext.is_fast_rounded_corner, shared_quad_state->de_jelly_delta_y = source_sqs->de_jelly_delta_y; - return shared_quad_state; } @@ -1104,9 +1129,23 @@ SharedQuadState* dest_shared_quad_state = CopySharedQuadState(quad->shared_quad_state, target_transform, clip_rect, dest_pass, new_mask_filter_info_ext); - - if (quad == quad_with_overlay_damage_index) + // Here we output the optional quad's |per_quad_damage| to the + // |surface_damage_rect_list_|. Any non per quad damage associated with + // this |source_pass| will have been added to the + // |surface_damage_rect_list_| before this phase. + if (source_pass.has_per_quad_damage && + GetOptionalDamageRectFromQuad(quad).has_value()) { + auto damage_rect_in_target_space = + GetOptionalDamageRectFromQuad(quad); + dest_shared_quad_state->overlay_damage_index = + surface_damage_rect_list_->size(); + AddSurfaceDamageToDamageList(damage_rect_in_target_space.value(), + target_transform, {}, &source_pass, + dest_pass, + /*surface=*/nullptr); + } else if (quad == quad_with_overlay_damage_index) { dest_shared_quad_state->overlay_damage_index = overlay_damage_index; + } if (de_jelly_enabled_) { // If a surface is being drawn for a second time, clear our @@ -1338,7 +1377,8 @@ // accumulated from all quads in the surface, and needs to be expanded by any // pixel-moving backdrop filter in the render pass if intersecting. Transform // this damage into the local space of the render pass for this purpose. - gfx::Rect surface_root_rp_damage = DamageRectForSurface(surface, *last_pass); + gfx::Rect surface_root_rp_damage = + DamageRectForSurface(surface, *last_pass, true); if (!surface_root_rp_damage.IsEmpty()) { gfx::Transform root_to_target_transform( gfx::Transform::kSkipInitialization); @@ -1618,7 +1658,7 @@ ++stats_->prewalked_surface_count; CompositorRenderPass* last_pass = frame.render_pass_list.back().get(); - gfx::Rect damage_rect = DamageRectForSurface(surface, *last_pass); + gfx::Rect damage_rect = DamageRectForSurface(surface, *last_pass, true); // Avoid infinite recursion by adding current surface to // |referenced_surfaces_|.
diff --git a/components/viz/service/display/surface_aggregator.h b/components/viz/service/display/surface_aggregator.h index 5e01d9f..fd547c37 100644 --- a/components/viz/service/display/surface_aggregator.h +++ b/components/viz/service/display/surface_aggregator.h
@@ -265,7 +265,8 @@ int ChildIdForSurface(Surface* surface); bool IsSurfaceFrameIndexSameAsPrevious(const Surface* surface) const; gfx::Rect DamageRectForSurface(const Surface* surface, - const CompositorRenderPass& source) const; + const CompositorRenderPass& source, + bool include_per_quad_damage) const; // This function adds |damage_rect| to // |damage_rects_union_of_surfaces_on_top_|. |damage_rect| is in the quad
diff --git a/components/viz/service/display/surface_aggregator_unittest.cc b/components/viz/service/display/surface_aggregator_unittest.cc index 8c4355f..21b4cf3 100644 --- a/components/viz/service/display/surface_aggregator_unittest.cc +++ b/components/viz/service/display/surface_aggregator_unittest.cc
@@ -51,6 +51,8 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkColor.h" +#include "ui/gfx/geometry/point_f.h" +#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_conversions.h" namespace viz { @@ -176,10 +178,21 @@ return quad; } - static Quad YUVVideoQuad(const gfx::Rect& rect) { + static Quad YUVVideoQuad(const gfx::Rect& rect, + bool per_quad_damage_output = false) { Quad quad; quad.material = DrawQuad::Material::kYuvVideoContent; quad.rect = rect; + quad.per_quad_damage_output = per_quad_damage_output; + return quad; + } + + static Quad TextureQuad(const gfx::Rect& rect, + bool per_quad_damage_output = false) { + Quad quad; + quad.material = DrawQuad::Material::kTextureContent; + quad.rect = rect; + quad.per_quad_damage_output = per_quad_damage_output; return quad; } @@ -244,6 +257,7 @@ gfx::MaskFilterInfo mask_filter_info; bool is_fast_rounded_corner = false; bool allow_merge = true; + bool per_quad_damage_output = false; // Set when material==DrawQuad::Material::kSolidColor. SkColor color{SK_ColorWHITE}; @@ -307,7 +321,10 @@ desc.intersects_damage_under); break; case DrawQuad::Material::kYuvVideoContent: - AddYUVVideoQuad(pass, desc.rect); + AddYUVVideoQuad(pass, desc.rect, desc.per_quad_damage_output); + break; + case DrawQuad::Material::kTextureContent: + AddTextureDrawQuad(pass, desc.rect, desc.per_quad_damage_output); break; default: NOTREACHED(); @@ -435,7 +452,8 @@ } static void AddYUVVideoQuad(CompositorRenderPass* pass, - const gfx::Rect& output_rect) { + const gfx::Rect& output_rect, + bool per_quad_damage_output) { auto* shared_state = pass->CreateAndAppendSharedQuadState(); shared_state->SetAll(gfx::Transform(), output_rect, output_rect, gfx::MaskFilterInfo(), absl::nullopt, false, 1, @@ -446,6 +464,32 @@ gfx::Size(), ResourceId(1), ResourceId(2), ResourceId(3), kInvalidResourceId, gfx::ColorSpace::CreateREC709(), 0, 1.0, 8); + if (per_quad_damage_output) { + quad->damage_rect = output_rect; + } + } + + static void AddTextureDrawQuad(CompositorRenderPass* pass, + const gfx::Rect& output_rect, + bool per_quad_damage_output) { + auto* shared_state = pass->CreateAndAppendSharedQuadState(); + shared_state->SetAll(gfx::Transform(), output_rect, output_rect, + gfx::MaskFilterInfo(), absl::nullopt, false, 1, + SkBlendMode::kSrcOver, 0); + auto* quad = pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); + float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + const gfx::PointF kUVTopLeft(0.1f, 0.2f); + const gfx::PointF kUVBottomRight(1.0f, 1.0f); + quad->SetNew(shared_state, output_rect, output_rect, + false /*needs_blending*/, ResourceId(1), + false /*premultiplied_alpha*/, kUVTopLeft, kUVBottomRight, + SK_ColorTRANSPARENT, vertex_opacity, false /*flipped*/, + false /*nearest_neighbor*/, false /*secure_output_only*/, + gfx::ProtectedVideoType::kClear); + + if (per_quad_damage_output) { + quad->damage_rect = output_rect; + } } protected: @@ -6807,7 +6851,7 @@ // Add a quad on top of video quad. child_surface_quads = std::vector<Quad>( {Quad::SolidColorQuad(SK_ColorRED, gfx::Rect(0, 0, 50, 50)), - Quad::YUVVideoQuad(gfx::Rect(0, 0, 100, 100))}); + Quad::YUVVideoQuad(gfx::Rect(0, 0, 100, 100), true)}); child_surface_passes = std::vector<Pass>({Pass(child_surface_quads, /*size*/ gfx::Size(100, 100), @@ -6842,8 +6886,7 @@ AddPasses(&child_surface_frame.render_pass_list, child_surface_passes, &child_surface_frame.metadata.referenced_surfaces); auto* render_pass = child_surface_frame.render_pass_list[0].get(); - auto* surface_quad_sqs = render_pass->shared_quad_state_list.front(); - surface_quad_sqs->no_damage = true; + render_pass->has_per_quad_damage = true; child_sink_->SubmitCompositorFrame(child_surface_id.local_surface_id(), std::move(child_surface_frame)); @@ -6862,7 +6905,7 @@ // No occluding damage. EXPECT_TRUE(video_sqs->overlay_damage_index.has_value()); auto index = video_sqs->overlay_damage_index.value(); - EXPECT_EQ(0U, index); + EXPECT_EQ(1U, index); // Video quad(10, 0, 80, 80) is damaged. EXPECT_EQ(gfx::Rect(10, 0, 80, 80), @@ -6870,6 +6913,141 @@ } } +// Tests the |per_quad_damage| feature by adding a few quads, flagged with +// |per_quad_damage|, and then checking the output damage after surface +// aggregation. By placing these quads in a surface we also test that the +// correct relevant transforms have been applied by examining the +// |surface_damage_rect_list_|. +TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassHasPerQuadDamage) { + // Video quad + gfx::Rect surface_quad_rect = gfx::Rect(0, 0, 100, 100); + std::vector<Quad> child_surface_quads = { + Quad::YUVVideoQuad(surface_quad_rect)}; + + std::vector<Pass> child_surface_passes = { + Pass(child_surface_quads, /*size*/ gfx::Size(100, 100), + /*damage_rect*/ gfx::Rect(0, 0, 100, 100))}; + + // Various rects configs that will be used to test per quad damage. + gfx::Rect quad_rects[] = {gfx::Rect(60, 0, 40, 40), gfx::Rect(0, 0, 50, 50), + gfx::Rect(0, 0, 75, 25), gfx::Rect(10, 0, 30, 30), + gfx::Rect(0, 5, 50, 50)}; + + CompositorFrame child_surface_frame = MakeEmptyCompositorFrame(); + AddPasses(&child_surface_frame.render_pass_list, child_surface_passes, + &child_surface_frame.metadata.referenced_surfaces); + PopulateTransferableResources(child_surface_frame); + + TestSurfaceIdAllocator child_surface_id(child_sink_->frame_sink_id()); + child_sink_->SubmitCompositorFrame(child_surface_id.local_surface_id(), + std::move(child_surface_frame)); + gfx::PointF child_surface_offset(10.0f, 5.0f); + gfx::Transform child_surface_transform( + 1.f, 0, 0, 1.f, child_surface_offset.x(), child_surface_offset.y()); + + auto apply_transform = [child_surface_offset](const gfx::Rect orig_rect) { + auto rtn_rect = orig_rect; + rtn_rect.set_x(static_cast<int>(child_surface_offset.x()) + rtn_rect.x()); + rtn_rect.set_y(static_cast<int>(child_surface_offset.y()) + rtn_rect.y()); + return rtn_rect; + }; + + // root surface quads + std::vector<Quad> root_surface_quads = { + Quad::SolidColorQuad(SK_ColorRED, quad_rects[0]), + Quad::SurfaceQuad( + SurfaceRange(absl::nullopt, child_surface_id), SK_ColorWHITE, + /*primary_surface_rect*/ gfx::Rect(0, 0, 100, 100), + /*opacity*/ 1.f, child_surface_transform, + /*stretch_content_to_fill_bounds=*/false, gfx::MaskFilterInfo(), + /*is_fast_rounded_corner=*/false)}; + + std::vector<Pass> root_passes = {Pass(root_surface_quads, + /*size*/ gfx::Size(200, 200), + /*damage_rect*/ quad_rects[0])}; + + CompositorFrame root_frame = MakeEmptyCompositorFrame(); + AddPasses(&root_frame.render_pass_list, root_passes, + &root_frame.metadata.referenced_surfaces); + + root_sink_->SubmitCompositorFrame(root_surface_id_.local_surface_id(), + std::move(root_frame)); + + auto aggregated_frame = AggregateFrame(root_surface_id_); + + // Initial test frame - Full occluding damage rect + // The damage rect of the very first frame is always the full rect. + auto* output_root_pass = aggregated_frame.render_pass_list.back().get(); + EXPECT_EQ(gfx::Rect(0, 0, 200, 200), output_root_pass->damage_rect); + // Make sure |surface_damage_rect_list_| is correct. + EXPECT_EQ(output_root_pass->damage_rect, + DamageListUnion(aggregated_frame.surface_damage_rect_list_)); + + const SharedQuadState* video_sqs = + output_root_pass->quad_list.back()->shared_quad_state; + + // The whole root surface (0, 0, 200, 200) is damaged. + EXPECT_EQ(gfx::Rect(0, 0, 200, 200), + aggregated_frame.surface_damage_rect_list_[0]); + + ASSERT_TRUE(video_sqs->overlay_damage_index.has_value()); + auto index = video_sqs->overlay_damage_index.value(); + EXPECT_EQ(1U, index); + EXPECT_EQ(apply_transform(surface_quad_rect), + aggregated_frame.surface_damage_rect_list_[index]); + + // Frame that has three quads that are flagged with per quad damage. + // Add a quad on top of video quad. + child_surface_quads = std::vector<Quad>({ + Quad::SolidColorQuad(SK_ColorRED, quad_rects[1]), + Quad::YUVVideoQuad(quad_rects[2], true), + Quad::TextureQuad(quad_rects[3], true), + Quad::TextureQuad(quad_rects[4], true), + }); + + child_surface_passes = std::vector<Pass>( + {Pass(child_surface_quads, gfx::Size(100, 100), quad_rects[1])}); + + { + CompositorFrame child_surface_frame = MakeEmptyCompositorFrame(); + AddPasses(&child_surface_frame.render_pass_list, child_surface_passes, + &child_surface_frame.metadata.referenced_surfaces); + auto* render_pass = child_surface_frame.render_pass_list[0].get(); + render_pass->has_per_quad_damage = true; + + child_sink_->SubmitCompositorFrame(child_surface_id.local_surface_id(), + std::move(child_surface_frame)); + // No change in root frame. + auto aggregated_frame = AggregateFrame(root_surface_id_); + auto* output_root_pass = aggregated_frame.render_pass_list.back().get(); + EXPECT_EQ(output_root_pass->damage_rect, + DamageListUnion(aggregated_frame.surface_damage_rect_list_)); + EXPECT_EQ(apply_transform(quad_rects[1]), + aggregated_frame.surface_damage_rect_list_[0]); + EXPECT_EQ(4u, aggregated_frame.surface_damage_rect_list_.size()); + EXPECT_EQ(5u, output_root_pass->quad_list.size()); + uint32_t i = 0; + // There should be 5 quads in total: + // 0 - root color quad + // 1 - surface color quad + // 2-4 - Quads that have |per_quad_damage| + for (auto* quad : output_root_pass->quad_list) { + EXPECT_EQ(quad_rects[i], quad->rect); + + // Looking at only the quads with |per_quad_damage|. + if (i >= 2) { + const SharedQuadState* sqs = quad->shared_quad_state; + EXPECT_TRUE(sqs->overlay_damage_index.has_value()); + auto index = sqs->overlay_damage_index.value(); + EXPECT_EQ(i - 1, index); + EXPECT_EQ(apply_transform(quad_rects[i]), + aggregated_frame.surface_damage_rect_list_[i - 1]); + } + i++; + } + } +} + // Tests that quads outside the damage rect are not ignored for cached render // pass. TEST_F(SurfaceAggregatorPartialSwapTest, NotIgnoreOutsideForCachedRenderPass) {
diff --git a/components/viz/service/transitions/surface_animation_manager.cc b/components/viz/service/transitions/surface_animation_manager.cc index 3e013e0..6f804ff 100644 --- a/components/viz/service/transitions/surface_animation_manager.cc +++ b/components/viz/service/transitions/surface_animation_manager.cc
@@ -533,7 +533,7 @@ source_pass.subtree_capture_id, source_pass.subtree_size, source_pass.has_transparent_background, source_pass.cache_render_pass, source_pass.has_damage_from_contributing_content, - source_pass.generate_mipmap); + source_pass.generate_mipmap, source_pass.has_per_quad_damage); if (source_pass.shared_quad_state_list.empty()) return copy_pass;
diff --git a/content/browser/accessibility/accessibility_event_recorder_uia_win.cc b/content/browser/accessibility/accessibility_event_recorder_uia_win.cc index 2bd11a3..cb51ac8 100644 --- a/content/browser/accessibility/accessibility_event_recorder_uia_win.cc +++ b/content/browser/accessibility/accessibility_event_recorder_uia_win.cc
@@ -94,7 +94,7 @@ base::subtle::NoBarrier_AtomicExchange(&instantiated_, 0); } -void AccessibilityEventRecorderUia::FlushAsyncEvents() { +void AccessibilityEventRecorderUia::WaitForDoneRecording() { // Pump messages via |shutdown_loop_| until the thread is complete. shutdown_loop_.Run(); base::PlatformThread::Join(thread_handle_); @@ -197,12 +197,6 @@ // Wait for shutdown signal shutdown_signal_.Wait(); - { - base::AutoLock lock{on_event_lock_}; - for (const std::string& event : event_logs_) - owner_->OnEvent(event); - } - // Cleanup uia_->RemoveAllEventHandlers(); uia_event_handler_->CleanUp(); @@ -221,10 +215,8 @@ } void AccessibilityEventRecorderUia::Thread::OnEvent(const std::string& event) { - // We need to synchronize event logging, since UIA event callbacks can be - // coming from multiple threads. - base::AutoLock lock{on_event_lock_}; - event_logs_.push_back(event); + // Pass the event to the thread-safe owner_. + owner_->OnEvent(event); } AccessibilityEventRecorderUia::Thread::EventHandler::EventHandler() {
diff --git a/content/browser/accessibility/accessibility_event_recorder_uia_win.h b/content/browser/accessibility/accessibility_event_recorder_uia_win.h index 01d7c06..e2f7541 100644 --- a/content/browser/accessibility/accessibility_event_recorder_uia_win.h +++ b/content/browser/accessibility/accessibility_event_recorder_uia_win.h
@@ -15,7 +15,6 @@ #include "base/atomicops.h" #include "base/run_loop.h" -#include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h" #include "base/threading/platform_thread.h" #include "base/win/atl.h" @@ -32,7 +31,7 @@ ~AccessibilityEventRecorderUia() override; // Called to ensure the event recorder has finished recording async events. - void FlushAsyncEvents() override; + void WaitForDoneRecording() override; private: // Used to prevent creation of multiple instances simultaneously @@ -68,10 +67,7 @@ base::OnceClosure shutdown_complete_; base::WaitableEvent shutdown_signal_; - // Thread-specific wrapper for OnEvent to handle necessary locking void OnEvent(const std::string& event); - base::Lock on_event_lock_; - std::vector<std::string> event_logs_; // An implementation of various UIA interfaces that forward event // notifications to the owning event recorder.
diff --git a/content/browser/accessibility/accessibility_tree_formatter_mac_browsertest.mm b/content/browser/accessibility/accessibility_tree_formatter_mac_browsertest.mm index 9a5f209..f5144c3 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_mac_browsertest.mm +++ b/content/browser/accessibility/accessibility_tree_formatter_mac_browsertest.mm
@@ -372,4 +372,12 @@ )~~"); } +IN_PROC_BROWSER_TEST_F(AccessibilityTreeFormatterMacBrowserTest, Script_Chain) { + TestAndCheck(R"~~(data:text/html, + <input id='input' aria-label='input'>)~~", + {{"input.AXFocusableAncestor.AXRole", SCRIPT}}, {{"*", "*"}}, + R"~~(input.AXFocusableAncestor.AXRole='AXTextField' +)~~"); +} + } // namespace content
diff --git a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h index d8a71f0..fdf1baf 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h +++ b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.h
@@ -85,6 +85,10 @@ const OptionalNSObject& value) const; private: + // Invokes a property node for a given target. + OptionalNSObject InvokeFor(const id target, + const ui::AXPropertyNode& property_node) const; + // Returns a parameterized attribute parameter by a property node. OptionalNSObject ParamByPropertyNode(const ui::AXPropertyNode&) const;
diff --git a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm index cd3f9b2..3e47fed 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm +++ b/content/browser/accessibility/accessibility_tree_formatter_utils_mac.mm
@@ -79,12 +79,14 @@ // Get a target to invoke an attribute for. If the property node doesn't // provide a target then use the default one. id target = node; - if (!property_node.target.empty()) { - target = line_indexer->NodeBy(property_node.target); + auto* current_node = &property_node; + if (property_node.IsTarget()) { + target = line_indexer->NodeBy(property_node.name_or_value); if (!target) { LOG(ERROR) << "No target in " << property_node.ToString(); return OptionalNSObject::Error(); } + current_node = property_node.next.get(); } // No target indicates the property_node is a scalar value or an AX object. @@ -93,6 +95,22 @@ return OptionalNSObject::NotApplicable(); } + while (current_node) { + auto target_optional = InvokeFor(target, *current_node); + if (!target_optional.IsNotNil()) { + LOG(ERROR) << "No target for " << current_node->ToString(); + return target_optional; + } + target = *target_optional; + current_node = current_node->next.get(); + } + + return OptionalNSObject(target); +} + +OptionalNSObject AttributeInvoker::InvokeFor( + const id target, + const AXPropertyNode& property_node) const { // Attributes. for (NSString* attribute : AttributeNamesOf(target)) { if (property_node.IsMatching(base::SysNSStringToUTF8(attribute))) { @@ -157,14 +175,14 @@ OptionalNSObject AttributeInvoker::ParamByPropertyNode( const AXPropertyNode& property_node) const { // NSAccessibility attributes always take a single parameter. - if (property_node.parameters.size() != 1) { + if (property_node.arguments.size() != 1) { LOG(ERROR) << "Failed to parse " << property_node.original_property << ": single parameter is expected"; return OptionalNSObject::Error(); } // Nested attribute case: attempt to invoke an attribute for an argument node. - const AXPropertyNode& arg_node = property_node.parameters[0]; + const AXPropertyNode& arg_node = property_node.arguments[0]; OptionalNSObject subvalue = Invoke(arg_node); if (!subvalue.IsNotApplicable()) { return subvalue; @@ -218,8 +236,8 @@ } NSMutableArray* array = - [[NSMutableArray alloc] initWithCapacity:arraynode.parameters.size()]; - for (const auto& paramnode : arraynode.parameters) { + [[NSMutableArray alloc] initWithCapacity:arraynode.arguments.size()]; + for (const auto& paramnode : arraynode.arguments) { absl::optional<int> param = paramnode.AsInt(); if (!param) { INTARRAY_FAIL(arraynode, paramnode.name_or_value + " is not a number") @@ -266,23 +284,23 @@ if (!dictnode.IsDict()) { TEXTMARKER_FAIL(dictnode, "dictionary is expected") } - if (dictnode.parameters.size() != 3) { + if (dictnode.arguments.size() != 3) { TEXTMARKER_FAIL(dictnode, "wrong number of dictionary elements") } BrowserAccessibilityCocoa* anchor_cocoa = - line_indexer->NodeBy(dictnode.parameters[0].name_or_value); + line_indexer->NodeBy(dictnode.arguments[0].name_or_value); if (!anchor_cocoa) { TEXTMARKER_FAIL(dictnode, "1st argument: wrong anchor") } - absl::optional<int> offset = dictnode.parameters[1].AsInt(); + absl::optional<int> offset = dictnode.arguments[1].AsInt(); if (!offset) { TEXTMARKER_FAIL(dictnode, "2nd argument: wrong offset") } ax::mojom::TextAffinity affinity; - const std::string& affinity_str = dictnode.parameters[2].name_or_value; + const std::string& affinity_str = dictnode.arguments[2].name_or_value; if (affinity_str == "none") { affinity = ax::mojom::TextAffinity::kNone; } else if (affinity_str == "down") {
diff --git a/content/browser/accessibility/dump_accessibility_events_browsertest.cc b/content/browser/accessibility/dump_accessibility_events_browsertest.cc index cb1a8de..c194820a 100644 --- a/content/browser/accessibility/dump_accessibility_events_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_events_browsertest.cc
@@ -105,24 +105,6 @@ std::string final_tree_; }; -bool IsRecordingComplete(ui::AXEventRecorder& event_recorder, - std::vector<std::string>& run_until) { - // If no @*-RUN-UNTIL-EVENT directives, then having any events is enough. - LOG(ERROR) << "=== IsRecordingComplete#1 run_until size=" << run_until.size(); - if (run_until.empty()) - return true; - - std::vector<std::string> event_logs = event_recorder.EventLogs(); - LOG(ERROR) << "=== IsRecordingComplete#2 Logs size=" << event_logs.size(); - - for (size_t i = 0; i < event_logs.size(); ++i) - for (size_t j = 0; j < run_until.size(); ++j) - if (event_logs[i].find(run_until[j]) != std::string::npos) - return true; - - return false; -} - std::vector<std::string> DumpAccessibilityEventsTest::Dump( std::vector<std::string>& run_until) { WebContentsImpl* web_contents = @@ -168,7 +150,7 @@ // observes either an ax::mojom::Event or ui::AXEventGenerator::Event, or // when |event_recorder| records a platform event. waiter->WaitForNotification(); - if (IsRecordingComplete(*event_recorder, run_until)) + if (event_recorder->IsRunUntilEventSatisfied(run_until)) break; } @@ -185,6 +167,7 @@ web_contents->GetRootBrowserAccessibilityManager(); manager->SignalEndOfTest(); waiter->WaitForNotification(); + event_recorder->WaitForDoneRecording(); // Save a copy of the final accessibility tree (as a text dump); we'll // log this for the user later if the test fails. @@ -192,8 +175,7 @@ // Dump the event logs, running them through any filters specified // in the HTML file. - event_recorder->FlushAsyncEvents(); - std::vector<std::string> event_logs = event_recorder->EventLogs(); + std::vector<std::string> event_logs = event_recorder->GetEventLogs(); // Sort the logs so that results are predictable. There are too many // nondeterministic things that affect the exact order of events fired,
diff --git a/content/browser/back_forward_cache_browsertest.cc b/content/browser/back_forward_cache_browsertest.cc index 2e4b5d0f..30affa7 100644 --- a/content/browser/back_forward_cache_browsertest.cc +++ b/content/browser/back_forward_cache_browsertest.cc
@@ -43,7 +43,7 @@ #include "content/common/content_navigation_policy.h" #include "content/common/render_accessibility.mojom.h" #include "content/public/browser/back_forward_cache.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/global_routing_id.h" #include "content/public/browser/idle_manager.h" #include "content/public/browser/media_session.h" @@ -9005,13 +9005,13 @@ namespace { -// Subclass of FrameServiceBase for test. -class EchoImpl final : public FrameServiceBase<mojom::Echo> { +// Subclass of DocumentServiceBase for test. +class EchoImpl final : public DocumentServiceBase<mojom::Echo> { public: EchoImpl(RenderFrameHost* render_frame_host, mojo::PendingReceiver<mojom::Echo> receiver, bool* deleted) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), deleted_(deleted) {} ~EchoImpl() final { *deleted_ = true; } @@ -9026,7 +9026,7 @@ } // namespace -IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, FrameServiceBase) { +IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DocumentServiceBase) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html"));
diff --git a/content/browser/eye_dropper_chooser_impl.cc b/content/browser/eye_dropper_chooser_impl.cc index 82b9c09..e144757 100644 --- a/content/browser/eye_dropper_chooser_impl.cc +++ b/content/browser/eye_dropper_chooser_impl.cc
@@ -39,7 +39,7 @@ EyeDropperChooserImpl::EyeDropperChooserImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::EyeDropperChooser> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)) {} + : DocumentServiceBase(render_frame_host, std::move(receiver)) {} EyeDropperChooserImpl::~EyeDropperChooserImpl() { if (callback_)
diff --git a/content/browser/eye_dropper_chooser_impl.h b/content/browser/eye_dropper_chooser_impl.h index cb3c873..ee23279 100644 --- a/content/browser/eye_dropper_chooser_impl.h +++ b/content/browser/eye_dropper_chooser_impl.h
@@ -7,8 +7,8 @@ #include <memory> +#include "content/public/browser/document_service_base.h" #include "content/public/browser/eye_dropper_listener.h" -#include "content/public/browser/frame_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/choosers/color_chooser.mojom.h" @@ -18,7 +18,7 @@ class EyeDropperListener; class EyeDropperChooserImpl final - : public FrameServiceBase<blink::mojom::EyeDropperChooser>, + : public DocumentServiceBase<blink::mojom::EyeDropperChooser>, public EyeDropperListener { public: static void Create(RenderFrameHost*,
diff --git a/content/browser/federated_learning/floc_service_impl.cc b/content/browser/federated_learning/floc_service_impl.cc index a66de61b..35e5231c 100644 --- a/content/browser/federated_learning/floc_service_impl.cc +++ b/content/browser/federated_learning/floc_service_impl.cc
@@ -16,7 +16,7 @@ FlocServiceImpl::FlocServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::FlocService> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), render_frame_host_(static_cast<RenderFrameHostImpl*>(render_frame_host)) { DCHECK(render_frame_host_); } @@ -28,7 +28,7 @@ DCHECK(render_frame_host); // The object is bound to the lifetime of |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new FlocServiceImpl(render_frame_host, std::move(receiver)); }
diff --git a/content/browser/federated_learning/floc_service_impl.h b/content/browser/federated_learning/floc_service_impl.h index 87efa16..6f1ec83 100644 --- a/content/browser/federated_learning/floc_service_impl.h +++ b/content/browser/federated_learning/floc_service_impl.h
@@ -6,7 +6,7 @@ #define CONTENT_BROWSER_FEDERATED_LEARNING_FLOC_SERVICE_IMPL_H_ #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/federated_learning/floc.mojom.h" @@ -16,7 +16,7 @@ class RenderFrameHostImpl; class CONTENT_EXPORT FlocServiceImpl final - : public FrameServiceBase<blink::mojom::FlocService> { + : public DocumentServiceBase<blink::mojom::FlocService> { public: FlocServiceImpl(RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::FlocService> receiver); @@ -29,7 +29,7 @@ void GetInterestCohort(GetInterestCohortCallback callback) override; private: - // |this| can only be destroyed by FrameServiceBase. + // |this| can only be destroyed by DocumentServiceBase. ~FlocServiceImpl() override; RenderFrameHostImpl* const render_frame_host_;
diff --git a/content/browser/hid/hid_service.cc b/content/browser/hid/hid_service.cc index f3cea98..0fc84578 100644 --- a/content/browser/hid/hid_service.cc +++ b/content/browser/hid/hid_service.cc
@@ -70,7 +70,7 @@ HidService::HidService(RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::HidService> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), origin_(render_frame_host->GetMainFrame()->GetLastCommittedOrigin()) { watchers_.set_disconnect_handler( base::BindRepeating(&HidService::OnWatcherRemoved, base::Unretained(this),
diff --git a/content/browser/hid/hid_service.h b/content/browser/hid/hid_service.h index 3fd7638..a44e90d 100644 --- a/content/browser/hid/hid_service.h +++ b/content/browser/hid/hid_service.h
@@ -10,7 +10,7 @@ #include <vector> #include "base/memory/weak_ptr.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/hid_delegate.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" @@ -26,9 +26,10 @@ // HidService provides an implementation of the HidService mojom interface. This // interface is used by Blink to implement the WebHID API. -class HidService : public content::FrameServiceBase<blink::mojom::HidService>, - public device::mojom::HidConnectionWatcher, - public HidDelegate::Observer { +class HidService + : public content::DocumentServiceBase<blink::mojom::HidService>, + public device::mojom::HidConnectionWatcher, + public HidDelegate::Observer { public: HidService(HidService&) = delete; HidService& operator=(HidService&) = delete;
diff --git a/content/browser/image_capture/image_capture_impl.cc b/content/browser/image_capture/image_capture_impl.cc index 0371396..893bd44 100644 --- a/content/browser/image_capture/image_capture_impl.cc +++ b/content/browser/image_capture/image_capture_impl.cc
@@ -151,7 +151,7 @@ ImageCaptureImpl::ImageCaptureImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<media::mojom::ImageCapture> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)) {} + : DocumentServiceBase(render_frame_host, std::move(receiver)) {} ImageCaptureImpl::~ImageCaptureImpl() = default;
diff --git a/content/browser/image_capture/image_capture_impl.h b/content/browser/image_capture/image_capture_impl.h index 1f2bf3f..2bb806f 100644 --- a/content/browser/image_capture/image_capture_impl.h +++ b/content/browser/image_capture/image_capture_impl.h
@@ -6,14 +6,14 @@ #define CONTENT_BROWSER_IMAGE_CAPTURE_IMAGE_CAPTURE_IMPL_H_ #include "base/memory/weak_ptr.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "media/capture/mojom/image_capture.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" namespace content { class ImageCaptureImpl final - : public content::FrameServiceBase<media::mojom::ImageCapture> { + : public content::DocumentServiceBase<media::mojom::ImageCapture> { public: static void Create( RenderFrameHost* render_frame_host,
diff --git a/content/browser/interest_group/ad_auction_service_impl.cc b/content/browser/interest_group/ad_auction_service_impl.cc index 669745d..c6e69cb 100644 --- a/content/browser/interest_group/ad_auction_service_impl.cc +++ b/content/browser/interest_group/ad_auction_service_impl.cc
@@ -130,7 +130,7 @@ AdAuctionServiceImpl::AdAuctionServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::AdAuctionService> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)) {} + : DocumentServiceBase(render_frame_host, std::move(receiver)) {} AdAuctionServiceImpl::~AdAuctionServiceImpl() = default; @@ -141,7 +141,7 @@ DCHECK(render_frame_host); // The object is bound to the lifetime of `render_frame_host` and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new AdAuctionServiceImpl(render_frame_host, std::move(receiver)); }
diff --git a/content/browser/interest_group/ad_auction_service_impl.h b/content/browser/interest_group/ad_auction_service_impl.h index 52bb197..971d688 100644 --- a/content/browser/interest_group/ad_auction_service_impl.h +++ b/content/browser/interest_group/ad_auction_service_impl.h
@@ -12,7 +12,7 @@ #include "content/browser/interest_group/auction_runner.h" #include "content/browser/interest_group/interest_group_manager.h" #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom-forward.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/remote.h" @@ -29,7 +29,7 @@ // Implements the AdAuctionService service called by Blink code. class CONTENT_EXPORT AdAuctionServiceImpl final - : public FrameServiceBase<blink::mojom::AdAuctionService>, + : public DocumentServiceBase<blink::mojom::AdAuctionService>, public AuctionRunner::Delegate { public: // Factory method for creating an instance of this interface that is @@ -47,17 +47,17 @@ network::mojom::URLLoaderFactory* GetTrustedURLLoaderFactory() override; auction_worklet::mojom::AuctionWorkletService* GetWorkletService() override; - using FrameServiceBase::origin; - using FrameServiceBase::render_frame_host; + using DocumentServiceBase::origin; + using DocumentServiceBase::render_frame_host; private: - // `render_frame_host` must not be null, and FrameServiceBase guarantees + // `render_frame_host` must not be null, and DocumentServiceBase guarantees // `this` will not outlive the `render_frame_host`. AdAuctionServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::AdAuctionService> receiver); - // `this` can only be destroyed by FrameServiceBase. + // `this` can only be destroyed by DocumentServiceBase. ~AdAuctionServiceImpl() override; // Deletes `auction`.
diff --git a/content/browser/interest_group/auction_runner.cc b/content/browser/interest_group/auction_runner.cc index 2254ddef..169f3505 100644 --- a/content/browser/interest_group/auction_runner.cc +++ b/content/browser/interest_group/auction_runner.cc
@@ -84,9 +84,8 @@ DCHECK(!filtered_buyers.empty()); std::unique_ptr<AuctionRunner> instance(new AuctionRunner( delegate, interest_group_manager, std::move(auction_config), - std::move(filtered_buyers), std::move(browser_signals), frame_origin, - std::move(callback))); - instance->ReadNextInterestGroup(); + std::move(browser_signals), frame_origin, std::move(callback))); + instance->ReadInterestGroups(std::move(filtered_buyers)); return instance; } @@ -94,47 +93,44 @@ Delegate* delegate, InterestGroupManager* interest_group_manager, blink::mojom::AuctionAdConfigPtr auction_config, - std::vector<url::Origin> filtered_buyers, auction_worklet::mojom::BrowserSignalsPtr browser_signals, const url::Origin& frame_origin, RunAuctionCallback callback) : delegate_(delegate), interest_group_manager_(interest_group_manager), auction_config_(std::move(auction_config)), - pending_buyers_(std::move(filtered_buyers)), browser_signals_(std::move(browser_signals)), frame_origin_(frame_origin), callback_(std::move(callback)) {} AuctionRunner::~AuctionRunner() = default; -void AuctionRunner::ReadNextInterestGroup() { - DCHECK_LT(next_pending_buyer_, pending_buyers_.size()); +void AuctionRunner::ReadInterestGroups( + std::vector<url::Origin> filtered_buyers) { + num_pending_buyers_ = filtered_buyers.size(); - interest_group_manager_->GetInterestGroupsForOwner( - pending_buyers_[next_pending_buyer_], - base::BindOnce(&AuctionRunner::OnInterestGroupRead, - weak_ptr_factory_.GetWeakPtr())); + for (const url::Origin& buyer : filtered_buyers) { + interest_group_manager_->GetInterestGroupsForOwner( + buyer, base::BindOnce(&AuctionRunner::OnInterestGroupRead, + weak_ptr_factory_.GetWeakPtr())); + } } void AuctionRunner::OnInterestGroupRead( std::vector<auction_worklet::mojom::BiddingInterestGroupPtr> interest_groups) { + DCHECK_GT(num_pending_buyers_, 0u); + --num_pending_buyers_; + for (auto bidder = std::make_move_iterator(interest_groups.begin()); bidder != std::make_move_iterator(interest_groups.end()); ++bidder) { bid_states_.emplace_back(BidState()); bid_states_.back().bidder = std::move(*bidder); } - next_pending_buyer_++; - // If more buyers in the queue, load the next one. - if (next_pending_buyer_ < pending_buyers_.size()) { - ReadNextInterestGroup(); + // Wait for more buyers to be loaded, if there are still some pending. + if (num_pending_buyers_ > 0) return; - } - - // Pending buyers are no longer needed. - pending_buyers_.clear(); // If no interest groups were found, end the auction without a winner. if (bid_states_.empty()) {
diff --git a/content/browser/interest_group/auction_runner.h b/content/browser/interest_group/auction_runner.h index 4366ce48..994cd4c3 100644 --- a/content/browser/interest_group/auction_runner.h +++ b/content/browser/interest_group/auction_runner.h
@@ -162,14 +162,14 @@ AuctionRunner(Delegate* delegate, InterestGroupManager* interest_group_manager, blink::mojom::AuctionAdConfigPtr auction_config, - std::vector<url::Origin> filtered_buyers, auction_worklet::mojom::BrowserSignalsPtr browser_signals, const url::Origin& frame_origin, RunAuctionCallback callback); - // Retrieves the next interest group in `pending_buyers_` from storage. - // OnInterestGroupRead() will be invoked with the lookup results. - void ReadNextInterestGroup(); + // Starts retrieving all interest groups owned by `filtered_buyers` from + // storage. OnInterestGroupRead() will be invoked with the lookup results for + // each buyer. + void ReadInterestGroups(std::vector<url::Origin> filtered_buyers); // Adds `interest_groups` to `bid_states_`. Continues retrieving bidders from // `pending_buyers_` if any have not been retrieved yet. Otherwise, invokes @@ -235,11 +235,10 @@ // Configuration. blink::mojom::AuctionAdConfigPtr auction_config_; - // Buyers whose interest groups need to be looked up to be added to - // `bid_states_`. - std::vector<url::Origin> pending_buyers_; - // Next entry in `pending_buyers_` to fetch the interest group for. - size_t next_pending_buyer_ = 0; + // The number of buyers with pending interest group loads from storage. + // Decremented each time OnInterestGroupRead() is invoked. The auction is + // started once this hits 0. + size_t num_pending_buyers_ = 0; auction_worklet::mojom::BrowserSignalsPtr browser_signals_; const url::Origin frame_origin_; RunAuctionCallback callback_;
diff --git a/content/browser/interest_group/interest_group_service_impl.cc b/content/browser/interest_group/interest_group_service_impl.cc index a22dc6a..0688e57 100644 --- a/content/browser/interest_group/interest_group_service_impl.cc +++ b/content/browser/interest_group/interest_group_service_impl.cc
@@ -42,7 +42,7 @@ InterestGroupServiceImpl::InterestGroupServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::RestrictedInterestGroupStore> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), interest_group_manager_(*static_cast<StoragePartitionImpl*>( render_frame_host->GetStoragePartition()) ->GetInterestGroupStorage()) {} @@ -55,7 +55,7 @@ DCHECK(render_frame_host); // The object is bound to the lifetime of |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new InterestGroupServiceImpl(render_frame_host, std::move(receiver)); }
diff --git a/content/browser/interest_group/interest_group_service_impl.h b/content/browser/interest_group/interest_group_service_impl.h index b32e9bc..d583b8e0 100644 --- a/content/browser/interest_group/interest_group_service_impl.h +++ b/content/browser/interest_group/interest_group_service_impl.h
@@ -7,7 +7,7 @@ #include "content/browser/interest_group/interest_group_manager.h" #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/interest_group/restricted_interest_group_store.mojom.h" @@ -17,7 +17,7 @@ // Implements the RestrictedInterestGroupStore service called by Blink code. class CONTENT_EXPORT InterestGroupServiceImpl final - : public FrameServiceBase<blink::mojom::RestrictedInterestGroupStore> { + : public DocumentServiceBase<blink::mojom::RestrictedInterestGroupStore> { public: // Factory method for creating an instance of this interface that is bound // to the lifetime of the frame or receiver (whichever is shorter). @@ -32,14 +32,14 @@ const std::string& name) override; private: - // `render_frame_host` must not be null, and FrameServiceBase guarantees + // `render_frame_host` must not be null, and DocumentServiceBase guarantees // `this` will not outlive the `render_frame_host`. InterestGroupServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::RestrictedInterestGroupStore> receiver); - // `this` can only be destroyed by FrameServiceBase. + // `this` can only be destroyed by DocumentServiceBase. ~InterestGroupServiceImpl() override; InterestGroupManager& interest_group_manager_;
diff --git a/content/browser/keyboard_lock/keyboard_lock_service_impl.cc b/content/browser/keyboard_lock/keyboard_lock_service_impl.cc index dc1bf9f..fb1197e 100644 --- a/content/browser/keyboard_lock/keyboard_lock_service_impl.cc +++ b/content/browser/keyboard_lock/keyboard_lock_service_impl.cc
@@ -40,7 +40,7 @@ KeyboardLockServiceImpl::KeyboardLockServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::KeyboardLockService> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), render_frame_host_(static_cast<RenderFrameHostImpl*>(render_frame_host)) { DCHECK(render_frame_host_); } @@ -52,7 +52,7 @@ DCHECK(render_frame_host); // The object is bound to the lifetime of |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new KeyboardLockServiceImpl(render_frame_host, std::move(receiver)); }
diff --git a/content/browser/keyboard_lock/keyboard_lock_service_impl.h b/content/browser/keyboard_lock/keyboard_lock_service_impl.h index 51f0efd..1d9e04d2 100644 --- a/content/browser/keyboard_lock/keyboard_lock_service_impl.h +++ b/content/browser/keyboard_lock/keyboard_lock_service_impl.h
@@ -9,7 +9,7 @@ #include <vector> #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/keyboard_lock/keyboard_lock.mojom.h" @@ -19,7 +19,7 @@ class RenderFrameHostImpl; class CONTENT_EXPORT KeyboardLockServiceImpl final - : public FrameServiceBase<blink::mojom::KeyboardLockService> { + : public DocumentServiceBase<blink::mojom::KeyboardLockService> { public: KeyboardLockServiceImpl( RenderFrameHost* render_frame_host, @@ -36,7 +36,7 @@ void GetKeyboardLayoutMap(GetKeyboardLayoutMapCallback callback) override; private: - // |this| can only be destroyed by FrameServiceBase. + // |this| can only be destroyed by DocumentServiceBase. ~KeyboardLockServiceImpl() override; RenderFrameHostImpl* const render_frame_host_;
diff --git a/content/browser/media/audio_stream_monitor_unittest.cc b/content/browser/media/audio_stream_monitor_unittest.cc index 7df7204..cf72904 100644 --- a/content/browser/media/audio_stream_monitor_unittest.cc +++ b/content/browser/media/audio_stream_monitor_unittest.cc
@@ -12,6 +12,7 @@ #include "base/callback_helpers.h" #include "base/macros.h" #include "base/test/simple_test_tick_clock.h" +#include "build/chromeos_buildflags.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/invalidate_type.h" #include "content/public/browser/web_contents_delegate.h" @@ -20,6 +21,10 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +#include "chromeos/lacros/lacros_test_helper.h" +#endif + using ::testing::InvokeWithoutArgs; namespace content { @@ -167,6 +172,11 @@ EXPECT_FALSE(monitor_->WasRecentlyAudible()); } +#if BUILDFLAG(IS_CHROMEOS_LACROS) + // Instantiate LacrosService for WakeLock support. + chromeos::ScopedLacrosServiceTestHelper scoped_lacros_service_test_helper_; +#endif + MockWebContentsDelegate mock_web_contents_delegate_; base::SimpleTestTickClock clock_;
diff --git a/content/browser/media/capture/frame_sink_video_capture_device_unittest.cc b/content/browser/media/capture/frame_sink_video_capture_device_unittest.cc index b59069c..85539e4 100644 --- a/content/browser/media/capture/frame_sink_video_capture_device_unittest.cc +++ b/content/browser/media/capture/frame_sink_video_capture_device_unittest.cc
@@ -11,6 +11,7 @@ #include "base/containers/flat_map.h" #include "base/memory/read_only_shared_memory_region.h" #include "base/memory/shared_memory_mapping.h" +#include "build/chromeos_buildflags.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/browser_task_environment.h" @@ -28,6 +29,10 @@ #include "ui/gfx/geometry/size.h" #include "ui/gfx/native_widget_types.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +#include "chromeos/lacros/lacros_test_helper.h" +#endif + using testing::_; using testing::ByRef; using testing::Eq; @@ -427,6 +432,11 @@ // See the threading notes at top of this file. BrowserTaskEnvironment task_environment_; +#if BUILDFLAG(IS_CHROMEOS_LACROS) + // Instantiate LacrosService for WakeLock support. + chromeos::ScopedLacrosServiceTestHelper scoped_lacros_service_test_helper_; +#endif + NiceMock<MockFrameSinkVideoCapturer> capturer_; std::unique_ptr<FrameSinkVideoCaptureDevice> device_; };
diff --git a/content/browser/media/cdm_storage_impl.cc b/content/browser/media/cdm_storage_impl.cc index 4ed0008..4337bf3 100644 --- a/content/browser/media/cdm_storage_impl.cc +++ b/content/browser/media/cdm_storage_impl.cc
@@ -77,7 +77,7 @@ const std::string& cdm_file_system_id, scoped_refptr<storage::FileSystemContext> file_system_context, mojo::PendingReceiver<media::mojom::CdmStorage> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), cdm_file_system_id_(cdm_file_system_id), file_system_context_(std::move(file_system_context)), child_process_id_(render_frame_host->GetProcess()->GetID()) {}
diff --git a/content/browser/media/cdm_storage_impl.h b/content/browser/media/cdm_storage_impl.h index 49f7886e..b4294275 100644 --- a/content/browser/media/cdm_storage_impl.h +++ b/content/browser/media/cdm_storage_impl.h
@@ -14,7 +14,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "media/mojo/mojom/cdm_storage.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/unique_associated_receiver_set.h" @@ -31,7 +31,7 @@ // PluginPrivateFileSystem for backwards compatibility with CDMs running // as a pepper plugin. class CONTENT_EXPORT CdmStorageImpl final - : public content::FrameServiceBase<media::mojom::CdmStorage> { + : public content::DocumentServiceBase<media::mojom::CdmStorage> { public: // Check if |cdm_file_system_id| is valid.
diff --git a/content/browser/media/webaudio/audio_context_manager_impl.cc b/content/browser/media/webaudio/audio_context_manager_impl.cc index 24ee4ea..b4133d0 100644 --- a/content/browser/media/webaudio/audio_context_manager_impl.cc +++ b/content/browser/media/webaudio/audio_context_manager_impl.cc
@@ -35,14 +35,14 @@ DCHECK(render_frame_host); // The object is bound to the lifetime of |render_frame_host| and the mojo - // connection. See FrameServiceBase for details. + // connection. See DocumentServiceBase for details. new AudioContextManagerImpl(render_frame_host, std::move(receiver)); } AudioContextManagerImpl::AudioContextManagerImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::AudioContextManager> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), render_frame_host_impl_( static_cast<RenderFrameHostImpl*>(render_frame_host)), clock_(base::DefaultTickClock::GetInstance()) {
diff --git a/content/browser/media/webaudio/audio_context_manager_impl.h b/content/browser/media/webaudio/audio_context_manager_impl.h index ffd7fb6..b0c495b0 100644 --- a/content/browser/media/webaudio/audio_context_manager_impl.h +++ b/content/browser/media/webaudio/audio_context_manager_impl.h
@@ -6,7 +6,7 @@ #define CONTENT_BROWSER_MEDIA_WEBAUDIO_AUDIO_CONTEXT_MANAGER_IMPL_H_ #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/webaudio/audio_context_manager.mojom.h" @@ -26,7 +26,7 @@ // We do not expect to see more than 3~4 AudioContexts per render frame, so // handling multiple contexts would not be a significant bottle neck. class CONTENT_EXPORT AudioContextManagerImpl final - : public content::FrameServiceBase<blink::mojom::AudioContextManager> { + : public content::DocumentServiceBase<blink::mojom::AudioContextManager> { public: explicit AudioContextManagerImpl( RenderFrameHost* render_frame_host,
diff --git a/content/browser/picture_in_picture/picture_in_picture_service_impl.cc b/content/browser/picture_in_picture/picture_in_picture_service_impl.cc index 99339af..7d0850e 100644 --- a/content/browser/picture_in_picture/picture_in_picture_service_impl.cc +++ b/content/browser/picture_in_picture/picture_in_picture_service_impl.cc
@@ -65,7 +65,7 @@ PictureInPictureServiceImpl::PictureInPictureServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::PictureInPictureService> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)) {} + : DocumentServiceBase(render_frame_host, std::move(receiver)) {} PictureInPictureServiceImpl::~PictureInPictureServiceImpl() { // If the service is destroyed because the frame was destroyed, the session
diff --git a/content/browser/picture_in_picture/picture_in_picture_service_impl.h b/content/browser/picture_in_picture/picture_in_picture_service_impl.h index 099f359c..fc07b31 100644 --- a/content/browser/picture_in_picture/picture_in_picture_service_impl.h +++ b/content/browser/picture_in_picture/picture_in_picture_service_impl.h
@@ -6,7 +6,7 @@ #define CONTENT_BROWSER_PICTURE_IN_PICTURE_PICTURE_IN_PICTURE_SERVICE_IMPL_H_ #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "media/mojo/mojom/media_player.mojom.h" #include "mojo/public/cpp/bindings/pending_associated_remote.h" #include "mojo/public/cpp/bindings/pending_receiver.h" @@ -24,9 +24,10 @@ // killed given that the PictureInPictureWindowControllerImpl is // WebContents-bound instead of RenderFrameHost. // PictureInPictureServiceImpl owns itself. It self-destruct as needed, see the -// FrameServiceBase's documentation for more information. +// DocumentServiceBase's documentation for more information. class CONTENT_EXPORT PictureInPictureServiceImpl final - : public content::FrameServiceBase<blink::mojom::PictureInPictureService> { + : public content::DocumentServiceBase< + blink::mojom::PictureInPictureService> { public: static void Create( RenderFrameHost*,
diff --git a/content/browser/prerender/prerender_host_unittest.cc b/content/browser/prerender/prerender_host_unittest.cc index 3da652d..98b8864 100644 --- a/content/browser/prerender/prerender_host_unittest.cc +++ b/content/browser/prerender/prerender_host_unittest.cc
@@ -223,5 +223,57 @@ EXPECT_FALSE(subframe_nav_sim->IsDeferred()); } +// Tests that an activation can successfully commit after the prerendering page +// has updated its PageState. +TEST_F(PrerenderHostTest, ActivationAfterPageStateUpdate) { + std::unique_ptr<TestWebContents> web_contents = + CreateWebContents(GURL("https://example.com/")); + RenderFrameHostImpl* initiator_rfh = web_contents->GetMainFrame(); + PrerenderHostRegistry* registry = web_contents->GetPrerenderHostRegistry(); + + // Start prerendering a page. + const GURL kPrerenderingUrl("https://example.com/next"); + auto attributes = blink::mojom::PrerenderAttributes::New(); + attributes->url = kPrerenderingUrl; + const int prerender_frame_tree_node_id = + registry->CreateAndStartHost(std::move(attributes), *initiator_rfh); + PrerenderHost* prerender_host = + registry->FindNonReservedHostById(prerender_frame_tree_node_id); + CommitPrerenderNavigation(*prerender_host); + + FrameTreeNode* prerender_root_ftn = + FrameTreeNode::GloballyFindByID(prerender_frame_tree_node_id); + RenderFrameHostImpl* prerender_rfh = prerender_root_ftn->current_frame_host(); + NavigationEntryImpl* prerender_nav_entry = + prerender_root_ftn->frame_tree()->controller().GetLastCommittedEntry(); + FrameNavigationEntry* prerender_root_fne = + prerender_nav_entry->GetFrameEntry(prerender_root_ftn); + + blink::PageState page_state = + blink::PageState::CreateForTestingWithSequenceNumbers( + GURL("about:blank"), prerender_root_fne->item_sequence_number(), + prerender_root_fne->document_sequence_number()); + + // Update PageState for prerender RFH, causing it to become different from + // the one stored in RFH's last commit params. + static_cast<mojom::FrameHost*>(prerender_rfh)->UpdateState(page_state); + + // Perform a navigation in the primary frame tree which activates the + // prerendered page. The main expectation is that this navigation commits + // successfully and doesn't hit any DCHECKs. + NavigationSimulatorImpl::NavigateAndCommitFromBrowser(web_contents.get(), + kPrerenderingUrl); + ExpectFinalStatus(PrerenderHost::FinalStatus::kActivated); + + // Ensure that the the page_state was preserved. + EXPECT_EQ(web_contents->GetMainFrame(), prerender_rfh); + NavigationEntryImpl* activated_nav_entry = + web_contents->GetController().GetLastCommittedEntry(); + EXPECT_EQ( + page_state, + activated_nav_entry->GetFrameEntry(web_contents->GetFrameTree()->root()) + ->page_state()); +} + } // namespace } // namespace content
diff --git a/content/browser/renderer_host/frame_service_base_unittest.cc b/content/browser/renderer_host/document_service_base_unittest.cc similarity index 85% rename from content/browser/renderer_host/frame_service_base_unittest.cc rename to content/browser/renderer_host/document_service_base_unittest.cc index afd84a06..5489a675 100644 --- a/content/browser/renderer_host/frame_service_base_unittest.cc +++ b/content/browser/renderer_host/document_service_base_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 "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "base/bind.h" #include "base/run_loop.h" @@ -17,7 +17,7 @@ #include "mojo/public/cpp/bindings/remote.h" #include "url/gurl.h" -// Unit test for FrameServiceBase in content/public/browser. +// Unit test for DocumentServiceBase in content/public/browser. namespace content { @@ -26,13 +26,13 @@ const char kFooOrigin[] = "https://foo.com"; const char kBarOrigin[] = "https://bar.com"; -// Subclass of FrameServiceBase for test. -class EchoImpl final : public FrameServiceBase<mojom::Echo> { +// Subclass of DocumentServiceBase for test. +class EchoImpl final : public DocumentServiceBase<mojom::Echo> { public: EchoImpl(RenderFrameHost* render_frame_host, mojo::PendingReceiver<mojom::Echo> receiver, base::OnceClosure destruction_cb) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), destruction_cb_(std::move(destruction_cb)) {} ~EchoImpl() final { std::move(destruction_cb_).Run(); } @@ -67,7 +67,7 @@ } // namespace -class FrameServiceBaseTest : public RenderViewHostTestHarness { +class DocumentServiceBaseTest : public RenderViewHostTestHarness { protected: void SetUp() final { RenderViewHostTestHarness::SetUp(); @@ -83,7 +83,7 @@ void CreateEchoImpl(RenderFrameHost* rfh) { DCHECK(!is_echo_impl_alive_); new EchoImpl(rfh, echo_remote_.BindNewPipeAndPassReceiver(), - base::BindOnce(&FrameServiceBaseTest::OnEchoImplDestructed, + base::BindOnce(&DocumentServiceBaseTest::OnEchoImplDestructed, base::Unretained(this))); is_echo_impl_alive_ = true; } @@ -103,13 +103,13 @@ bool is_echo_impl_alive_ = false; }; -TEST_F(FrameServiceBaseTest, ConnectionError) { +TEST_F(DocumentServiceBaseTest, ConnectionError) { CreateEchoImpl(main_rfh_); ResetConnection(); EXPECT_FALSE(is_echo_impl_alive_); } -TEST_F(FrameServiceBaseTest, RenderFrameDeleted) { +TEST_F(DocumentServiceBaseTest, RenderFrameDeleted) { // Needs to create a child frame so we can delete it using DetachFrame() // because it is not allowed to detach the main frame. RenderFrameHost* child_rfh = AddChildFrame(main_rfh_, GURL(kBarOrigin)); @@ -118,7 +118,7 @@ EXPECT_FALSE(is_echo_impl_alive_); } -TEST_F(FrameServiceBaseTest, DidFinishNavigation) { +TEST_F(DocumentServiceBaseTest, DidFinishNavigation) { // When a page enters the BackForwardCache, the RenderFrameHost is not // deleted. web_contents()->GetController().GetBackForwardCache().DisableForTesting( @@ -128,7 +128,7 @@ EXPECT_FALSE(is_echo_impl_alive_); } -TEST_F(FrameServiceBaseTest, SameDocumentNavigation) { +TEST_F(DocumentServiceBaseTest, SameDocumentNavigation) { CreateEchoImpl(main_rfh_); // Must use the same origin to simulate same document navigation. @@ -140,7 +140,7 @@ EXPECT_TRUE(is_echo_impl_alive_); } -TEST_F(FrameServiceBaseTest, FailedNavigation) { +TEST_F(DocumentServiceBaseTest, FailedNavigation) { CreateEchoImpl(main_rfh_); auto navigation_simulator = @@ -151,7 +151,7 @@ EXPECT_FALSE(is_echo_impl_alive_); } -TEST_F(FrameServiceBaseTest, DeleteContents) { +TEST_F(DocumentServiceBaseTest, DeleteContents) { CreateEchoImpl(main_rfh_); DeleteContents(); EXPECT_FALSE(is_echo_impl_alive_);
diff --git a/content/browser/renderer_host/media/media_stream_ui_proxy_unittest.cc b/content/browser/renderer_host/media/media_stream_ui_proxy_unittest.cc index 65864104..53d0de1 100644 --- a/content/browser/renderer_host/media/media_stream_ui_proxy_unittest.cc +++ b/content/browser/renderer_host/media/media_stream_ui_proxy_unittest.cc
@@ -70,16 +70,14 @@ const std::string& label, std::vector<DesktopMediaID> screen_capture_ids, StateChangeCallback state_change) override { - // gmock cannot handle move-only types: - return MockOnStarted(base::AdaptCallbackForRepeating(std::move(stop)), - source); + return MockOnStarted(std::move(stop), source); } void OnDeviceStopped(const std::string& label, const DesktopMediaID& media_id) override {} MOCK_METHOD2(MockOnStarted, - gfx::NativeViewId(base::RepeatingClosure stop, + gfx::NativeViewId(base::OnceClosure stop, MediaStreamUI::SourceCallback source)); }; @@ -260,8 +258,11 @@ devices.push_back(blink::MediaStreamDevice( blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE, "Mic", "Mic")); auto ui = std::make_unique<MockMediaStreamUI>(); - EXPECT_CALL(*ui, MockOnStarted(_, _)) - .WillOnce(testing::DoAll(MoveArg<0>(&stop_callback), Return(0))); + EXPECT_CALL(*ui, MockOnStarted(_, _)).WillOnce([&](auto closure, auto) { + stop_callback = std::move(closure); + return 0; + }); + std::move(callback).Run(devices, blink::mojom::MediaStreamRequestResult::OK, std::move(ui)); @@ -357,8 +358,10 @@ blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE, "fake_desktop_video_device", "Fake Desktop Video Device")); auto ui = std::make_unique<MockMediaStreamUI>(); - EXPECT_CALL(*ui, MockOnStarted(_, _)) - .WillOnce(testing::DoAll(SaveArg<1>(&source_callback), Return(0))); + EXPECT_CALL(*ui, MockOnStarted(_, _)).WillOnce([&](auto, auto callback) { + source_callback = std::move(callback); + return 0; + }); std::move(callback).Run(devices, blink::mojom::MediaStreamRequestResult::OK, std::move(ui));
diff --git a/content/browser/renderer_host/media/render_frame_audio_input_stream_factory_unittest.cc b/content/browser/renderer_host/media/render_frame_audio_input_stream_factory_unittest.cc index 9e9c600..2b1c29a8 100644 --- a/content/browser/renderer_host/media/render_frame_audio_input_stream_factory_unittest.cc +++ b/content/browser/renderer_host/media/render_frame_audio_input_stream_factory_unittest.cc
@@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/run_loop.h" #include "build/build_config.h" +#include "build/chromeos_buildflags.h" #include "content/browser/media/forwarding_audio_stream_factory.h" #include "content/browser/renderer_host/media/audio_input_device_manager.h" #include "content/browser/renderer_host/media/media_stream_manager.h" @@ -40,6 +41,10 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +#include "chromeos/lacros/lacros_test_helper.h" +#endif + namespace content { // RenderViewHostTestHarness works poorly on Android. @@ -179,6 +184,10 @@ const std::string kDeviceName = "test name"; const bool kAGC = false; const uint32_t kSharedMemoryCount = 123; +#if BUILDFLAG(IS_CHROMEOS_LACROS) + // Instantiate LacrosService for WakeLock support. + chromeos::ScopedLacrosServiceTestHelper scoped_lacros_service_test_helper_; +#endif MockStreamFactory audio_service_stream_factory_; media::FakeAudioLogFactory log_factory_; media::FakeAudioManager audio_manager_;
diff --git a/content/browser/renderer_host/navigation_controller_impl.cc b/content/browser/renderer_host/navigation_controller_impl.cc index 162cc8e6..756ed3d 100644 --- a/content/browser/renderer_host/navigation_controller_impl.cc +++ b/content/browser/renderer_host/navigation_controller_impl.cc
@@ -152,10 +152,10 @@ return false; } -// Returns true this navigation should be treated as a reload. For e.g. +// Returns true if this navigation should be treated as a reload. For e.g. // navigating to the last committed url via the address bar or clicking on a -// link which results in a navigation to the last committed or pending -// navigation, etc. +// link which results in a navigation to the last committed URL (but wasn't +// converted to do a replacement navigation in the renderer), etc. // |node| is the FrameTreeNode which is navigating. |url|, |virtual_url|, // |base_url_for_data_url|, |transition_type| correspond to the new navigation // (i.e. the pending NavigationEntry). |last_committed_entry| is the last @@ -166,10 +166,11 @@ const GURL& base_url_for_data_url, ui::PageTransition transition_type, bool is_post, - bool is_reload, - bool is_navigation_to_existing_entry, + bool should_replace_current_entry, NavigationEntryImpl* last_committed_entry) { - if (is_reload || is_navigation_to_existing_entry) + // Navigations intended to do a replacement shouldn't be converted to do a + // reload. + if (should_replace_current_entry) return false; // Only convert to reload if at least one navigation committed. if (!last_committed_entry) @@ -3162,8 +3163,7 @@ params.base_url_for_data_url, params.transition_type, params.load_type == NavigationController::LOAD_TYPE_HTTP_POST /* is_post */, - false /* is_reload */, false /* is_navigation_to_existing_entry */, - GetLastCommittedEntry())) { + params.should_replace_current_entry, GetLastCommittedEntry())) { reload_type = ReloadType::NORMAL; pending_entry_->set_reload_type(reload_type);
diff --git a/content/browser/renderer_host/navigation_controller_impl_browsertest.cc b/content/browser/renderer_host/navigation_controller_impl_browsertest.cc index 9db9a13..f674e7d3 100644 --- a/content/browser/renderer_host/navigation_controller_impl_browsertest.cc +++ b/content/browser/renderer_host/navigation_controller_impl_browsertest.cc
@@ -2188,7 +2188,8 @@ } // Verify that navigations to the same URL are correctly classified as -// EXISTING_ENTRY. +// EXISTING_ENTRY (if it becomes a reload) or NEW_ENTRY (if it becomes a +// replacement navigation). IN_PROC_BROWSER_TEST_P(NavigationControllerBrowserTest, NavigationTypeClassification_ExistingEntrySameURL) { GURL url1(embedded_test_server()->GetURL( @@ -2318,6 +2319,133 @@ // We lost the history.state value from before the failed navigation. EXPECT_EQ(nullptr, EvalJs(root, "history.state")); + previous_entry = controller.GetLastCommittedEntry(); + } + + // Replace history.state to "foo". + ReplaceState(root, "foo"); + EXPECT_EQ("foo", EvalJs(root, "history.state")); + previous_entry = controller.GetLastCommittedEntry(); + + { + // Navigate to the same URL (browser-initiated) with LoadURLParams, setting + // should_replace_current_entry to true. The browser should not convert this + // navigation to do a reload, and should continue to do replacement. + FrameNavigateParamsCapturer capturer(root); + NavigationController::LoadURLParams params(url1); + params.transition_type = ui::PageTransitionFromInt( + ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); + params.should_replace_current_entry = true; + contents()->GetController().LoadURLWithParams(params); + capturer.Wait(); + // We're classifying this as NEW_ENTRY. + EXPECT_EQ(NAVIGATION_TYPE_NEW_ENTRY, capturer.navigation_type()); + + // The navigation replaced the previously committed entry with a new entry. + EXPECT_TRUE(capturer.did_replace_entry()); + EXPECT_NE(previous_entry, controller.GetLastCommittedEntry()); + EXPECT_EQ(2, controller.GetEntryCount()); + + // We keep the same history.state value. + EXPECT_EQ("foo", EvalJs(root, "history.state")); + previous_entry = controller.GetLastCommittedEntry(); + } + + { + // Navigate to the same URL (browser-initiated) with LoadURLParams, setting + // should_replace_current_entry to true, but hit a network error. The + // browser will convert this navigation to do a reload, but ended up doing + // replacement instead. + auto url_loader_interceptor = std::make_unique<URLLoaderInterceptor>( + base::BindRepeating([](URLLoaderInterceptor::RequestParams* params) { + network::URLLoaderCompletionStatus status; + status.error_code = net::ERR_NOT_IMPLEMENTED; + params->client->OnComplete(status); + return true; + })); + + FrameNavigateParamsCapturer capturer(root); + NavigationController::LoadURLParams params(url1); + params.transition_type = ui::PageTransitionFromInt( + ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); + params.should_replace_current_entry = true; + contents()->GetController().LoadURLWithParams(params); + capturer.Wait(); + + // We're classifying this as NEW_ENTRY. + EXPECT_EQ(NAVIGATION_TYPE_NEW_ENTRY, capturer.navigation_type()); + + // The navigation replaced the previously committed entry with a new entry + // because the navigation resulted in an error page. + EXPECT_TRUE(capturer.did_replace_entry()); + EXPECT_NE(previous_entry, controller.GetLastCommittedEntry()); + EXPECT_EQ(2, controller.GetEntryCount()); + + url_loader_interceptor.reset(); + } +} + +// Verify that navigations to the same WebUI URL are correctly classified as +// EXISTING_ENTRY (if it becomes a reload) or NEW_ENTRY (if it becomes a +// replacement navigation). +IN_PROC_BROWSER_TEST_P( + NavigationControllerBrowserTest, + NavigationTypeClassification_ExistingEntrySameURL_WebUI) { + // Navigate to a WebUI page. + GURL web_ui_url(std::string(kChromeUIScheme) + "://" + + std::string(kChromeUIGpuHost)); + EXPECT_TRUE(NavigateToURL(shell(), web_ui_url)); + + NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( + shell()->web_contents()->GetController()); + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) + ->GetFrameTree() + ->root(); + EXPECT_EQ(1, controller.GetEntryCount()); + + NavigationEntryImpl* previous_entry = controller.GetLastCommittedEntry(); + + { + // Navigate to the same Web UI URL (browser-initiated). + FrameNavigateParamsCapturer capturer(root); + EXPECT_TRUE(NavigateToURL(shell(), web_ui_url)); + capturer.Wait(); + // The navigation got converted into a reload, and we're classifying this as + // EXISTING_ENTRY. + EXPECT_EQ(NAVIGATION_TYPE_EXISTING_ENTRY, capturer.navigation_type()); + + // Ensure the pending entry was cleared after commit. + EXPECT_FALSE(shell()->web_contents()->GetController().GetPendingEntry()); + + // We reuse the last committed entry for this navigation. + EXPECT_FALSE(capturer.did_replace_entry()); + EXPECT_EQ(previous_entry, controller.GetLastCommittedEntry()); + EXPECT_EQ(1, controller.GetEntryCount()); + + previous_entry = controller.GetLastCommittedEntry(); + } + + { + // Navigate to the same WebUI URL (renderer-initiated). This will go through + // the "browser-initiated" path in the browser (OpenURL instead of + // BeginNavigation), but should still behave like a renderer-initiated + // navigation, which will do a replacement instead of reload for same-URL + // navigations. + FrameNavigateParamsCapturer capturer(root); + EXPECT_TRUE(ExecJs(contents(), JsReplace("location.href = $1", web_ui_url), + EXECUTE_SCRIPT_DEFAULT_OPTIONS, 1 /* world_id */)); + capturer.Wait(); + // We're classifying this as NEW_ENTRY. + EXPECT_EQ(NAVIGATION_TYPE_NEW_ENTRY, capturer.navigation_type()); + + // The navigation replaced the previously committed entry with a new entry. + // This differs than the browser-initiated case's behavior, but it's OK. + // The renderer-initiated navigation follows the spec at + // https://html.spec.whatwg.org/#navigating-across-documents:hh-replace-3, + // while the browser-initiated version got converted into a reload. + EXPECT_TRUE(capturer.did_replace_entry()); + EXPECT_NE(previous_entry, controller.GetLastCommittedEntry()); + EXPECT_EQ(1, controller.GetEntryCount()); } }
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc index 3d769f1..8974f4e 100644 --- a/content/browser/renderer_host/navigation_request.cc +++ b/content/browser/renderer_host/navigation_request.cc
@@ -12,7 +12,6 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/debug/alias.h" -#include "base/debug/crash_logging.h" #include "base/debug/dump_without_crashing.h" #include "base/feature_list.h" #include "base/files/file_path.h" @@ -607,28 +606,6 @@ return crash_key; } -class ScopedNavigationRequestCrashKeys { - public: - explicit ScopedNavigationRequestCrashKeys( - NavigationRequest* navigation_request) - : initiator_origin_( - GetNavigationRequestInitiatorCrashKey(), - base::OptionalOrNullptr(navigation_request->GetInitiatorOrigin())), - url_(GetNavigationRequestUrlCrashKey(), - navigation_request->GetURL().possibly_invalid_spec()) {} - ~ScopedNavigationRequestCrashKeys() = default; - - // No copy constructor and no copy assignment operator. - ScopedNavigationRequestCrashKeys(const ScopedNavigationRequestCrashKeys&) = - delete; - ScopedNavigationRequestCrashKeys& operator=( - const ScopedNavigationRequestCrashKeys&) = delete; - - private: - url::debug::ScopedOriginCrashKey initiator_origin_; - base::debug::ScopedCrashKeyString url_; -}; - // Start a new nested async event with the given name. void EnterChildTraceEvent(const char* name, NavigationRequest* request) { // Tracing no longer outputs the end event name, so we can simply pass an @@ -1209,7 +1186,10 @@ DCHECK(!blink::IsRendererDebugURL(common_params_->url)); DCHECK(common_params_->method == "POST" || !common_params_->post_data); DCHECK_EQ(common_params_->url, commit_params_->original_url); - ScopedNavigationRequestCrashKeys crash_keys(this); + // Navigations can't be a replacement and a reload at the same time. + DCHECK(!common_params_->should_replace_current_entry || + !NavigationTypeUtils::IsReload(common_params_->navigation_type)); + ScopedCrashKeys crash_keys(*this); // There should be no navigations to about:newtab, about:version or other // similar URLs (see https://crbug.com/1145717): @@ -1515,7 +1495,7 @@ EnterChildTraceEvent("BeginNavigation", this); DCHECK(!loader_); DCHECK(!render_frame_host_); - ScopedNavigationRequestCrashKeys crash_keys(this); + ScopedCrashKeys crash_keys(*this); SetState(WILL_START_NAVIGATION); @@ -2035,7 +2015,7 @@ const net::RedirectInfo& redirect_info, const net::NetworkIsolationKey& network_isolation_key, network::mojom::URLResponseHeadPtr response_head) { - ScopedNavigationRequestCrashKeys crash_keys(this); + ScopedCrashKeys crash_keys(*this); // Sanity check - this can only be set at commit time. DCHECK(!auth_challenge_info_); @@ -2561,7 +2541,7 @@ net::NetworkIsolationKey network_isolation_key, absl::optional<SubresourceLoaderParams> subresource_loader_params, EarlyHints early_hints) { - ScopedNavigationRequestCrashKeys crash_keys(this); + ScopedCrashKeys crash_keys(*this); // The |loader_|'s job is finished. It must not call the NavigationRequest // anymore from now. @@ -3033,7 +3013,7 @@ CheckStateTransition(WILL_FAIL_REQUEST); DCHECK(!(status.error_code == net::ERR_ABORTED && error_page_content.has_value())); - ScopedNavigationRequestCrashKeys crash_keys(this); + ScopedCrashKeys crash_keys(*this); // The request failed, the |loader_| must not call the NavigationRequest // anymore from now while the error page is being loaded. @@ -5553,8 +5533,15 @@ // TODO(https://crbug.com/1179428): Investigate when a new entry should // replace an old one when prerendering a page. params->did_create_new_entry = true; - // Unlike bfcache restore, Prerendering makes a new navigation entry, so it - // doesn't need to set params->page_state.. + // Prerendering already has a navigation entry which has correct PageState. + // Set params->page_state accordingly to ensure that DCHECKs expecting them to + // match are happy. + // Note: |params| are using last commit params as a basis (via + // TakeLastCommitParams call), which have a page state from the last commit, + // but the page state might have been updated since the last commit. + params->page_state = + prerender_navigation_entry_->GetFrameEntry(frame_tree_node()) + ->page_state(); return params; } @@ -6331,4 +6318,14 @@ console_messages_.clear(); } +NavigationRequest::ScopedCrashKeys::ScopedCrashKeys( + NavigationRequest& navigation_request) + : initiator_origin_( + GetNavigationRequestInitiatorCrashKey(), + base::OptionalOrNullptr(navigation_request.GetInitiatorOrigin())), + url_(GetNavigationRequestUrlCrashKey(), + navigation_request.GetURL().possibly_invalid_spec()) {} + +NavigationRequest::ScopedCrashKeys::~ScopedCrashKeys() = default; + } // namespace content
diff --git a/content/browser/renderer_host/navigation_request.h b/content/browser/renderer_host/navigation_request.h index 2299438..371ec4f 100644 --- a/content/browser/renderer_host/navigation_request.h +++ b/content/browser/renderer_host/navigation_request.h
@@ -11,6 +11,7 @@ #include "base/callback.h" #include "base/callback_forward.h" +#include "base/debug/crash_logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -62,6 +63,7 @@ #include "third_party/blink/public/common/tokens/tokens.h" #include "third_party/blink/public/mojom/loader/mixed_content.mojom-forward.h" #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" +#include "url/origin.h" #if defined(OS_ANDROID) #include "base/android/scoped_java_ref.h" @@ -892,6 +894,24 @@ void RenderFallbackContentForObjectTag(); + // Helper for logging crash keys related to a NavigationRequest (e.g. + // "navigation_request_url" and "navigation_request_initiator"). The crash + // keys will be logged if a ScopedCrashKeys instance exists when a crash or + // DumpWithoutCrashing happens. + class ScopedCrashKeys { + public: + explicit ScopedCrashKeys(NavigationRequest& navigation_request); + ~ScopedCrashKeys(); + + // No copy constructor and no copy assignment operator. + ScopedCrashKeys(const ScopedCrashKeys&) = delete; + ScopedCrashKeys& operator=(const ScopedCrashKeys&) = delete; + + private: + url::debug::ScopedOriginCrashKey initiator_origin_; + base::debug::ScopedCrashKeyString url_; + }; + private: friend class NavigationRequestTest;
diff --git a/content/browser/renderer_host/page_impl_browsertest.cc b/content/browser/renderer_host/page_impl_browsertest.cc index cb0d745..7e0f8dd 100644 --- a/content/browser/renderer_host/page_impl_browsertest.cc +++ b/content/browser/renderer_host/page_impl_browsertest.cc
@@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/test/scoped_feature_list.h" +#include "content/browser/renderer_host/frame_tree.h" #include "content/browser/renderer_host/frame_tree_node.h" #include "content/browser/renderer_host/navigation_request.h" #include "content/browser/renderer_host/render_frame_host_impl.h" @@ -20,6 +21,7 @@ #include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test_utils.h" #include "content/public/test/render_frame_host_test_support.h" +#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_utils.h" #include "content/public/test/url_loader_interceptor.h" #include "content/shell/browser/shell.h" @@ -49,7 +51,7 @@ }; // Test that Page objects are same for main RenderFrameHosts and subframes which -// belong to the same page. +// belong to the same Page. IN_PROC_BROWSER_TEST_F(PageImplTest, AllFramesBelongToTheSamePage) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL( @@ -67,4 +69,232 @@ EXPECT_EQ(&page_a, &page_b); } +// Test that the Page object doesn't change for new subframe RFHs after +// subframes does a cross-site or same-site navigation. +// +// 1) Navigate to A(A1, B). +// 2) Navigate cross site A1 to C. +// 3) Navigate same site B to B2. +IN_PROC_BROWSER_TEST_F(PageImplTest, PageObjectAfterSubframeNavigation) { + ASSERT_TRUE(embedded_test_server()->Start()); + + // 1) Navigate to A1(A2, B). + GURL main_url(embedded_test_server()->GetURL( + "a.com", "/cross_site_iframe_factory.html?a(a,b)")); + EXPECT_TRUE(NavigateToURL(shell(), main_url)); + RenderFrameHostImpl* rfh_a = top_frame_host(); + RenderFrameHostImpl* rfh_a2 = rfh_a->child_at(0)->current_frame_host(); + RenderFrameHostImpl* rfh_b = rfh_a->child_at(1)->current_frame_host(); + + // It is safe to obtain the root frame tree node here, as it doesn't change. + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); + + // 2) Check that Page for A1, A2, B point to same object. + PageImpl& page_a = rfh_a->GetPage(); + PageImpl& page_a2 = rfh_a2->GetPage(); + PageImpl& page_b = rfh_b->GetPage(); + EXPECT_EQ(&page_a, &page_a2); + EXPECT_EQ(&page_a2, &page_b); + + // 3) Navigate subframe cross-site from A2 -> C. + GURL url_c = embedded_test_server()->GetURL("c.com", "/title1.html"); + EXPECT_TRUE(NavigateToURLFromRenderer(root->child_at(0), url_c)); + + // 4) Page object of new subframe C should be same as page_a. + RenderFrameHostImpl* rfh_c = rfh_a->child_at(0)->current_frame_host(); + PageImpl& page_c = rfh_c->GetPage(); + EXPECT_EQ(&page_c, &page_a); + + // 5) Navigate subframe same-site from B -> B2. + GURL url_b = embedded_test_server()->GetURL("b.com", "/title2.html"); + EXPECT_TRUE(NavigateToURLFromRenderer(root->child_at(1), url_b)); + + // 6) Page object of new subframe B2 should be same as page_a. + RenderFrameHostImpl* rfh_b2 = rfh_a->child_at(1)->current_frame_host(); + PageImpl& page_b2 = rfh_b2->GetPage(); + EXPECT_EQ(&page_b2, &page_a); +} + +// Test that Page object remains the same for pending page before and after +// commit. +IN_PROC_BROWSER_TEST_F(PageImplTest, PageObjectBeforeAndAfterCommit) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); + GURL url_b(embedded_test_server()->GetURL("b.com", "/title2.html")); + + // Isolate "b.com" so we are guaranteed to get a different process + // for navigations to this origin on Android. Doing this ensures that a + // speculative RenderFrameHost is used. + IsolateOriginsForTesting(embedded_test_server(), shell()->web_contents(), + {"b.com"}); + + // 1) Navigate to A. + EXPECT_TRUE(NavigateToURL(shell(), url_a)); + RenderFrameHostImpl* rfh_a = top_frame_host(); + PageImpl& page_a = rfh_a->GetPage(); + + // 2) Start navigation to B, but don't commit yet. + TestNavigationManager manager(shell()->web_contents(), url_b); + shell()->LoadURL(url_b); + EXPECT_TRUE(manager.WaitForRequestStart()); + + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); + RenderFrameHostImpl* pending_rfh = + root->render_manager()->speculative_frame_host(); + NavigationRequest* navigation_request = root->navigation_request(); + EXPECT_EQ(navigation_request->associated_site_instance_type(), + NavigationRequest::AssociatedSiteInstanceType::SPECULATIVE); + EXPECT_TRUE(pending_rfh); + + // 3) While there is a speculative RenderFrameHost in the root FrameTreeNode, + // get the Page associated with this RenderFrameHost. + PageImpl& pending_rfh_page = pending_rfh->GetPage(); + EXPECT_NE(&pending_rfh_page, &page_a); + + // 4) Let the navigation finish and make sure it has succeeded. + manager.WaitForNavigationFinished(); + EXPECT_EQ(url_b, web_contents()->GetMainFrame()->GetLastCommittedURL()); + + RenderFrameHostImpl* rfh_b = top_frame_host(); + EXPECT_EQ(pending_rfh, rfh_b); + PageImpl& rfh_b_page = rfh_b->GetPage(); + + // 5) Check |pending_rfh_page| and |rfh_b_page| point to the same object. + EXPECT_EQ(&pending_rfh_page, &rfh_b_page); +} + +// Test that a new Page object is created for a same-site same-RFH navigation. +IN_PROC_BROWSER_TEST_F(PageImplTest, SameSiteSameRenderFrameHostNavigation) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a1(embedded_test_server()->GetURL("a.com", "/title1.html")); + GURL url_a2(embedded_test_server()->GetURL("a.com", "/title2.html")); + + // 1) Navigate to A1. + EXPECT_TRUE(NavigateToURL(shell(), url_a1)); + RenderFrameHostImpl* main_rfh_a1 = top_frame_host(); + PageImpl& page_a1 = main_rfh_a1->GetPage(); + + // 2) Navigate to A2, both A1 and A2 should reuse RenderFrameHost. + EXPECT_TRUE(NavigateToURL(shell(), url_a2)); + RenderFrameHostImpl* main_rfh_a2 = top_frame_host(); + EXPECT_EQ(main_rfh_a1, main_rfh_a2); + PageImpl& page_a2 = main_rfh_a1->GetPage(); + + // 3) New Page object should be created. + EXPECT_NE(&page_a1, &page_a2); +} + +// Test that a new Page object is created when RenderFrame is recreated after +// crash. +IN_PROC_BROWSER_TEST_F(PageImplTest, NewPageObjectCreatedOnFrameCrash) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); + + // 1) Navigate to A. + EXPECT_TRUE(NavigateToURL(shell(), url_a)); + RenderFrameHostImpl* rfh_a = top_frame_host(); + PageImpl& page_a = rfh_a->GetPage(); + + // 2) Make the renderer crash. + RenderProcessHost* renderer_process = rfh_a->GetProcess(); + RenderProcessHostWatcher crash_observer( + renderer_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); + renderer_process->Shutdown(0); + crash_observer.Wait(); + EXPECT_TRUE(&(rfh_a->GetPage())); + + // 3) Re-initialize RenderFrame. + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); + root->render_manager()->InitializeMainRenderFrameForImmediateUse(); + RenderFrameHostImpl* new_rfh_a = top_frame_host(); + + // 4) Check that new Page object was created after new RenderFrame creation. + PageImpl& new_page_a = new_rfh_a->GetPage(); + EXPECT_NE(&page_a, &new_page_a); +} + +// Test that a new Page object is created when we do a same-site navigation +// after renderer crashes. +IN_PROC_BROWSER_TEST_F(PageImplTest, SameSiteNavigationAfterFrameCrash) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a1(embedded_test_server()->GetURL("a.com", "/title1.html")); + GURL url_a2(embedded_test_server()->GetURL("a.com", "/title2.html")); + + // 1) Navigate to A1. + EXPECT_TRUE(NavigateToURL(shell(), url_a1)); + RenderFrameHostImpl* rfh_a1 = top_frame_host(); + PageImpl& page_a1 = rfh_a1->GetPage(); + + // 2) Crash the renderer hosting current RFH. + RenderProcessHost* renderer_process = rfh_a1->GetProcess(); + RenderProcessHostWatcher crash_observer( + renderer_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); + renderer_process->Shutdown(0); + crash_observer.Wait(); + EXPECT_TRUE(&(web_contents()->GetMainFrame()->GetPage())); + + // 3) Navigate same-site to A2. + EXPECT_TRUE(NavigateToURL(shell(), url_a2)); + RenderFrameHostImpl* rfh_a2 = top_frame_host(); + PageImpl& page_a2 = rfh_a2->GetPage(); + + // 4) Check that new Page object was created after same-site navigation which + // resulted in new RenderFrame creation. + EXPECT_NE(&page_a1, &page_a2); +} + +// Test PageImpl with BackForwardCache feature enabled. +class PageImplWithBackForwardCacheTest : public PageImplTest { + public: + PageImplWithBackForwardCacheTest() { + scoped_feature_list_.InitWithFeaturesAndParameters( + {{features::kBackForwardCache, + // Set a very long TTL before expiration (longer than the test + // timeout) so tests that are expecting deletion don't pass when + // they shouldn't. + {{"TimeToLiveInBackForwardCacheInSeconds", "3600"}}}}, + // Allow BackForwardCache for all devices regardless of their memory. + {features::kBackForwardCacheMemoryControls}); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +// Tests that PageImpl object is not cleared on storing and restoring a Page +// from back-forward cache. +IN_PROC_BROWSER_TEST_F(PageImplWithBackForwardCacheTest, + BackForwardCacheNavigation) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a(embedded_test_server()->GetURL( + "a.com", "/cross_site_iframe_factory.html?a(b)")); + GURL url_c(embedded_test_server()->GetURL("c.com", "/title1.html")); + + // 1) Navigate to A(B). + EXPECT_TRUE(NavigateToURL(shell(), url_a)); + RenderFrameHostImpl* rfh_a = top_frame_host(); + RenderFrameHostImpl* rfh_b = rfh_a->child_at(0)->current_frame_host(); + + // 2) Get the PageImpl object associated with A and B RenderFrameHost. + PageImpl& page_a = rfh_a->GetPage(); + PageImpl& page_b = rfh_b->GetPage(); + + // 3) Navigate to C. A(B) should be stored in back-forward cache. + EXPECT_TRUE(NavigateToURL(shell(), url_c)); + EXPECT_TRUE(rfh_a->IsInBackForwardCache()); + EXPECT_TRUE(rfh_b->IsInBackForwardCache()); + + // 4) PageImpl associated with document should point to the same object on + // navigating away with BackForwardCache. + EXPECT_EQ(&page_a, &(rfh_a->GetPage())); + EXPECT_EQ(&page_b, &(rfh_b->GetPage())); + + // 5) Go back to A(B) and the Page object before and after restore should + // point to the same object. + web_contents()->GetController().GoBack(); + EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); + EXPECT_EQ(&page_a, &(rfh_a->GetPage())); + EXPECT_EQ(&page_b, &(rfh_b->GetPage())); +} + } // namespace content
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index 1221cd60..18fd3226 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -156,6 +156,7 @@ #include "content/common/associated_interfaces.mojom.h" #include "content/common/content_constants_internal.h" #include "content/common/content_navigation_policy.h" +#include "content/common/debug_utils.h" #include "content/common/frame.mojom.h" #include "content/common/navigation_client.mojom.h" #include "content/common/navigation_params.h" @@ -843,6 +844,19 @@ } #endif + // TODO(https://crbug.com/888079): Remove the DwoC below once we are sure that + // the `browser_side_origin` is always the same as the `renderer_side_origin`. + if (browser_side_origin != renderer_side_origin) { + NavigationRequest::ScopedCrashKeys navigation_request_crash_keys( + *navigation_request); + SCOPED_CRASH_KEY_STRING256("", "browser_side_origin", + browser_side_origin.GetDebugString()); + SCOPED_CRASH_KEY_STRING256("", "renderer_side_origin", + renderer_side_origin.GetDebugString()); + CaptureTraceForNavigationDebugScenario( + DebugScenario::kDebugBrowserVsRendererOriginToCommit); + base::debug::DumpWithoutCrashing(); + } DCHECK_EQ(browser_side_origin, renderer_side_origin) << "; navigation_request->GetURL() = " << navigation_request->GetURL(); }
diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc index 3b0b758..665ef86f 100644 --- a/content/browser/service_worker/service_worker_context_core.cc +++ b/content/browser/service_worker/service_worker_context_core.cc
@@ -108,19 +108,18 @@ void SuccessReportingCallback( int* expected_calls, std::vector<std::unique_ptr<RegistrationDeletionListener>>* listeners, - const base::RepeatingCallback<void(blink::ServiceWorkerStatusCode)>& - callback, + base::OnceCallback<void(blink::ServiceWorkerStatusCode)>& callback, blink::ServiceWorkerStatusCode status) { if (status != blink::ServiceWorkerStatusCode::kOk) { *expected_calls = -1; listeners->clear(); - callback.Run(blink::ServiceWorkerStatusCode::kErrorFailed); + std::move(callback).Run(blink::ServiceWorkerStatusCode::kErrorFailed); return; } (*expected_calls)--; if (*expected_calls == 0) { listeners->clear(); - callback.Run(blink::ServiceWorkerStatusCode::kOk); + std::move(callback).Run(blink::ServiceWorkerStatusCode::kOk); } } @@ -627,7 +626,7 @@ base::RepeatingCallback<void(blink::ServiceWorkerStatusCode)> barrier = base::BindRepeating(SuccessReportingCallback, base::Owned(expected_calls), base::Owned(listeners), - base::AdaptCallbackForRepeating(std::move(callback))); + base::OwnedRef(std::move(callback))); for (const auto& registration : registrations) { DCHECK(registration); if (*expected_calls != -1) {
diff --git a/content/browser/service_worker/service_worker_version_browsertest.cc b/content/browser/service_worker/service_worker_version_browsertest.cc index 49ecf2e..f25f31d 100644 --- a/content/browser/service_worker/service_worker_version_browsertest.cc +++ b/content/browser/service_worker/service_worker_version_browsertest.cc
@@ -544,13 +544,14 @@ ASSERT_EQ(blink::ServiceWorkerStatusCode::kOk, start_worker_status); version_->SetStatus(ServiceWorkerVersion::INSTALLING); - auto repeating_done = base::AdaptCallbackForRepeating(std::move(done)); + auto callback_pair = base::SplitOnceCallback(std::move(done)); int request_id = version_->StartRequest( ServiceWorkerMetrics::EventType::INSTALL, - CreateReceiver(BrowserThread::UI, repeating_done, result)); + CreateReceiver(BrowserThread::UI, std::move(callback_pair.first), + result)); version_->endpoint()->DispatchInstallEvent( base::BindOnce(&self::ReceiveInstallEvent, base::Unretained(this), - repeating_done, result, request_id)); + std::move(callback_pair.second), result, request_id)); } void ReceiveInstallEvent(
diff --git a/content/browser/sms/webotp_service.cc b/content/browser/sms/webotp_service.cc index 7f9c000..50b69a2 100644 --- a/content/browser/sms/webotp_service.cc +++ b/content/browser/sms/webotp_service.cc
@@ -88,7 +88,7 @@ const OriginList& origin_list, RenderFrameHost* host, mojo::PendingReceiver<blink::mojom::WebOTPService> receiver) - : FrameServiceBase(host, std::move(receiver)), + : DocumentServiceBase(host, std::move(receiver)), fetcher_(fetcher), origin_list_(origin_list), timeout_timer_(FROM_HERE,
diff --git a/content/browser/sms/webotp_service.h b/content/browser/sms/webotp_service.h index 4c3c757..c732dfb 100644 --- a/content/browser/sms/webotp_service.h +++ b/content/browser/sms/webotp_service.h
@@ -17,7 +17,7 @@ #include "content/browser/sms/sms_queue.h" #include "content/browser/sms/user_consent_handler.h" #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/sms/webotp_service.mojom.h" #include "url/origin.h" @@ -31,11 +31,11 @@ // WebOTPService handles mojo connections from the renderer, observing the // incoming SMS messages from an SmsFetcher. In practice, it is owned and // managed by a RenderFrameHost. It accomplishes that via subclassing -// FrameServiceBase, which observes the lifecycle of a RenderFrameHost and +// DocumentServiceBase, which observes the lifecycle of a RenderFrameHost and // manages it own memory. Create() creates a self-managed instance of // WebOTPService and binds it to the request. class CONTENT_EXPORT WebOTPService - : public FrameServiceBase<blink::mojom::WebOTPService>, + : public DocumentServiceBase<blink::mojom::WebOTPService>, public SmsFetcher::Subscriber { public: // Return value indicates success. Creation can fail if origin requirements
diff --git a/content/browser/speculation_rules/speculation_host_impl.cc b/content/browser/speculation_rules/speculation_host_impl.cc index bc94f32..e93a180 100644 --- a/content/browser/speculation_rules/speculation_host_impl.cc +++ b/content/browser/speculation_rules/speculation_host_impl.cc
@@ -50,14 +50,14 @@ return; } - // FrameServiceBase will destroy this on pipe closure or frame destruction. + // DocumentServiceBase will destroy this on pipe closure or frame destruction. new SpeculationHostImpl(frame_host, std::move(receiver)); } SpeculationHostImpl::SpeculationHostImpl( RenderFrameHost* frame_host, mojo::PendingReceiver<blink::mojom::SpeculationHost> receiver) - : FrameServiceBase(frame_host, std::move(receiver)) { + : DocumentServiceBase(frame_host, std::move(receiver)) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); delegate_ = GetContentClient()->browser()->CreateSpeculationHostDelegate( *render_frame_host());
diff --git a/content/browser/speculation_rules/speculation_host_impl.h b/content/browser/speculation_rules/speculation_host_impl.h index 3c33c87..9c7ccb8 100644 --- a/content/browser/speculation_rules/speculation_host_impl.h +++ b/content/browser/speculation_rules/speculation_host_impl.h
@@ -8,7 +8,7 @@ #include <vector> #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/speculation_host_delegate.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h" @@ -20,7 +20,7 @@ // Receiver for speculation rules from the web platform. See // third_party/blink/renderer/core/speculation_rules/README.md class CONTENT_EXPORT SpeculationHostImpl final - : public content::FrameServiceBase<blink::mojom::SpeculationHost> { + : public content::DocumentServiceBase<blink::mojom::SpeculationHost> { public: // Creates and binds an instance of this per-frame. static void Bind(
diff --git a/content/browser/wake_lock/wake_lock_service_impl.cc b/content/browser/wake_lock/wake_lock_service_impl.cc index 3a8932b..012453e2 100644 --- a/content/browser/wake_lock/wake_lock_service_impl.cc +++ b/content/browser/wake_lock/wake_lock_service_impl.cc
@@ -36,6 +36,6 @@ WakeLockServiceImpl::WakeLockServiceImpl( RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::WakeLockService> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)) {} + : DocumentServiceBase(render_frame_host, std::move(receiver)) {} } // namespace content
diff --git a/content/browser/wake_lock/wake_lock_service_impl.h b/content/browser/wake_lock/wake_lock_service_impl.h index 8876d81..5a59171 100644 --- a/content/browser/wake_lock/wake_lock_service_impl.h +++ b/content/browser/wake_lock/wake_lock_service_impl.h
@@ -5,14 +5,14 @@ #ifndef CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ #define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/wake_lock/wake_lock.mojom.h" namespace content { class WakeLockServiceImpl final - : public FrameServiceBase<blink::mojom::WakeLockService> { + : public DocumentServiceBase<blink::mojom::WakeLockService> { public: static void Create(RenderFrameHost*, mojo::PendingReceiver<blink::mojom::WakeLockService>);
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index ca25b37..f56771c 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4244,7 +4244,7 @@ event_recorder_->ListenToEvents(*callback); } else { if (event_recorder_) { - event_recorder_->FlushAsyncEvents(); + event_recorder_->WaitForDoneRecording(); event_recorder_.reset(nullptr); } }
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc index eb2bd9d..33b8c611 100644 --- a/content/browser/web_contents/web_contents_impl_unittest.cc +++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -18,6 +18,7 @@ #include "base/test/bind.h" #include "base/test/scoped_feature_list.h" #include "build/build_config.h" +#include "build/chromeos_buildflags.h" #include "components/download/public/common/download_url_parameters.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/media/audio_stream_monitor.h" @@ -79,6 +80,10 @@ #include "ui/gfx/skia_util.h" #include "url/url_constants.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +#include "chromeos/lacros/lacros_test_helper.h" +#endif + namespace content { namespace { class WebContentsImplTestBrowserClient : public TestContentBrowserClient { @@ -138,6 +143,11 @@ } private: +#if BUILDFLAG(IS_CHROMEOS_LACROS) + // Instantiate LacrosService for WakeLock support. + chromeos::ScopedLacrosServiceTestHelper scoped_lacros_service_test_helper_; +#endif + ScopedWebUIControllerFactoryRegistration factory_registration_{ ContentWebUIControllerFactory::GetInstance()}; };
diff --git a/content/browser/webauth/authenticator_impl.cc b/content/browser/webauth/authenticator_impl.cc index 173a30c..78b654e 100644 --- a/content/browser/webauth/authenticator_impl.cc +++ b/content/browser/webauth/authenticator_impl.cc
@@ -10,7 +10,7 @@ #include "base/timer/timer.h" #include "content/browser/webauth/authenticator_common.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" @@ -28,7 +28,7 @@ } // AuthenticatorImpl owns itself. It self-destructs when the RenderFrameHost - // navigates or is deleted. See FrameServiceBase for details. + // navigates or is deleted. See DocumentServiceBase for details. DCHECK(render_frame_host); new AuthenticatorImpl( render_frame_host, std::move(receiver), @@ -39,7 +39,7 @@ RenderFrameHost* render_frame_host, mojo::PendingReceiver<blink::mojom::Authenticator> receiver, std::unique_ptr<AuthenticatorCommon> authenticator_common) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), authenticator_common_(std::move(authenticator_common)) { DCHECK(authenticator_common_); }
diff --git a/content/browser/webauth/authenticator_impl.h b/content/browser/webauth/authenticator_impl.h index 8c1c2bf..d5d0fec 100644 --- a/content/browser/webauth/authenticator_impl.h +++ b/content/browser/webauth/authenticator_impl.h
@@ -11,7 +11,7 @@ #include "base/macros.h" #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver.h" #include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h" @@ -41,7 +41,7 @@ // Implementation of the public Authenticator interface. class CONTENT_EXPORT AuthenticatorImpl - : public FrameServiceBase<blink::mojom::Authenticator> { + : public DocumentServiceBase<blink::mojom::Authenticator> { public: static void Create( RenderFrameHost* render_frame_host,
diff --git a/content/browser/webid/federated_auth_request_impl.cc b/content/browser/webid/federated_auth_request_impl.cc index 04f91f0..31998b4 100644 --- a/content/browser/webid/federated_auth_request_impl.cc +++ b/content/browser/webid/federated_auth_request_impl.cc
@@ -25,7 +25,7 @@ FederatedAuthRequestImpl::FederatedAuthRequestImpl( RenderFrameHost* host, mojo::PendingReceiver<blink::mojom::FederatedAuthRequest> receiver) - : FrameServiceBase(host, std::move(receiver)) {} + : DocumentServiceBase(host, std::move(receiver)) {} FederatedAuthRequestImpl::~FederatedAuthRequestImpl() { // Ensures key data members are destructed in proper order and resolves any @@ -43,7 +43,7 @@ // the mojo method is invoked, causing the promise to be rejected. // https://crbug.com/1141125 // It is safe to access host->GetLastCommittedOrigin during construction - // but FrameServiceBase::origin() should be used thereafter. + // but DocumentServiceBase::origin() should be used thereafter. if (!IsSameOriginWithAncestors(host, host->GetLastCommittedOrigin())) { mojo::ReportBadMessage( "navigator.id.get cannot be invoked from within cross-origin iframes.");
diff --git a/content/browser/webid/federated_auth_request_impl.h b/content/browser/webid/federated_auth_request_impl.h index 8ef3bb2..f209d0b 100644 --- a/content/browser/webid/federated_auth_request_impl.h +++ b/content/browser/webid/federated_auth_request_impl.h
@@ -13,7 +13,7 @@ #include "base/macros.h" #include "content/browser/webid/idp_network_request_manager.h" #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/identity_request_dialog_controller.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h" @@ -29,12 +29,12 @@ // fulfill WebID-related requests. // // In practice, it is owned and managed by a RenderFrameHost. It accomplishes -// that via subclassing FrameServiceBase, which observes the lifecycle of a +// that via subclassing DocumentServiceBase, which observes the lifecycle of a // RenderFrameHost and manages its own memory. // Create() creates a self-managed instance of FederatedAuthRequestImpl and // binds it to the receiver. class CONTENT_EXPORT FederatedAuthRequestImpl - : public FrameServiceBase<blink::mojom::FederatedAuthRequest> { + : public DocumentServiceBase<blink::mojom::FederatedAuthRequest> { public: static void Create(RenderFrameHost*, mojo::PendingReceiver<blink::mojom::FederatedAuthRequest>);
diff --git a/content/browser/webid/federated_auth_response_impl.cc b/content/browser/webid/federated_auth_response_impl.cc index 83e680b26..1ee92e5 100644 --- a/content/browser/webid/federated_auth_response_impl.cc +++ b/content/browser/webid/federated_auth_response_impl.cc
@@ -18,7 +18,7 @@ FederatedAuthResponseImpl::FederatedAuthResponseImpl( RenderFrameHost* host, mojo::PendingReceiver<blink::mojom::FederatedAuthResponse> receiver) - : FrameServiceBase(host, std::move(receiver)) {} + : DocumentServiceBase(host, std::move(receiver)) {} // TODO(majidvp): We should reject any pending promise here. // http://crbug.com/1141125 @@ -34,7 +34,7 @@ // the mojo method is invoked, causing the promise to be rejected. // https://crbug.com/1141125 // It is safe to access host->GetLastCommittedOrigin during construction - // but FrameServiceBase::origin() should be used thereafter. + // but DocumentServiceBase::origin() should be used thereafter. if (!IsSameOriginWithAncestors(host, host->GetLastCommittedOrigin())) { mojo::ReportBadMessage( "WebID cannot be invoked from within cross-origin iframes.");
diff --git a/content/browser/webid/federated_auth_response_impl.h b/content/browser/webid/federated_auth_response_impl.h index 37564df..6a04c22 100644 --- a/content/browser/webid/federated_auth_response_impl.h +++ b/content/browser/webid/federated_auth_response_impl.h
@@ -11,7 +11,7 @@ #include "base/callback_forward.h" #include "base/macros.h" #include "content/common/content_export.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/mojom/webid/federated_auth_response.mojom.h" @@ -22,7 +22,7 @@ // FederatedAuthResponseImpl handles mojo connections from the renderer to // fulfill WebID-related response by an IDP. class FederatedAuthResponseImpl - : public FrameServiceBase<blink::mojom::FederatedAuthResponse> { + : public DocumentServiceBase<blink::mojom::FederatedAuthResponse> { public: // Creates a self-managed instance of FederatedAuthResponseImpl and binds it // to the receiver.
diff --git a/content/browser/webid/webid_utils.h b/content/browser/webid/webid_utils.h index c6435c6..2233c99d 100644 --- a/content/browser/webid/webid_utils.h +++ b/content/browser/webid/webid_utils.h
@@ -14,8 +14,8 @@ // Determines whether |host| is same-origin with all of its ancestors in the // frame tree. Returns false if not. // |origin| is provided because it is not considered safe to use -// host->GetLastCommittedOrigin() at some times, so FrameServiceBase::origin() -// should be used to obtain the frame's origin. +// host->GetLastCommittedOrigin() at some times, so +// DocumentServiceBase::origin() should be used to obtain the frame's origin. bool IsSameOriginWithAncestors(RenderFrameHost* host, const url::Origin& origin);
diff --git a/content/browser/webrtc/webrtc_internals.cc b/content/browser/webrtc/webrtc_internals.cc index bae334e..d8b989c 100644 --- a/content/browser/webrtc/webrtc_internals.cc +++ b/content/browser/webrtc/webrtc_internals.cc
@@ -50,27 +50,26 @@ const size_t kMaxGetUserMediaEntries = 1000; // Makes sure that |dict| has a ListValue under path "log". -base::ListValue* EnsureLogList(base::DictionaryValue* dict) { - base::ListValue* log = nullptr; - if (!dict->GetList("log", &log)) - log = dict->SetList("log", std::make_unique<base::ListValue>()); +base::Value* EnsureLogList(base::Value* dict) { + base::Value* log = dict->FindListKey("log"); + if (!log) { + log = dict->SetKey("log", base::Value(base::Value::Type::LIST)); + } return log; } // Removes the log entry associated with a given record. void FreeLogList(base::Value* value) { DCHECK(value->is_dict()); - auto* dict = static_cast<base::DictionaryValue*>(value); - dict->Remove("log", nullptr); + value->RemoveKey("log"); } } // namespace WebRTCInternals* WebRTCInternals::g_webrtc_internals = nullptr; -WebRTCInternals::PendingUpdate::PendingUpdate( - const std::string& event_name, - std::unique_ptr<base::Value> event_data) +WebRTCInternals::PendingUpdate::PendingUpdate(const std::string& event_name, + base::Value event_data) : event_name_(event_name), event_data_(std::move(event_data)) {} WebRTCInternals::PendingUpdate::PendingUpdate(PendingUpdate&& other) @@ -88,7 +87,7 @@ const base::Value* WebRTCInternals::PendingUpdate::event_data() const { DCHECK(thread_checker_.CalledOnValidThread()); - return event_data_.get(); + return event_data_.is_none() ? nullptr : &event_data_; } WebRTCInternals::WebRTCInternals() : WebRTCInternals(500, true) {} @@ -166,18 +165,18 @@ // TODO(tommi): Consider changing this design so that webrtc-internals has // minimal impact if chrome://webrtc-internals isn't open. - std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); - dict->SetInteger("rid", frame_id.child_id); - dict->SetInteger("lid", lid); - dict->SetInteger("pid", static_cast<int>(pid)); - dict->SetString("rtcConfiguration", rtc_configuration); - dict->SetString("constraints", constraints); - dict->SetString("url", url); - dict->SetBoolean("isOpen", true); - dict->SetBoolean("connected", false); + base::Value dict(base::Value::Type::DICTIONARY); + dict.SetIntKey("rid", frame_id.child_id); + dict.SetIntKey("lid", lid); + dict.SetIntKey("pid", static_cast<int>(pid)); + dict.SetStringKey("rtcConfiguration", rtc_configuration); + dict.SetStringKey("constraints", constraints); + dict.SetStringKey("url", url); + dict.SetBoolKey("isOpen", true); + dict.SetBoolKey("connected", false); if (!observers_.empty()) - SendUpdate("add-peer-connection", dict->CreateDeepCopy()); + SendUpdate("add-peer-connection", dict.Clone()); peer_connection_data_.Append(std::move(dict)); @@ -192,17 +191,16 @@ int lid) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - size_t index; - base::DictionaryValue* dict = FindRecord(frame_id, lid, &index); - if (dict) { - MaybeClosePeerConnection(dict); - peer_connection_data_.Remove(index, nullptr); + auto it = FindRecord(frame_id, lid); + if (it != peer_connection_data_.GetList().end()) { + MaybeClosePeerConnection(&*it); + peer_connection_data_.EraseListIter(it); } if (!observers_.empty()) { - std::unique_ptr<base::DictionaryValue> id(new base::DictionaryValue()); - id->SetInteger("rid", frame_id.child_id); - id->SetInteger("lid", lid); + base::Value id(base::Value::Type::DICTIONARY); + id.SetIntKey("rid", frame_id.child_id); + id.SetIntKey("lid", lid); SendUpdate("remove-peer-connection", std::move(id)); } } @@ -213,45 +211,45 @@ const string& value) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - base::DictionaryValue* record = FindRecord(frame_id, lid); - if (!record) + auto it = FindRecord(frame_id, lid); + if (it == peer_connection_data_.GetList().end()) return; if (type == "iceConnectionStateChange") { if (value == "connected" || value == "checking" || value == "completed") { - MaybeMarkPeerConnectionAsConnected(record); + MaybeMarkPeerConnectionAsConnected(&*it); } else if (value == "failed" || value == "disconnected" || value == "closed" || value == "new") { - MaybeMarkPeerConnectionAsNotConnected(record); + MaybeMarkPeerConnectionAsNotConnected(&*it); } } else if (type == "stop") { - MaybeClosePeerConnection(record); + MaybeClosePeerConnection(&*it); } else if (type == "setConfiguration") { // Update the configuration we have for this connection. - record->SetString("rtcConfiguration", value); + it->SetStringKey("rtcConfiguration", value); } // Don't update entries if there aren't any observers. if (observers_.empty()) return; - auto log_entry = std::make_unique<base::DictionaryValue>(); + base::Value log_entry(base::Value::Type::DICTIONARY); double epoch_time = base::Time::Now().ToJsTime(); string time = base::NumberToString(epoch_time); - log_entry->SetString("time", time); - log_entry->SetString("type", type); - log_entry->SetString("value", value); + log_entry.SetStringKey("time", time); + log_entry.SetStringKey("type", type); + log_entry.SetStringKey("value", value); - auto update = std::make_unique<base::DictionaryValue>(); - update->SetInteger("rid", frame_id.child_id); - update->SetInteger("lid", lid); - update->MergeDictionary(log_entry.get()); + base::Value update(base::Value::Type::DICTIONARY); + update.SetIntKey("rid", frame_id.child_id); + update.SetIntKey("lid", lid); + update.MergeDictionary(&log_entry); SendUpdate("update-peer-connection", std::move(update)); // Append the update to the end of the log. - EnsureLogList(record)->Append(std::move(log_entry)); + EnsureLogList(&*it)->Append(std::move(log_entry)); } void WebRTCInternals::OnAddStandardStats(GlobalFrameRoutingId frame_id, @@ -260,11 +258,11 @@ if (observers_.empty()) return; - auto dict = std::make_unique<base::DictionaryValue>(); - dict->SetInteger("rid", frame_id.child_id); - dict->SetInteger("lid", lid); + base::Value dict(base::Value::Type::DICTIONARY); + dict.SetIntKey("rid", frame_id.child_id); + dict.SetIntKey("lid", lid); - dict->SetKey("reports", std::move(value)); + dict.SetKey("reports", std::move(value)); SendUpdate("add-standard-stats", std::move(dict)); } @@ -275,11 +273,11 @@ if (observers_.empty()) return; - auto dict = std::make_unique<base::DictionaryValue>(); - dict->SetInteger("rid", frame_id.child_id); - dict->SetInteger("lid", lid); + base::Value dict(base::Value::Type::DICTIONARY); + dict.SetIntKey("rid", frame_id.child_id); + dict.SetIntKey("lid", lid); - dict->SetKey("reports", std::move(value)); + dict.SetKey("reports", std::move(value)); SendUpdate("add-legacy-stats", std::move(dict)); } @@ -299,18 +297,18 @@ return; } - auto dict = std::make_unique<base::DictionaryValue>(); - dict->SetInteger("rid", frame_id.child_id); - dict->SetInteger("pid", static_cast<int>(pid)); - dict->SetString("origin", origin); - dict->SetDouble("timestamp", base::Time::Now().ToJsTime()); + base::Value dict(base::Value::Type::DICTIONARY); + dict.SetIntKey("rid", frame_id.child_id); + dict.SetIntKey("pid", static_cast<int>(pid)); + dict.SetStringKey("origin", origin); + dict.SetDoubleKey("timestamp", base::Time::Now().ToJsTime()); if (audio) - dict->SetString("audio", audio_constraints); + dict.SetStringKey("audio", audio_constraints); if (video) - dict->SetString("video", video_constraints); + dict.SetStringKey("video", video_constraints); if (!observers_.empty()) - SendUpdate("add-get-user-media", dict->CreateDeepCopy()); + SendUpdate("add-get-user-media", dict.Clone()); get_user_media_requests_.Append(std::move(dict)); @@ -356,7 +354,7 @@ void WebRTCInternals::UpdateObserver(WebRTCInternalsUIObserver* observer) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (peer_connection_data_.GetSize() > 0) + if (peer_connection_data_.GetList().size() > 0) observer->OnUpdate("update-all-peer-connections", &peer_connection_data_); for (const auto& request : get_user_media_requests_.GetList()) { @@ -454,7 +452,7 @@ } void WebRTCInternals::SendUpdate(const std::string& event_name, - std::unique_ptr<base::Value> event_data) { + base::Value event_data) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!observers_.empty()); @@ -506,10 +504,12 @@ DCHECK_CURRENTLY_ON(BrowserThread::UI); switch (selection_type_) { case SelectionType::kRtcEventLogs: - SendUpdate("event-log-recordings-file-selection-cancelled", nullptr); + SendUpdate("event-log-recordings-file-selection-cancelled", + base::Value()); break; case SelectionType::kAudioDebugRecordings: - SendUpdate("audio-debug-recordings-file-selection-cancelled", nullptr); + SendUpdate("audio-debug-recordings-file-selection-cancelled", + base::Value()); break; default: NOTREACHED(); @@ -521,26 +521,26 @@ DCHECK_CURRENTLY_ON(BrowserThread::UI); // Iterates from the end of the list to remove the PeerConnections created - // by the exitting renderer. - for (int i = peer_connection_data_.GetSize() - 1; i >= 0; --i) { + // by the exiting renderer. + base::Value::ListView peer_conn_view = peer_connection_data_.GetList(); + for (int i = peer_conn_view.size() - 1; i >= 0; --i) { base::DictionaryValue* record = nullptr; - peer_connection_data_.GetDictionary(i, &record); + DCHECK(peer_conn_view[i].is_dict()); + peer_conn_view[i].GetAsDictionary(&record); - int this_rid, this_lid = 0; - record->GetInteger("rid", &this_rid); - record->GetInteger("lid", &this_lid); + absl::optional<int> this_rid, this_lid; + this_rid = record->FindIntKey("rid"); + this_lid = record->FindIntKey("lid"); - if (this_rid == render_process_id) { + if (this_rid.value_or(0) == render_process_id) { if (!observers_.empty()) { - - std::unique_ptr<base::DictionaryValue> update( - new base::DictionaryValue()); - update->SetInteger("rid", this_rid); - update->SetInteger("lid", this_lid); + base::Value update(base::Value::Type::DICTIONARY); + update.SetIntKey("rid", this_rid.value_or(0)); + update.SetIntKey("lid", this_lid.value_or(0)); SendUpdate("remove-peer-connection", std::move(update)); } MaybeClosePeerConnection(record); - peer_connection_data_.Remove(i, nullptr); + peer_connection_data_.EraseListIter(peer_conn_view.begin() + i); } } UpdateWakeLock(); @@ -548,22 +548,25 @@ bool found_any = false; // Iterates from the end of the list to remove the getUserMedia requests // created by the exiting renderer. - for (int i = get_user_media_requests_.GetSize() - 1; i >= 0; --i) { + base::Value::ListView get_user_media_requests_view = + get_user_media_requests_.GetList(); + for (int i = get_user_media_requests_view.size() - 1; i >= 0; --i) { base::DictionaryValue* record = nullptr; - get_user_media_requests_.GetDictionary(i, &record); + DCHECK(get_user_media_requests_view[i].is_dict()); + get_user_media_requests_view[i].GetAsDictionary(&record); - int this_rid = 0; - record->GetInteger("rid", &this_rid); + absl::optional<int> this_rid = record->FindIntKey("rid"); - if (this_rid == render_process_id) { - get_user_media_requests_.Remove(i, nullptr); + if (this_rid.value_or(0) == render_process_id) { + get_user_media_requests_.EraseListIter( + get_user_media_requests_view.begin() + i); found_any = true; } } if (found_any && !observers_.empty()) { - std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue()); - update->SetInteger("rid", render_process_id); + base::Value update(base::Value::Type::DICTIONARY); + update.SetIntKey("rid", render_process_id); SendUpdate("remove-get-user-media-for-renderer", std::move(update)); } } @@ -585,24 +588,21 @@ } } -void WebRTCInternals::MaybeClosePeerConnection(base::DictionaryValue* record) { - bool is_open; - bool did_read = record->GetBoolean("isOpen", &is_open); - DCHECK(did_read); - if (!is_open) +void WebRTCInternals::MaybeClosePeerConnection(base::Value* record) { + absl::optional<bool> is_open = record->FindBoolKey("isOpen"); + DCHECK(is_open.has_value()); + if (!*is_open) return; - record->SetBoolean("isOpen", false); + record->SetBoolKey("isOpen", false); MaybeMarkPeerConnectionAsNotConnected(record); } -void WebRTCInternals::MaybeMarkPeerConnectionAsConnected( - base::DictionaryValue* record) { - bool was_connected = true; - record->GetBoolean("connected", &was_connected); +void WebRTCInternals::MaybeMarkPeerConnectionAsConnected(base::Value* record) { + bool was_connected = record->FindBoolKey("connected").value_or(true); if (!was_connected) { ++num_connected_connections_; - record->SetBoolean("connected", true); + record->SetBoolKey("connected", true); UpdateWakeLock(); for (auto& observer : connections_observers_) observer.OnConnectionsCountChange(num_connected_connections_); @@ -610,11 +610,10 @@ } void WebRTCInternals::MaybeMarkPeerConnectionAsNotConnected( - base::DictionaryValue* record) { - bool was_connected = false; - record->GetBoolean("connected", &was_connected); + base::Value* record) { + bool was_connected = record->FindBoolKey("connected").value_or(false); if (was_connected) { - record->SetBoolean("connected", false); + record->SetBoolKey("connected", false); --num_connected_connections_; DCHECK_GE(num_connected_connections_, 0); UpdateWakeLock(); @@ -666,26 +665,23 @@ } } -base::DictionaryValue* WebRTCInternals::FindRecord( +base::CheckedContiguousIterator<base::Value> WebRTCInternals::FindRecord( GlobalFrameRoutingId frame_id, - int lid, - size_t* index /*= nullptr*/) { + int lid) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - base::DictionaryValue* record = nullptr; - for (size_t i = 0; i < peer_connection_data_.GetSize(); ++i) { - peer_connection_data_.GetDictionary(i, &record); + base::Value::ListView peer_conn_view = peer_connection_data_.GetList(); + for (auto it = peer_conn_view.begin(); it != peer_conn_view.end(); ++it) { + base::DictionaryValue* record = nullptr; + DCHECK(it->is_dict()); + it->GetAsDictionary(&record); - int this_rid = 0, this_lid = 0; - record->GetInteger("rid", &this_rid); - record->GetInteger("lid", &this_lid); + int this_rid = record->FindIntKey("rid").value_or(0); + int this_lid = record->FindIntKey("lid").value_or(0); - if (this_rid == frame_id.child_id && this_lid == lid) { - if (index) - *index = i; - return record; - } + if (this_rid == frame_id.child_id && this_lid == lid) + return it; } - return nullptr; + return peer_conn_view.end(); } } // namespace content
diff --git a/content/browser/webrtc/webrtc_internals.h b/content/browser/webrtc/webrtc_internals.h index 377c9046..3127ee0 100644 --- a/content/browser/webrtc/webrtc_internals.h +++ b/content/browser/webrtc/webrtc_internals.h
@@ -134,8 +134,7 @@ static WebRTCInternals* g_webrtc_internals; - void SendUpdate(const std::string& event_name, - std::unique_ptr<base::Value> event_data); + void SendUpdate(const std::string& event_name, base::Value event_data); // RenderProcessHostObserver implementation. void RenderProcessExited(RenderProcessHost* host, @@ -156,10 +155,10 @@ // Updates the number of open PeerConnections. Called when a PeerConnection // is stopped or removed. - void MaybeClosePeerConnection(base::DictionaryValue* record); + void MaybeClosePeerConnection(base::Value* record); - void MaybeMarkPeerConnectionAsConnected(base::DictionaryValue* record); - void MaybeMarkPeerConnectionAsNotConnected(base::DictionaryValue* record); + void MaybeMarkPeerConnectionAsConnected(base::Value* record); + void MaybeMarkPeerConnectionAsNotConnected(base::Value* record); // Called whenever a PeerConnection is created or stopped in order to // request/cancel a wake lock on suspending the current application for power @@ -174,9 +173,11 @@ // notifications. void ProcessPendingUpdates(); - base::DictionaryValue* FindRecord(GlobalFrameRoutingId frame_id, - int lid, - size_t* index = nullptr); + // Returns an iterator for peer_connection_data_.GetList (an end() iterator + // if not found). + base::CheckedContiguousIterator<base::Value> FindRecord( + GlobalFrameRoutingId frame_id, + int lid); base::ObserverList<WebRTCInternalsUIObserver>::Unchecked observers_; @@ -248,8 +249,7 @@ // thread. class PendingUpdate { public: - PendingUpdate(const std::string& event_name, - std::unique_ptr<base::Value> event_data); + PendingUpdate(const std::string& event_name, base::Value event_data); PendingUpdate(PendingUpdate&& other); ~PendingUpdate(); @@ -259,7 +259,7 @@ private: base::ThreadChecker thread_checker_; const std::string event_name_; - std::unique_ptr<base::Value> event_data_; + base::Value event_data_; DISALLOW_COPY_AND_ASSIGN(PendingUpdate); };
diff --git a/content/common/debug_utils.h b/content/common/debug_utils.h index a57487c..56537920 100644 --- a/content/common/debug_utils.h +++ b/content/common/debug_utils.h
@@ -33,9 +33,13 @@ // Metrics and the bfcache situations do not match. kDebugBackForwardCacheMetricsMismatch = 3, + // Detected a mismatch between the origin to commit as calculated on 1) the + // browser-side VS 2) the renderer-side. + kDebugBrowserVsRendererOriginToCommit = 4, + // After making changes, you MUST update the histograms xml by running: // "python tools/metrics/histograms/update_debug_scenarios.py" - kMaxValue = kDebugBackForwardCacheMetricsMismatch + kMaxValue = kDebugBrowserVsRendererOriginToCommit }; // The tracing categories enabled for debugging navigation scenarios can be
diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn index 1048061..b852b9d 100644 --- a/content/public/browser/BUILD.gn +++ b/content/public/browser/BUILD.gn
@@ -140,6 +140,7 @@ "devtools_permission_overrides.cc", "devtools_permission_overrides.h", "devtools_socket_factory.h", + "document_service_base.h", "dom_storage_context.h", "download_item_utils.h", "download_manager.cc", @@ -170,7 +171,6 @@ "font_list_async.h", "frame_accept_header.cc", "frame_accept_header.h", - "frame_service_base.h", "generated_code_cache_settings.h", "global_request_id.cc", "global_request_id.h",
diff --git a/content/public/browser/frame_service_base.h b/content/public/browser/document_service_base.h similarity index 85% rename from content/public/browser/frame_service_base.h rename to content/public/browser/document_service_base.h index 92646a4..a7d9457f 100644 --- a/content/public/browser/frame_service_base.h +++ b/content/public/browser/document_service_base.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_PUBLIC_BROWSER_FRAME_SERVICE_BASE_H_ -#define CONTENT_PUBLIC_BROWSER_FRAME_SERVICE_BASE_H_ +#ifndef CONTENT_PUBLIC_BROWSER_DOCUMENT_SERVICE_BASE_H_ +#define CONTENT_PUBLIC_BROWSER_DOCUMENT_SERVICE_BASE_H_ #include <utility> @@ -33,10 +33,10 @@ // origin() instead of from |render_frame_host| passed in the constructor. // See https://crbug.com/769189 for an example of such a race. template <typename Interface> -class FrameServiceBase : public Interface, public WebContentsObserver { +class DocumentServiceBase : public Interface, public WebContentsObserver { public: - FrameServiceBase(RenderFrameHost* render_frame_host, - mojo::PendingReceiver<Interface> pending_receiver) + DocumentServiceBase(RenderFrameHost* render_frame_host, + mojo::PendingReceiver<Interface> pending_receiver) : WebContentsObserver( WebContents::FromRenderFrameHost(render_frame_host)), render_frame_host_(render_frame_host), @@ -44,12 +44,12 @@ receiver_(this, std::move(pending_receiver)) { // |this| owns |receiver_|, so unretained is safe. receiver_.set_disconnect_handler( - base::BindOnce(&FrameServiceBase::Close, base::Unretained(this))); + base::BindOnce(&DocumentServiceBase::Close, base::Unretained(this))); } protected: // Make the destructor private since |this| can only be deleted by Close(). - virtual ~FrameServiceBase() = default; + virtual ~DocumentServiceBase() = default; // All subclasses should use this function to obtain the origin instead of // trying to get it from the RenderFrameHost pointer directly. @@ -64,8 +64,8 @@ private: // Disallow calling web_contents() directly from the subclasses to ensure that - // tab-level state doesn't get queried or updated when the frame is - // not current. + // tab-level state doesn't get queried or updated when the RenderFrameHost is + // not active. // Use WebContents::From(render_frame_host()) instead, but please keep in mind // that the render_frame_host() might not be active. See // RenderFrameHost::IsActive() for details. @@ -110,4 +110,4 @@ } // namespace content -#endif // CONTENT_PUBLIC_BROWSER_FRAME_SERVICE_BASE_H_ +#endif // CONTENT_PUBLIC_BROWSER_DOCUMENT_SERVICE_BASE_H_
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h index bb987f3a..7ec0901 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h
@@ -50,6 +50,7 @@ class WebServiceWorkerContextProxy; class WebURL; class WebURLRequest; +class WebView; struct WebContentSecurityPolicyHeader; struct WebPluginParams; struct WebURLError; @@ -67,7 +68,6 @@ namespace content { class RenderFrame; -class RenderView; // Embedder API for participating in renderer logic. class CONTENT_EXPORT ContentRendererClient { @@ -85,8 +85,8 @@ // Notifies that a new RenderFrame has been created. virtual void RenderFrameCreated(RenderFrame* render_frame) {} - // Notifies that a new RenderView has been created. - virtual void RenderViewCreated(RenderView* render_view) {} + // Notifies that a new WebView has been created. + virtual void WebViewCreated(blink::WebView* web_view) {} // Returns the bitmap to show when a plugin crashed, or NULL for none. virtual SkBitmap* GetSadPluginBitmap();
diff --git a/content/public/test/DEPS b/content/public/test/DEPS index 6f38fcbd..58f50ac 100644 --- a/content/public/test/DEPS +++ b/content/public/test/DEPS
@@ -4,6 +4,8 @@ # These are low-level system APIs on ChromeOS that need to be available # everywhere. "+chromeos/crosapi/cpp/crosapi_constants.h", + "+chromeos/lacros/lacros_chrome_service_delegate.h", + "+chromeos/lacros/lacros_service.h", "+chromeos/lacros/lacros_test_helper.h", "+chromeos/startup/startup_switches.h",
diff --git a/content/public/test/accessibility_notification_waiter.cc b/content/public/test/accessibility_notification_waiter.cc index d566c751..e0c437a5 100644 --- a/content/public/test/accessibility_notification_waiter.cc +++ b/content/public/test/accessibility_notification_waiter.cc
@@ -30,7 +30,8 @@ : WebContentsObserver(web_contents), event_to_wait_for_(ax::mojom::Event::kNone), generated_event_to_wait_for_(absl::nullopt), - loop_runner_(std::make_unique<base::RunLoop>()) { + loop_runner_(std::make_unique<base::RunLoop>()), + loop_runner_quit_closure_(loop_runner_->QuitClosure()) { ListenToAllFrames(web_contents); } @@ -41,7 +42,8 @@ : WebContentsObserver(web_contents), event_to_wait_for_(event_type), generated_event_to_wait_for_(absl::nullopt), - loop_runner_(std::make_unique<base::RunLoop>()) { + loop_runner_(std::make_unique<base::RunLoop>()), + loop_runner_quit_closure_(loop_runner_->QuitClosure()) { ListenToAllFrames(web_contents); static_cast<WebContentsImpl*>(web_contents) ->AddAccessibilityMode(accessibility_mode); @@ -59,7 +61,8 @@ : WebContentsObserver(web_contents), event_to_wait_for_(absl::nullopt), generated_event_to_wait_for_(event_type), - loop_runner_(std::make_unique<base::RunLoop>()) { + loop_runner_(std::make_unique<base::RunLoop>()), + loop_runner_quit_closure_(loop_runner_->QuitClosure()) { ListenToAllFrames(web_contents); static_cast<WebContentsImpl*>(web_contents) ->AddAccessibilityMode(accessibility_mode); @@ -111,6 +114,7 @@ // Each loop runner can only be called once. Create a new one in case // the caller wants to call this again to wait for the next notification. loop_runner_ = std::make_unique<base::RunLoop>(); + loop_runner_quit_closure_ = loop_runner_->QuitClosure(); } void AccessibilityNotificationWaiter::WaitForNotificationWithTimeout( @@ -150,7 +154,7 @@ event_to_wait_for_ == event_type) { event_target_id_ = event_target_id; event_render_frame_host_ = rfhi; - loop_runner_->Quit(); + loop_runner_quit_closure_.Run(); } } @@ -176,7 +180,7 @@ if (generated_event_to_wait_for_ == event) { event_target_id_ = event_target_id; event_render_frame_host_ = static_cast<RenderFrameHostImpl*>(delegate); - loop_runner_->Quit(); + loop_runner_quit_closure_.Run(); } } @@ -209,7 +213,7 @@ } void AccessibilityNotificationWaiter::Quit() { - loop_runner_->Quit(); + loop_runner_quit_closure_.Run(); } } // namespace content
diff --git a/content/public/test/accessibility_notification_waiter.h b/content/public/test/accessibility_notification_waiter.h index 8126bd8..25669a09 100644 --- a/content/public/test/accessibility_notification_waiter.h +++ b/content/public/test/accessibility_notification_waiter.h
@@ -111,6 +111,7 @@ absl::optional<ax::mojom::Event> event_to_wait_for_; absl::optional<ui::AXEventGenerator::Event> generated_event_to_wait_for_; std::unique_ptr<base::RunLoop> loop_runner_; + base::RepeatingClosure loop_runner_quit_closure_; int event_target_id_ = 0; RenderFrameHostImpl* event_render_frame_host_ = nullptr;
diff --git a/content/public/test/content_browser_test_shell_main_delegate.cc b/content/public/test/content_browser_test_shell_main_delegate.cc index adc3494..a18ff13 100644 --- a/content/public/test/content_browser_test_shell_main_delegate.cc +++ b/content/public/test/content_browser_test_shell_main_delegate.cc
@@ -7,6 +7,10 @@ #include "base/test/task_environment.h" #include "content/shell/browser/shell_content_browser_client.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +#include "chromeos/lacros/lacros_chrome_service_delegate.h" +#endif + namespace content { // Acts like normal ShellContentBrowserClient but injects a test TaskTracker to @@ -21,6 +25,21 @@ } }; +ContentBrowserTestShellMainDelegate::ContentBrowserTestShellMainDelegate() + : ShellMainDelegate(/*is_content_browsertests=*/true) {} + +ContentBrowserTestShellMainDelegate::~ContentBrowserTestShellMainDelegate() = + default; + +#if BUILDFLAG(IS_CHROMEOS_LACROS) +void ContentBrowserTestShellMainDelegate::PostEarlyInitialization( + bool is_running_tests) { + // Browser tests on Lacros requires a non-null LacrosService. + lacros_service_ = std::make_unique<chromeos::LacrosService>( + /*delegate=*/nullptr); +} +#endif // BUILDFLAG(IS_CHROMEOS_LACROS) + ContentBrowserClient* ContentBrowserTestShellMainDelegate::CreateContentBrowserClient() { browser_client_ =
diff --git a/content/public/test/content_browser_test_shell_main_delegate.h b/content/public/test/content_browser_test_shell_main_delegate.h index 57616759..c763df9 100644 --- a/content/public/test/content_browser_test_shell_main_delegate.h +++ b/content/public/test/content_browser_test_shell_main_delegate.h
@@ -5,18 +5,36 @@ #ifndef CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_SHELL_MAIN_DELEGATE_H_ #define CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_SHELL_MAIN_DELEGATE_H_ +#include <memory> + +#include "build/chromeos_buildflags.h" #include "content/shell/app/shell_main_delegate.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +// TODO(erikchen): Move #include to .cc file and forward declare +// chromeos::LacrosService to resolve crbug.com/1195401. +#include "chromeos/lacros/lacros_service.h" +#endif + namespace content { // Acts like normal ShellMainDelegate but inserts behaviour for browser tests. class ContentBrowserTestShellMainDelegate : public ShellMainDelegate { public: - ContentBrowserTestShellMainDelegate() - : ShellMainDelegate(/*is_content_browsertests=*/true) {} + ContentBrowserTestShellMainDelegate(); + ~ContentBrowserTestShellMainDelegate() override; + // ContentMainDelegate implementation: +#if BUILDFLAG(IS_CHROMEOS_LACROS) + void PostEarlyInitialization(bool is_running_tests) override; +#endif // ShellMainDelegate overrides. content::ContentBrowserClient* CreateContentBrowserClient() override; + + private: +#if BUILDFLAG(IS_CHROMEOS_LACROS) + std::unique_ptr<chromeos::LacrosService> lacros_service_; +#endif }; } // namespace content
diff --git a/content/public/test/test_renderer_host.cc b/content/public/test/test_renderer_host.cc index d9d390d..d078124c 100644 --- a/content/public/test/test_renderer_host.cc +++ b/content/public/test/test_renderer_host.cc
@@ -180,34 +180,20 @@ } RenderViewHost* RenderViewHostTestHarness::rvh() { - RenderViewHost* result = web_contents()->GetMainFrame()->GetRenderViewHost(); - CHECK_EQ(result, web_contents()->GetMainFrame()->GetRenderViewHost()); - return result; -} - -RenderViewHost* RenderViewHostTestHarness::pending_rvh() { - return pending_main_rfh() ? pending_main_rfh()->GetRenderViewHost() : nullptr; -} - -RenderViewHost* RenderViewHostTestHarness::active_rvh() { - return pending_rvh() ? pending_rvh() : rvh(); + return web_contents()->GetMainFrame()->GetRenderViewHost(); } RenderFrameHost* RenderViewHostTestHarness::main_rfh() { return web_contents()->GetMainFrame(); } -RenderFrameHost* RenderViewHostTestHarness::pending_main_rfh() { - return static_cast<TestWebContents*>(web_contents()) - ->GetSpeculativePrimaryMainFrame(); -} - BrowserContext* RenderViewHostTestHarness::browser_context() { return GetBrowserContext(); } MockRenderProcessHost* RenderViewHostTestHarness::process() { - return static_cast<MockRenderProcessHost*>(active_rvh()->GetProcess()); + auto* contents = static_cast<TestWebContents*>(web_contents()); + return contents->GetMainFrame()->GetProcess(); } void RenderViewHostTestHarness::DeleteContents() {
diff --git a/content/public/test/test_renderer_host.h b/content/public/test/test_renderer_host.h index 287944c..abc7a007 100644 --- a/content/public/test/test_renderer_host.h +++ b/content/public/test/test_renderer_host.h
@@ -219,21 +219,12 @@ // web_contents()->GetRenderViewHost() RenderViewHost* rvh(); - // pending_rvh() is equivalent to: - // WebContentsTester::For(web_contents())->GetPendingRenderViewHost() - RenderViewHost* pending_rvh(); - - // active_rvh() is equivalent to pending_rvh() ? pending_rvh() : rvh() - RenderViewHost* active_rvh(); - // main_rfh() is equivalent to web_contents()->GetMainFrame() RenderFrameHost* main_rfh(); - // pending_main_rfh() is equivalent to: - // WebContentsTester::For(web_contents())->GetPendingMainFrame() - RenderFrameHost* pending_main_rfh(); - BrowserContext* browser_context(); + + // Returns |main_rfh()|'s process. MockRenderProcessHost* process(); // Frees the current WebContents for tests that want to test destruction.
diff --git a/content/renderer/render_frame_impl_browsertest.cc b/content/renderer/render_frame_impl_browsertest.cc index 12020bf..0d94ee5c 100644 --- a/content/renderer/render_frame_impl_browsertest.cc +++ b/content/renderer/render_frame_impl_browsertest.cc
@@ -193,7 +193,7 @@ } static int32_t AutoplayFlagsForFrame(TestRenderFrame* frame) { - return frame->render_view()->GetWebView()->AutoplayFlagsForTest(); + return frame->GetWebView()->AutoplayFlagsForTest(); } private:
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 870b5f6..9f02342 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc
@@ -152,7 +152,7 @@ webview_->SetRendererPreferences(params->renderer_preferences); - GetContentClient()->renderer()->RenderViewCreated(this); + GetContentClient()->renderer()->WebViewCreated(webview_); #if defined(OS_ANDROID) // TODO(sgurun): crbug.com/325351 Needed only for android webview's deprecated
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index a1debdc..0c3a81a 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -658,6 +658,7 @@ if (is_chromeos_lacros) { deps += [ "//chromeos/crosapi/cpp", + "//chromeos/lacros", "//chromeos/lacros:test_support", "//chromeos/startup:constants", ] @@ -828,6 +829,10 @@ deps += [ "//ui/base/mojom" ] } + if (is_chromeos_lacros) { + deps += [ "//chromeos/lacros:lacros" ] + } + configs += [ "//v8:external_startup_data" ] } @@ -2023,8 +2028,8 @@ "../browser/renderer_host/clipboard_host_impl_unittest.cc", "../browser/renderer_host/commit_deferring_condition_runner_unittest.cc", "../browser/renderer_host/cursor_manager_unittest.cc", + "../browser/renderer_host/document_service_base_unittest.cc", "../browser/renderer_host/embedded_frame_sink_provider_impl_unittest.cc", - "../browser/renderer_host/frame_service_base_unittest.cc", "../browser/renderer_host/frame_token_message_queue_unittest.cc", "../browser/renderer_host/frame_tree_node_blame_context_unittest.cc", "../browser/renderer_host/frame_tree_unittest.cc", @@ -2566,6 +2571,9 @@ "//chromeos/services/machine_learning/public/mojom", ] } + if (is_chromeos_lacros) { + deps += [ "//chromeos/lacros:test_support" ] + } if (is_android) { sources += [ "../browser/android/android_overlay_provider_impl_unittest.cc",
diff --git a/content/test/data/accessibility/event/aria-relevant-changed-expected-uia-win.txt b/content/test/data/accessibility/event/aria-relevant-changed-expected-uia-win.txt index 4670f83..bc6f145 100644 --- a/content/test/data/accessibility/event/aria-relevant-changed-expected-uia-win.txt +++ b/content/test/data/accessibility/event/aria-relevant-changed-expected-uia-win.txt
@@ -1,6 +1,13 @@ +=== Start Continuation === +=== Start Continuation === AriaProperties changed on role=group, name=Div3 +=== Start Continuation === AriaProperties changed on role=group, name=Div4 +=== Start Continuation === AriaProperties changed on role=group, name=Div5 +=== Start Continuation === AriaProperties changed on role=group, name=Div6 +=== Start Continuation === AriaProperties changed on role=group, name=Div7 +=== Start Continuation === AriaProperties changed on role=group, name=Div8
diff --git a/content/test/data/accessibility/event/aria-relevant-changed.html b/content/test/data/accessibility/event/aria-relevant-changed.html index 5a0a016..c56e031 100644 --- a/content/test/data/accessibility/event/aria-relevant-changed.html +++ b/content/test/data/accessibility/event/aria-relevant-changed.html
@@ -14,38 +14,44 @@ <div id="d7" tabindex='0' aria-label="Div7" aria-live="polite" aria-relevant="true">Div7</div> <div id="d8" tabindex='0' aria-label="Div8" aria-live="polite" aria-relevant="true">Div8</div> <script> - function go() { + var go_passes = [ // Set aria-relevant from default 'additions text'->'all' on a non-live region; // should not fire an event. - document.getElementById('d1').setAttribute('aria-relevant', 'all'); + () => document.getElementById('d1').setAttribute('aria-relevant', 'all'), // Set aria-relevant from default 'additions text'->'additions text'; // should not fire an event. - document.getElementById('d2').setAttribute('aria-relevant', 'additions text'); + () => document.getElementById('d2').setAttribute('aria-relevant', 'additions text'), // Set aria-relevant from default 'additions text'->'additions'; // should fire an event. - document.getElementById('d3').setAttribute('aria-relevant', 'additions'); + () => document.getElementById('d3').setAttribute('aria-relevant', 'additions'), // Set aria-relevant from default 'additions text'->'all'; // should fire an event. - document.getElementById('d4').setAttribute('aria-relevant', 'all'); + () => document.getElementById('d4').setAttribute('aria-relevant', 'all'), // Set aria-relevant from default 'additions text'->'removals'; // should fire an event. - document.getElementById('d5').setAttribute('aria-relevant', 'removals'); + () => document.getElementById('d5').setAttribute('aria-relevant', 'removals'), // Set aria-relevant from default 'additions text'->'text'; // should fire an event. - document.getElementById('d6').setAttribute('aria-relevant', 'text'); + () => document.getElementById('d6').setAttribute('aria-relevant', 'text'), // Set aria-relevant from 'additions'->'additions text'; // should fire an event. - document.getElementById('d7').setAttribute('aria-relevant', 'additions text'); + () => document.getElementById('d7').setAttribute('aria-relevant', 'additions text'), // Set aria-relevant from 'additions'->[removed]; // should fire an event. - document.getElementById('d8').removeAttribute('aria-relevant'); + () => document.getElementById('d8').removeAttribute('aria-relevant'), + ]; + + let current_pass = 0; + function go() { + go_passes[current_pass++].call(); + return current_pass < go_passes.length; } </script> </body>
diff --git a/content/test/data/accessibility/readme.md b/content/test/data/accessibility/readme.md index d200be1..5e30894 100644 --- a/content/test/data/accessibility/readme.md +++ b/content/test/data/accessibility/readme.md
@@ -165,15 +165,25 @@ ### Scripting +Note: Mac platform is supported only. + `Script tests` provide platform dependent `-SCRIPT` directive to indicate a script to run. For example: `MAC-SCRIPT: input.AXName` to dump accessible name of an accessible node for a DOM element having -`input` DOM id on Mac platform. You can also you `:LINE_NUM` to indicate an -accessible object, where `LINE_NUM` is a number of a line where the accessible -object is placed at in the formatted tree. +`input` DOM id on Mac platform. You can also use `:LINE_NUM` syntax to indicate +an accessible object, where `LINE_NUM` is index of a line where +the accessible object is placed in the formatted tree. + +Calls can be chained, for example: + +`input.AXFocusableAncestor.AXRole` + +Paramaterized attributes are also supported, for example: + +`textarea.AXPreviousWordStartTextMarkerForTextMarker({:3, 3, down})` ### Advanced directives
diff --git a/content/test/test_render_view_host.cc b/content/test/test_render_view_host.cc index 88bd15d..917f286 100644 --- a/content/test/test_render_view_host.cc +++ b/content/test/test_render_view_host.cc
@@ -376,16 +376,6 @@ return contents()->GetRenderViewHost(); } -TestRenderViewHost* RenderViewHostImplTestHarness::pending_test_rvh() { - return contents()->GetSpeculativePrimaryMainFrame() - ? contents()->GetSpeculativePrimaryMainFrame()->GetRenderViewHost() - : nullptr; -} - -TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { - return static_cast<TestRenderViewHost*>(active_rvh()); -} - TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { return contents()->GetMainFrame(); }
diff --git a/content/test/test_render_view_host.h b/content/test/test_render_view_host.h index 5482020..fb8cc12 100644 --- a/content/test/test_render_view_host.h +++ b/content/test/test_render_view_host.h
@@ -278,21 +278,6 @@ // prefer to use the GetMainFrame() method in tests. TestRenderViewHost* test_rvh(); - // pending_test_rvh() is equivalent to all of the following: - // contents()->GetPendingMainFrame()->GetRenderViewHost() [if frame exists] - // contents()->GetPendingRenderViewHost() - // static_cast<TestRenderViewHost*>(pending_rvh()) - // - // Since most functionality will eventually shift from RVH to RFH, you may - // prefer to use the GetPendingMainFrame() method in tests. - TestRenderViewHost* pending_test_rvh(); - - // active_test_rvh() is equivalent to: - // contents()->GetPendingRenderViewHost() ? - // contents()->GetPendingRenderViewHost() : - // contents()->GetRenderViewHost(); - TestRenderViewHost* active_test_rvh(); - // main_test_rfh() is equivalent to contents()->GetMainFrame() // TODO(nick): Replace all uses with contents()->GetMainFrame() TestRenderFrameHost* main_test_rfh();
diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc index b62fc641..4dada0a 100644 --- a/device/bluetooth/bluetooth_device_unittest.cc +++ b/device/bluetooth/bluetooth_device_unittest.cc
@@ -8,9 +8,9 @@ #include "base/bind.h" #include "base/containers/contains.h" +#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" #include "base/test/bind.h" #include "build/build_config.h"
diff --git a/device/bluetooth/bluetooth_gatt_descriptor.cc b/device/bluetooth/bluetooth_gatt_descriptor.cc index 5ddfd46..822e3ab 100644 --- a/device/bluetooth/bluetooth_gatt_descriptor.cc +++ b/device/bluetooth/bluetooth_gatt_descriptor.cc
@@ -7,8 +7,8 @@ #include <stddef.h> #include <vector> +#include "base/cxx17_backports.h" #include "base/lazy_instance.h" -#include "base/stl_util.h" namespace device { namespace {
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc index 2f23b34..43dbb6fa 100644 --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
@@ -8,9 +8,9 @@ #include <utility> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/bind.h" #include "build/build_config.h" #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc index 0a481db5..a3eb5a2 100644 --- a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc +++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
@@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "build/build_config.h" #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" #include "device/bluetooth/bluetooth_remote_gatt_service.h"
diff --git a/device/bluetooth/public/cpp/bluetooth_uuid_unittest.cc b/device/bluetooth/public/cpp/bluetooth_uuid_unittest.cc index 523f65e..40bc572 100644 --- a/device/bluetooth/public/cpp/bluetooth_uuid_unittest.cc +++ b/device/bluetooth/public/cpp/bluetooth_uuid_unittest.cc
@@ -6,7 +6,7 @@ #include <stddef.h> -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "base/strings/string_piece.h" #include "build/build_config.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/device/fido/ctap_response_unittest.cc b/device/fido/ctap_response_unittest.cc index eee050b7..a2c59f29 100644 --- a/device/fido/ctap_response_unittest.cc +++ b/device/fido/ctap_response_unittest.cc
@@ -5,7 +5,7 @@ #include <algorithm> #include "base/containers/contains.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "components/cbor/reader.h" #include "components/cbor/values.h" #include "components/cbor/writer.h"
diff --git a/device/gamepad/gamepad_blocklist_unittest.cc b/device/gamepad/gamepad_blocklist_unittest.cc index a8915bb..5aa19e7 100644 --- a/device/gamepad/gamepad_blocklist_unittest.cc +++ b/device/gamepad/gamepad_blocklist_unittest.cc
@@ -4,7 +4,7 @@ #include "device/gamepad/gamepad_blocklist.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "device/gamepad/gamepad_id_list.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/device/gamepad/gamepad_device_linux.cc b/device/gamepad/gamepad_device_linux.cc index 44e4ebf..891eaf16 100644 --- a/device/gamepad/gamepad_device_linux.cc +++ b/device/gamepad/gamepad_device_linux.cc
@@ -12,8 +12,8 @@ #include <sys/ioctl.h> #include "base/callback_helpers.h" +#include "base/cxx17_backports.h" #include "base/posix/eintr_wrapper.h" -#include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h"
diff --git a/device/gamepad/gamepad_id_list.cc b/device/gamepad/gamepad_id_list.cc index 9aad703..2ee9697 100644 --- a/device/gamepad/gamepad_id_list.cc +++ b/device/gamepad/gamepad_id_list.cc
@@ -7,7 +7,7 @@ #include <algorithm> #include <iterator> -#include "base/stl_util.h" +#include "base/cxx17_backports.h" namespace device {
diff --git a/device/gamepad/raw_input_data_fetcher_win.cc b/device/gamepad/raw_input_data_fetcher_win.cc index 5d2a549..3a7fd991f 100644 --- a/device/gamepad/raw_input_data_fetcher_win.cc +++ b/device/gamepad/raw_input_data_fetcher_win.cc
@@ -9,7 +9,7 @@ #include <memory> #include "base/bind.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "base/strings/sys_string_conversions.h" #include "base/trace_event/trace_event.h" #include "device/gamepad/gamepad_standard_mappings.h"
diff --git a/device/gamepad/raw_input_gamepad_device_win.cc b/device/gamepad/raw_input_gamepad_device_win.cc index 2ca55e2..5acdb931 100644 --- a/device/gamepad/raw_input_gamepad_device_win.cc +++ b/device/gamepad/raw_input_gamepad_device_win.cc
@@ -13,7 +13,7 @@ } // clang-format on -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "base/strings/string_util_win.h" #include "base/strings/sys_string_conversions.h" #include "device/gamepad/dualshock4_controller.h"
diff --git a/device/gamepad/xbox_data_fetcher_mac.cc b/device/gamepad/xbox_data_fetcher_mac.cc index f242852d..509e5d6 100644 --- a/device/gamepad/xbox_data_fetcher_mac.cc +++ b/device/gamepad/xbox_data_fetcher_mac.cc
@@ -15,9 +15,9 @@ #include <IOKit/usb/IOUSBLib.h> #include <IOKit/usb/USB.h> +#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/mac/foundation_util.h" -#include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" #include "device/gamepad/gamepad_id_list.h"
diff --git a/device/vr/android/arcore/ar_renderer.cc b/device/vr/android/arcore/ar_renderer.cc index 51f721a..d292e86 100644 --- a/device/vr/android/arcore/ar_renderer.cc +++ b/device/vr/android/arcore/ar_renderer.cc
@@ -4,7 +4,7 @@ #include "device/vr/android/arcore/ar_renderer.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "device/vr/vr_gl_util.h" namespace device {
diff --git a/device/vr/openxr/openxr_controller.cc b/device/vr/openxr/openxr_controller.cc index 57558b55..5491b8c 100644 --- a/device/vr/openxr/openxr_controller.cc +++ b/device/vr/openxr/openxr_controller.cc
@@ -7,8 +7,8 @@ #include <stdint.h> #include "base/check.h" +#include "base/cxx17_backports.h" #include "base/notreached.h" -#include "base/stl_util.h" #include "device/gamepad/public/cpp/gamepads.h" #include "device/vr/openxr/openxr_util.h" #include "device/vr/util/xr_standard_gamepad_builder.h"
diff --git a/device/vr/openxr/openxr_util.cc b/device/vr/openxr/openxr_util.cc index c1c88ae..ea39c651 100644 --- a/device/vr/openxr/openxr_util.cc +++ b/device/vr/openxr/openxr_util.cc
@@ -7,7 +7,7 @@ #include <string> #include "base/check_op.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "base/version.h" #include "base/win/scoped_handle.h" #include "build/build_config.h"
diff --git a/device/vr/openxr/test/fake_openxr_impl_api.cc b/device/vr/openxr/test/fake_openxr_impl_api.cc index 84e5d9c8..834c0de 100644 --- a/device/vr/openxr/test/fake_openxr_impl_api.cc +++ b/device/vr/openxr/test/fake_openxr_impl_api.cc
@@ -4,7 +4,7 @@ #include <wrl.h> -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "device/vr/openxr/openxr_util.h" #include "device/vr/openxr/test/openxr_negotiate.h" #include "device/vr/openxr/test/openxr_test_helper.h"
diff --git a/device/vr/windows/d3d11_device_helpers.cc b/device/vr/windows/d3d11_device_helpers.cc index d84cf00..7264fb3d 100644 --- a/device/vr/windows/d3d11_device_helpers.cc +++ b/device/vr/windows/d3d11_device_helpers.cc
@@ -8,7 +8,8 @@ #include <dxgi.h> #include <wrl.h> -#include "base/stl_util.h" +#include "base/check.h" +#include "base/cxx17_backports.h" namespace vr {
diff --git a/device/vr/windows/d3d11_texture_helper.cc b/device/vr/windows/d3d11_texture_helper.cc index 9154c4cd..ef5a5f0 100644 --- a/device/vr/windows/d3d11_texture_helper.cc +++ b/device/vr/windows/d3d11_texture_helper.cc
@@ -3,7 +3,7 @@ // found in the LICENSE file. #include "device/vr/windows/d3d11_texture_helper.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "base/trace_event/common/trace_event_common.h" #include "base/trace_event/trace_event.h" #include "mojo/public/c/system/platform_handle.h"
diff --git a/docs/enterprise/active_directory_native_integration.md b/docs/enterprise/active_directory_native_integration.md index 786bacf..c1dcd1a 100644 --- a/docs/enterprise/active_directory_native_integration.md +++ b/docs/enterprise/active_directory_native_integration.md
@@ -62,7 +62,7 @@ [AuthPolicyCredentialsManager](https://cs.chromium.org/chromium/src/chrome/browser/ash/authpolicy/authpolicy_credentials_manager.h) keeps track of user credential status, shows notifications if the Kerberos ticket expires and handles network connection changes. The -[ActiveDirectoryPolicyManager](https://cs.chromium.org/chromium/src/chrome/browser/chromeos/policy/active_directory_policy_manager.h) +[ActiveDirectoryPolicyManager](https://cs.chromium.org/chromium/src/chrome/browser/chromeos/policy/active_directory/active_directory_policy_manager.h) is the AD equivalent of the CloudPolicyManager and handles policy for AD-managed devices.
diff --git a/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc b/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc index 356de36..fc9b56da 100644 --- a/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc +++ b/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
@@ -971,16 +971,15 @@ override_headers_ = nullptr; redirect_url_ = GURL(); - net::CompletionRepeatingCallback copyable_callback = - base::AdaptCallbackForRepeating(std::move(continuation)); + auto callback_pair = base::SplitOnceCallback(std::move(continuation)); if (request_.url.SchemeIsHTTPOrHTTPS() || request_.url.SchemeIs(url::kUrnScheme)) { DCHECK(info_.has_value()); int result = ExtensionWebRequestEventRouter::GetInstance()->OnHeadersReceived( - factory_->browser_context_, &info_.value(), copyable_callback, - current_response_->headers.get(), &override_headers_, - &redirect_url_); + factory_->browser_context_, &info_.value(), + std::move(callback_pair.first), current_response_->headers.get(), + &override_headers_, &redirect_url_); if (result == net::ERR_BLOCKED_BY_CLIENT) { const int status_code = current_response_->headers ? current_response_->headers->response_code() @@ -1014,7 +1013,7 @@ DCHECK_EQ(net::OK, result); } - copyable_callback.Run(net::OK); + std::move(callback_pair.second).Run(net::OK); } void WebRequestProxyingURLLoaderFactory::InProgressRequest::OnRequestError( const network::URLLoaderCompletionStatus& status,
diff --git a/extensions/browser/extension_message_filter.cc b/extensions/browser/extension_message_filter.cc index b225535..9ee2211 100644 --- a/extensions/browser/extension_message_filter.cc +++ b/extensions/browser/extension_message_filter.cc
@@ -100,13 +100,9 @@ return true; case MessagingEndpoint::Type::kTab: - if (source_endpoint.extension_id.has_value() && - !ContentScriptTracker::DidProcessRunContentScriptFromExtension( - process, source_endpoint.extension_id.value())) { - bad_message::ReceivedBadMessage( - &process, bad_message::EMF_INVALID_EXTENSION_ID_FOR_CONTENT_SCRIPT); - return false; - } + // TODO(https://crbug.com/1212918: Re-enable the enforcement after + // investigating and fixing the root cause of bad message reports coming + // from the end users. return true; } }
diff --git a/extensions/shell/test/test_shell_main_delegate.cc b/extensions/shell/test/test_shell_main_delegate.cc index b2ba4fe0..63202393 100644 --- a/extensions/shell/test/test_shell_main_delegate.cc +++ b/extensions/shell/test/test_shell_main_delegate.cc
@@ -13,7 +13,6 @@ #if BUILDFLAG(IS_CHROMEOS_LACROS) #include "chromeos/lacros/lacros_chrome_service_delegate.h" -#include "chromeos/lacros/lacros_chrome_service_impl.h" #endif namespace { @@ -52,8 +51,8 @@ #if BUILDFLAG(IS_CHROMEOS_LACROS) void TestShellMainDelegate::PostEarlyInitialization(bool is_running_tests) { - // Browser tests on Lacros requires a non-null LacrosChromeService. - lacros_chrome_service_ = std::make_unique<chromeos::LacrosChromeServiceImpl>( + // Browser tests on Lacros requires a non-null LacrosService. + lacros_service_ = std::make_unique<chromeos::LacrosService>( /*delegate=*/nullptr); } #endif // BUILDFLAG(IS_CHROMEOS_LACROS)
diff --git a/extensions/shell/test/test_shell_main_delegate.h b/extensions/shell/test/test_shell_main_delegate.h index 3b44bad5..8ea0f86 100644 --- a/extensions/shell/test/test_shell_main_delegate.h +++ b/extensions/shell/test/test_shell_main_delegate.h
@@ -12,16 +12,16 @@ #include "build/chromeos_buildflags.h" #include "extensions/shell/app/shell_main_delegate.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +// TODO(erikchen): Move #include to .cc file and forward declare +// chromeos::LacrosService to resolve crbug.com/1195401. +#include "chromeos/lacros/lacros_service.h" +#endif + namespace content { class ContentUtilityClient; } -#if BUILDFLAG(IS_CHROMEOS_LACROS) -namespace chromeos { -class LacrosChromeServiceImpl; -} -#endif - namespace extensions { class TestShellMainDelegate : public extensions::ShellMainDelegate { @@ -42,7 +42,7 @@ std::unique_ptr<content::ContentUtilityClient> utility_client_; #if BUILDFLAG(IS_CHROMEOS_LACROS) - std::unique_ptr<chromeos::LacrosChromeServiceImpl> lacros_chrome_service_; + std::unique_ptr<chromeos::LacrosService> lacros_service_; #endif DISALLOW_COPY_AND_ASSIGN(TestShellMainDelegate);
diff --git a/fuchsia/engine/browser/media_resource_provider_service.cc b/fuchsia/engine/browser/media_resource_provider_service.cc index 5cc824f..8dfdda0 100644 --- a/fuchsia/engine/browser/media_resource_provider_service.cc +++ b/fuchsia/engine/browser/media_resource_provider_service.cc
@@ -12,7 +12,7 @@ #include "base/files/file_path.h" #include "base/fuchsia/process_context.h" #include "content/public/browser/browser_context.h" -#include "content/public/browser/frame_service_base.h" +#include "content/public/browser/document_service_base.h" #include "content/public/browser/provision_fetcher_factory.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" @@ -27,7 +27,7 @@ namespace { class MediaResourceProviderImpl - : public content::FrameServiceBase< + : public content::DocumentServiceBase< media::mojom::FuchsiaMediaResourceProvider> { public: MediaResourceProviderImpl( @@ -59,7 +59,7 @@ media::FuchsiaCdmManager* cdm_manager, content::RenderFrameHost* render_frame_host, mojo::PendingReceiver<media::mojom::FuchsiaMediaResourceProvider> receiver) - : FrameServiceBase(render_frame_host, std::move(receiver)), + : DocumentServiceBase(render_frame_host, std::move(receiver)), cdm_manager_(cdm_manager) { DCHECK(cdm_manager_); }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc index e3a6455..90e5de37 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
@@ -23,47 +23,12 @@ #include "ui/gfx/geometry/rect_conversions.h" #include "ui/gl/ca_renderer_layer_params.h" #include "ui/gl/dc_renderer_layer_params.h" +#include "ui/gl/gl_utils.h" #include "ui/gl/gl_version_info.h" namespace gpu { namespace gles2 { -// Temporarily allows compilation of shaders that use the -// ARB_texture_rectangle/ANGLE_texture_rectangle extension. We don't want to -// expose the extension to WebGL user shaders but we still need to use it for -// parts of the implementation on macOS. Note that the extension is always -// enabled on macOS and this only controls shader compilation. -class GLES2DecoderPassthroughImpl:: - ScopedEnableTextureRectangleInShaderCompiler { - public: - ScopedEnableTextureRectangleInShaderCompiler( - const ScopedEnableTextureRectangleInShaderCompiler&) = delete; - ScopedEnableTextureRectangleInShaderCompiler& operator=( - const ScopedEnableTextureRectangleInShaderCompiler&) = delete; - - // This class is a no-op except on macOS. -#if !defined(OS_MAC) - explicit ScopedEnableTextureRectangleInShaderCompiler( - GLES2DecoderPassthroughImpl* decoder) {} - - private: -#else - explicit ScopedEnableTextureRectangleInShaderCompiler( - GLES2DecoderPassthroughImpl* decoder) - : decoder_(decoder) { - if (decoder_->feature_info_->IsWebGLContext()) - decoder_->api_->glEnableFn(GL_TEXTURE_RECTANGLE_ANGLE); - } - ~ScopedEnableTextureRectangleInShaderCompiler() { - if (decoder_->feature_info_->IsWebGLContext()) - decoder_->api_->glDisableFn(GL_TEXTURE_RECTANGLE_ANGLE); - } - - private: - GLES2DecoderPassthroughImpl* decoder_; -#endif -}; - namespace { template <typename ClientType, typename ServiceType, typename GenFunction> @@ -4505,7 +4470,8 @@ GLboolean unpack_flip_y, GLboolean unpack_premultiply_alpha, GLboolean unpack_unmultiply_alpha) { - ScopedEnableTextureRectangleInShaderCompiler enable(this); + gl::ScopedEnableTextureRectangleInShaderCompiler enable( + feature_info_->IsWebGLContext() ? api() : nullptr); BindPendingImageForClientIDIfNeeded(source_id); api()->glCopyTextureCHROMIUMFn( GetTextureServiceID(api(), source_id, resources_, false), source_level, @@ -4533,7 +4499,8 @@ GLboolean unpack_flip_y, GLboolean unpack_premultiply_alpha, GLboolean unpack_unmultiply_alpha) { - ScopedEnableTextureRectangleInShaderCompiler enable(this); + gl::ScopedEnableTextureRectangleInShaderCompiler enable( + feature_info_->IsWebGLContext() ? api() : nullptr); BindPendingImageForClientIDIfNeeded(source_id); api()->glCopySubTextureCHROMIUMFn( GetTextureServiceID(api(), source_id, resources_, false), source_level,
diff --git a/gpu/command_buffer/service/raster_decoder.cc b/gpu/command_buffer/service/raster_decoder.cc index 8433fbd..01f43c92 100644 --- a/gpu/command_buffer/service/raster_decoder.cc +++ b/gpu/command_buffer/service/raster_decoder.cc
@@ -3179,6 +3179,15 @@ return; } + // This check only fails on validating decoder since clear tracking for + // passthrough textures is done by ANGLE. Nonetheless the check is important + // so that clients cannot use uninitialized textures with validating decoder. + if (!needs_clear && !shared_image_->IsCleared()) { + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginRasterCHROMIUM", + "SharedImage not cleared before use."); + return; + } + DCHECK(locked_handles_.empty()); DCHECK(!raster_canvas_); shared_context_state_->set_need_context_state_reset(true);
diff --git a/gpu/ipc/in_process_command_buffer.cc b/gpu/ipc/in_process_command_buffer.cc index 3956f5e..9b0ad6c7 100644 --- a/gpu/ipc/in_process_command_buffer.cc +++ b/gpu/ipc/in_process_command_buffer.cc
@@ -1265,10 +1265,11 @@ void InProcessCommandBuffer::SignalSyncTokenOnGpuThread( const SyncToken& sync_token, base::OnceClosure callback) { - base::RepeatingClosure maybe_pass_callback = - base::AdaptCallbackForRepeating(WrapClientCallback(std::move(callback))); - if (!sync_point_client_state_->Wait(sync_token, maybe_pass_callback)) { - maybe_pass_callback.Run(); + auto callback_pair = + base::SplitOnceCallback(WrapClientCallback(std::move(callback))); + if (!sync_point_client_state_->Wait(sync_token, + std::move(callback_pair.first))) { + std::move(callback_pair.second).Run(); } }
diff --git a/ios/chrome/app/first_run_app_state_agent.mm b/ios/chrome/app/first_run_app_state_agent.mm index cc9fa4a..a8ad953 100644 --- a/ios/chrome/app/first_run_app_state_agent.mm +++ b/ios/chrome/app/first_run_app_state_agent.mm
@@ -18,6 +18,8 @@ #import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" #import "ios/chrome/browser/ui/commands/browsing_data_commands.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h" +#import "ios/chrome/browser/ui/first_run/first_run_coordinator.h" +#import "ios/chrome/browser/ui/first_run/first_run_screen_provider.h" #import "ios/chrome/browser/ui/first_run/first_run_util.h" #import "ios/chrome/browser/ui/first_run/location_permissions_field_trial.h" #import "ios/chrome/browser/ui/first_run/orientation_limiting_navigation_controller.h" @@ -48,7 +50,8 @@ } @interface FirstRunAppAgent () <AppStateObserver, - PolicyWatcherBrowserAgentObserving> + PolicyWatcherBrowserAgentObserving, + FirstRunCoordinatorDelegate> // The app state for the app. @property(nonatomic, weak, readonly) AppState* appState; @@ -59,6 +62,9 @@ // The scene that is chosen for presenting the FRE on. @property(nonatomic, strong) SceneState* presentingSceneState; +// Coordinator of the new First Run UI. +@property(nonatomic, strong) FirstRunCoordinator* firstRunCoordinator; + @end @implementation FirstRunAppAgent { @@ -175,7 +181,7 @@ [self setUpPolicyWatcher]; if (base::FeatureList::IsEnabled(kEnableFREUIModuleIOS)) { - [self.presentingSceneState.controller showFirstRunUI]; + [self showNewFirstRunUI]; } else { [self showLegacyFirstRunUI]; } @@ -230,7 +236,31 @@ completion:nil]; } +// Shows the new first run UI. +- (void)showNewFirstRunUI { + DCHECK(!_firstRunUIBlocker); + _firstRunUIBlocker = + std::make_unique<ScopedUIBlocker>(self.presentingSceneState); + + FirstRunScreenProvider* provider = [[FirstRunScreenProvider alloc] init]; + + self.firstRunCoordinator = [[FirstRunCoordinator alloc] + initWithBaseViewController:self.presentingSceneState.interfaceProvider + .mainInterface.bvc + browser:self.presentingSceneState.interfaceProvider + .mainInterface.browser + syncPresenter:self.presentingSceneState.interfaceProvider + .mainInterface.bvc + screenProvider:provider]; + self.firstRunCoordinator.delegate = self; + self.presentingSceneState.presentingFirstRunUI = YES; + [self.firstRunCoordinator start]; +} + - (void)handleFirstRunUIWillFinish { + if (![self ignoreFirstRunStageForTesting]) { + DCHECK(self.appState.initStage == InitStageFirstRun); + } DCHECK(self.presentingSceneState.presentingFirstRunUI); _firstRunUIBlocker.reset(); self.presentingSceneState.presentingFirstRunUI = NO; @@ -280,9 +310,39 @@ } } -// TODO(crbug.com/1210246): Remove this hook once the chrome test fixture is -// adapted to startup testing. -// +#pragma mark - FirstRunCoordinatorDelegate + +- (void)willFinishPresentingScreens { + [self handleFirstRunUIWillFinish]; + + [self.firstRunCoordinator stop]; +} + +- (void)didFinishPresentingScreensWithSubsequentActionsTriggered: + (BOOL)actionsTriggered { + // Triggers all the events after the first run is dismissed. Note that the + // below logic should be removed after the new first run UI supports location + // permission page. + [self maybePromptLocationWithSystemAlert]; + + // Only show the location permission if no additional actions were taken. + if (!actionsTriggered && + location_permissions_field_trial::IsInFirstRunModalGroup()) { + id<ApplicationCommands> handler = static_cast<id<ApplicationCommands>>( + self.presentingSceneState.interfaceProvider.mainInterface.browser + ->GetCommandDispatcher()); + [handler showLocationPermissionsFromViewController:self.presentingSceneState + .interfaceProvider + .mainInterface.bvc]; + } + if (![self ignoreFirstRunStageForTesting]) { + [self.appState queueTransitionToNextInitStage]; + } +} + +#pragma mark - Test hooks + +// TODO(crbug.com/1178821): Move this to the FRE agent. // Determines whether the First Run stage has to be ignored because of // testing. When testing with first_run_egtest.mm, the First Run UI is // manually triggered after the browser is fully initialized, in which
diff --git a/ios/chrome/app/strings/ios_chromium_strings.grd b/ios/chrome/app/strings/ios_chromium_strings.grd index 2c5555cb5..f2bebd8 100644 --- a/ios/chrome/app/strings/ios_chromium_strings.grd +++ b/ios/chrome/app/strings/ios_chromium_strings.grd
@@ -250,9 +250,15 @@ <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_METRICS_CONSENT" desc="The label next to the metrics reporting consent checkbox of the welcome screen presented to the user on First Run [iOS only]"> Help improve Chromium by sending usage statistics and crash reports to Google </message> + <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE" desc="The title of the welcome screen presented to the user on First Run when the browser is managed [iOS only]"> + Get more done with Chromium + </message> <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE" desc="The subtitle of the welcome screen presented to the user on First Run [iOS only]"> Get more done with a simple, secure and faster-than-ever Chromium </message> + <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE" desc="The subtitle of the welcome screen presented to the user on First Run when the browser is managed [iOS only]"> + Chromium is simple, secure and faster-than-ever + </message> <message name="IDS_IOS_FIRSTRUN_AGREE_TO_TERMS" desc="Label containing a link to the Terms of Service, displayed in the first run flow. [Length: 117em] [iOS only]"> By using Chromium, you agree to the <ph name="BEGIN_LINK_TOS">BEGIN_LINK_TOS</ph>Terms of Service<ph name="END_LINK_TOS">END_LINK_TOS</ph>. </message>
diff --git a/ios/chrome/app/strings/ios_chromium_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE.png.sha1 b/ios/chrome/app/strings/ios_chromium_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE.png.sha1 new file mode 100644 index 0000000..ee810ea --- /dev/null +++ b/ios/chrome/app/strings/ios_chromium_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE.png.sha1
@@ -0,0 +1 @@ +9ab4175c43468add867a5e466858c071c86b3098 \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_chromium_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE.png.sha1 b/ios/chrome/app/strings/ios_chromium_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE.png.sha1 new file mode 100644 index 0000000..cdcb0af --- /dev/null +++ b/ios/chrome/app/strings/ios_chromium_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE.png.sha1
@@ -0,0 +1 @@ +97fc733ecba3665821f12569c5ebb9f8648ef94d \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_google_chrome_strings.grd b/ios/chrome/app/strings/ios_google_chrome_strings.grd index bbcbea8..0dfe11e0 100644 --- a/ios/chrome/app/strings/ios_google_chrome_strings.grd +++ b/ios/chrome/app/strings/ios_google_chrome_strings.grd
@@ -250,9 +250,15 @@ <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_METRICS_CONSENT" desc="The label next to the metrics reporting consent checkbox of the welcome screen presented to the user on First Run [iOS only]"> Help improve Chrome by sending usage statistics and crash reports to Google </message> + <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE" desc="The title of the welcome screen presented to the user on First Run when the browser is managed [iOS only]"> + Get more done with Chrome + </message> <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE" desc="The subtitle of the welcome screen presented to the user on First Run [iOS only]"> Get more done with a simple, secure and faster-than-ever Google Chrome </message> + <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE" desc="The subtitle of the welcome screen presented to the user on First Run when the browser is managed [iOS only]"> + Google Chrome is simple, secure and faster-than-ever + </message> <message name="IDS_IOS_FIRSTRUN_AGREE_TO_TERMS" desc="Label containing a link to the Terms of Service, displayed in the first run flow. [Length: 117em] [iOS only]"> By using Chrome, you agree to the <ph name="BEGIN_LINK_TOS">BEGIN_LINK_TOS</ph>Terms of Service<ph name="END_LINK_TOS">END_LINK_TOS</ph>. </message>
diff --git a/ios/chrome/app/strings/ios_google_chrome_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE.png.sha1 b/ios/chrome/app/strings/ios_google_chrome_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE.png.sha1 new file mode 100644 index 0000000..dda02ab --- /dev/null +++ b/ios/chrome/app/strings/ios_google_chrome_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE.png.sha1
@@ -0,0 +1 @@ +eae9f19609ec763cf512d3e009134a47b1c3a041 \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_google_chrome_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE.png.sha1 b/ios/chrome/app/strings/ios_google_chrome_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE.png.sha1 new file mode 100644 index 0000000..818c952 --- /dev/null +++ b/ios/chrome/app/strings/ios_google_chrome_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE.png.sha1
@@ -0,0 +1 @@ +66dcda3a980a4013a303616b838e00b684b2e50b \ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd index 2fbaea8..146b9fe 100644 --- a/ios/chrome/app/strings/ios_strings.grd +++ b/ios/chrome/app/strings/ios_strings.grd
@@ -900,6 +900,9 @@ <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_IPHONE" desc="The title of the welcome screen presented to the user on First Run when on iPhone [iOS only]"> Built for your iPhone </message> + <message name="IDS_IOS_FIRST_RUN_WELCOME_SCREEN_MANAGED" desc="The disclaimer that the browser is managed on the welcome screen presented to the user on First Run when the browser is managed [iOS only]"> + This browser is managed by your organization + </message> <message name="IDS_IOS_FIRSTRUN_BROWSER_MANAGED" desc="Label explaining that the app is managed by an organization. This is shown on the Welcome screen presented to the user on First Run. Only shown if some enterprise policies are set. [iOS only]"> Your browser is managed by your organization. Some features may be disabled. </message>
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_MANAGED.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_MANAGED.png.sha1 new file mode 100644 index 0000000..ce4b527 --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_FIRST_RUN_WELCOME_SCREEN_MANAGED.png.sha1
@@ -0,0 +1 @@ +16a391cece53bfa37bf6d7cbd2ece31659f5828f \ No newline at end of file
diff --git a/ios/chrome/browser/browsing_data/browsing_data_remover_impl.mm b/ios/chrome/browser/browsing_data/browsing_data_remover_impl.mm index c3a0879..ae8bc27 100644 --- a/ios/chrome/browser/browsing_data/browsing_data_remover_impl.mm +++ b/ios/chrome/browser/browsing_data/browsing_data_remover_impl.mm
@@ -132,8 +132,8 @@ net::CookieStore* cookie_store = request_context_getter->GetURLRequestContext()->cookie_store(); cookie_store->DeleteAllCreatedInTimeRangeAsync( - creation_range, AdaptCallbackForRepeating(base::BindOnce( - &DeleteCallbackAdapter, std::move(callback)))); + creation_range, + base::BindOnce(&DeleteCallbackAdapter, std::move(callback))); } } // namespace @@ -423,8 +423,7 @@ if (password_store) { password_store->RemoveLoginsCreatedBetween( - delete_begin, delete_end, - AdaptCallbackForRepeating(CreatePendingTaskCompletionClosure())); + delete_begin, delete_end, CreatePendingTaskCompletionClosure()); } } @@ -532,8 +531,7 @@ // Always wipe accumulated network related data (TransportSecurityState and // HttpServerPropertiesManager data). browser_state_->ClearNetworkingHistorySince( - delete_begin, - AdaptCallbackForRepeating(CreatePendingTaskCompletionClosure())); + delete_begin, CreatePendingTaskCompletionClosure()); // Remove browsing data stored in WKWebsiteDataStore if necessary. RemoveDataFromWKWebsiteDataStore(delete_begin, mask);
diff --git a/ios/chrome/browser/ui/first_run/welcome/BUILD.gn b/ios/chrome/browser/ui/first_run/welcome/BUILD.gn index e958ceb..237b7ff 100644 --- a/ios/chrome/browser/ui/first_run/welcome/BUILD.gn +++ b/ios/chrome/browser/ui/first_run/welcome/BUILD.gn
@@ -36,12 +36,14 @@ deps = [ "//base", "//components/metrics", + "//components/policy/core/common:common_constants", "//components/prefs", "//ios/chrome/app/strings", "//ios/chrome/browser", "//ios/chrome/browser/ui/first_run:first_run_ui", "//ios/chrome/browser/ui/first_run/resources:welcome_metrics_checkmark", "//ios/chrome/browser/ui/first_run/resources:welcome_screen_banner", + "//ios/chrome/browser/ui/settings/resources:enterprise_icon", "//ios/chrome/browser/ui/util", "//ios/chrome/common", "//ios/chrome/common/ui/colors",
diff --git a/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm b/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm index 6a39163..bd6ee2e4 100644 --- a/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm +++ b/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm
@@ -4,6 +4,7 @@ #import "ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.h" +#import "components/policy/core/common/policy_loader_ios_constants.h" #import "ios/chrome/browser/ui/first_run/welcome/checkbox_button.h" #import "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/common/string_util.h" @@ -25,6 +26,8 @@ // URL for the terms of service text. NSString* const kTermsOfServiceUrl = @"internal://terms-of-service"; +NSString* const kEnterpriseIconImageName = @"enterprise_icon"; + } // namespace @interface WelcomeScreenViewController () <UITextViewDelegate> @@ -38,13 +41,8 @@ @dynamic delegate; - (void)viewDidLoad { - self.titleText = - IsIPadIdiom() - ? l10n_util::GetNSString(IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_IPAD) - : l10n_util::GetNSString( - IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_IPHONE); - self.subtitleText = - l10n_util::GetNSString(IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE); + [self configureLabels]; + self.bannerImage = [UIImage imageNamed:@"welcome_screen_banner"]; self.isTallBanner = YES; self.scrollToEndMandatory = YES; @@ -58,9 +56,6 @@ [self.specificContentView addSubview:self.termsOfServiceTextView]; [NSLayoutConstraint activateConstraints:@[ - [self.metricsConsentButton.topAnchor - constraintGreaterThanOrEqualToAnchor:self.specificContentView - .topAnchor], [self.metricsConsentButton.centerXAnchor constraintEqualToAnchor:self.specificContentView.centerXAnchor], [self.metricsConsentButton.widthAnchor @@ -77,6 +72,38 @@ constraintEqualToAnchor:self.specificContentView.bottomAnchor], ]]; + if ([self isBrowserManaged]) { + UILabel* managedLabel = [self createManagedLabel]; + UIImage* image = [UIImage imageNamed:kEnterpriseIconImageName]; + UIImageView* imageView = [[UIImageView alloc] initWithImage:image]; + imageView.translatesAutoresizingMaskIntoConstraints = NO; + [self.specificContentView addSubview:managedLabel]; + [self.specificContentView addSubview:imageView]; + + [NSLayoutConstraint activateConstraints:@[ + [managedLabel.topAnchor + constraintEqualToAnchor:self.specificContentView.topAnchor], + [managedLabel.centerXAnchor + constraintEqualToAnchor:self.specificContentView.centerXAnchor], + [managedLabel.widthAnchor + constraintLessThanOrEqualToAnchor:self.specificContentView + .widthAnchor], + + [imageView.topAnchor constraintEqualToAnchor:managedLabel.bottomAnchor + constant:kDefaultMargin], + [imageView.centerXAnchor + constraintEqualToAnchor:self.specificContentView.centerXAnchor], + + [self.metricsConsentButton.topAnchor + constraintGreaterThanOrEqualToAnchor:imageView.bottomAnchor + constant:kDefaultMargin], + ]]; + } else { + [self.metricsConsentButton.topAnchor + constraintGreaterThanOrEqualToAnchor:self.specificContentView.topAnchor] + .active = YES; + } + [super viewDidLoad]; } @@ -88,6 +115,39 @@ #pragma mark - Private +// Configures the text for the title and subtitle based on whether the browser +// is managed or not. +- (void)configureLabels { + if ([self isBrowserManaged]) { + self.titleText = l10n_util::GetNSString( + IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_ENTERPRISE); + self.subtitleText = l10n_util::GetNSString( + IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE_ENTERPRISE); + } else { + self.titleText = IsIPadIdiom() + ? l10n_util::GetNSString( + IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_IPAD) + : l10n_util::GetNSString( + IDS_IOS_FIRST_RUN_WELCOME_SCREEN_TITLE_IPHONE); + self.subtitleText = + l10n_util::GetNSString(IDS_IOS_FIRST_RUN_WELCOME_SCREEN_SUBTITLE); + } +} + +// Creates and configures the label for the disclaimer that the browser is +// managed. +- (UILabel*)createManagedLabel { + UILabel* label = [[UILabel alloc] init]; + label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]; + label.numberOfLines = 0; + label.text = l10n_util::GetNSString(IDS_IOS_FIRST_RUN_WELCOME_SCREEN_MANAGED); + label.textColor = [UIColor colorNamed:kTextSecondaryColor]; + label.textAlignment = NSTextAlignmentCenter; + label.translatesAutoresizingMaskIntoConstraints = NO; + label.adjustsFontForContentSizeCategory = YES; + return label; +} + // Creates and configures the UMA consent checkbox button. - (CheckboxButton*)createMetricsConsentButton { CheckboxButton* button = [[CheckboxButton alloc] initWithFrame:CGRectZero]; @@ -140,10 +200,19 @@ return textView; } +// Handler for when the metrics button gets tapped. Toggles the button's +// selected state. - (void)didTapMetricsButton { self.metricsConsentButton.selected = !self.metricsConsentButton.selected; } +// Returns whether the browser is managed based on the presence of policy data +// in the app configuration. +- (BOOL)isBrowserManaged { + return [[[NSUserDefaults standardUserDefaults] + dictionaryForKey:kPolicyLoaderIOSConfigurationKey] count] > 0; +} + #pragma mark - UITextViewDelegate - (BOOL)textView:(UITextView*)textView
diff --git a/ios/chrome/browser/ui/main/scene_controller.h b/ios/chrome/browser/ui/main/scene_controller.h index f7fb10b..31fa3fac 100644 --- a/ios/chrome/browser/ui/main/scene_controller.h +++ b/ios/chrome/browser/ui/main/scene_controller.h
@@ -44,10 +44,6 @@ completionHandler:(void (^)(BOOL succeeded))completionHandler API_AVAILABLE(ios(13)); -// TODO(crbug.com/1210256): Remove this once it is migrated to the agent. -// Shows the new first run UI. -- (void)showFirstRunUI; - @end #endif // IOS_CHROME_BROWSER_UI_MAIN_SCENE_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/main/scene_controller.mm b/ios/chrome/browser/ui/main/scene_controller.mm index 1b8e7db..05260f0 100644 --- a/ios/chrome/browser/ui/main/scene_controller.mm +++ b/ios/chrome/browser/ui/main/scene_controller.mm
@@ -84,9 +84,6 @@ #import "ios/chrome/browser/ui/commands/show_signin_command.h" #import "ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_scheduler.h" #import "ios/chrome/browser/ui/default_promo/default_browser_utils.h" -#import "ios/chrome/browser/ui/first_run/first_run_coordinator.h" -#import "ios/chrome/browser/ui/first_run/first_run_screen_provider.h" -#import "ios/chrome/browser/ui/first_run/first_run_util.h" #import "ios/chrome/browser/ui/first_run/location_permissions_commands.h" #import "ios/chrome/browser/ui/first_run/location_permissions_coordinator.h" #import "ios/chrome/browser/ui/first_run/location_permissions_field_trial.h" @@ -185,7 +182,6 @@ } // namespace @interface SceneController () <AppStateObserver, - FirstRunCoordinatorDelegate, LocationPermissionsCommands, PolicyWatcherBrowserAgentObserving, SettingsNavigationControllerDelegate, @@ -268,15 +264,10 @@ @property(nonatomic, weak) WelcomeToChromeViewController* welcomeToChromeController; -// Coordinator of the new first run UI. -@property(nonatomic, strong) FirstRunCoordinator* firstRunCoordinator; - @end -@implementation SceneController { - // UI blocker used while FRE is shown in the scene controlled by this object. - std::unique_ptr<ScopedUIBlocker> _firstRunUIBlocker; -} +@implementation SceneController + @synthesize startupParameters = _startupParameters; @synthesize startupParametersAreBeingHandled = _startupParametersAreBeingHandled; @@ -922,10 +913,7 @@ [self.mainCoordinator setActivePage:[self activePage]]; - // Decide if the First Run UI needs to run. - const bool firstRun = ShouldPresentFirstRunExperience(); - - if (!firstRun) { + if (!self.sceneState.appState.startupInformation.isFirstRun) { [self reconcileEulaAsAccepted]; } @@ -1167,28 +1155,11 @@ #pragma mark - First Run -// Shows the first run UI. -- (void)showFirstRunUI { - DCHECK(!_firstRunUIBlocker); - _firstRunUIBlocker = std::make_unique<ScopedUIBlocker>(self.sceneState); - - FirstRunScreenProvider* provider = [[FirstRunScreenProvider alloc] init]; - - self.firstRunCoordinator = [[FirstRunCoordinator alloc] - initWithBaseViewController:self.mainInterface.bvc - browser:self.mainInterface.browser - syncPresenter:self.mainInterface.bvc - screenProvider:provider]; - self.firstRunCoordinator.delegate = self; - self.sceneState.presentingFirstRunUI = YES; - [self.firstRunCoordinator start]; -} - // Sets a LocalState pref marking the TOS EULA as accepted. // If this function is called, the EULA flag is not set but the FRE was not // displayed. // This can only happen if the EULA flag has not been set correctly on a -// previous +// previous session. - (void)reconcileEulaAsAccepted { static dispatch_once_t once_token = 0; dispatch_once(&once_token, ^{ @@ -1202,19 +1173,6 @@ }); } -- (void)handleFirstRunUIWillFinish { - if (![self ignoreFirstRunStageForTesting]) { - DCHECK(self.sceneState.appState.initStage == InitStageFirstRun); - } - DCHECK(self.sceneState.presentingFirstRunUI); - _firstRunUIBlocker.reset(); - self.sceneState.presentingFirstRunUI = NO; - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:kChromeFirstRunUIWillFinishNotification - object:nil]; -} - // Presents the sign-in upgrade promo if is relevant and possible. // Returns YES if the promo is shown. - (BOOL)presentSigninUpgradePromoIfPossible { @@ -3022,61 +2980,8 @@ self.incognitoInterface.bvc; } -#pragma mark - FirstRunCoordinatorDelegate - -- (void)willFinishPresentingScreens { - // Reset |sceneState.presentingFirstRunUI| flag. - [self handleFirstRunUIWillFinish]; - - [self.firstRunCoordinator stop]; -} - -- (void)didFinishPresentingScreensWithSubsequentActionsTriggered: - (BOOL)actionsTriggered { - // Triggers all the events after the first run is dismissed. Note that the - // below logic should be removed after the new first run UI supports location - // permission page. - if (!location_permissions_field_trial::IsInRemoveFirstRunPromptGroup() && - !location_permissions_field_trial::IsInFirstRunModalGroup()) { - [self logLocationPermissionsExperimentForGroupShown: - LocationPermissionsUI::kFirstRunPromptNotShown]; - // As soon as First Run has finished, give OmniboxGeolocationController an - // opportunity to present the iOS system location alert. - [[OmniboxGeolocationController sharedInstance] triggerSystemPrompt]; - } else if (location_permissions_field_trial:: - IsInRemoveFirstRunPromptGroup()) { - // If in RemoveFirstRunPrompt group, the system prompt will be delayed until - // the site requests location information. - [[OmniboxGeolocationController sharedInstance] - systemPromptSkippedForNewUser]; - } - - // Only show the location permission if no additional actions were taken. - if (!actionsTriggered && - location_permissions_field_trial::IsInFirstRunModalGroup()) { - id<ApplicationCommands> handler = static_cast<id<ApplicationCommands>>( - self.mainInterface.browser->GetCommandDispatcher()); - [handler showLocationPermissionsFromViewController:self.mainInterface.bvc]; - } - - if (![self ignoreFirstRunStageForTesting]) { - [self.sceneState.appState queueTransitionToNextInitStage]; - } -} - #pragma mark - Test hooks -// TODO(crbug.com/1178821): Move this to the FRE agent. -// Determines whether the First Run stage has to be ignored because of -// testing. When testing with first_run_egtest.mm, the First Run UI is -// manually triggered after the browser is fully initialized, in which -// case the code that assumes that the app is in the First Run stage when -// showing the FRE has to be ignored to avoid unexepted failures (e.g., DCHECKs, -// unexpected init stage transition). -- (BOOL)ignoreFirstRunStageForTesting { - return tests_hook::DisableFirstRun(); -} - #pragma mark - PolicyWatcherBrowserAgentObserving - (void)policyWatcherBrowserAgentNotifySignInDisabled:
diff --git a/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_coordinator.mm b/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_coordinator.mm index a1218d1..04e13a1 100644 --- a/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_coordinator.mm +++ b/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_coordinator.mm
@@ -7,6 +7,7 @@ #import <MaterialComponents/MaterialSnackbar.h> #include "base/check.h" +#include "base/mac/foundation_util.h" #include "base/strings/sys_string_conversions.h" #include "components/send_tab_to_self/send_tab_to_self_sync_service.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h" @@ -100,10 +101,19 @@ #pragma mark - SendTabToSelfModalPositioner -- (CGFloat)modalHeight { - UITableView* tableView = self.sendTabToSelfViewController.tableView; - [tableView setNeedsLayout]; - [tableView layoutIfNeeded]; +- (CGFloat)modalHeightForWidth:(CGFloat)width { + UIView* view = self.sendTabToSelfViewController.view; + CGSize contentSize = CGSizeZero; + if (UIScrollView* scrollView = base::mac::ObjCCast<UIScrollView>(view)) { + CGRect layoutFrame = self.baseViewController.view.bounds; + layoutFrame.size.width = width; + scrollView.frame = layoutFrame; + [scrollView setNeedsLayout]; + [scrollView layoutIfNeeded]; + contentSize = scrollView.contentSize; + } else { + contentSize = [view sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)]; + } // Since the TableView is contained in a NavigationController get the // navigation bar height. @@ -111,7 +121,7 @@ self.sendTabToSelfViewController.navigationController.navigationBar.frame .size.height; - return tableView.contentSize.height + navigationBarHeight; + return contentSize.height + navigationBarHeight; } #pragma mark-- SendTabToSelfModalDelegate
diff --git a/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_positioner.h b/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_positioner.h index 8e007c3..ee6344b4 100644 --- a/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_positioner.h +++ b/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_positioner.h
@@ -11,8 +11,8 @@ // to self modal dialog. @protocol SendTabToSelfModalPositioner -// The target height for the modal view to be presented. -- (CGFloat)modalHeight; +// The target height for the modal view for |width|. +- (CGFloat)modalHeightForWidth:(CGFloat)width; @end
diff --git a/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_presentation_controller.mm b/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_presentation_controller.mm index 71973409..3bcb5549 100644 --- a/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_presentation_controller.mm +++ b/ios/chrome/browser/ui/send_tab_to_self/send_tab_to_self_modal_presentation_controller.mm
@@ -45,7 +45,8 @@ CGFloat maxAvailableWidth = safeAreaWidth - 2 * kPresentedViewMargin; CGFloat frameWidth = fmin(maxAvailableWidth, kPresentedViewMaxWidth); - CGFloat modalTargetHeight = [self.modalPositioner modalHeight]; + CGFloat modalTargetHeight = + [self.modalPositioner modalHeightForWidth:frameWidth]; CGFloat maxAvailableHeight = safeAreaHeight - 2 * kPresentedViewMargin; CGFloat frameHeight = fmin(maxAvailableHeight, modalTargetHeight);
diff --git a/ios/net/http_cache_helper.cc b/ios/net/http_cache_helper.cc index e3cc7f7f..1936e99 100644 --- a/ios/net/http_cache_helper.cc +++ b/ios/net/http_cache_helper.cc
@@ -40,15 +40,15 @@ int error) { // |*backend| may be null in case of error. if (*backend) { - net::CompletionRepeatingCallback copyable_callback = - base::AdaptCallbackForRepeating(std::move(callback)); + auto callback_pair = base::SplitOnceCallback(std::move(callback)); const int rv = (*backend)->DoomEntriesBetween( delete_begin, delete_end, - base::BindOnce(&PostCallback, client_task_runner, copyable_callback)); + base::BindOnce(&PostCallback, client_task_runner, + std::move(callback_pair.first))); // DoomEntriesBetween does not invoke callback unless rv is ERR_IO_PENDING. if (rv != net::ERR_IO_PENDING) { - client_task_runner->PostTask(FROM_HERE, - base::BindOnce(copyable_callback, rv)); + client_task_runner->PostTask( + FROM_HERE, base::BindOnce(std::move(callback_pair.second), rv)); } } else { client_task_runner->PostTask(FROM_HERE, @@ -77,16 +77,16 @@ new disk_cache::Backend*(nullptr)); disk_cache::Backend** backend_ptr = backend.get(); - net::CompletionRepeatingCallback doom_callback = - base::AdaptCallbackForRepeating( - base::BindOnce(&DoomHttpCache, std::move(backend), client_task_runner, - delete_begin, delete_end, std::move(callback))); + auto doom_callback_pair = base::SplitOnceCallback( + base::BindOnce(&DoomHttpCache, std::move(backend), client_task_runner, + delete_begin, delete_end, std::move(callback))); - const int rv = http_cache->GetBackend(backend_ptr, doom_callback); + const int rv = + http_cache->GetBackend(backend_ptr, std::move(doom_callback_pair.first)); if (rv != net::ERR_IO_PENDING) { // GetBackend doesn't call the callback if it completes synchronously, so // call it directly here. - doom_callback.Run(rv); + std::move(doom_callback_pair.second).Run(rv); } }
diff --git a/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.h b/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.h index dc6c0fc..651f555 100644 --- a/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.h +++ b/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.h
@@ -74,6 +74,16 @@ UIViewController* presentingViewController, void (^callback)(BOOL success, NSError* error)); + // Presents the trusted vault key reauthentication UI for |identity| for the + // purpose of opting into trusted vault passphrase. Once the reauth is done + // and the UI is dismissed, |callback| is called. |callback| is not called if + // the reauthentication is canceled. + // TODO(crbug.com/1202088): Make pure. + virtual void ReauthenticationForOptIn( + ChromeIdentity* chrome_identity, + UIViewController* presentingViewController, + void (^callback)(BOOL success, NSError* error)); + // Cancels the presented trusted vault reauthentication UI, triggered via // either ReauthenticationForFetchKeys() or via // ReauthenticationForDegradedRecoverability(). The reauthentication callback
diff --git a/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.mm b/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.mm index 559ff4b1..7a88b0ace 100644 --- a/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.mm +++ b/ios/public/provider/chrome/browser/signin/chrome_trusted_vault_service.mm
@@ -47,6 +47,11 @@ Reauthentication(chrome_identity, presentingViewController, callback); } +void ChromeTrustedVaultService::ReauthenticationForOptIn( + ChromeIdentity* chrome_identity, + UIViewController* presentingViewController, + void (^callback)(BOOL success, NSError* error)) {} + void ChromeTrustedVaultService::NotifyKeysChanged() { for (Observer& observer : observer_list_) { observer.OnTrustedVaultKeysChanged();
diff --git a/mojo/core/channel_fuchsia.cc b/mojo/core/channel_fuchsia.cc index eb4356c..7b112ded 100644 --- a/mojo/core/channel_fuchsia.cc +++ b/mojo/core/channel_fuchsia.cc
@@ -16,13 +16,13 @@ #include "base/bind.h" #include "base/containers/circular_deque.h" +#include "base/cxx17_backports.h" #include "base/files/scoped_file.h" #include "base/fuchsia/fuchsia_logging.h" #include "base/location.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_pump_for_io.h" -#include "base/stl_util.h" #include "base/synchronization/lock.h" #include "base/task/current_thread.h" #include "base/task_runner.h"
diff --git a/mojo/core/data_pipe_unittest.cc b/mojo/core/data_pipe_unittest.cc index 395e8d8..330c957cf1 100644 --- a/mojo/core/data_pipe_unittest.cc +++ b/mojo/core/data_pipe_unittest.cc
@@ -9,9 +9,9 @@ #include "base/bind.h" #include "base/check_op.h" +#include "base/cxx17_backports.h" #include "base/location.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/task_environment.h" #include "build/build_config.h" #include "mojo/core/embedder/embedder.h"
diff --git a/mojo/core/embedder_unittest.cc b/mojo/core/embedder_unittest.cc index 7f24ea6b..79a5ef2 100644 --- a/mojo/core/embedder_unittest.cc +++ b/mojo/core/embedder_unittest.cc
@@ -13,6 +13,7 @@ #include "base/base_paths.h" #include "base/bind.h" #include "base/command_line.h" +#include "base/cxx17_backports.h" #include "base/files/file.h" #include "base/macros.h" #include "base/memory/ptr_util.h" @@ -22,7 +23,6 @@ #include "base/path_service.h" #include "base/rand_util.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/synchronization/waitable_event.h" #include "base/test/test_timeouts.h"
diff --git a/mojo/core/multiprocess_message_pipe_unittest.cc b/mojo/core/multiprocess_message_pipe_unittest.cc index 14d7bc9..cd1fd73f 100644 --- a/mojo/core/multiprocess_message_pipe_unittest.cc +++ b/mojo/core/multiprocess_message_pipe_unittest.cc
@@ -13,13 +13,13 @@ #include <vector> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/string_split.h" #include "base/test/task_environment.h" #include "build/build_config.h"
diff --git a/mojo/core/shared_buffer_dispatcher_unittest.cc b/mojo/core/shared_buffer_dispatcher_unittest.cc index fe206b6..108359a 100644 --- a/mojo/core/shared_buffer_dispatcher_unittest.cc +++ b/mojo/core/shared_buffer_dispatcher_unittest.cc
@@ -9,10 +9,10 @@ #include <limits> +#include "base/cxx17_backports.h" #include "base/memory/platform_shared_memory_region.h" #include "base/memory/ref_counted.h" #include "base/memory/writable_shared_memory_region.h" -#include "base/stl_util.h" #include "mojo/core/dispatcher.h" #include "mojo/core/platform_shared_memory_mapping.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/mojo/public/cpp/base/ref_counted_memory_unittest.cc b/mojo/public/cpp/base/ref_counted_memory_unittest.cc index 7dfe2e70..24c32dc 100644 --- a/mojo/public/cpp/base/ref_counted_memory_unittest.cc +++ b/mojo/public/cpp/base/ref_counted_memory_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 "base/stl_util.h" +#include "base/cxx17_backports.h" #include "mojo/public/cpp/base/big_buffer_mojom_traits.h" #include "mojo/public/cpp/base/ref_counted_memory_mojom_traits.h" #include "mojo/public/cpp/test_support/test_utils.h"
diff --git a/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc b/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc index 96d43904..94ccbdd5 100644 --- a/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc +++ b/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
@@ -10,13 +10,13 @@ #include "base/bind_post_task.h" #include "base/check.h" #include "base/containers/contains.h" +#include "base/cxx17_backports.h" #include "base/location.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/sequenced_task_runner.h" -#include "base/stl_util.h" #include "mojo/public/cpp/bindings/associated_group.h" #include "mojo/public/cpp/bindings/associated_group_controller.h" #include "mojo/public/cpp/bindings/interface_endpoint_controller.h"
diff --git a/mojo/public/cpp/bindings/remote_set.h b/mojo/public/cpp/bindings/remote_set.h index eb98f73..1453d4a 100644 --- a/mojo/public/cpp/bindings/remote_set.h +++ b/mojo/public/cpp/bindings/remote_set.h
@@ -122,7 +122,7 @@ // Returns an `Interface*` for the given ID, that can be used to issue // interface calls. Interface* Get(RemoteSetElementId id) { - auto* it = storage_.find(id); + auto it = storage_.find(id); if (it == storage_.end()) return nullptr; return it->second.get(); @@ -148,7 +148,7 @@ void FlushForTesting() { for (auto& it : storage_) { - it.second.FlushForTesting(); + it.second.FlushForTesting(); } }
diff --git a/mojo/public/cpp/bindings/tests/connector_unittest.cc b/mojo/public/cpp/bindings/tests/connector_unittest.cc index 8d3d0296..0dedf24 100644 --- a/mojo/public/cpp/bindings/tests/connector_unittest.cc +++ b/mojo/public/cpp/bindings/tests/connector_unittest.cc
@@ -11,8 +11,8 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/cxx17_backports.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/task_environment.h" #include "base/threading/thread.h" #include "base/threading/thread_task_runner_handle.h"
diff --git a/mojo/public/cpp/bindings/tests/remote_unittest.cc b/mojo/public/cpp/bindings/tests/remote_unittest.cc index a6b6072d..e0d91524 100644 --- a/mojo/public/cpp/bindings/tests/remote_unittest.cc +++ b/mojo/public/cpp/bindings/tests/remote_unittest.cc
@@ -1257,18 +1257,28 @@ { base::RunLoop loop; constexpr double kValue = 42.0; - auto on_add = base::BarrierClosure(3, loop.QuitClosure()); + auto on_add = base::BarrierClosure(6, loop.QuitClosure()); for (auto& remote : remotes) { remote->Add(kValue, base::BindLambdaForTesting([&](double total) { EXPECT_EQ(kValue, total); on_add.Run(); })); } + + // Use Get() to get a specified remote from RemoteSet. + std::vector<mojo::RemoteSetElementId> ids = {id0, id1, id2}; + for (auto& id : ids) { + remotes.Get(id)->Add(kValue, + base::BindLambdaForTesting([&](double total) { + EXPECT_EQ(kValue * 2, total); + on_add.Run(); + })); + } loop.Run(); - EXPECT_EQ(kValue, impls[0]->total()); - EXPECT_EQ(kValue, impls[1]->total()); - EXPECT_EQ(kValue, impls[2]->total()); + EXPECT_EQ(kValue * 2, impls[0]->total()); + EXPECT_EQ(kValue * 2, impls[1]->total()); + EXPECT_EQ(kValue * 2, impls[2]->total()); } EXPECT_FALSE(remotes.empty());
diff --git a/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc b/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc index 586da3c..32168ec3 100644 --- a/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc +++ b/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc
@@ -3,8 +3,8 @@ // found in the LICENSE file. #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/task_environment.h" #include "mojo/public/cpp/bindings/lib/message_fragment.h" #include "mojo/public/cpp/bindings/lib/serialization.h"
diff --git a/net/dns/mdns_client_unittest.cc b/net/dns/mdns_client_unittest.cc index 811f3d3b..f432500a 100644 --- a/net/dns/mdns_client_unittest.cc +++ b/net/dns/mdns_client_unittest.cc
@@ -1259,7 +1259,7 @@ std::vector<std::unique_ptr<DatagramServerSocket>>* sockets) override { auto socket = std::make_unique<MockMDnsDatagramServerSocket>(ADDRESS_FAMILY_IPV4); - EXPECT_CALL(*socket, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket, RecvFrom(_, _, _, _)) .WillRepeatedly(Return(ERR_FAILED)); sockets->push_back(std::move(socket)); } @@ -1372,9 +1372,9 @@ TEST_F(MDnsConnectionTest, ReceiveSynchronous) { socket_ipv6_->SetResponsePacket(sample_packet_); - EXPECT_CALL(*socket_ipv4_, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _)) .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*socket_ipv6_, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _)) .WillOnce( Invoke(socket_ipv6_, &MockMDnsDatagramServerSocket::HandleRecvNow)) .WillOnce(Return(ERR_IO_PENDING)); @@ -1386,9 +1386,9 @@ TEST_F(MDnsConnectionTest, ReceiveAsynchronous) { socket_ipv6_->SetResponsePacket(sample_packet_); - EXPECT_CALL(*socket_ipv4_, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _)) .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*socket_ipv6_, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _)) .Times(2) .WillOnce( Invoke(socket_ipv6_, &MockMDnsDatagramServerSocket::HandleRecvLater)) @@ -1402,17 +1402,20 @@ } TEST_F(MDnsConnectionTest, Error) { - CompletionRepeatingCallback callback; + CompletionOnceCallback callback; - EXPECT_CALL(*socket_ipv4_, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _)) .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*socket_ipv6_, RecvFromInternal(_, _, _, _)) - .WillOnce(DoAll(SaveArg<3>(&callback), Return(ERR_IO_PENDING))); + EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _)) + .WillOnce([&](auto, auto, auto, auto cb) { + callback = std::move(cb); + return ERR_IO_PENDING; + }); ASSERT_THAT(InitConnection(), test::IsOk()); EXPECT_CALL(delegate_, OnConnectionError(ERR_SOCKET_NOT_CONNECTED)); - callback.Run(ERR_SOCKET_NOT_CONNECTED); + std::move(callback).Run(ERR_SOCKET_NOT_CONNECTED); base::RunLoop().RunUntilIdle(); } @@ -1420,9 +1423,9 @@ protected: void SetUp() override { MDnsConnectionTest::SetUp(); - EXPECT_CALL(*socket_ipv4_, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket_ipv4_, RecvFrom(_, _, _, _)) .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*socket_ipv6_, RecvFromInternal(_, _, _, _)) + EXPECT_CALL(*socket_ipv6_, RecvFrom(_, _, _, _)) .WillOnce(Return(ERR_IO_PENDING)); EXPECT_THAT(InitConnection(), test::IsOk()); } @@ -1456,11 +1459,14 @@ .Times(2) .WillRepeatedly(Return(OK)); - CompletionRepeatingCallback callback; + CompletionOnceCallback callback; // Delay sending data. Only the first call should be made. EXPECT_CALL(*socket_ipv6_, SendToInternal(sample_packet_, "[ff02::fb]:5353", _)) - .WillOnce(DoAll(SaveArg<2>(&callback), Return(ERR_IO_PENDING))); + .WillOnce([&](auto, auto, auto cb) { + callback = std::move(cb); + return ERR_IO_PENDING; + }); connection_.Send(sample_buffer_, sample_packet_.size()); connection_.Send(sample_buffer_, sample_packet_.size()); @@ -1473,7 +1479,7 @@ EXPECT_CALL(*socket_ipv6_, SendToInternal(sample_packet_, "[ff02::fb]:5353", _)) .WillOnce(Return(OK)); - callback.Run(OK); + std::move(callback).Run(OK); } TEST(MDnsSocketTest, CreateSocket) {
diff --git a/net/dns/mock_mdns_socket_factory.cc b/net/dns/mock_mdns_socket_factory.cc index 794dcc65..b12bdc4 100644 --- a/net/dns/mock_mdns_socket_factory.cc +++ b/net/dns/mock_mdns_socket_factory.cc
@@ -32,15 +32,7 @@ const IPEndPoint& address, CompletionOnceCallback callback) { return SendToInternal(std::string(buf->data(), buf_len), address.ToString(), - base::AdaptCallbackForRepeating(std::move(callback))); -} - -int MockMDnsDatagramServerSocket::RecvFrom(IOBuffer* buffer, - int size, - IPEndPoint* address, - CompletionOnceCallback callback) { - return RecvFromInternal(buffer, size, address, - base::AdaptCallbackForRepeating(std::move(callback))); + std::move(callback)); } int MockMDnsDatagramServerSocket::GetLocalAddress(IPEndPoint* address) const { @@ -57,7 +49,7 @@ IOBuffer* buffer, int size, IPEndPoint* address, - CompletionRepeatingCallback callback) { + CompletionOnceCallback callback) { int size_returned = std::min(response_packet_.size(), static_cast<size_t>(size)); memcpy(buffer->data(), response_packet_.data(), size_returned); @@ -68,10 +60,10 @@ IOBuffer* buffer, int size, IPEndPoint* address, - CompletionRepeatingCallback callback) { - int rv = HandleRecvNow(buffer, size, address, callback); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::BindOnce(callback, rv)); + CompletionOnceCallback callback) { + int rv = HandleRecvNow(buffer, size, address, base::DoNothing()); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), rv)); return ERR_IO_PENDING; } @@ -96,7 +88,7 @@ this, &MockMDnsSocketFactory::SendToInternal)); - ON_CALL(*new_socket, RecvFromInternal(_, _, _, _)) + ON_CALL(*new_socket, RecvFrom(_, _, _, _)) .WillByDefault(Invoke(this, &MockMDnsSocketFactory::RecvFromInternal)); sockets->push_back(std::move(new_socket)); @@ -111,14 +103,13 @@ std::move(recv_callback_).Run(size); } -int MockMDnsSocketFactory::RecvFromInternal( - IOBuffer* buffer, - int size, - IPEndPoint* address, - CompletionRepeatingCallback callback) { +int MockMDnsSocketFactory::RecvFromInternal(IOBuffer* buffer, + int size, + IPEndPoint* address, + CompletionOnceCallback callback) { recv_buffer_ = buffer; recv_buffer_size_ = size; - recv_callback_ = callback; + recv_callback_ = std::move(callback); return ERR_IO_PENDING; }
diff --git a/net/dns/mock_mdns_socket_factory.h b/net/dns/mock_mdns_socket_factory.h index 8f0d5b59..78036ef 100644 --- a/net/dns/mock_mdns_socket_factory.h +++ b/net/dns/mock_mdns_socket_factory.h
@@ -29,18 +29,11 @@ // DatagramServerSocket implementation: MOCK_METHOD1(Listen, int(const IPEndPoint& address)); - // GMock cannot handle move-only types like CompletionOnceCallback, so it - // needs to be converted into the copyable type CompletionRepeatingCallback. - int RecvFrom(IOBuffer* buffer, - int size, - IPEndPoint* address, - CompletionOnceCallback callback) override; - - MOCK_METHOD4(RecvFromInternal, + MOCK_METHOD4(RecvFrom, int(IOBuffer* buffer, int size, IPEndPoint* address, - CompletionRepeatingCallback callback)); + CompletionOnceCallback callback)); int SendTo(IOBuffer* buf, int buf_len, @@ -50,7 +43,7 @@ MOCK_METHOD3(SendToInternal, int(const std::string& packet, const std::string address, - CompletionRepeatingCallback callback)); + CompletionOnceCallback callback)); MOCK_METHOD1(SetReceiveBufferSize, int(int32_t size)); MOCK_METHOD1(SetSendBufferSize, int(int32_t size)); @@ -87,12 +80,12 @@ int HandleRecvNow(IOBuffer* buffer, int size, IPEndPoint* address, - CompletionRepeatingCallback callback); + CompletionOnceCallback callback); int HandleRecvLater(IOBuffer* buffer, int size, IPEndPoint* address, - CompletionRepeatingCallback callback); + CompletionOnceCallback callback); private: std::string response_packet_; @@ -121,7 +114,7 @@ int RecvFromInternal(IOBuffer* buffer, int size, IPEndPoint* address, - CompletionRepeatingCallback callback); + CompletionOnceCallback callback); void CreateSocket( AddressFamily address_family, @@ -129,7 +122,7 @@ scoped_refptr<IOBuffer> recv_buffer_; int recv_buffer_size_; - CompletionRepeatingCallback recv_callback_; + CompletionOnceCallback recv_callback_; }; } // namespace net
diff --git a/net/websockets/websocket_channel_test.cc b/net/websockets/websocket_channel_test.cc index 878aa77..c017fd8e 100644 --- a/net/websockets/websocket_channel_test.cc +++ b/net/websockets/websocket_channel_test.cc
@@ -705,28 +705,12 @@ // the extent that they are implemented in WebSocketCommon). class MockWebSocketStream : public WebSocketStream { public: - // GMock cannot save or forward move-only types like CompletionOnceCallback, - // therefore they have to be converted into a copyable type like - // CompletionRepeatingCallback. - int ReadFrames(std::vector<std::unique_ptr<WebSocketFrame>>* frames, - CompletionOnceCallback callback) { - return ReadFramesInternal( - frames, callback ? base::AdaptCallbackForRepeating(std::move(callback)) - : CompletionRepeatingCallback()); - } - int WriteFrames(std::vector<std::unique_ptr<WebSocketFrame>>* frames, - CompletionOnceCallback callback) { - return WriteFramesInternal( - frames, callback ? base::AdaptCallbackForRepeating(std::move(callback)) - : CompletionRepeatingCallback()); - } - - MOCK_METHOD2(ReadFramesInternal, + MOCK_METHOD2(ReadFrames, int(std::vector<std::unique_ptr<WebSocketFrame>>*, - const CompletionRepeatingCallback&)); - MOCK_METHOD2(WriteFramesInternal, + CompletionOnceCallback)); + MOCK_METHOD2(WriteFrames, int(std::vector<std::unique_ptr<WebSocketFrame>>*, - const CompletionRepeatingCallback&)); + CompletionOnceCallback)); MOCK_METHOD0(Close, void()); MOCK_CONST_METHOD0(GetSubProtocol, std::string()); @@ -1761,7 +1745,7 @@ InSequence s; EXPECT_CALL(*event_interface_, HasPendingDataFrames()) .WillOnce(Return(false)); - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)); EXPECT_CALL(*event_interface_, HasPendingDataFrames()) .WillOnce(Return(true)); @@ -1771,7 +1755,7 @@ EXPECT_CALL(checkpoint, Call(2)); EXPECT_CALL(*event_interface_, HasPendingDataFrames()) .WillOnce(Return(false)); - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(Return(ERR_IO_PENDING)); } @@ -1874,9 +1858,8 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, MASKED, "NEEDS MASKING"}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce(Return(ERR_IO_PENDING)); + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); CreateChannelAndConnectSuccessfully(); @@ -1891,9 +1874,8 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(NORMAL_CLOSURE, "Success")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce(Return(ERR_IO_PENDING)); + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); CreateChannelAndConnectSuccessfully(); @@ -1912,10 +1894,10 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(NORMAL_CLOSURE, "Close")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); CreateChannelAndConnectSuccessfully(); @@ -1940,14 +1922,16 @@ Checkpoint checkpoint; { InSequence s; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(DoAll(SaveArg<0>(&frames), SaveArg<1>(&read_callback), - Return(ERR_IO_PENDING))); + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce([&](auto f, auto cb) { + frames = f; + read_callback = std::move(cb); + return ERR_IO_PENDING; + }); EXPECT_CALL(checkpoint, Call(1)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(checkpoint, Call(2)); - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(Return(ERR_IO_PENDING)); EXPECT_CALL(checkpoint, Call(3)); // WriteFrames() must not be called again. GoogleMock will ensure that the @@ -1959,6 +1943,7 @@ ASSERT_EQ(CHANNEL_ALIVE, channel_->StartClosingHandshake(kWebSocketNormalClosure, "Close")); checkpoint.Call(2); + ASSERT_TRUE(frames); *frames = CreateFrameVector(frames_init, &result_frame_data_); std::move(read_callback).Run(OK); checkpoint.Call(3); @@ -1970,10 +1955,9 @@ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(SERVER_ERROR, "")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)); + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)); CreateChannelAndConnectSuccessfully(); ASSERT_EQ(CHANNEL_ALIVE, channel_->StartClosingHandshake(999, "")); @@ -1986,10 +1970,9 @@ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(SERVER_ERROR, "")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)); + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)); CreateChannelAndConnectSuccessfully(); ASSERT_EQ(CHANNEL_ALIVE, @@ -2006,10 +1989,10 @@ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, NOT_MASKED, ""}}; static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, ""}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); CreateChannelAndConnectSuccessfully(); @@ -2020,10 +2003,10 @@ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, NOT_MASKED, nullptr}}; static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, ""}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); CreateChannelAndConnectSuccessfully(); @@ -2039,10 +2022,10 @@ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(PROTOCOL_ERROR, "Invalid UTF-8 in Close frame")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()); @@ -2061,10 +2044,10 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodePong, MASKED, "Application data"}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); CreateChannelAndConnectSuccessfully(); @@ -2077,10 +2060,10 @@ {FINAL_FRAME, WebSocketFrameHeader::kOpCodePing, NOT_MASKED, nullptr}}; static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodePong, MASKED, nullptr}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); CreateChannelAndConnectSuccessfully(); @@ -2100,18 +2083,21 @@ MASKED, "World"}}; std::vector<std::unique_ptr<WebSocketFrame>>* read_frames; CompletionOnceCallback read_callback; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(DoAll(SaveArg<0>(&read_frames), SaveArg<1>(&read_callback), - Return(ERR_IO_PENDING))) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) + .WillOnce([&](auto frames, auto cb) { + read_frames = std::move(frames); + read_callback = std::move(cb); + return ERR_IO_PENDING; + }) .WillRepeatedly(Return(ERR_IO_PENDING)); { InSequence s; - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected1), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected1), _)) .WillOnce(Return(OK)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected2), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected2), _)) .WillOnce(Return(OK)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected3), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected3), _)) .WillOnce(Return(OK)); } @@ -2136,15 +2122,17 @@ CompletionOnceCallback write_callback; Checkpoint checkpoint; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce(Return(ERR_IO_PENDING)); { InSequence s; EXPECT_CALL(checkpoint, Call(1)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected1), _)) - .WillOnce(DoAll(SaveArg<1>(&write_callback), Return(ERR_IO_PENDING))); + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected1), _)) + .WillOnce([&](auto, auto cb) { + write_callback = std::move(cb); + return ERR_IO_PENDING; + }); EXPECT_CALL(checkpoint, Call(2)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected2), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected2), _)) .WillOnce(Return(ERR_IO_PENDING)); EXPECT_CALL(checkpoint, Call(3)); } @@ -2176,13 +2164,15 @@ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, MASKED, "o"}}; CompletionOnceCallback write_callback; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce(Return(ERR_IO_PENDING)); { InSequence s; - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected1), _)) - .WillOnce(DoAll(SaveArg<1>(&write_callback), Return(ERR_IO_PENDING))); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected2), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected1), _)) + .WillOnce([&](auto, auto cb) { + write_callback = std::move(cb); + return ERR_IO_PENDING; + }); + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected2), _)) .WillOnce(Return(ERR_IO_PENDING)); } @@ -2202,9 +2192,8 @@ TEST_F(WebSocketChannelStreamTest, WrittenBinaryFramesAre8BitClean) { std::vector<std::unique_ptr<WebSocketFrame>>* frames = nullptr; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)).WillOnce(Return(ERR_IO_PENDING)); + EXPECT_CALL(*mock_stream_, WriteFrames(_, _)) .WillOnce(DoAll(SaveArg<0>(&frames), Return(ERR_IO_PENDING))); CreateChannelAndConnectSuccessfully(); @@ -2383,9 +2372,9 @@ static const InitFrame expected[] = {{FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(GOING_AWAY, "")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).Times(1); @@ -2409,10 +2398,10 @@ CLOSE_DATA(PROTOCOL_ERROR, "Invalid UTF-8 in text frame")}}; { InSequence s; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).Times(1); } @@ -2428,10 +2417,10 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(PROTOCOL_ERROR, "Invalid UTF-8 in text frame")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).Times(1); @@ -2442,7 +2431,7 @@ TEST_F(WebSocketChannelReceiveUtf8Test, IncompleteCharacterIncompleteMessage) { static const InitFrame frames[] = { {NOT_FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, NOT_MASKED, "\xc2"}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); @@ -2457,10 +2446,10 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(PROTOCOL_ERROR, "Invalid UTF-8 in text frame")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).Times(1); @@ -2474,7 +2463,7 @@ {NOT_FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, NOT_MASKED, "\xf1"}, {FINAL_FRAME, WebSocketFrameHeader::kOpCodeContinuation, NOT_MASKED, "\x80\xa0\xbf"}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); @@ -2490,10 +2479,10 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(PROTOCOL_ERROR, "Invalid UTF-8 in text frame")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).Times(1); @@ -2511,10 +2500,10 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(PROTOCOL_ERROR, "Invalid UTF-8 in text frame")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).Times(1); @@ -2529,7 +2518,7 @@ NOT_MASKED, "bar"}, {FINAL_FRAME, WebSocketFrameHeader::kOpCodeContinuation, NOT_MASKED, "\xff"}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); @@ -2541,7 +2530,7 @@ static const InitFrame frames[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, NOT_MASKED, "foo"}, {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, NOT_MASKED, "bar"}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); @@ -2657,7 +2646,7 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(NORMAL_CLOSURE, "OK")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); { @@ -2666,7 +2655,7 @@ // frame before calling ReadFrames() again, but that is an implementation // detail and better not to consider required behaviour. InSequence s; - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).Times(1); } @@ -2680,9 +2669,9 @@ static const InitFrame expected[] = { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, MASKED, CLOSE_DATA(PROTOCOL_ERROR, "WebSocket Protocol Error")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(Return(ERR_WS_PROTOCOL_ERROR)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()); @@ -2722,14 +2711,14 @@ MASKED, CLOSE_DATA(NORMAL_CLOSURE, "OK")}}; EXPECT_CALL(*mock_stream_, GetSubProtocol()).Times(AnyNumber()); EXPECT_CALL(*mock_stream_, GetExtensions()).Times(AnyNumber()); - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(ReturnFrames(&frames, &result_frame_data_)) .WillRepeatedly(Return(ERR_IO_PENDING)); Checkpoint checkpoint; TestClosure completion; { InSequence s; - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(checkpoint, Call(1)); EXPECT_CALL(*mock_stream_, Close()).WillOnce(InvokeClosure(&completion)); @@ -2750,12 +2739,12 @@ MASKED, CLOSE_DATA(NORMAL_CLOSURE, "OK")}}; EXPECT_CALL(*mock_stream_, GetSubProtocol()).Times(AnyNumber()); EXPECT_CALL(*mock_stream_, GetExtensions()).Times(AnyNumber()); - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillRepeatedly(Return(ERR_IO_PENDING)); TestClosure completion; { InSequence s; - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); EXPECT_CALL(*mock_stream_, Close()).WillOnce(InvokeClosure(&completion)); } @@ -2786,17 +2775,21 @@ InSequence s; // Copy the arguments to ReadFrames so that the test can call the callback // after it has send the close message. - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(DoAll(SaveArg<0>(&read_frames), SaveArg<1>(&read_callback), - Return(ERR_IO_PENDING))); + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) + .WillOnce([&](auto frames, auto cb) { + read_frames = frames; + read_callback = std::move(cb); + return ERR_IO_PENDING; + }); + // The first real event that happens is the client sending the Close // message. - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) + EXPECT_CALL(*mock_stream_, WriteFrames(EqualsFrames(expected), _)) .WillOnce(Return(OK)); // The |read_frames| callback is called (from this test case) at this // point. ReadFrames is called again by WebSocketChannel, waiting for // ERR_CONNECTION_CLOSED. - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) + EXPECT_CALL(*mock_stream_, ReadFrames(_, _)) .WillOnce(Return(ERR_IO_PENDING)); // The timeout happens and so WebSocketChannel closes the stream. EXPECT_CALL(*mock_stream_, Close()).WillOnce(InvokeClosure(&completion));
diff --git a/pdf/pdf_features.cc b/pdf/pdf_features.cc index 08708c9..f5e9449 100644 --- a/pdf/pdf_features.cc +++ b/pdf/pdf_features.cc
@@ -22,12 +22,6 @@ const base::Feature kPdfPartialLoading = {"PdfPartialLoading", base::FEATURE_DISABLED_BY_DEFAULT}; -const base::Feature kPdfViewerDocumentProperties = { - "PdfViewerDocumentProperties", base::FEATURE_ENABLED_BY_DEFAULT}; - -const base::Feature kPdfViewerPresentationMode = { - "PdfViewerPresentationMode", base::FEATURE_ENABLED_BY_DEFAULT}; - // Feature has no effect if Chrome is built with no XFA support. const base::Feature kPdfXfaSupport = {"PdfXfaSupport", base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/pdf/pdf_features.h b/pdf/pdf_features.h index 200fd23..2adf0e5 100644 --- a/pdf/pdf_features.h +++ b/pdf/pdf_features.h
@@ -16,8 +16,6 @@ extern const base::Feature kAccessiblePDFForm; extern const base::Feature kPdfIncrementalLoading; extern const base::Feature kPdfPartialLoading; -extern const base::Feature kPdfViewerDocumentProperties; -extern const base::Feature kPdfViewerPresentationMode; extern const base::Feature kPdfXfaSupport; extern const base::Feature kTabAcrossPDFAnnotations;
diff --git a/pdf/pdf_view_plugin_base.cc b/pdf/pdf_view_plugin_base.cc index 41eb62d..4234ff1 100644 --- a/pdf/pdf_view_plugin_base.cc +++ b/pdf/pdf_view_plugin_base.cc
@@ -815,7 +815,6 @@ } void PdfViewPluginBase::HandleSetReadOnlyMessage(const base::Value& message) { - DCHECK(base::FeatureList::IsEnabled(features::kPdfViewerPresentationMode)); engine()->SetReadOnly(message.FindBoolKey("enableReadOnly").value()); }
diff --git a/printing/backend/PRESUBMIT.py b/printing/backend/PRESUBMIT.py index 303ef5d..4ef6bce 100644 --- a/printing/backend/PRESUBMIT.py +++ b/printing/backend/PRESUBMIT.py
@@ -9,6 +9,8 @@ for more details about the presubmit API. """ +USE_PYTHON3 = True + def _CheckForStringViewFromNullableIppApi(input_api, output_api): """ Looks for all affected lines in CL where one constructs either
diff --git a/services/audio/public/cpp/sounds/sounds_manager_unittest.cc b/services/audio/public/cpp/sounds/sounds_manager_unittest.cc index c3253e51..7720861 100644 --- a/services/audio/public/cpp/sounds/sounds_manager_unittest.cc +++ b/services/audio/public/cpp/sounds/sounds_manager_unittest.cc
@@ -8,8 +8,8 @@ #include "base/callback_helpers.h" #include "base/compiler_specific.h" +#include "base/cxx17_backports.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/string_piece.h" #include "base/test/test_message_loop.h" #include "base/threading/thread_task_runner_handle.h"
diff --git a/services/data_decoder/image_decoder_impl_unittest.cc b/services/data_decoder/image_decoder_impl_unittest.cc index e7845059..0226126d 100644 --- a/services/data_decoder/image_decoder_impl_unittest.cc +++ b/services/data_decoder/image_decoder_impl_unittest.cc
@@ -6,8 +6,8 @@ #include <vector> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/lazy_instance.h" -#include "base/stl_util.h" #include "base/test/task_environment.h" #include "gin/array_buffer.h" #include "gin/public/isolate_holder.h"
diff --git a/services/device/BUILD.gn b/services/device/BUILD.gn index 6510276..66e8bbc 100644 --- a/services/device/BUILD.gn +++ b/services/device/BUILD.gn
@@ -191,10 +191,6 @@ sources += [ "generic_sensor/platform_sensor_provider_unittest_android.cc" ] } - if (is_chromeos_ash) { - sources += [ "geolocation/wifi_data_provider_chromeos_unittest.cc" ] - } - if (is_win) { sources += [ "battery/battery_status_manager_win_unittest.cc", @@ -226,7 +222,10 @@ } if (is_chromeos_ash) { - sources += [ "fingerprint/fingerprint_chromeos_unittest.cc" ] + sources += [ + "fingerprint/fingerprint_chromeos_unittest.cc", + "geolocation/wifi_data_provider_chromeos_unittest.cc", + ] deps += [ "//chromeos/dbus:test_support", "//chromeos/dbus/biod:test_support", @@ -237,6 +236,10 @@ ] } + if (is_chromeos_lacros) { + deps += [ "//chromeos/lacros:test_support" ] + } + if (is_android) { sources -= [ "battery/battery_status_service_unittest.cc",
diff --git a/services/device/generic_sensor/platform_sensor_reader_linux.cc b/services/device/generic_sensor/platform_sensor_reader_linux.cc index 6ff992d..ffd3748 100644 --- a/services/device/generic_sensor/platform_sensor_reader_linux.cc +++ b/services/device/generic_sensor/platform_sensor_reader_linux.cc
@@ -7,10 +7,10 @@ #include <memory> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/files/file_util.h" #include "base/sequence_checker.h" #include "base/sequenced_task_runner.h" -#include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/task/post_task.h"
diff --git a/services/device/generic_sensor/platform_sensor_reader_win.cc b/services/device/generic_sensor/platform_sensor_reader_win.cc index 79b8c68..f360f69b 100644 --- a/services/device/generic_sensor/platform_sensor_reader_win.cc +++ b/services/device/generic_sensor/platform_sensor_reader_win.cc
@@ -12,9 +12,9 @@ #include <iomanip> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/memory/ptr_util.h" #include "base/numerics/math_constants.h" -#include "base/stl_util.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/win/scoped_propvariant.h"
diff --git a/services/device/geolocation/wifi_data_provider_linux_unittest.cc b/services/device/geolocation/wifi_data_provider_linux_unittest.cc index 0552077..271518cc 100644 --- a/services/device/geolocation/wifi_data_provider_linux_unittest.cc +++ b/services/device/geolocation/wifi_data_provider_linux_unittest.cc
@@ -8,9 +8,9 @@ #include <memory> +#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" #include "base/test/task_environment.h" #include "dbus/message.h"
diff --git a/services/device/geolocation/wifi_data_provider_win.cc b/services/device/geolocation/wifi_data_provider_win.cc index e383a590..5517b7c 100644 --- a/services/device/geolocation/wifi_data_provider_win.cc +++ b/services/device/geolocation/wifi_data_provider_win.cc
@@ -8,11 +8,11 @@ #include <winioctl.h> #include <wlanapi.h> +#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/memory/free_deleter.h" #include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" -#include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" #include "base/win/windows_version.h" #include "services/device/geolocation/wifi_data_provider_common.h"
diff --git a/services/device/time_zone_monitor/time_zone_monitor_linux.cc b/services/device/time_zone_monitor/time_zone_monitor_linux.cc index d5f2abc2..da5b585f 100644 --- a/services/device/time_zone_monitor/time_zone_monitor_linux.cc +++ b/services/device/time_zone_monitor/time_zone_monitor_linux.cc
@@ -11,11 +11,11 @@ #include <vector> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/files/file_path.h" #include "base/files/file_path_watcher.h" #include "base/memory/ref_counted.h" #include "base/sequenced_task_runner.h" -#include "base/stl_util.h" #include "base/threading/scoped_blocking_call.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h"
diff --git a/services/device/wake_lock/wake_lock_unittest.cc b/services/device/wake_lock/wake_lock_unittest.cc index f0dca917..ab282758 100644 --- a/services/device/wake_lock/wake_lock_unittest.cc +++ b/services/device/wake_lock/wake_lock_unittest.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/run_loop.h" +#include "build/chromeos_buildflags.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver_set.h" @@ -19,6 +20,10 @@ #include "services/device/public/mojom/wake_lock_provider.mojom.h" #include "services/device/wake_lock/wake_lock_provider.h" +#if BUILDFLAG(IS_CHROMEOS_LACROS) +#include "chromeos/lacros/lacros_test_helper.h" +#endif + namespace device { namespace { @@ -134,6 +139,11 @@ bool has_wakelock_; bool result_; +#if BUILDFLAG(IS_CHROMEOS_LACROS) + // Instantiate LacrosService for WakeLock support. + chromeos::ScopedLacrosServiceTestHelper scoped_lacros_service_test_helper_; +#endif + mojo::Remote<device::mojom::WakeLockProvider> wake_lock_provider_; mojo::Remote<mojom::WakeLock> wake_lock_;
diff --git a/services/network/cookie_manager_unittest.cc b/services/network/cookie_manager_unittest.cc index d56496a..7d235963 100644 --- a/services/network/cookie_manager_unittest.cc +++ b/services/network/cookie_manager_unittest.cc
@@ -7,9 +7,9 @@ #include <algorithm> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/files/scoped_temp_dir.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/strcat.h" #include "base/task/post_task.h" #include "base/task/thread_pool.h"
diff --git a/services/network/http_cache_data_counter_unittest.cc b/services/network/http_cache_data_counter_unittest.cc index 0ff1200..550b13f 100644 --- a/services/network/http_cache_data_counter_unittest.cc +++ b/services/network/http_cache_data_counter_unittest.cc
@@ -11,9 +11,9 @@ #include <vector> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/files/scoped_temp_dir.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/bind.h" #include "base/test/task_environment.h" #include "base/threading/thread_task_runner_handle.h"
diff --git a/services/network/http_cache_data_remover_unittest.cc b/services/network/http_cache_data_remover_unittest.cc index 899b438f..97a737f 100644 --- a/services/network/http_cache_data_remover_unittest.cc +++ b/services/network/http_cache_data_remover_unittest.cc
@@ -7,10 +7,10 @@ #include <vector> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/files/file_util.h" #include "base/location.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "base/threading/thread_task_runner_handle.h"
diff --git a/services/network/mdns_responder_unittest.cc b/services/network/mdns_responder_unittest.cc index 4c29f7b..451c8f5 100644 --- a/services/network/mdns_responder_unittest.cc +++ b/services/network/mdns_responder_unittest.cc
@@ -152,13 +152,9 @@ // primitive but failed sending; int FailToSend(const std::string& packet, const std::string& address, - net::CompletionRepeatingCallback callback) { + net::CompletionOnceCallback callback) { OnSendTo(packet); - task_runner_->PostTask( - FROM_HERE, - base::BindOnce( - [](net::CompletionRepeatingCallback callback) { callback.Run(-1); }, - callback)); + task_runner_->PostTask(FROM_HERE, base::BindOnce(std::move(callback), -1)); return -1; } @@ -167,17 +163,14 @@ // called. int MaybeBlockSend(const std::string& packet, const std::string& address, - net::CompletionRepeatingCallback callback) { + net::CompletionOnceCallback callback) { OnSendTo(packet); if (block_send_) { blocked_packet_size_ = packet.size(); blocked_send_callback_ = std::move(callback); } else { task_runner_->PostTask( - FROM_HERE, - base::BindOnce([](net::CompletionRepeatingCallback callback, - size_t packet_size) { callback.Run(packet_size); }, - callback, packet.size())); + FROM_HERE, base::BindOnce(std::move(callback), packet.size())); } return -1; } @@ -190,7 +183,7 @@ void ResumeSend() { DCHECK(block_send_); block_send_ = false; - blocked_send_callback_.Run(blocked_packet_size_); + std::move(blocked_send_callback_).Run(blocked_packet_size_); } // Emulates the asynchronous contract of invoking |callback| in the RecvFrom @@ -198,20 +191,16 @@ int FailToRecv(net::IOBuffer* buffer, int size, net::IPEndPoint* address, - net::CompletionRepeatingCallback callback) { - task_runner_->PostTask(FROM_HERE, - base::BindOnce( - [](net::CompletionRepeatingCallback callback) { - callback.Run(net::ERR_FAILED); - }, - callback)); + net::CompletionOnceCallback callback) { + task_runner_->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), net::ERR_FAILED)); return net::ERR_IO_PENDING; } private: bool block_send_ = false; size_t blocked_packet_size_ = 0; - net::CompletionRepeatingCallback blocked_send_callback_; + net::CompletionOnceCallback blocked_send_callback_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; }; @@ -996,8 +985,7 @@ ON_CALL(*socket, SendToInternal(_, _, _)) .WillByDefault(Invoke(&failing_socket_factory_, &MockFailingMdnsSocketFactory::FailToSend)); - ON_CALL(*socket, RecvFromInternal(_, _, _, _)) - .WillByDefault(Return(-1)); + ON_CALL(*socket, RecvFrom(_, _, _, _)).WillByDefault(Return(-1)); sockets->push_back(std::move(socket)); }; @@ -1372,7 +1360,7 @@ net::ADDRESS_FAMILY_IPV4); ON_CALL(*socket, SendToInternal(_, _, _)).WillByDefault(Return(0)); - ON_CALL(*socket, RecvFromInternal(_, _, _, _)) + ON_CALL(*socket, RecvFrom(_, _, _, _)) .WillByDefault(Invoke(&failing_socket_factory_, &MockFailingMdnsSocketFactory::FailToRecv)); @@ -1406,8 +1394,7 @@ .WillByDefault( Invoke(&failing_socket_factory_, &MockFailingMdnsSocketFactory::MaybeBlockSend)); - ON_CALL(*socket, RecvFromInternal(_, _, _, _)) - .WillByDefault(Return(-1)); + ON_CALL(*socket, RecvFrom(_, _, _, _)).WillByDefault(Return(-1)); sockets->push_back(std::move(socket)); };
diff --git a/services/network/p2p/socket_tcp_unittest.cc b/services/network/p2p/socket_tcp_unittest.cc index 3ef08e47..7fa2f35 100644 --- a/services/network/p2p/socket_tcp_unittest.cc +++ b/services/network/p2p/socket_tcp_unittest.cc
@@ -9,8 +9,8 @@ #include <memory> +#include "base/cxx17_backports.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/sys_byteorder.h" #include "base/test/bind.h"
diff --git a/services/network/public/cpp/client_hints.cc b/services/network/public/cpp/client_hints.cc index fb9d1441f..9113846 100644 --- a/services/network/public/cpp/client_hints.cc +++ b/services/network/public/cpp/client_hints.cc
@@ -8,8 +8,8 @@ #include <vector> #include "base/containers/flat_map.h" +#include "base/cxx17_backports.h" #include "base/no_destructor.h" -#include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_tokenizer.h" #include "base/strings/string_util.h"
diff --git a/services/network/public/cpp/server/http_server_unittest.cc b/services/network/public/cpp/server/http_server_unittest.cc index 0d91b30..ab26d54 100644 --- a/services/network/public/cpp/server/http_server_unittest.cc +++ b/services/network/public/cpp/server/http_server_unittest.cc
@@ -11,10 +11,10 @@ #include "base/auto_reset.h" #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/location.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/test/task_environment.h" #include "base/threading/thread_task_runner_handle.h"
diff --git a/services/network/ssl_config_service_mojo_unittest.cc b/services/network/ssl_config_service_mojo_unittest.cc index 2b85ba4..356cd67 100644 --- a/services/network/ssl_config_service_mojo_unittest.cc +++ b/services/network/ssl_config_service_mojo_unittest.cc
@@ -4,10 +4,10 @@ #include "services/network/ssl_config_service_mojo.h" +#include "base/cxx17_backports.h" #include "base/feature_list.h" #include "base/files/file_util.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/task_environment.h" #include "build/build_config.h" #include "crypto/sha2.h"
diff --git a/services/network/throttling/throttling_controller_unittest.cc b/services/network/throttling/throttling_controller_unittest.cc index 1e1c079..72bcc50 100644 --- a/services/network/throttling/throttling_controller_unittest.cc +++ b/services/network/throttling/throttling_controller_unittest.cc
@@ -11,9 +11,9 @@ #include <utility> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/memory/ref_counted.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/task_environment.h" #include "base/test/test_mock_time_task_runner.h" #include "net/base/chunked_upload_data_stream.h"
diff --git a/services/preferences/tracked/device_id_win.cc b/services/preferences/tracked/device_id_win.cc index b6d37f8..17a2e75 100644 --- a/services/preferences/tracked/device_id_win.cc +++ b/services/preferences/tracked/device_id_win.cc
@@ -11,7 +11,7 @@ #include <memory> #include "base/check.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" MachineIdStatus GetDeterministicMachineSpecificId(std::string* machine_id) { DCHECK(machine_id);
diff --git a/services/preferences/tracked/pref_hash_filter.cc b/services/preferences/tracked/pref_hash_filter.cc index c9ced554..5ccb87a 100644 --- a/services/preferences/tracked/pref_hash_filter.cc +++ b/services/preferences/tracked/pref_hash_filter.cc
@@ -12,9 +12,9 @@ #include "base/bind.h" #include "base/check_op.h" +#include "base/cxx17_backports.h" #include "base/metrics/histogram_macros.h" #include "base/notreached.h" -#include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/time/time.h" #include "base/values.h"
diff --git a/services/preferences/tracked/pref_hash_filter_unittest.cc b/services/preferences/tracked/pref_hash_filter_unittest.cc index 070d419..87a3b7e 100644 --- a/services/preferences/tracked/pref_hash_filter_unittest.cc +++ b/services/preferences/tracked/pref_hash_filter_unittest.cc
@@ -15,11 +15,11 @@ #include "base/bind.h" #include "base/compiler_specific.h" +#include "base/cxx17_backports.h" #include "base/metrics/histogram_base.h" #include "base/metrics/histogram_samples.h" #include "base/metrics/statistics_recorder.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/test/task_environment.h" #include "base/values.h" #include "components/prefs/testing_pref_store.h"
diff --git a/services/proxy_resolver/proxy_resolver_v8.cc b/services/proxy_resolver/proxy_resolver_v8.cc index 8f0ca6b50..5d514c1 100644 --- a/services/proxy_resolver/proxy_resolver_v8.cc +++ b/services/proxy_resolver/proxy_resolver_v8.cc
@@ -12,10 +12,10 @@ #include "base/auto_reset.h" #include "base/check_op.h" #include "base/compiler_specific.h" +#include "base/cxx17_backports.h" #include "base/debug/leak_annotations.h" #include "base/lazy_instance.h" #include "base/notreached.h" -#include "base/stl_util.h" #include "base/strings/string_tokenizer.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h"
diff --git a/services/proxy_resolver/proxy_resolver_v8_tracing_unittest.cc b/services/proxy_resolver/proxy_resolver_v8_tracing_unittest.cc index e4dde44..954d10c 100644 --- a/services/proxy_resolver/proxy_resolver_v8_tracing_unittest.cc +++ b/services/proxy_resolver/proxy_resolver_v8_tracing_unittest.cc
@@ -9,10 +9,10 @@ #include <vector> #include "base/bind.h" +#include "base/cxx17_backports.h" #include "base/files/file_util.h" #include "base/path_service.h" #include "base/run_loop.h" -#include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h"
diff --git a/services/proxy_resolver/proxy_resolver_v8_unittest.cc b/services/proxy_resolver/proxy_resolver_v8_unittest.cc index 1355390a..1445458 100644 --- a/services/proxy_resolver/proxy_resolver_v8_unittest.cc +++ b/services/proxy_resolver/proxy_resolver_v8_unittest.cc
@@ -5,9 +5,9 @@ #include "services/proxy_resolver/proxy_resolver_v8.h" #include "base/compiler_specific.h" +#include "base/cxx17_backports.h" #include "base/files/file_util.h" #include "base/path_service.h" -#include "base/stl_util.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h"
diff --git a/services/tracing/public/cpp/perfetto/trace_string_lookup.cc b/services/tracing/public/cpp/perfetto/trace_string_lookup.cc index ae93134..610172c 100644 --- a/services/tracing/public/cpp/perfetto/trace_string_lookup.cc +++ b/services/tracing/public/cpp/perfetto/trace_string_lookup.cc
@@ -4,7 +4,7 @@ #include "services/tracing/public/cpp/perfetto/trace_string_lookup.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "base/strings/pattern.h" using ::perfetto::protos::pbzero::ChromeProcessDescriptor;
diff --git a/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.cc b/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.cc index d2ce152..d98c1d9 100644 --- a/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.cc +++ b/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.cc
@@ -42,6 +42,8 @@ return false; } (*out)->has_transparent_background = data.has_transparent_background(); + (*out)->has_per_quad_damage = data.has_per_quad_damage(); + (*out)->cache_render_pass = data.cache_render_pass(); (*out)->has_damage_from_contributing_content = data.has_damage_from_contributing_content();
diff --git a/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.h b/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.h index 9afe9ab2..0b0ce88 100644 --- a/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.h +++ b/services/viz/public/cpp/compositing/compositor_render_pass_mojom_traits.h
@@ -76,6 +76,11 @@ return input->has_transparent_background; } + static bool has_per_quad_damage( + const std::unique_ptr<viz::CompositorRenderPass>& input) { + return input->has_per_quad_damage; + } + static bool cache_render_pass( const std::unique_ptr<viz::CompositorRenderPass>& input) { return input->cache_render_pass;
diff --git a/services/viz/public/cpp/compositing/mojom_traits_perftest.cc b/services/viz/public/cpp/compositing/mojom_traits_perftest.cc index d178da9..3ebb8957 100644 --- a/services/viz/public/cpp/compositing/mojom_traits_perftest.cc +++ b/services/viz/public/cpp/compositing/mojom_traits_perftest.cc
@@ -178,6 +178,7 @@ bool arbitrary_bool4 = true; bool arbitrary_bool5 = false; bool arbitrary_bool6 = true; + bool arbitrary_bool7 = false; gfx::ProtectedVideoType arbitrary_protected_video_type = gfx::ProtectedVideoType::kClear; int arbitrary_context_id1 = 12; @@ -210,7 +211,7 @@ arbitrary_matrix1, arbitrary_filters2, arbitrary_filters1, arbitrary_rrectf1, SubtreeCaptureId(), arbitrary_rect1.size(), arbitrary_bool1, arbitrary_bool1, - arbitrary_bool1, arbitrary_bool1); + arbitrary_bool1, arbitrary_bool1, arbitrary_bool7); // Texture quads for (uint32_t i = 0; i < 10; ++i) {
diff --git a/services/viz/public/cpp/compositing/mojom_traits_unittest.cc b/services/viz/public/cpp/compositing/mojom_traits_unittest.cc index 6f700cd..e5b9190 100644 --- a/services/viz/public/cpp/compositing/mojom_traits_unittest.cc +++ b/services/viz/public/cpp/compositing/mojom_traits_unittest.cc
@@ -709,12 +709,14 @@ const bool cache_render_pass = true; const bool has_damage_from_contributing_content = true; const bool generate_mipmap = true; + const bool has_per_quad_damage = true; auto input = CompositorRenderPass::Create(); input->SetAll(render_pass_id, output_rect, damage_rect, transform_to_root, filters, backdrop_filters, backdrop_filter_bounds, subtree_capture_id, output_rect.size(), has_transparent_background, cache_render_pass, - has_damage_from_contributing_content, generate_mipmap); + has_damage_from_contributing_content, generate_mipmap, + has_per_quad_damage); input->copy_requests.push_back(CopyOutputRequest::CreateStubForTesting()); const gfx::Rect copy_output_area(24, 42, 75, 57); input->copy_requests.back()->set_area(copy_output_area); @@ -782,6 +784,7 @@ EXPECT_EQ(cache_render_pass, output->cache_render_pass); EXPECT_EQ(has_damage_from_contributing_content, output->has_damage_from_contributing_content); + EXPECT_EQ(has_per_quad_damage, output->has_per_quad_damage); EXPECT_EQ(generate_mipmap, output->generate_mipmap); ASSERT_EQ(1u, output->copy_requests.size()); EXPECT_EQ(copy_output_area, output->copy_requests.front()->area()); @@ -853,12 +856,14 @@ const bool cache_render_pass = false; const bool has_damage_from_contributing_content = false; const bool generate_mipmap = false; + const bool has_per_quad_damage = false; auto input = CompositorRenderPass::Create(); input->SetAll(render_pass_id, output_rect, damage_rect, transform_to_root, cc::FilterOperations(), cc::FilterOperations(), backdrop_filter_bounds, subtree_capture_id, output_rect.size(), has_transparent_background, cache_render_pass, - has_damage_from_contributing_content, generate_mipmap); + has_damage_from_contributing_content, generate_mipmap, + has_per_quad_damage); // Unlike the previous test, don't add any quads to the list; we need to // verify that the serialization code can deal with that.
diff --git a/services/viz/public/cpp/compositing/quads_mojom_traits.cc b/services/viz/public/cpp/compositing/quads_mojom_traits.cc index e31e53e..2c6daf2 100644 --- a/services/viz/public/cpp/compositing/quads_mojom_traits.cc +++ b/services/viz/public/cpp/compositing/quads_mojom_traits.cc
@@ -7,6 +7,8 @@ #include "services/viz/public/cpp/compositing/compositor_render_pass_id_mojom_traits.h" #include "services/viz/public/cpp/compositing/resource_id_mojom_traits.h" #include "services/viz/public/cpp/crash_keys.h" +#include "third_party/abseil-cpp/absl/types/optional.h" +#include "ui/gfx/geometry/rect.h" #include "ui/gfx/mojom/color_space_mojom_traits.h" #include "ui/gfx/mojom/transform_mojom_traits.h" @@ -165,6 +167,10 @@ quad->secure_output_only = data.secure_output_only(); quad->is_video_frame = data.is_video_frame(); quad->hw_protected_validation_id = data.hw_protected_validation_id(); + + if (!data.ReadDamageRect(&quad->damage_rect)) + return false; + return true; } @@ -240,6 +246,9 @@ viz::SetDeserializationCrashKeyString("Bits per channel too big"); return false; } + if (!data.ReadDamageRect(&quad->damage_rect)) + return false; + return true; }
diff --git a/services/viz/public/cpp/compositing/quads_mojom_traits.h b/services/viz/public/cpp/compositing/quads_mojom_traits.h index ec418f9..f05a1f2 100644 --- a/services/viz/public/cpp/compositing/quads_mojom_traits.h +++ b/services/viz/public/cpp/compositing/quads_mojom_traits.h
@@ -25,7 +25,9 @@ #include "services/viz/public/cpp/compositing/shared_quad_state_mojom_traits.h" #include "services/viz/public/cpp/compositing/surface_range_mojom_traits.h" #include "services/viz/public/mojom/compositing/quads.mojom-shared.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gfx/geometry/mojom/geometry_mojom_traits.h" +#include "ui/gfx/geometry/rect.h" #include "ui/gfx/hdr_metadata.h" #include "ui/gfx/ipc/color/gfx_param_traits.h" #include "ui/gfx/mojom/hdr_metadata_mojom_traits.h" @@ -435,6 +437,13 @@ return quad->hw_protected_validation_id; } + static const absl::optional<gfx::Rect>& damage_rect( + const viz::DrawQuad& input) { + const viz::TextureDrawQuad* quad = + viz::TextureDrawQuad::MaterialCast(&input); + return quad->damage_rect; + } + static bool Read(viz::mojom::TextureQuadStateDataView data, viz::DrawQuad* out); }; @@ -552,12 +561,20 @@ viz::YUVVideoDrawQuad::MaterialCast(&input); return quad->protected_video_type; } + static const gfx::HDRMetadata& hdr_metadata(const viz::DrawQuad& input) { const viz::YUVVideoDrawQuad* quad = viz::YUVVideoDrawQuad::MaterialCast(&input); return quad->hdr_metadata; } + static const absl::optional<gfx::Rect>& damage_rect( + const viz::DrawQuad& input) { + const viz::YUVVideoDrawQuad* quad = + viz::YUVVideoDrawQuad::MaterialCast(&input); + return quad->damage_rect; + } + static bool Read(viz::mojom::YUVVideoQuadStateDataView data, viz::DrawQuad* out); };
diff --git a/services/viz/public/cpp/compositing/shared_quad_state_mojom_traits.h b/services/viz/public/cpp/compositing/shared_quad_state_mojom_traits.h index c78cbf9..0ddd869 100644 --- a/services/viz/public/cpp/compositing/shared_quad_state_mojom_traits.h +++ b/services/viz/public/cpp/compositing/shared_quad_state_mojom_traits.h
@@ -70,10 +70,6 @@ static float de_jelly_delta_y(const OptSharedQuadState& input) { return input.sqs->de_jelly_delta_y; } - - static bool no_damage(const OptSharedQuadState& input) { - return input.sqs->no_damage; - } }; template <> @@ -124,10 +120,6 @@ return sqs.de_jelly_delta_y; } - static bool no_damage(const viz::SharedQuadState& sqs) { - return sqs.no_damage; - } - static bool Read(viz::mojom::SharedQuadStateDataView data, viz::SharedQuadState* out) { if (!data.ReadQuadToTargetTransform(&out->quad_to_target_transform) || @@ -146,7 +138,7 @@ out->sorting_context_id = data.sorting_context_id(); out->is_fast_rounded_corner = data.is_fast_rounded_corner(); out->de_jelly_delta_y = data.de_jelly_delta_y(); - out->no_damage = data.no_damage(); + return true; } };
diff --git a/services/viz/public/mojom/compositing/compositor_render_pass.mojom b/services/viz/public/mojom/compositing/compositor_render_pass.mojom index 26f0700a..05669c04 100644 --- a/services/viz/public/mojom/compositing/compositor_render_pass.mojom +++ b/services/viz/public/mojom/compositing/compositor_render_pass.mojom
@@ -31,4 +31,13 @@ // |copy_requests| are only allowed by privileged clients. array<CopyOutputRequest> copy_requests; array<DrawQuad> quad_list; + // |has_per_quad_damage| is primarily used as a performance hint to surface + // aggregator. Maliciously setting to true means some extra work looping + // over the quads looking for a |per_quad_damage| rect where none exists. + // Maliciously setting this to false will result in skipping damage found in + // |quad_list|. This missing damage may lead to incorrect repaint but only + // for this specific |CompositorRenderPass|. Neither one of these malicious + // inconsistent states give new privileges to the sender that were not already + // available with |damage_rect| or |quad_list|. + bool has_per_quad_damage; };
diff --git a/services/viz/public/mojom/compositing/quads.mojom b/services/viz/public/mojom/compositing/quads.mojom index b756244..904b110 100644 --- a/services/viz/public/mojom/compositing/quads.mojom +++ b/services/viz/public/mojom/compositing/quads.mojom
@@ -91,6 +91,7 @@ bool is_video_frame; ProtectedVideoState protected_video_type; uint32 hw_protected_validation_id; + gfx.mojom.Rect? damage_rect; }; struct TileQuadState { @@ -117,6 +118,7 @@ gfx.mojom.ColorSpace video_color_space; ProtectedVideoState protected_video_type; gfx.mojom.HDRMetadata hdr_metadata; + gfx.mojom.Rect? damage_rect; }; struct VideoHoleQuadState {
diff --git a/services/viz/public/mojom/compositing/shared_quad_state.mojom b/services/viz/public/mojom/compositing/shared_quad_state.mojom index 771d5e0c..88435f1e 100644 --- a/services/viz/public/mojom/compositing/shared_quad_state.mojom +++ b/services/viz/public/mojom/compositing/shared_quad_state.mojom
@@ -44,8 +44,4 @@ // de-jelly effect. float de_jelly_delta_y; - // If true, indicates that the quads do not contribute damage to their - // render pass's damage; if false, whether or not the quads contribute - // damage is unknown. - bool no_damage; };
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 10836a4..0afadc3 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -52999,6 +52999,36 @@ }, { "args": [ + "--board=eve", + "--flash" + ], + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_fyi_tast_tests_eve", + "resultdb": { + "enable": true + }, + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_type": "eve", + "os": "ChromeOS" + } + ], + "idempotent": false, + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_fyi_tast_tests", + "test_id_prefix": "ninja://chromeos/lacros:lacros_fyi_tast_tests/", + "trigger_script": { + "script": "//testing/trigger_scripts/chromeos_device_trigger.py" + } + }, + { + "args": [ "--board=amd64-generic", "--use-vm" ],
diff --git a/testing/buildbot/chromium.mac.json b/testing/buildbot/chromium.mac.json index 6683003..8fa6a7b0 100644 --- a/testing/buildbot/chromium.mac.json +++ b/testing/buildbot/chromium.mac.json
@@ -7985,7 +7985,6 @@ "test_id_prefix": "ninja://headless:headless_unittests/" }, { - "ci_only": true, "isolate_profile_data": true, "merge": { "args": [], @@ -8741,7 +8740,6 @@ "args": [ "--num-retries=3" ], - "ci_only": true, "isolate_name": "blink_web_tests", "isolate_profile_data": true, "merge": {
diff --git a/testing/buildbot/test_suite_exceptions.pyl b/testing/buildbot/test_suite_exceptions.pyl index bd4e971..7da90af 100644 --- a/testing/buildbot/test_suite_exceptions.pyl +++ b/testing/buildbot/test_suite_exceptions.pyl
@@ -273,7 +273,6 @@ }, }, 'Mac10.15 Tests': { - 'ci_only': True, 'swarming': { 'dimension_sets': [ { @@ -1797,9 +1796,6 @@ 'shards': 32, # Adjusted for testing, see https://crbug.com/1179567 }, }, - 'Mac10.15 Tests': { - 'ci_only': True, - }, 'Mac11 Tests': { # TODO(crbug.com/1206401): Restore to defaults when there is enough # capacity.
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl index 1850858..6e8c9db 100644 --- a/testing/buildbot/test_suites.pyl +++ b/testing/buildbot/test_suites.pyl
@@ -7316,6 +7316,7 @@ 'lacros_fyi_tast_tests': { 'variants': [ 'LACROS_AMD64_GENERIC', + 'LACROS_EVE', ] }, },
diff --git a/testing/merge_scripts/code_coverage/OWNERS b/testing/merge_scripts/code_coverage/OWNERS index 53f1daa..6078887 100644 --- a/testing/merge_scripts/code_coverage/OWNERS +++ b/testing/merge_scripts/code_coverage/OWNERS
@@ -1,4 +1,4 @@ pasthana@google.com zhaoyangli@chromium.org liaoyuke@chromium.org -per-file merge_js_lib.py,merge_js_lib_test.py=benreich@chromium.org +per-file merge_js_lib.py,merge_js_lib_test.py,convert_to_istanbul.js=benreich@chromium.org
diff --git a/testing/merge_scripts/code_coverage/convert_to_istanbul.js b/testing/merge_scripts/code_coverage/convert_to_istanbul.js new file mode 100644 index 0000000..94442f9 --- /dev/null +++ b/testing/merge_scripts/code_coverage/convert_to_istanbul.js
@@ -0,0 +1,124 @@ +// 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. + +/** + * @fileoverview Takes raw v8 coverage files and converts to IstanbulJS + * compliant coverage files. + */ + +// Relative path to the node modules. +const NODE_MODULES = ['..', '..', '..', 'third_party', 'node', 'node_modules']; + +const {createHash} = require('crypto'); +const {join, normalize} = require('path'); +const {readdir, readFile, writeFile, mkdir} = require('fs').promises; +const V8ToIstanbul = require(join(...NODE_MODULES, 'v8-to-istanbul')); +const {ArgumentParser} = require(join(...NODE_MODULES, 'argparse')); + +/** + * Extracts the raw coverage data from the v8 coverage reports and converts + * them into IstanbulJS compliant reports. + * @param {string} coverageDirectory Directory containing the raw v8 output. + * @param {string} instrumentedDirectoryRoot Directory containing the source + * files where the coverage was instrumented from. + * @param {string} outputDir Directory to store the istanbul coverage reports. + */ +async function extractCoverage( + coverageDirectory, instrumentedDirectoryRoot, outputDir) { + const coverages = await readdir(coverageDirectory); + + for (const fileName of coverages) { + if (!fileName.endsWith('.cov.json')) + continue; + + const filePath = join(coverageDirectory, fileName); + const contents = await readFile(filePath, 'utf-8'); + + const {result: scriptCoverages} = JSON.parse(contents); + + for (const coverage of scriptCoverages) { + // URLs with a "// #sourceURL=..." comment are rewritten by DevTools and + // thus we filter out any as these are not opted into coverage. + if (!coverage.url.startsWith('//')) + continue; + + const instrumentedFilePath = + join(instrumentedDirectoryRoot, normalizePath(coverage.url)); + const converter = V8ToIstanbul(instrumentedFilePath); + await converter.load(); + converter.applyCoverage(coverage.functions); + const convertedCoverage = converter.toIstanbul(); + + const jsonString = JSON.stringify(convertedCoverage); + await writeFile( + join(outputDir, createSHA1HashFromFileContents(jsonString) + '.json'), + jsonString); + } + } +} + +/** + * Remove the preceding // from the path and normalize it. + * @param {string} sourceURL The value proceeding the "// #sourceURL=...". + * @return {string} The normalized path. + */ +function normalizePath(sourceURL) { + if (sourceURL.startsWith('//')) + return sourceURL.replace('//', ''); + + return normalize(sourceURL); +} + +/** + * Helper function to provide a unique file name for resultant istanbul reports. + * @param {string} str File contents + * @return {string} A sha1 hash to be used as a file name. + */ +function createSHA1HashFromFileContents(contents) { + return createHash('sha1').update(contents).digest('hex'); +} + +/** + * The entry point to the function to enable the async functionality throughout. + * @param {Object} args The parsed CLI arguments. + */ +async function main(args) { + for (const coverageDir of args.raw_coverage_dirs) { + const outputDir = join(args.output_dir, 'istanbul') + await mkdir(outputDir, {recursive: true}); + await extractCoverage(coverageDir, args.source_dir, outputDir); + } +} + +const parser = new ArgumentParser({ + description: 'Converts raw v8 coverage into IstanbulJS compliant files.', +}); + +parser.addArgument(['-s', '--source-dir'], { + required: true, + help: 'Root directory where source files live. The corresponding ' + + 'coverage files must refer to these files. Currently source ' + + 'maps are not supported.', +}); +parser.addArgument(['-o', '--output-dir'], { + required: true, + help: 'Root directory to output all the converted istanbul coverage ' + + 'reports.', +}); +parser.addArgument(['-c', '--raw-coverage-dirs'], { + required: true, + nargs: '*', + help: 'Directory that contains the raw v8 coverage files (files ' + + 'ending in .cov.json)', +}); + +const args = parser.parseArgs(); +main(args) + .then(() => { + console.log('Successfully converted from v8 to IstanbulJS'); + }) + .catch(error => { + console.error(error); + process.exit(1); + });
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 45ed5fe9..a4cb211 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -5782,6 +5782,27 @@ ] } ], + "PageContentAnnotationsAndroid": [ + { + "platforms": [ + "android" + ], + "experiments": [ + { + "name": "PageContentAnnotationsMemImproved_20210604", + "params": { + "allowed_field_trial_names": "PageContentAnnotationsAndroid", + "write_to_history_service": "false" + }, + "enable_features": [ + "LoadModelFileForEachExecution", + "OptimizationHintsFieldTrials", + "PageContentAnnotations" + ] + } + ] + } + ], "PageInfoDiscoverability": [ { "platforms": [ @@ -6036,42 +6057,6 @@ ] } ], - "PdfViewerDocumentProperties": [ - { - "platforms": [ - "chromeos", - "linux", - "mac", - "windows" - ], - "experiments": [ - { - "name": "Enabled", - "enable_features": [ - "PdfViewerDocumentProperties" - ] - } - ] - } - ], - "PdfViewerPresentationMode": [ - { - "platforms": [ - "chromeos", - "linux", - "mac", - "windows" - ], - "experiments": [ - { - "name": "Enabled", - "enable_features": [ - "PdfViewerPresentationMode" - ] - } - ] - } - ], "PerProcessReclaim": [ { "platforms": [
diff --git a/third_party/blink/common/BUILD.gn b/third_party/blink/common/BUILD.gn index 09da2da..4e7fe7d9 100644 --- a/third_party/blink/common/BUILD.gn +++ b/third_party/blink/common/BUILD.gn
@@ -179,6 +179,7 @@ "service_worker/service_worker_status_code.cc", "service_worker/service_worker_type_converters.cc", "storage_key/storage_key.cc", + "storage_key/storage_key_mojom_traits.cc", "switches.cc", "thread_safe_browser_interface_broker_proxy.cc", "unique_name/unique_name_helper.cc",
diff --git a/third_party/blink/common/page_state/page_state.cc b/third_party/blink/common/page_state/page_state.cc index 9d15340..b1d37c49 100644 --- a/third_party/blink/common/page_state/page_state.cc +++ b/third_party/blink/common/page_state/page_state.cc
@@ -14,6 +14,7 @@ #include "services/network/public/mojom/referrer_policy.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/page_state/page_state_serialization.h" +#include "third_party/perfetto/include/perfetto/tracing/traced_value.h" namespace blink { namespace { @@ -180,4 +181,9 @@ // DCHECK(IsValid()); } +void PageState::WriteIntoTrace(perfetto::TracedValue context) const { + auto dict = std::move(context).WriteDictionary(); + dict.Add("data", data_); +} + } // namespace blink
diff --git a/third_party/blink/common/storage_key/storage_key.cc b/third_party/blink/common/storage_key/storage_key.cc index 7c80d2b..06b1d7b 100644 --- a/third_party/blink/common/storage_key/storage_key.cc +++ b/third_party/blink/common/storage_key/storage_key.cc
@@ -4,6 +4,9 @@ #include "third_party/blink/public/common/storage_key/storage_key.h" +#include <ostream> + +#include "base/strings/strcat.h" #include "url/gurl.h" namespace blink { @@ -26,6 +29,10 @@ return origin_.GetURL().spec(); } +std::string StorageKey::GetDebugString() const { + return base::StrCat({"{ origin: ", origin_.GetDebugString(), " }"}); +} + bool operator==(const StorageKey& lhs, const StorageKey& rhs) { return lhs.origin_ == rhs.origin_; } @@ -38,4 +45,8 @@ return lhs.origin_ < rhs.origin_; } +std::ostream& operator<<(std::ostream& ostream, const StorageKey& sk) { + return ostream << sk.GetDebugString(); +} + } // namespace blink
diff --git a/third_party/blink/public/common/page_state/page_state.h b/third_party/blink/public/common/page_state/page_state.h index d4ff9d64..d885072cc 100644 --- a/third_party/blink/public/common/page_state/page_state.h +++ b/third_party/blink/public/common/page_state/page_state.h
@@ -9,6 +9,7 @@ #include <vector> #include "third_party/blink/public/common/common_export.h" +#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" class GURL; @@ -59,6 +60,8 @@ return !(this->Equals(other)); } + void WriteIntoTrace(perfetto::TracedValue context) const; + private: PageState(const std::string& data);
diff --git a/third_party/blink/public/common/storage_key/storage_key.h b/third_party/blink/public/common/storage_key/storage_key.h index 0aec1b1..cdd1c98c 100644 --- a/third_party/blink/public/common/storage_key/storage_key.h +++ b/third_party/blink/public/common/storage_key/storage_key.h
@@ -5,6 +5,7 @@ #ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_STORAGE_KEY_STORAGE_KEY_H_ #define THIRD_PARTY_BLINK_PUBLIC_COMMON_STORAGE_KEY_STORAGE_KEY_H_ +#include <iosfwd> #include <string> #include "base/strings/string_piece.h" @@ -49,6 +50,8 @@ const url::Origin& origin() const { return origin_; } + std::string GetDebugString() const; + private: BLINK_COMMON_EXPORT friend bool operator==(const StorageKey& lhs, const StorageKey& rhs); @@ -64,6 +67,9 @@ url::Origin origin_; }; +BLINK_COMMON_EXPORT +std::ostream& operator<<(std::ostream& ostream, const StorageKey& sk); + } // namespace blink #endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_STORAGE_KEY_STORAGE_KEY_H_
diff --git a/third_party/blink/public/mojom/BUILD.gn b/third_party/blink/public/mojom/BUILD.gn index ece6ab8..c52c926 100644 --- a/third_party/blink/public/mojom/BUILD.gn +++ b/third_party/blink/public/mojom/BUILD.gn
@@ -185,7 +185,6 @@ "speech/speech_recognizer.mojom", "speech/speech_synthesis.mojom", "storage_access/storage_access_automation.mojom", - "storage_key/storage_key.mojom", "timing/performance_mark_or_measure.mojom", "timing/resource_timing.mojom", "timing/worker_timing_container.mojom", @@ -635,19 +634,6 @@ { types = [ { - mojom = "blink.mojom.StorageKey" - cpp = "::blink::StorageKey" - }, - ] - traits_headers = [ "//third_party/blink/public/common/storage_key/storage_key_mojom_traits.h" ] - traits_sources = [ - "//third_party/blink/common/storage_key/storage_key_mojom_traits.cc", - ] - traits_public_deps = [ "//url/mojom:url_mojom_origin" ] - }, - { - types = [ - { mojom = "blink.mojom.UseCounterFeature" cpp = "::blink::UseCounterFeature" }, @@ -1071,12 +1057,16 @@ # to a type in renderer/modules. This also means these interfaces are not # available from renderer/platform or renderer/core. mojom("mojom_modules") { - sources = [ "indexeddb/indexeddb.mojom" ] + sources = [ + "indexeddb/indexeddb.mojom", + "storage_key/storage_key.mojom", + ] public_deps = [ ":android_mojo_bindings", ":mojom_core", "//mojo/public/mojom/base", + "//url/mojom:url_mojom_origin", ] overridden_deps_blink = [ @@ -1145,6 +1135,17 @@ ] traits_deps = [ "//third_party/blink/renderer/platform/wtf" ] }, + { + types = [ + { + mojom = "blink.mojom.StorageKey" + cpp = "::blink::BlinkStorageKey" + }, + ] + traits_headers = [ "//third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.h" ] + traits_public_deps = + [ "//third_party/blink/renderer/modules/storage:blink_storage_key" ] + }, ] cpp_typemaps = [ @@ -1194,6 +1195,15 @@ ] traits_private_headers = [ "//third_party/blink/public/common/indexeddb/indexed_db_default_mojom_traits.h" ] }, + { + types = [ + { + mojom = "blink.mojom.StorageKey" + cpp = "::blink::StorageKey" + }, + ] + traits_headers = [ "//third_party/blink/public/common/storage_key/storage_key_mojom_traits.h" ] + }, ] }
diff --git a/third_party/blink/public/mojom/web_feature/web_feature.mojom b/third_party/blink/public/mojom/web_feature/web_feature.mojom index ae2cb770..756671d 100644 --- a/third_party/blink/public/mojom/web_feature/web_feature.mojom +++ b/third_party/blink/public/mojom/web_feature/web_feature.mojom
@@ -3242,6 +3242,7 @@ kHiddenBackfaceWith3D = 3927, kMainFrameNonSecurePrivateAddressSpace = 3928, kCSSSelectorPseudoHas = 3929, + kHTMLMediaElementControlsListNoPlaybackRate = 3930, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/third_party/blink/renderer/bindings/scripts/bind_gen/README.md b/third_party/blink/renderer/bindings/scripts/bind_gen/README.md new file mode 100644 index 0000000..e6bd4db --- /dev/null +++ b/third_party/blink/renderer/bindings/scripts/bind_gen/README.md
@@ -0,0 +1,166 @@ +# Blink-V8 bindings generator (bind_gen package) + +[TOC] + +## What's bind_gen? + +Python package +[`bind_gen`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/scripts/bind_gen/) +is the core part of Blink-V8 bindings code generator. +[`generate_bindings.py`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/scripts/generate_bindings.py) +is the driver script, which takes a Web IDL database (`web_idl_database.pickle` +generated by "web_idl_database" GN target) as an input and produces a set of +C++ source files of Blink-V8 bindings (v8_\*.h, v8_\*.cc). + +## Design and code structure + +The bindings code generator is implemented as a tree builder of `CodeNode` +which is a fundamental building block. The following sub sections describe +what `CodeNode` is and how the code generator builds a tree of `CodeNode`. + +### CodeNode + +The code generator produces C++ source files (text files) but the content of +each file is not represented as a single giant string nor a list of strings. +The content of each file is represented as a CodeNode tree. + +`CodeNode` (defined in +[code_node.py](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py)) +is a fundamental building block that represents a text fragment in the tree +structure. A text file is represented as a tree of CodeNodes, each of which +represents a corresponding text fragment. The code generator is the CodeNode +tree builder. + +Here is a simple example to build a CodeNode tree. +```python +# SequenceNode and TextNode are subclasses of CodeNode. + +def prologue(): + return SequenceNode([ + TextNode("// Prologue"), + TextNode("SetUp();"), + ]) + +def epilogue(): + return SequenceNode([ + TextNode("// Epilogue"), + TextNode("CleanUp();"), + ]) + +def main(): + root_node = SequenceNode([ + prologue(), + TextNode("LOG(INFO) << \"hello, world\";"), + epilogue(), + ]) +``` +The `root_node` above represents the following text. + +```c++ +// Prologue +SetUp(); +LOG(INFO) << "hello, world"; +// Epilogue +CleanUp(); +``` + +The basic features of CodeNode are implemented in +[code_node.py](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py). +Just for convenience, CodeNode subclasses corresponding to C++ constructs are +provided in +[code_node_cxx.py](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/scripts/bind_gen/code_node_cxx.py). + +`CodeNode` has an object-oriented design and has internal states (not only the +parent / child nodes but also more states to support advanced features). + +### CodeNode tree builders + +The bindings code generator consists of multiple sub code generators. For +example, `interface.py` is a sub code generator of Web IDL interface and +`enumeration.py` is a sub code generator of Web IDL enumeration. Each Web IDL +definition has its own sub code generator. + +This sub section describes how a sub code generator builds a CodeNode tree and +produces C++ source files by looking at +[`enumeration.py`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/scripts/bind_gen/enumeration.py) +as an example. The example code snippet below is simplified for explanation. + +```python +def generate_enumerations(task_queue): + for enumeration in web_idl_database.enumerations: + task_queue.post_task(generate_enumeration, enumeration.identifier) +``` + +`generate_enumerations` is the entry point to this sub code generator. In +favor of parallel processing, `task_queue` is used. `generate_enumeration` +(singular form) actually produces a pair of C++ source files (\*.h and \*.cc). + +```python +def generate_enumeration(enumeration_identifier): + # Filepaths + header_path = path_manager.api_path(ext="h") + source_path = path_manager.api_path(ext="cc") + + # Root nodes + header_node = ListNode(tail="\n") + source_node = ListNode(tail="\n") + + # ... fill the contents of `header_node` and `source_node` ... + + # Write down to the files. + write_code_node_to_file(header_node, path_manager.gen_path_to(header_path)) + write_code_node_to_file(source_node, path_manager.gen_path_to(source_path)) +``` + +The main task of `generate_enumeration` is to build the CodeNode trees and +write them down to files. A key point here is to build two trees in parallel; +one for \*.h and the other for \*.cc. We can add a function declaration to the +header file while adding the corresponding function definition to the source +file. The following code snippet is an example to add constructors into the +header file and the source file. + +```python + # Namespaces + header_blink_ns = CxxNamespaceNode(name_style.namespace("blink")) + source_blink_ns = CxxNamespaceNode(name_style.namespace("blink")) + # {header,source}_blink_ns are added to {header,source}_node (the root + # nodes) respectively. + + # Class definition + class_def = CxxClassDefNode(cg_context.class_name, + base_class_names=["bindings::EnumerationBase"], + final=True, + export=component_export( + api_component, for_testing)) + + ctor_decls, ctor_defs = make_constructors(cg_context) + + # Define the class in 'blink' namespace. + header_blink_ns.body.append(class_def) + + # Add constructors to public: section of the class. + class_def.public_section.append(ctor_decls) + # Add constructors (function definitions) into 'blink' namespace in the + # source file. + source_blink_ns.body.append(ctor_defs) +``` + +In the above code snippet, `make_constructors` creates and returns a CodeNode +tree for the header file and another CodeNode tree for the source file. For +most cases, functions named `make_xxx` creates and returns a pair of the +CodeNode trees. These functions are subtree builders of the CodeNode trees. +They are implemented in a way of functional programming (unlike CodeNodes +themselves are implemented in a way of object-oriented programming). These +subtree builders create a pair of new CodeNode trees at every function call +(returned code node instances are different per call, so their internal states +are separate), but the contents are 100% determined by the input arguments. +This property is very important when we use closures in advanced use cases. + +So far, the typical code structure of the sub code generators is covered. +`enumeration.py` consists of several `make_xxx` functions (subtree builders) + +`generate_enumeration` (the top-level tree builder + file writer). + +### Advanced: Auto-completion and declarative style + +TODO(yukishiino): Write about `SymbolNode`, `SymbolDefinitionNode`, +`SequenceNode`, and `SymbolScopeNode`.
diff --git a/third_party/blink/renderer/core/animation/animation.cc b/third_party/blink/renderer/core/animation/animation.cc index 477671c..50fb3c96 100644 --- a/third_party/blink/renderer/core/animation/animation.cc +++ b/third_party/blink/renderer/core/animation/animation.cc
@@ -1991,15 +1991,21 @@ bool had_no_effect = compositor_property_animations_have_no_effect_; compositor_property_animations_have_no_effect_ = false; - if (auto* keyframe_effect = DynamicTo<KeyframeEffect>(content_.Get())) { - Element* target = keyframe_effect->EffectTarget(); - if (target && keyframe_effect->Model()) { - compositor_property_animations_have_no_effect_ = - CompositorAnimations::CompositorPropertyAnimationsHaveNoEffect( - *target, *keyframe_effect->Model(), paint_artifact_compositor); - } + + auto* keyframe_effect = DynamicTo<KeyframeEffect>(content_.Get()); + if (!keyframe_effect || !keyframe_effect->IsCurrent()) { + // If the animation is not running, we can skip checking for having no + // effect. We can also skip the call to |SetCompositorPending| to avoid + // marking finished animations as pending. + return; } + Element* target = keyframe_effect->EffectTarget(); + if (target && keyframe_effect->Model()) { + compositor_property_animations_have_no_effect_ = + CompositorAnimations::CompositorPropertyAnimationsHaveNoEffect( + *target, *keyframe_effect->Model(), paint_artifact_compositor); + } if (compositor_property_animations_have_no_effect_ != had_no_effect) SetCompositorPending(); }
diff --git a/third_party/blink/renderer/core/animation/compositor_animations.cc b/third_party/blink/renderer/core/animation/compositor_animations.cc index a537f2d..f0d3ec9 100644 --- a/third_party/blink/renderer/core/animation/compositor_animations.cc +++ b/third_party/blink/renderer/core/animation/compositor_animations.cc
@@ -697,9 +697,20 @@ DCHECK(animation_playback_rate); double delay = animation_playback_rate > 0 ? timing.start_delay.InSecondsF() : 0; - out.scaled_time_offset = - -base::TimeDelta::FromSecondsD(delay / animation_playback_rate) + - time_offset; + + base::TimeDelta scaled_delay = + base::TimeDelta::FromSecondsD(delay / animation_playback_rate); + + // Arithmetic operations involving a value that is effectively +/-infinity + // result in a value that is +/-infinity or undefined. Check before computing + // the scaled time offset to guard against the following: + // infinity - infinity or + // -infinity + infinity + // The result of either of these edge cases is undefined. + if (scaled_delay.is_max() || scaled_delay.is_min()) + return false; + + out.scaled_time_offset = -scaled_delay + time_offset; // Delay is effectively +/- infinity. if (out.scaled_time_offset.is_max() || out.scaled_time_offset.is_min()) return false;
diff --git a/third_party/blink/renderer/core/animation/compositor_animations_test.cc b/third_party/blink/renderer/core/animation/compositor_animations_test.cc index 6dd999bc..27982c462 100644 --- a/third_party/blink/renderer/core/animation/compositor_animations_test.cc +++ b/third_party/blink/renderer/core/animation/compositor_animations_test.cc
@@ -754,6 +754,11 @@ EXPECT_TRUE( ConvertTimingForCompositor(timing_, compositor_timing_, play_reverse)); EXPECT_DOUBLE_EQ(0.0, compositor_timing_.scaled_time_offset.InSecondsF()); + + // Stress test with an effectively infinite start delay. + timing_.start_delay = AnimationTimeDelta::FromSecondsD(1e19); + EXPECT_FALSE( + ConvertTimingForCompositor(timing_, compositor_timing_, play_forward)); } TEST_P(AnimationCompositorAnimationsTest,
diff --git a/third_party/blink/renderer/core/css/css_math_expression_node.cc b/third_party/blink/renderer/core/css/css_math_expression_node.cc index 3f5ed02..597ec96 100644 --- a/third_party/blink/renderer/core/css/css_math_expression_node.cc +++ b/third_party/blink/renderer/core/css/css_math_expression_node.cc
@@ -39,8 +39,6 @@ #include "third_party/blink/renderer/platform/wtf/math_extras.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" -static const int maxExpressionDepth = 100; - enum ParseState { OK, TooDeep, NoMoreTokens }; namespace blink { @@ -1055,15 +1053,6 @@ // ------ End of CSSMathExpressionVariadicOperation member functions -static ParseState CheckDepthAndIndex(int* depth, CSSParserTokenRange tokens) { - (*depth)++; - if (tokens.AtEnd()) - return NoMoreTokens; - if (*depth > maxExpressionDepth) - return TooDeep; - return OK; -} - class CSSMathExpressionNodeParser { STACK_ALLOCATED(); @@ -1082,7 +1071,7 @@ CSSMathOperator op, int depth) { DCHECK(op == CSSMathOperator::kMin || op == CSSMathOperator::kMax); - if (CheckDepthAndIndex(&depth, tokens) != OK) + if (tokens.AtEnd()) return nullptr; CSSMathExpressionVariadicOperation::Operands operands; @@ -1108,7 +1097,7 @@ } CSSMathExpressionNode* ParseClamp(CSSParserTokenRange tokens, int depth) { - if (CheckDepthAndIndex(&depth, tokens) != OK) + if (tokens.AtEnd()) return nullptr; CSSMathExpressionNode* min_operand = ParseValueExpression(tokens, depth); @@ -1184,7 +1173,7 @@ CSSMathExpressionNode* ParseValueTerm(CSSParserTokenRange& tokens, int depth) { - if (CheckDepthAndIndex(&depth, tokens) != OK) + if (tokens.AtEnd()) return nullptr; if (tokens.Peek().GetType() == kLeftParenthesisToken || @@ -1222,7 +1211,7 @@ CSSMathExpressionNode* ParseValueMultiplicativeExpression( CSSParserTokenRange& tokens, int depth) { - if (CheckDepthAndIndex(&depth, tokens) != OK) + if (tokens.AtEnd()) return nullptr; CSSMathExpressionNode* result = ParseValueTerm(tokens, depth); @@ -1253,7 +1242,7 @@ CSSMathExpressionNode* ParseAdditiveValueExpression( CSSParserTokenRange& tokens, int depth) { - if (CheckDepthAndIndex(&depth, tokens) != OK) + if (tokens.AtEnd()) return nullptr; CSSMathExpressionNode* result = @@ -1290,6 +1279,8 @@ CSSMathExpressionNode* ParseValueExpression(CSSParserTokenRange& tokens, int depth) { + if (++depth > kMaxExpressionDepth) + return nullptr; return ParseAdditiveValueExpression(tokens, depth); } };
diff --git a/third_party/blink/renderer/core/css/css_math_expression_node.h b/third_party/blink/renderer/core/css/css_math_expression_node.h index 8b0d81e1..624e5d7 100644 --- a/third_party/blink/renderer/core/css/css_math_expression_node.h +++ b/third_party/blink/renderer/core/css/css_math_expression_node.h
@@ -43,6 +43,8 @@ namespace blink { +static const int kMaxExpressionDepth = 100; + class CalculationExpressionNode; class CSSNumericLiteralValue;
diff --git a/third_party/blink/renderer/core/css/css_math_expression_node_test.cc b/third_party/blink/renderer/core/css/css_math_expression_node_test.cc index 9d31c408..37a8d95 100644 --- a/third_party/blink/renderer/core/css/css_math_expression_node_test.cc +++ b/third_party/blink/renderer/core/css/css_math_expression_node_test.cc
@@ -35,6 +35,7 @@ #include "third_party/blink/renderer/core/css/css_primitive_value.h" #include "third_party/blink/renderer/core/css/css_property_value_set.h" #include "third_party/blink/renderer/core/css/css_to_length_conversion_data.h" +#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h" #include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/platform/geometry/calculation_expression_node.h" #include "third_party/blink/renderer/platform/heap/heap.h" @@ -212,6 +213,85 @@ actual, "calc((1 * 2) * (5px + 20em / 2) - 80% / (3 - 1) + 5px)"))); } +TEST(CSSMathExpressionNode, TestParseDeeplyNestedExpression) { + enum Kind { + calc, + min, + max, + clamp, + }; + + // Ref: https://bugs.chromium.org/p/chromium/issues/detail?id=1211283 + const struct TestCase { + const Kind kind; + const int nest_num; + const bool expected; + } test_cases[] = { + {calc, 1, true}, + {calc, 10, true}, + {calc, kMaxExpressionDepth - 1, true}, + {calc, kMaxExpressionDepth, false}, + {calc, kMaxExpressionDepth + 1, false}, + {min, 1, true}, + {min, 10, true}, + {min, kMaxExpressionDepth - 1, true}, + {min, kMaxExpressionDepth, false}, + {min, kMaxExpressionDepth + 1, false}, + {max, 1, true}, + {max, 10, true}, + {max, kMaxExpressionDepth - 1, true}, + {max, kMaxExpressionDepth, false}, + {max, kMaxExpressionDepth + 1, false}, + {clamp, 1, true}, + {clamp, 10, true}, + {clamp, kMaxExpressionDepth - 1, true}, + {clamp, kMaxExpressionDepth, false}, + {clamp, kMaxExpressionDepth + 1, false}, + }; + + for (const auto& test_case : test_cases) { + std::stringstream ss; + + // Make nested expression as follows: + // calc(1px + calc(1px + calc(1px))) + // min(1px, 1px + min(1px, 1px + min(1px, 1px))) + // max(1px, 1px + max(1px, 1px + max(1px, 1px))) + // clamp(1px, 1px, 1px + clamp(1px, 1px, 1px + clamp(1px, 1px, 1px))) + for (int i = 0; i < test_case.nest_num; i++) { + if (i) + ss << " + "; + switch (test_case.kind) { + case calc: + ss << "calc(1px"; + break; + case min: + ss << "min(1px, 1px"; + break; + case max: + ss << "max(1px, 1px"; + break; + case clamp: + ss << "clamp(1px, 1px, 1px"; + break; + } + } + for (int i = 0; i < test_case.nest_num; i++) { + ss << ")"; + } + + CSSTokenizer tokenizer(String(ss.str().c_str())); + const auto tokens = tokenizer.TokenizeToEOF(); + const CSSParserTokenRange range(tokens); + const CSSMathExpressionNode* res = CSSMathExpressionNode::ParseCalc(range); + + if (test_case.expected) { + EXPECT_TRUE(res); + } else { + EXPECT_FALSE(res); + } + } +} + } // anonymous namespace } // namespace blink
diff --git a/third_party/blink/renderer/core/css/css_properties.json5 b/third_party/blink/renderer/core/css/css_properties.json5 index 508cbd0..fee8861 100644 --- a/third_party/blink/renderer/core/css/css_properties.json5 +++ b/third_party/blink/renderer/core/css/css_properties.json5
@@ -3323,7 +3323,7 @@ interpolable: true, field_group: "*", field_template: "primitive", - default_value: "0.0", + default_value: "-1.0", type_name: "float", converter: "ConvertPerspective", keywords: ["none"],
diff --git a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc index 9a8b361..f57abae 100644 --- a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc +++ b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
@@ -5374,20 +5374,18 @@ if (range.Peek().Id() == CSSValueID::kNone) return css_parsing_utils::ConsumeIdent(range); CSSPrimitiveValue* parsed_value = - css_parsing_utils::ConsumeLength(range, context, kValueRangeAll); + css_parsing_utils::ConsumeLength(range, context, kValueRangeNonNegative); bool use_legacy_parsing = localContext.UseAliasParsing(); if (!parsed_value && use_legacy_parsing) { double perspective; - if (!css_parsing_utils::ConsumeNumberRaw(range, context, perspective)) + if (!css_parsing_utils::ConsumeNumberRaw(range, context, perspective) || + perspective < 0.0) return nullptr; context.Count(WebFeature::kUnitlessPerspectiveInPerspectiveProperty); parsed_value = CSSNumericLiteralValue::Create( perspective, CSSPrimitiveValue::UnitType::kPixels); } - if (parsed_value && - (parsed_value->IsCalculated() || parsed_value->GetDoubleValue() > 0)) - return parsed_value; - return nullptr; + return parsed_value; } const CSSValue* Perspective::CSSValueFromComputedStyleInternal(
diff --git a/third_party/blink/renderer/core/css/resolver/element_resolve_context.h b/third_party/blink/renderer/core/css/resolver/element_resolve_context.h index 43503c9..c65c69fc 100644 --- a/third_party/blink/renderer/core/css/resolver/element_resolve_context.h +++ b/third_party/blink/renderer/core/css/resolver/element_resolve_context.h
@@ -24,6 +24,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_ELEMENT_RESOLVE_CONTEXT_H_ #include "third_party/blink/renderer/core/dom/element.h" +#include "third_party/blink/renderer/core/dom/node_computed_style.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/selector_checker.cc b/third_party/blink/renderer/core/css/selector_checker.cc index 3c75c935..ee4d432 100644 --- a/third_party/blink/renderer/core/css/selector_checker.cc +++ b/third_party/blink/renderer/core/css/selector_checker.cc
@@ -236,9 +236,17 @@ if (sub_result.dynamic_pseudo != kPseudoIdNone) result.dynamic_pseudo = sub_result.dynamic_pseudo; - if (context.selector->IsLastInTagHistory()) { - result.has_argument_leftmost_compound_match = context.element; - return kSelectorMatches; + // Fix the perf test regression : https://crbug.com/1216100 + // Place the LIKELY conditional branch early to separate the + // ':has' argument matching sequence. + if (LIKELY(!context.in_has_argument_selector)) { + if (context.selector->IsLastInTagHistory()) + return kSelectorMatches; + } else { + if (context.selector->IsLastInTagHistory()) { + result.has_argument_leftmost_compound_match = context.element; + return kSelectorMatches; + } } MatchStatus match; @@ -317,8 +325,13 @@ case CSSSelector::kDescendant: if (next_context.selector->GetPseudoType() == CSSSelector::kPseudoScope) { if (next_context.selector->IsLastInTagHistory()) { - if (context.scope->IsDocumentFragment() || - UNLIKELY(context.in_has_argument_selector)) { + // Fix the perf test regression : https://crbug.com/1216100 + // Place the LIKELY conditional branch early to separate the + // ':has' argument matching sequence. + if (LIKELY(!context.in_has_argument_selector)) { + if (context.scope->IsDocumentFragment()) + return kSelectorMatches; + } else { result.has_argument_leftmost_compound_match = context.element; return kSelectorMatches; }
diff --git a/third_party/blink/renderer/core/dom/build.gni b/third_party/blink/renderer/core/dom/build.gni index eaa501d..4cb1e0ca 100644 --- a/third_party/blink/renderer/core/dom/build.gni +++ b/third_party/blink/renderer/core/dom/build.gni
@@ -311,6 +311,7 @@ "mutation_observer_test.cc", "names_map_test.cc", "node_test.cc", + "node_traversal_test.cc", "nth_index_cache_test.cc", "range_test.cc", "scripted_animation_controller_test.cc",
diff --git a/third_party/blink/renderer/core/dom/node.h b/third_party/blink/renderer/core/dom/node.h index 6a75ff4..b5d2f13 100644 --- a/third_party/blink/renderer/core/dom/node.h +++ b/third_party/blink/renderer/core/dom/node.h
@@ -732,10 +732,10 @@ // Note that the following 'inline' functions are not defined in this header, // but in node_computed_style.h. Please include that file if you want to use // these functions. - ComputedStyle* MutableComputedStyleForEditingDeprecated() const; - const ComputedStyle* GetComputedStyle() const; - const ComputedStyle* ParentComputedStyle() const; - const ComputedStyle& ComputedStyleRef() const; + inline ComputedStyle* MutableComputedStyleForEditingDeprecated() const; + inline const ComputedStyle* GetComputedStyle() const; + inline const ComputedStyle* ParentComputedStyle() const; + inline const ComputedStyle& ComputedStyleRef() const; bool ShouldSkipMarkingStyleDirty() const; const ComputedStyle* EnsureComputedStyle(
diff --git a/third_party/blink/renderer/core/dom/node_traversal.h b/third_party/blink/renderer/core/dom/node_traversal.h index 862f37c..94a9b44 100644 --- a/third_party/blink/renderer/core/dom/node_traversal.h +++ b/third_party/blink/renderer/core/dom/node_traversal.h
@@ -36,7 +36,7 @@ namespace blink { -class NodeTraversal { +class CORE_EXPORT NodeTraversal { STATIC_ONLY(NodeTraversal); public: @@ -61,9 +61,8 @@ } // Like next, but skips children and starts with the next sibling. - CORE_EXPORT static Node* NextSkippingChildren(const Node&); - CORE_EXPORT static Node* NextSkippingChildren(const Node&, - const Node* stay_within); + static Node* NextSkippingChildren(const Node&); + static Node* NextSkippingChildren(const Node&, const Node* stay_within); static Node* FirstWithin(const Node& current) { return current.firstChild(); } @@ -89,23 +88,20 @@ const Node* stay_within = nullptr); // Pre-order traversal including the pseudo-elements. - CORE_EXPORT static Node* PreviousIncludingPseudo( - const Node&, - const Node* stay_within = nullptr); - CORE_EXPORT static Node* NextIncludingPseudo( - const Node&, - const Node* stay_within = nullptr); + static Node* PreviousIncludingPseudo(const Node&, + const Node* stay_within = nullptr); + static Node* NextIncludingPseudo(const Node&, + const Node* stay_within = nullptr); // See comment for |FlatTreeTraversal::PreviousAbsoluteSibling| for details. - CORE_EXPORT static Node* PreviousAbsoluteSiblingIncludingPseudo( + static Node* PreviousAbsoluteSiblingIncludingPseudo( const Node&, const Node* stay_within = nullptr); - CORE_EXPORT static Node* NextIncludingPseudoSkippingChildren( + static Node* NextIncludingPseudoSkippingChildren( const Node&, const Node* stay_within = nullptr); - CORE_EXPORT static Node* NextAncestorSibling(const Node&); - CORE_EXPORT static Node* NextAncestorSibling(const Node&, - const Node* stay_within); + static Node* NextAncestorSibling(const Node&); + static Node* NextAncestorSibling(const Node&, const Node* stay_within); static Node& HighestAncestorOrSelf(const Node&); // Children traversal.
diff --git a/third_party/blink/renderer/core/dom/node_traversal_test.cc b/third_party/blink/renderer/core/dom/node_traversal_test.cc new file mode 100644 index 0000000..e14b7bab --- /dev/null +++ b/third_party/blink/renderer/core/dom/node_traversal_test.cc
@@ -0,0 +1,412 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/dom/node_traversal.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/core/dom/document.h" +#include "third_party/blink/renderer/core/dom/element.h" +#include "third_party/blink/renderer/core/dom/text.h" +#include "third_party/blink/renderer/core/html/html_element.h" +#include "third_party/blink/renderer/core/html/html_head_element.h" +#include "third_party/blink/renderer/core/testing/page_test_base.h" + +namespace blink { +namespace node_traversal_test { + +namespace { + +template <class T> +HeapVector<Member<Node>> CollectFromIterable(T iterable) { + HeapVector<Member<Node>> nodes; + for (auto& node : iterable) + nodes.push_back(&node); + return nodes; +} + +void RemoveWhiteSpaceOnlyTextNodes(ContainerNode& container) { + for (Node* descendant : + CollectFromIterable(NodeTraversal::InclusiveDescendantsOf(container))) { + if (auto* text = DynamicTo<Text>(descendant)) { + if (text->ContainsOnlyWhitespaceOrEmpty()) + text->remove(); + } + } +} + +} // namespace + +class NodeTraversalTest : public PageTestBase { + public: + NodeTraversalTest() {} + + protected: + void SetupSampleHTML(const char* html); +}; + +void NodeTraversalTest::SetupSampleHTML(const char* html) { + Element* body = GetDocument().body(); + SetBodyInnerHTML(String::FromUTF8(html)); + RemoveWhiteSpaceOnlyTextNodes(*body); +} + +namespace { + +void TestCommonAncestor(Node* expected_result, + const Node& node_a, + const Node& node_b) { + Node* result1 = NodeTraversal::CommonAncestor(node_a, node_b); + EXPECT_EQ(expected_result, result1) + << "CommonAncestor(" << node_a.textContent() << "," + << node_b.textContent() << ")"; + Node* result2 = NodeTraversal::CommonAncestor(node_b, node_a); + EXPECT_EQ(expected_result, result2) + << "CommonAncestor(" << node_b.textContent() << "," + << node_a.textContent() << ")"; +} + +} // namespace + +// Test case for +// - Next +// - NextSkippingChildren +// - NextPostOrder +TEST_F(NodeTraversalTest, NextFunctions) { + SetupSampleHTML(R"( + <div id='c0'> + <div id='c00'></div> + <div id='c01'></div> + </div> + <div id='c1'> + <div id='c10'></div> + </div>)"); + + Element* html = GetDocument().documentElement(); + Element* body = GetDocument().body(); + Element* c0 = body->QuerySelector("#c0"); + Element* c1 = body->QuerySelector("#c1"); + Element* c00 = body->QuerySelector("#c00"); + Element* c01 = body->QuerySelector("#c01"); + Element* c10 = body->QuerySelector("#c10"); + + EXPECT_EQ(c0, NodeTraversal::Next(*body)); + EXPECT_EQ(c00, NodeTraversal::Next(*c0)); + EXPECT_EQ(c01, NodeTraversal::Next(*c00)); + EXPECT_EQ(c1, NodeTraversal::Next(*c01)); + EXPECT_EQ(c10, NodeTraversal::Next(*c1)); + EXPECT_EQ(nullptr, NodeTraversal::Next(*c10)); + + EXPECT_EQ(nullptr, NodeTraversal::NextSkippingChildren(*body)); + EXPECT_EQ(c1, NodeTraversal::NextSkippingChildren(*c0)); + EXPECT_EQ(c01, NodeTraversal::NextSkippingChildren(*c00)); + EXPECT_EQ(c1, NodeTraversal::NextSkippingChildren(*c01)); + EXPECT_EQ(nullptr, NodeTraversal::NextSkippingChildren(*c1)); + EXPECT_EQ(nullptr, NodeTraversal::Next(*c10)); + + EXPECT_EQ(html, NodeTraversal::NextPostOrder(*body)); + EXPECT_EQ(c10, NodeTraversal::NextPostOrder(*c0)); + EXPECT_EQ(body, NodeTraversal::NextPostOrder(*c1)); + EXPECT_EQ(c01, NodeTraversal::NextPostOrder(*c00)); + EXPECT_EQ(c0, NodeTraversal::NextPostOrder(*c01)); + EXPECT_EQ(c1, NodeTraversal::NextPostOrder(*c10)); +} + +// Test case for +// - LastWithin +// - LastWithinOrSelf +TEST_F(NodeTraversalTest, LastWithin) { + SetupSampleHTML(R"( + <div id='c0'> + <div id='c00'></div> + </div> + <div id='c1'></div>)"); + + Element* body = GetDocument().body(); + Element* c0 = body->QuerySelector("#c0"); + Element* c1 = body->QuerySelector("#c1"); + Element* c00 = body->QuerySelector("#c00"); + + EXPECT_EQ(c1, NodeTraversal::LastWithin(*body)); + EXPECT_EQ(c1, NodeTraversal::LastWithinOrSelf(*body)); + + EXPECT_EQ(c00, NodeTraversal::LastWithin(*c0)); + EXPECT_EQ(c00, NodeTraversal::LastWithinOrSelf(*c0)); + + EXPECT_EQ(nullptr, NodeTraversal::LastWithin(*c1)); + EXPECT_EQ(c1, NodeTraversal::LastWithinOrSelf(*c1)); +} + +// Test case for +// - Previous +// - PreviousAbsoluteSibling +// - PreviousPostOrder +TEST_F(NodeTraversalTest, PreviousFunctions) { + SetupSampleHTML(R"( + <div id='c0'> + <div id='c00'></div> + <div id='c01'></div> + </div> + <div id='c1'> + <div id='c10'></div> + </div>)"); + + Element* html = GetDocument().documentElement(); + Element* head = GetDocument().head(); + Element* body = GetDocument().body(); + Element* c0 = body->QuerySelector("#c0"); + Element* c1 = body->QuerySelector("#c1"); + Element* c00 = body->QuerySelector("#c00"); + Element* c01 = body->QuerySelector("#c01"); + Element* c10 = body->QuerySelector("#c10"); + + EXPECT_EQ(head, NodeTraversal::Previous(*body)); + EXPECT_EQ(body, NodeTraversal::Previous(*c0)); + EXPECT_EQ(c0, NodeTraversal::Previous(*c00)); + EXPECT_EQ(c00, NodeTraversal::Previous(*c01)); + EXPECT_EQ(c01, NodeTraversal::Previous(*c1)); + EXPECT_EQ(c1, NodeTraversal::Previous(*c10)); + + EXPECT_EQ(nullptr, NodeTraversal::PreviousAbsoluteSibling(*html)); + EXPECT_EQ(head, NodeTraversal::PreviousAbsoluteSibling(*body)); + EXPECT_EQ(head, NodeTraversal::PreviousAbsoluteSibling(*c0)); + EXPECT_EQ(head, NodeTraversal::PreviousAbsoluteSibling(*c00)); + EXPECT_EQ(c00, NodeTraversal::PreviousAbsoluteSibling(*c01)); + EXPECT_EQ(c0, NodeTraversal::PreviousAbsoluteSibling(*c1)); + EXPECT_EQ(c0, NodeTraversal::PreviousAbsoluteSibling(*c10)); + + EXPECT_EQ(c1, NodeTraversal::PreviousPostOrder(*body)); + EXPECT_EQ(c01, NodeTraversal::PreviousPostOrder(*c0)); + EXPECT_EQ(c10, NodeTraversal::PreviousPostOrder(*c1)); + EXPECT_EQ(head, NodeTraversal::PreviousPostOrder(*c00)); + EXPECT_EQ(c00, NodeTraversal::PreviousPostOrder(*c01)); + EXPECT_EQ(c0, NodeTraversal::PreviousPostOrder(*c10)); +} + +// Test case for +// - ChildAt +// - CountChildren +// - HasChildren +// - Index +// - IsDescendantOf +TEST_F(NodeTraversalTest, ChildAt) { + SetupSampleHTML(R"( + <div id='c0'> + <span id='c00'>c00</span> + </div> + <div id='c1'></div> + <div id='c2'></div>)"); + + Element* body = GetDocument().body(); + Element* c0 = body->QuerySelector("#c0"); + Element* c1 = body->QuerySelector("#c1"); + Element* c2 = body->QuerySelector("#c2"); + Element* c00 = body->QuerySelector("#c00"); + + const unsigned kNumberOfChildNodes = 3; + Node* expected_child_nodes[3] = {c0, c1, c2}; + + ASSERT_EQ(kNumberOfChildNodes, NodeTraversal::CountChildren(*body)); + EXPECT_TRUE(NodeTraversal::HasChildren(*body)); + + for (unsigned index = 0; index < kNumberOfChildNodes; ++index) { + Node* child = NodeTraversal::ChildAt(*body, index); + EXPECT_EQ(index, NodeTraversal::Index(*child)) + << "NodeTraversal::index(NodeTraversal(*body, " << index << "))"; + EXPECT_TRUE(NodeTraversal::IsDescendantOf(*child, *body)) + << "NodeTraversal::isDescendantOf(*NodeTraversal(*body, " << index + << "), *body)"; + EXPECT_EQ(expected_child_nodes[index], child) + << "NodeTraversal::childAt(*body, " << index << ")"; + } + EXPECT_EQ(nullptr, NodeTraversal::ChildAt(*body, kNumberOfChildNodes + 1)) + << "Out of bounds childAt() returns nullptr."; + + EXPECT_EQ(c00, NodeTraversal::FirstChild(*c0)); +} + +// Test case for +// - FirstChild +// - LastChild +// - NextSibling +// - PreviousSibling +// - Parent +TEST_F(NodeTraversalTest, Siblings) { + SetupSampleHTML(R"( + <div id='c0'></div> + <div id='c1'></div> + <div id='c2'></div>)"); + + Element* body = GetDocument().body(); + Element* c0 = body->QuerySelector("#c0"); + Element* c1 = body->QuerySelector("#c1"); + Element* c2 = body->QuerySelector("#c2"); + + EXPECT_EQ(c0, NodeTraversal::FirstChild(*body)); + EXPECT_EQ(c2, NodeTraversal::LastChild(*body)); + + EXPECT_EQ(body, NodeTraversal::Parent(*c0)); + EXPECT_EQ(body, NodeTraversal::Parent(*c1)); + EXPECT_EQ(body, NodeTraversal::Parent(*c2)); + + EXPECT_EQ(c1, NodeTraversal::NextSibling(*c0)); + EXPECT_EQ(c2, NodeTraversal::NextSibling(*c1)); + EXPECT_EQ(nullptr, NodeTraversal::NextSibling(*c2)); + + EXPECT_EQ(c1, NodeTraversal::PreviousSibling(*c2)); + EXPECT_EQ(c0, NodeTraversal::PreviousSibling(*c1)); + EXPECT_EQ(nullptr, NodeTraversal::PreviousSibling(*c0)); +} + +TEST_F(NodeTraversalTest, commonAncestor) { + SetupSampleHTML(R"( + <div id='c0'> + <div id='c00'> + <div id='c000'></div> + </div> + <div id='c01'></div> + </div> + <div id='c1'> + <div id='c10'></div> + </div> + <div id='c2'></div>)"); + + Element* body = GetDocument().body(); + Element* c0 = body->QuerySelector("#c0"); + Element* c1 = body->QuerySelector("#c1"); + Element* c2 = body->QuerySelector("#c2"); + + Element* c00 = body->QuerySelector("#c00"); + Element* c01 = body->QuerySelector("#c01"); + Element* c10 = body->QuerySelector("#c10"); + Element* c000 = body->QuerySelector("#c000"); + + TestCommonAncestor(body, *c0, *c1); + TestCommonAncestor(body, *c1, *c2); + TestCommonAncestor(body, *c00, *c10); + TestCommonAncestor(body, *c01, *c10); + TestCommonAncestor(body, *c2, *c10); + TestCommonAncestor(body, *c2, *c000); + + TestCommonAncestor(c0, *c00, *c01); + TestCommonAncestor(c0, *c000, *c01); + TestCommonAncestor(c1, *c1, *c10); +} + +TEST_F(NodeTraversalTest, AncestorsOf) { + SetupSampleHTML(R"( + <div> + <div> + <div id='child'></div> + </div> + </div>)"); + + Element* child = GetDocument().getElementById("child"); + + HeapVector<Member<Node>> expected_nodes; + for (Node* parent = NodeTraversal::Parent(*child); parent; + parent = NodeTraversal::Parent(*parent)) { + expected_nodes.push_back(parent); + } + + HeapVector<Member<Node>> actual_nodes; + for (Node& ancestor : NodeTraversal::AncestorsOf(*child)) + actual_nodes.push_back(&ancestor); + + EXPECT_EQ(expected_nodes, actual_nodes); +} + +TEST_F(NodeTraversalTest, InclusiveAncestorsOf) { + SetupSampleHTML(R"( + <div> + <div> + <div id='child'></div> + </div> + </div>)"); + + Element* child = GetDocument().getElementById("child"); + + HeapVector<Member<Node>> expected_nodes; + for (Node* parent = child; parent; parent = NodeTraversal::Parent(*parent)) { + expected_nodes.push_back(parent); + } + + HeapVector<Member<Node>> actual_nodes; + for (Node& ancestor : NodeTraversal::InclusiveAncestorsOf(*child)) + actual_nodes.push_back(&ancestor); + + EXPECT_EQ(expected_nodes, actual_nodes); +} + +TEST_F(NodeTraversalTest, ChildrenOf) { + SetupSampleHTML(R"( + <div id='c0'></div> + <div id='c1'></div> + <div id='c2'></div>)"); + + Element* body = GetDocument().body(); + + HeapVector<Member<Node>> expected_nodes; + for (Node* child = NodeTraversal::FirstChild(*body); child; + child = NodeTraversal::NextSibling(*child)) { + expected_nodes.push_back(child); + } + + HeapVector<Member<Node>> actual_nodes; + for (Node& child : NodeTraversal::ChildrenOf(*body)) + actual_nodes.push_back(&child); + + EXPECT_EQ(expected_nodes, actual_nodes); +} + +TEST_F(NodeTraversalTest, DescendantsOf) { + SetupSampleHTML(R"( + <div id='c0'> + <div id='c00'></div> + <div id='c01'></div> + </div> + <div id='c1'> + <div id='c10'></div> + </div>)"); + + Element* body = GetDocument().body(); + + HeapVector<Member<Node>> expected_nodes; + for (Node* child = NodeTraversal::FirstChild(*body); child; + child = NodeTraversal::Next(*child)) { + expected_nodes.push_back(child); + } + + HeapVector<Member<Node>> actual_nodes; + for (Node& descendant : NodeTraversal::DescendantsOf(*body)) + actual_nodes.push_back(&descendant); + + EXPECT_EQ(expected_nodes, actual_nodes); +} + +TEST_F(NodeTraversalTest, InclusiveDescendantsOf) { + SetupSampleHTML(R"( + <div id='c0'> + <div id='c00'></div> + <div id='c01'></div> + </div> + <div id='c1'> + <div id='c10'></div> + </div>)"); + + Element* body = GetDocument().body(); + + HeapVector<Member<Node>> expected_nodes; + for (Node* child = body; child; child = NodeTraversal::Next(*child)) { + expected_nodes.push_back(child); + } + + HeapVector<Member<Node>> actual_nodes; + for (Node& descendant : NodeTraversal::InclusiveDescendantsOf(*body)) + actual_nodes.push_back(&descendant); + + EXPECT_EQ(expected_nodes, actual_nodes); +} + +} // namespace node_traversal_test +} // namespace blink
diff --git a/third_party/blink/renderer/core/html/media/html_media_element_controls_list.cc b/third_party/blink/renderer/core/html/media/html_media_element_controls_list.cc index 1f552d45..03be7b18 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element_controls_list.cc +++ b/third_party/blink/renderer/core/html/media/html_media_element_controls_list.cc
@@ -12,10 +12,11 @@ const char kNoDownload[] = "nodownload"; const char kNoFullscreen[] = "nofullscreen"; +const char kNoPlaybackRate[] = "noplaybackrate"; const char kNoRemotePlayback[] = "noremoteplayback"; const char* const kSupportedTokens[] = {kNoDownload, kNoFullscreen, - kNoRemotePlayback}; + kNoPlaybackRate, kNoRemotePlayback}; } // namespace @@ -41,6 +42,10 @@ return contains(kNoFullscreen); } +bool HTMLMediaElementControlsList::ShouldHidePlaybackRate() const { + return contains(kNoPlaybackRate); +} + bool HTMLMediaElementControlsList::ShouldHideRemotePlayback() const { return contains(kNoRemotePlayback); }
diff --git a/third_party/blink/renderer/core/html/media/html_media_element_controls_list.h b/third_party/blink/renderer/core/html/media/html_media_element_controls_list.h index e5af347..652416f 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element_controls_list.h +++ b/third_party/blink/renderer/core/html/media/html_media_element_controls_list.h
@@ -20,6 +20,7 @@ // Whether the list dictates to hide a certain control. bool ShouldHideDownload() const; bool ShouldHideFullscreen() const; + bool ShouldHidePlaybackRate() const; bool ShouldHideRemotePlayback() const; private:
diff --git a/third_party/blink/renderer/core/layout/layout_box.cc b/third_party/blink/renderer/core/layout/layout_box.cc index 4a6f5f66..3fb5588 100644 --- a/third_party/blink/renderer/core/layout/layout_box.cc +++ b/third_party/blink/renderer/core/layout/layout_box.cc
@@ -1995,7 +1995,7 @@ TransformationMatrix perspective_matrix; perspective_matrix.ApplyPerspective( - container_object->StyleRef().Perspective()); + container_object->StyleRef().UsedPerspective()); perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), perspective_origin.Y(), 0);
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc index 2fad389..d52faa7f 100644 --- a/third_party/blink/renderer/core/layout/layout_object.cc +++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -3339,7 +3339,7 @@ TransformationMatrix perspective_matrix; perspective_matrix.ApplyPerspective( - container_object->StyleRef().Perspective()); + container_object->StyleRef().UsedPerspective()); perspective_matrix.ApplyTransformOrigin(perspective_origin.X(), perspective_origin.Y(), 0);
diff --git a/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc b/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc index f30d9417..8551bd9 100644 --- a/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc +++ b/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc
@@ -247,7 +247,7 @@ row_baseline_tabulator.ProcessCell( fragment, cell_block_constraint.min_block_size, NGTableAlgorithmUtils::IsBaseline(cell_style.VerticalAlign()), - is_parallel, + is_parallel, rowspan > 1, layout_result->HasDescendantThatDependsOnPercentageBlockSize()); // Compute cell's css block size. @@ -689,6 +689,7 @@ const LayoutUnit cell_min_block_size, const bool is_baseline_aligned, const bool is_parallel, + const bool is_rowspanned, const bool descendant_depends_on_percentage_block_size) { if (is_parallel && is_baseline_aligned && fragment.HasDescendantsForTablePart()) { @@ -697,8 +698,14 @@ const LayoutUnit cell_baseline = fragment.FirstBaselineOrSynthesize(); max_cell_ascent_ = std::max(max_cell_ascent_.value_or(LayoutUnit::Min()), cell_baseline); - max_cell_descent_ = std::max(max_cell_descent_.value_or(LayoutUnit::Min()), - cell_min_block_size - cell_baseline); + if (is_rowspanned) { + if (!max_cell_descent_) + max_cell_descent_ = LayoutUnit(); + } else { + max_cell_descent_ = + std::max(max_cell_descent_.value_or(LayoutUnit::Min()), + cell_min_block_size - cell_baseline); + } } // https://www.w3.org/TR/css-tables-3/#row-layout "If there is no such
diff --git a/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h b/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h index 81d0685..8e5c8ba 100644 --- a/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h +++ b/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h
@@ -119,6 +119,7 @@ const LayoutUnit cell_min_block_size, bool is_baseline_aligned, bool is_parallel, + bool is_rowspanned, bool descendant_depends_on_percentage_block_size); LayoutUnit ComputeRowBlockSize(const LayoutUnit max_cell_block_size);
diff --git a/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc index 33aeb30..9d7fded 100644 --- a/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc
@@ -102,7 +102,7 @@ row_baseline_tabulator.ProcessCell( fragment, row.block_size, NGTableAlgorithmUtils::IsBaseline(cell.Style().VerticalAlign()), - is_parallel, + is_parallel, cell.TableCellRowspan() > 1, layout_result->HasDescendantThatDependsOnPercentageBlockSize()); } row_baseline = row_baseline_tabulator.ComputeBaseline(row.block_size); @@ -132,7 +132,7 @@ row_baseline_tabulator.ProcessCell( fragment, row.block_size, NGTableAlgorithmUtils::IsBaseline(cell.Style().VerticalAlign()), - is_parallel, + is_parallel, cell.TableCellRowspan() > 1, cell_result->HasDescendantThatDependsOnPercentageBlockSize()); } container_builder_.SetFragmentBlockSize(row.block_size);
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc index 394c787..61917469 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc +++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
@@ -1917,7 +1917,7 @@ // most transform nodes do. TransformPaintPropertyNode::State state{ TransformPaintPropertyNode::TransformAndOrigin( - TransformationMatrix().ApplyPerspective(style.Perspective()), + TransformationMatrix().ApplyPerspective(style.UsedPerspective()), PerspectiveOrigin(To<LayoutBox>(object_)) + FloatSize(context_.current.paint_offset))}; state.flags.flattens_inherited_transform =
diff --git a/third_party/blink/renderer/core/style/computed_style.h b/third_party/blink/renderer/core/style/computed_style.h index 467e9b0..9643112 100644 --- a/third_party/blink/renderer/core/style/computed_style.h +++ b/third_party/blink/renderer/core/style/computed_style.h
@@ -26,6 +26,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_H_ +#include <algorithm> #include <memory> #include "base/types/pass_key.h" #include "third_party/blink/renderer/core/core_export.h" @@ -1931,7 +1932,12 @@ } // Perspective utility functions. - bool HasPerspective() const { return Perspective() > 0; } + bool HasPerspective() const { return Perspective() >= 0; } + + float UsedPerspective() const { + DCHECK(HasPerspective()); + return std::max(1.0f, Perspective()); + } // Outline utility functions. // HasOutline is insufficient to determine whether Node has an outline.
diff --git a/third_party/blink/renderer/modules/media_controls/media_controls_impl.cc b/third_party/blink/renderer/modules/media_controls/media_controls_impl.cc index a3aab3c1..5219c55 100644 --- a/third_party/blink/renderer/modules/media_controls/media_controls_impl.cc +++ b/third_party/blink/renderer/modules/media_controls/media_controls_impl.cc
@@ -152,6 +152,16 @@ parent->ParserAppendChild(child); } +bool ShouldShowPlaybackSpeedButton(HTMLMediaElement& media_element) { + // The page disabled the button via the controlsList attribute. + if (media_element.ControlsListInternal()->ShouldHidePlaybackRate()) { + UseCounter::Count(media_element.GetDocument(), + WebFeature::kHTMLMediaElementControlsListNoPlaybackRate); + return false; + } + return true; +} + bool ShouldShowPictureInPictureButton(HTMLMediaElement& media_element) { return media_element.SupportsPictureInPicture(); } @@ -567,6 +577,8 @@ if (base::FeatureList::IsEnabled(media::kPlaybackSpeedButton)) { playback_speed_button_ = MakeGarbageCollected<MediaControlPlaybackSpeedButtonElement>(*this); + playback_speed_button_->SetIsWanted( + ShouldShowPlaybackSpeedButton(MediaElement())); } overflow_menu_ = MakeGarbageCollected<MediaControlOverflowMenuButtonElement>(*this); @@ -927,6 +939,11 @@ download_button_->SetIsWanted( download_button_->ShouldDisplayDownloadButton()); + + if (playback_speed_button_) { + playback_speed_button_->SetIsWanted( + ShouldShowPlaybackSpeedButton(MediaElement())); + } } LayoutObject* MediaControlsImpl::PanelLayoutObject() {
diff --git a/third_party/blink/renderer/modules/mediastream/processed_local_audio_source.cc b/third_party/blink/renderer/modules/mediastream/processed_local_audio_source.cc index 32f4dfc..ec7ce45 100644 --- a/third_party/blink/renderer/modules/mediastream/processed_local_audio_source.cc +++ b/third_party/blink/renderer/modules/mediastream/processed_local_audio_source.cc
@@ -86,7 +86,8 @@ "goog_experimental_noise_suppression: %s, " "goog_highpass_filter: %s, " "goog_experimental_agc: %s, " - "hybrid_agc: %s", + "hybrid_agc: %s" + "analog_agc_clipping_control: %s", aec_to_string(properties.echo_cancellation_type), bool_to_string(properties.disable_hw_noise_suppression), bool_to_string(properties.goog_audio_mirroring), @@ -98,7 +99,9 @@ bool_to_string(properties.goog_highpass_filter), bool_to_string(properties.goog_experimental_auto_gain_control), bool_to_string( - base::FeatureList::IsEnabled(::features::kWebRtcHybridAgc))); + base::FeatureList::IsEnabled(::features::kWebRtcHybridAgc)), + bool_to_string(base::FeatureList::IsEnabled( + ::features::kWebRtcAnalogAgcClippingControl))); return str; }
diff --git a/third_party/blink/renderer/modules/storage/BUILD.gn b/third_party/blink/renderer/modules/storage/BUILD.gn index 01d50276..b2236f54 100644 --- a/third_party/blink/renderer/modules/storage/BUILD.gn +++ b/third_party/blink/renderer/modules/storage/BUILD.gn
@@ -27,9 +27,33 @@ ] } +component("blink_storage_key") { + visibility = [ + ":*", + "//third_party/blink/public/mojom:mojom_modules_blink", + ] + + sources = [ + "blink_storage_key.cc", + "blink_storage_key.h", + "blink_storage_key_mojom_traits.cc", + "blink_storage_key_mojom_traits.h", + ] + + defines = [ "IS_MODULES_STORAGE_BLINK_STORAGE_KEY_IMPL" ] + + deps = [ + "//third_party/blink/public/mojom:mojom_modules_shared", + "//third_party/blink/renderer/platform", + "//url/mojom:url_mojom_origin", + ] +} + source_set("unit_tests") { testonly = true sources = [ + "blink_storage_key_mojom_traits_test.cc", + "blink_storage_key_test.cc", "cached_storage_area_test.cc", "storage_area_map_test.cc", "storage_controller_test.cc", @@ -46,6 +70,8 @@ ] deps = [ + ":blink_storage_key", + "//mojo/public/cpp/test_support:test_utils", "//testing/gmock", "//testing/gtest", "//third_party/blink/public:test_headers",
diff --git a/third_party/blink/renderer/modules/storage/DEPS b/third_party/blink/renderer/modules/storage/DEPS index 9b836bbc8..02701b8e 100644 --- a/third_party/blink/renderer/modules/storage/DEPS +++ b/third_party/blink/renderer/modules/storage/DEPS
@@ -1,4 +1,15 @@ specific_include_rules = { + "blink_storage_key\.h": [ + "+base/component_export.h", + ], + "blink_storage_key_mojom_traits\.h": [ + "+base/component_export.h", + ], + "blink_storage_key_mojom_traits_test\.cc": [ + "+mojo/public/cpp/test_support/test_utils.h", + "+url/gurl.h", + "+url/origin.h", + ], "storage_controller_test\.cc": [ "+base/run_loop.h", ],
diff --git a/third_party/blink/renderer/modules/storage/OWNERS b/third_party/blink/renderer/modules/storage/OWNERS index ec289ebc7..24d6d7b1 100644 --- a/third_party/blink/renderer/modules/storage/OWNERS +++ b/third_party/blink/renderer/modules/storage/OWNERS
@@ -4,3 +4,6 @@ # Secondary: jsbell@chromium.org pwnall@chromium.org + +per-file *_mojom_traits*.*=set noparent +per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
diff --git a/third_party/blink/renderer/modules/storage/blink_storage_key.cc b/third_party/blink/renderer/modules/storage/blink_storage_key.cc new file mode 100644 index 0000000..eaf825e --- /dev/null +++ b/third_party/blink/renderer/modules/storage/blink_storage_key.cc
@@ -0,0 +1,38 @@ +// 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 <ostream> + +#include "third_party/blink/renderer/modules/storage/blink_storage_key.h" + +namespace blink { + +BlinkStorageKey::BlinkStorageKey() + : origin_(SecurityOrigin::CreateUniqueOpaque()) {} + +BlinkStorageKey::BlinkStorageKey(scoped_refptr<const SecurityOrigin> origin) + : origin_(std::move(origin)) { + DCHECK(origin_); +} + +String BlinkStorageKey::ToDebugString() const { + return "{ origin: " + GetSecurityOrigin()->ToString() + " }"; +} + +bool operator==(const BlinkStorageKey& lhs, const BlinkStorageKey& rhs) { + DCHECK(lhs.GetSecurityOrigin()); + DCHECK(rhs.GetSecurityOrigin()); + return lhs.GetSecurityOrigin()->IsSameOriginWith( + rhs.GetSecurityOrigin().get()); +} + +bool operator!=(const BlinkStorageKey& lhs, const BlinkStorageKey& rhs) { + return !(lhs == rhs); +} + +std::ostream& operator<<(std::ostream& ostream, const BlinkStorageKey& key) { + return ostream << key.ToDebugString(); +} + +} // namespace blink
diff --git a/third_party/blink/renderer/modules/storage/blink_storage_key.h b/third_party/blink/renderer/modules/storage/blink_storage_key.h new file mode 100644 index 0000000..7700941 --- /dev/null +++ b/third_party/blink/renderer/modules/storage/blink_storage_key.h
@@ -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. + +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_STORAGE_BLINK_STORAGE_KEY_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_STORAGE_BLINK_STORAGE_KEY_H_ + +#include <iosfwd> + +#include "base/component_export.h" +#include "base/memory/scoped_refptr.h" +#include "third_party/blink/renderer/platform/weborigin/security_origin.h" +#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" +#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" + +namespace blink { + +// This class represents the key by which DOM Storage keys its +// CachedStorageAreas. +// It is typemapped to blink.mojom.StorageKey, and should stay in sync with +// blink::StorageKey (third_party/blink/public/common/storage_key/storage_key.h) +class COMPONENT_EXPORT(MODULES_STORAGE_BLINK_STORAGE_KEY) BlinkStorageKey { + DISALLOW_NEW(); + + public: + // Creates a BlinkStorageKey with a unique opaque origin. + BlinkStorageKey(); + + // Creates a BlinkStorageKey with the given origin. `origin` must not be null. + // `origin` can be opaque. + explicit BlinkStorageKey(scoped_refptr<const SecurityOrigin> origin); + + ~BlinkStorageKey() = default; + + BlinkStorageKey(const BlinkStorageKey& other) = default; + BlinkStorageKey& operator=(const BlinkStorageKey& other) = default; + BlinkStorageKey(BlinkStorageKey&& other) = default; + BlinkStorageKey& operator=(BlinkStorageKey&& other) = default; + + const scoped_refptr<const SecurityOrigin>& GetSecurityOrigin() const { + return origin_; + } + + String ToDebugString() const; + + private: + scoped_refptr<const SecurityOrigin> origin_; +}; + +COMPONENT_EXPORT(MODULES_STORAGE_BLINK_STORAGE_KEY) +bool operator==(const BlinkStorageKey&, const BlinkStorageKey&); +COMPONENT_EXPORT(MODULES_STORAGE_BLINK_STORAGE_KEY) +bool operator!=(const BlinkStorageKey&, const BlinkStorageKey&); +COMPONENT_EXPORT(MODULES_STORAGE_BLINK_STORAGE_KEY) +std::ostream& operator<<(std::ostream&, const BlinkStorageKey&); + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_STORAGE_BLINK_STORAGE_KEY_H_
diff --git a/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.cc b/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.cc new file mode 100644 index 0000000..9bd84ec8 --- /dev/null +++ b/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.cc
@@ -0,0 +1,23 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.h" + +#include "third_party/blink/renderer/platform/mojo/security_origin_mojom_traits.h" + +namespace mojo { + +// static +bool StructTraits<blink::mojom::StorageKeyDataView, blink::BlinkStorageKey>:: + Read(blink::mojom::StorageKeyDataView data, blink::BlinkStorageKey* out) { + scoped_refptr<const blink::SecurityOrigin> origin; + if (!data.ReadOrigin(&origin)) + return false; + DCHECK(origin); + + *out = blink::BlinkStorageKey(std::move(origin)); + return true; +} + +} // namespace mojo
diff --git a/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.h b/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.h new file mode 100644 index 0000000..462da81 --- /dev/null +++ b/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.h
@@ -0,0 +1,28 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_STORAGE_BLINK_STORAGE_KEY_MOJOM_TRAITS_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_STORAGE_BLINK_STORAGE_KEY_MOJOM_TRAITS_H_ + +#include "base/component_export.h" +#include "third_party/blink/public/mojom/storage_key/storage_key.mojom-shared.h" +#include "third_party/blink/renderer/modules/storage/blink_storage_key.h" + +namespace mojo { + +template <> +struct COMPONENT_EXPORT(MODULES_STORAGE_BLINK_STORAGE_KEY) + StructTraits<blink::mojom::StorageKeyDataView, blink::BlinkStorageKey> { + static const scoped_refptr<const blink::SecurityOrigin>& origin( + const blink::BlinkStorageKey& input) { + return input.GetSecurityOrigin(); + } + + static bool Read(blink::mojom::StorageKeyDataView data, + blink::BlinkStorageKey* out); +}; + +} // namespace mojo + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_STORAGE_BLINK_STORAGE_KEY_MOJOM_TRAITS_H_
diff --git a/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits_test.cc b/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits_test.cc new file mode 100644 index 0000000..39a9084 --- /dev/null +++ b/third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits_test.cc
@@ -0,0 +1,114 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/modules/storage/blink_storage_key_mojom_traits.h" + +#include "mojo/public/cpp/test_support/test_utils.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/public/common/storage_key/storage_key.h" +#include "third_party/blink/public/common/storage_key/storage_key_mojom_traits.h" +#include "third_party/blink/public/mojom/storage_key/storage_key.mojom-blink.h" +#include "third_party/blink/renderer/modules/storage/blink_storage_key.h" +#include "third_party/blink/renderer/platform/weborigin/security_origin.h" +#include "third_party/blink/renderer/platform/wtf/vector.h" +#include "url/gurl.h" +#include "url/origin.h" + +namespace blink { + +TEST(BlinkStorageKeyMojomTraitsTest, SerializeAndDeserialize_BlinkStorageKey) { + scoped_refptr<const SecurityOrigin> origin1 = + SecurityOrigin::CreateUniqueOpaque(); + scoped_refptr<const SecurityOrigin> origin2 = + SecurityOrigin::CreateFromString("http://example.site"); + scoped_refptr<const SecurityOrigin> origin3 = + SecurityOrigin::CreateFromString("https://example.site"); + scoped_refptr<const SecurityOrigin> origin4 = + SecurityOrigin::CreateFromString("file:///path/to/file"); + + Vector<BlinkStorageKey> keys = { + BlinkStorageKey(), BlinkStorageKey(origin1), + BlinkStorageKey(origin2), BlinkStorageKey(origin3), + BlinkStorageKey(origin4), + }; + + for (BlinkStorageKey& key : keys) { + BlinkStorageKey copied; + EXPECT_TRUE(mojo::test::SerializeAndDeserialize<mojom::blink::StorageKey>( + key, copied)); + EXPECT_EQ(key, copied); + EXPECT_TRUE(key.GetSecurityOrigin()->IsSameOriginWith( + copied.GetSecurityOrigin().get())); + } +} + +// Tests serializing from blink::StorageKey and deserializing to +// blink::BlinkStorageKey. +TEST(BlinkStorageKeyMojomTraitsTest, + SerializeFromStorageKey_DeserializeToBlinkStorageKey) { + scoped_refptr<const SecurityOrigin> origin1 = + SecurityOrigin::CreateUniqueOpaque(); + scoped_refptr<const SecurityOrigin> origin2 = + SecurityOrigin::CreateFromString("http://example.site"); + scoped_refptr<const SecurityOrigin> origin3 = + SecurityOrigin::CreateFromString("https://example.site"); + scoped_refptr<const SecurityOrigin> origin4 = + SecurityOrigin::CreateFromString("file:///path/to/file"); + + url::Origin url_origin1 = origin1->ToUrlOrigin(); + url::Origin url_origin2 = origin2->ToUrlOrigin(); + url::Origin url_origin3 = origin3->ToUrlOrigin(); + url::Origin url_origin4 = origin4->ToUrlOrigin(); + + Vector<StorageKey> storage_keys = { + StorageKey(url_origin1), StorageKey(url_origin2), StorageKey(url_origin3), + StorageKey(url_origin4)}; + Vector<BlinkStorageKey> blink_storage_keys = { + BlinkStorageKey(origin1), BlinkStorageKey(origin2), + BlinkStorageKey(origin3), BlinkStorageKey(origin4)}; + + for (size_t i = 0; i < storage_keys.size(); ++i) { + auto serialized = mojom::StorageKey::Serialize(&storage_keys[i]); + + BlinkStorageKey deserialized; + EXPECT_TRUE(mojom::StorageKey::Deserialize(serialized, &deserialized)); + EXPECT_EQ(blink_storage_keys[i], deserialized); + } +} + +// Tests serializing from blink::StorageKey and deserializing to +// blink::BlinkStorageKey. +TEST(BlinkStorageKeyMojomTraitsTest, + SerializeFromBlinkStorageKey_DeserializeToStorageKey) { + url::Origin url_origin1; + url::Origin url_origin2 = url::Origin::Create(GURL("http://example.site")); + url::Origin url_origin3 = url::Origin::Create(GURL("https://example.site")); + url::Origin url_origin4 = url::Origin::Create(GURL("file:///path/to/file")); + + scoped_refptr<const SecurityOrigin> origin1 = + SecurityOrigin::CreateFromUrlOrigin(url_origin1); + scoped_refptr<const SecurityOrigin> origin2 = + SecurityOrigin::CreateFromUrlOrigin(url_origin2); + scoped_refptr<const SecurityOrigin> origin3 = + SecurityOrigin::CreateFromUrlOrigin(url_origin3); + scoped_refptr<const SecurityOrigin> origin4 = + SecurityOrigin::CreateFromUrlOrigin(url_origin4); + + Vector<StorageKey> storage_keys = { + StorageKey(url_origin1), StorageKey(url_origin2), StorageKey(url_origin3), + StorageKey(url_origin4)}; + Vector<BlinkStorageKey> blink_storage_keys = { + BlinkStorageKey(origin1), BlinkStorageKey(origin2), + BlinkStorageKey(origin3), BlinkStorageKey(origin4)}; + + for (size_t i = 0; i < storage_keys.size(); ++i) { + auto serialized = mojom::StorageKey::Serialize(&blink_storage_keys[i]); + + StorageKey deserialized; + EXPECT_TRUE(mojom::StorageKey::Deserialize(serialized, &deserialized)); + EXPECT_EQ(storage_keys[i], deserialized); + } +} + +} // namespace blink
diff --git a/third_party/blink/renderer/modules/storage/blink_storage_key_test.cc b/third_party/blink/renderer/modules/storage/blink_storage_key_test.cc new file mode 100644 index 0000000..fb51bd7b --- /dev/null +++ b/third_party/blink/renderer/modules/storage/blink_storage_key_test.cc
@@ -0,0 +1,60 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/modules/storage/blink_storage_key.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/platform/weborigin/security_origin.h" + +namespace blink { + +TEST(BlinkStorageKeyTest, OpaqueOriginsDistinct) { + // Test that two opaque origins give distinct BlinkStorageKeys. + BlinkStorageKey unique_opaque1; + EXPECT_TRUE(unique_opaque1.GetSecurityOrigin()); + EXPECT_TRUE(unique_opaque1.GetSecurityOrigin()->IsOpaque()); + BlinkStorageKey unique_opaque2; + EXPECT_FALSE(unique_opaque2.GetSecurityOrigin()->IsSameOriginWith( + unique_opaque1.GetSecurityOrigin().get())); + EXPECT_NE(unique_opaque1, unique_opaque2); +} + +TEST(BlinkStorageKeyTest, OpaqueOriginRetained) { + // Test that a StorageKey made from an opaque origin retains the origin. + scoped_refptr<const SecurityOrigin> opaque_origin = + SecurityOrigin::CreateUniqueOpaque(); + scoped_refptr<const SecurityOrigin> opaque_copied = + opaque_origin->IsolatedCopy(); + BlinkStorageKey from_opaque(std::move(opaque_origin)); + EXPECT_TRUE( + from_opaque.GetSecurityOrigin()->IsSameOriginWith(opaque_copied.get())); +} + +TEST(BlinkStorageKeyTest, CreateFromNonOpaqueOrigin) { + struct { + const char* origin; + } kTestCases[] = { + {"http://example.site"}, + {"https://example.site"}, + {"file:///path/to/file"}, + }; + + for (const auto& test : kTestCases) { + scoped_refptr<const SecurityOrigin> origin = + SecurityOrigin::CreateFromString(test.origin); + ASSERT_FALSE(origin->IsOpaque()); + scoped_refptr<const SecurityOrigin> copied = origin->IsolatedCopy(); + + // Test that the origin is retained. + BlinkStorageKey storage_key(std::move(origin)); + EXPECT_TRUE( + storage_key.GetSecurityOrigin()->IsSameOriginWith(copied.get())); + + // Test that two StorageKeys from the same origin are the same. + BlinkStorageKey storage_key_from_copy(std::move(copied)); + EXPECT_EQ(storage_key, storage_key_from_copy); + } +} + +} // namespace blink
diff --git a/third_party/blink/renderer/platform/transforms/perspective_transform_operation.cc b/third_party/blink/renderer/platform/transforms/perspective_transform_operation.cc index 83fe6f2b..66c77ff 100644 --- a/third_party/blink/renderer/platform/transforms/perspective_transform_operation.cc +++ b/third_party/blink/renderer/platform/transforms/perspective_transform_operation.cc
@@ -25,6 +25,7 @@ #include "third_party/blink/renderer/platform/transforms/perspective_transform_operation.h" +#include <algorithm> #include "third_party/blink/renderer/platform/geometry/blend.h" #include "third_party/blink/renderer/platform/wtf/math_extras.h" @@ -33,18 +34,15 @@ scoped_refptr<TransformOperation> PerspectiveTransformOperation::Accumulate( const TransformOperation& other) { DCHECK(other.IsSameType(*this)); - double other_p = To<PerspectiveTransformOperation>(other).p_; - - if (p_ == 0 && other_p == 0) - return nullptr; + double other_p = To<PerspectiveTransformOperation>(other).UsedPerspective(); + double p = UsedPerspective(); // We want to solve: // -1/p + -1/p' == -1/p'', where we know p and p'. // // This can be rewritten as: // p'' == (p * p') / (p + p') - double p = (p_ * other_p) / (p_ + other_p); - return PerspectiveTransformOperation::Create(p); + return PerspectiveTransformOperation::Create((p * other_p) / (p + other_p)); } scoped_refptr<TransformOperation> PerspectiveTransformOperation::Blend( @@ -54,34 +52,27 @@ if (from && !from->IsSameType(*this)) return this; + // https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions + // says that we should run matrix decomposition and then run the rules for + // interpolation of matrices, but we know what those rules are going to + // yield, so just do that directly. + double from_p_inverse, to_p_inverse; if (blend_to_identity) { - // FIXME: this seems wrong. https://bugs.webkit.org/show_bug.cgi?id=52700 - double p = blink::Blend(p_, 1., progress); - return PerspectiveTransformOperation::Create(clampTo<int>(p, 0)); + from_p_inverse = 1.0 / UsedPerspective(); + to_p_inverse = 0.0; + } else { + if (from) { + const PerspectiveTransformOperation* from_op = + static_cast<const PerspectiveTransformOperation*>(from); + from_p_inverse = 1.0 / from_op->UsedPerspective(); + } else { + from_p_inverse = 0.0; + } + to_p_inverse = 1.0 / UsedPerspective(); } - - const PerspectiveTransformOperation* from_op = - static_cast<const PerspectiveTransformOperation*>(from); - - TransformationMatrix from_t; - TransformationMatrix to_t; - from_t.ApplyPerspective(from_op ? from_op->p_ : 0); - to_t.ApplyPerspective(p_); - to_t.Blend(from_t, progress); - - TransformationMatrix::DecomposedType decomp; - if (!to_t.Decompose(decomp)) { - // If we can't decompose, bail out of interpolation. - const PerspectiveTransformOperation* used_operation = - progress > 0.5 ? this : from_op; - return PerspectiveTransformOperation::Create(used_operation->Perspective()); - } - - if (decomp.perspective_z) { - double val = -1.0 / decomp.perspective_z; - return PerspectiveTransformOperation::Create(clampTo<double>(val, 0)); - } - return PerspectiveTransformOperation::Create(0); + double p = + 1.0 / std::max(0.0, blink::Blend(from_p_inverse, to_p_inverse, progress)); + return PerspectiveTransformOperation::Create(clampTo<double>(p, 0)); } scoped_refptr<TransformOperation> PerspectiveTransformOperation::Zoom(
diff --git a/third_party/blink/renderer/platform/transforms/perspective_transform_operation.h b/third_party/blink/renderer/platform/transforms/perspective_transform_operation.h index cae996b..2db2120e 100644 --- a/third_party/blink/renderer/platform/transforms/perspective_transform_operation.h +++ b/third_party/blink/renderer/platform/transforms/perspective_transform_operation.h
@@ -26,6 +26,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TRANSFORMS_PERSPECTIVE_TRANSFORM_OPERATION_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TRANSFORMS_PERSPECTIVE_TRANSFORM_OPERATION_H_ +#include <algorithm> #include "third_party/blink/renderer/platform/transforms/transform_operation.h" #include "third_party/blink/renderer/platform/wtf/casting.h" @@ -40,6 +41,8 @@ double Perspective() const { return p_; } + double UsedPerspective() const { return std::max(1.0, p_); } + static bool IsMatchingOperationType(OperationType type) { return type == kPerspective; } @@ -56,7 +59,7 @@ } void Apply(TransformationMatrix& transform, const FloatSize&) const override { - transform.ApplyPerspective(p_); + transform.ApplyPerspective(UsedPerspective()); } scoped_refptr<TransformOperation> Accumulate(
diff --git a/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py b/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py index 8d4bc9f..b61c4f9 100755 --- a/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py +++ b/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py
@@ -1447,7 +1447,13 @@ 'third_party/blink/renderer/platform/graphics/document_transition_shared_element_id.h' ], 'allowed': ['cc::DocumentTransitionSharedElementId'], - } + }, + { + 'paths': [ + 'third_party/blink/renderer/modules/storage/', + ], + 'allowed': ['blink::mojom::StorageKeyDataView'], + }, ]
diff --git a/third_party/blink/tools/blinkpy/w3c/test_importer.py b/third_party/blink/tools/blinkpy/w3c/test_importer.py index 7a6020a..e0679e5 100644 --- a/third_party/blink/tools/blinkpy/w3c/test_importer.py +++ b/third_party/blink/tools/blinkpy/w3c/test_importer.py
@@ -521,7 +521,7 @@ self.fs.remove(dest) def _upload_patchset(self, message): - self.git_cl.run(['upload', '-f', '-t', message]) + self.git_cl.run(['upload', '--bypass-hooks', '-f', '-t', message]) def _upload_cl(self): _log.info('Uploading change list.') @@ -535,6 +535,7 @@ self.git_cl.run([ 'upload', + '--bypass-hooks', '-f', '--message-file', temp_path,
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index af102ae..a157f509 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -5298,6 +5298,8 @@ # Temporary suppression to allow devtools-frontend changes crbug.com/1029489 http/tests/devtools/elements/elements-linkify-attributes.js [ Pass Failure Timeout ] +crbug.com/1197542 http/tests/devtools/elements/elements-panel-styles.js [ Pass Failure ] +crbug.com/1197542 http/tests/devtools/elements/styles-4/styles-grid-template.js [ Pass Failure ] crbug.com/1030258 http/tests/devtools/network/network-cookies-pane.js [ Pass Failure ] crbug.com/1041830 http/tests/devtools/tracing/timeline-js/timeline-js-line-level-profile.js [ Pass Failure ] @@ -5444,11 +5446,9 @@ crbug.com/943503 external/wpt/css/css-transforms/transform3d-perspective-003.html [ Failure ] crbug.com/943503 external/wpt/css/css-transforms/transform3d-perspective-004.html [ Failure ] -crbug.com/943503 external/wpt/css/css-transforms/transform3d-perspective-005.html [ Failure ] crbug.com/943503 virtual/transform-interop/external/wpt/css/css-transforms/transform3d-perspective-003.html [ Pass ] crbug.com/943503 virtual/transform-interop/external/wpt/css/css-transforms/transform3d-perspective-004.html [ Pass ] -crbug.com/943503 virtual/transform-interop/external/wpt/css/css-transforms/transform3d-perspective-005.html [ Pass ] # Swiftshader issue. crbug.com/1048149 external/wpt/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/open-features-non-integer-innerwidth.html [ Crash Timeout ]
diff --git a/third_party/blink/web_tests/VirtualTestSuites b/third_party/blink/web_tests/VirtualTestSuites index ebe1ab3..eb54cf9 100644 --- a/third_party/blink/web_tests/VirtualTestSuites +++ b/third_party/blink/web_tests/VirtualTestSuites
@@ -1081,7 +1081,7 @@ }, { "prefix": "playback_speed_button", - "bases": ["media/controls"], + "bases": ["http/tests/media/controls", "media/controls"], "args": [ "--enable-features=PlaybackSpeedButton" ] }, {
diff --git a/third_party/blink/web_tests/animations/interpolation/webkit-perspective-interpolation.html b/third_party/blink/web_tests/animations/interpolation/webkit-perspective-interpolation.html index 5c79eb3..1b7f010 100644 --- a/third_party/blink/web_tests/animations/interpolation/webkit-perspective-interpolation.html +++ b/third_party/blink/web_tests/animations/interpolation/webkit-perspective-interpolation.html
@@ -32,7 +32,7 @@ from: '50px', to: '100px' }, [ - {at: -20, is: 'none'}, // perspective does not accept 0 or negative values + {at: -20, is: '0px'}, {at: -0.3, is: '35px'}, {at: 0, is: '50px'}, {at: 0.3, is: '65px'},
diff --git a/third_party/blink/web_tests/animations/responsive/animations-responsive-perspective.html b/third_party/blink/web_tests/animations/responsive/animations-responsive-perspective.html index 6f45c9e9..411c760 100644 --- a/third_party/blink/web_tests/animations/responsive/animations-responsive-perspective.html +++ b/third_party/blink/web_tests/animations/responsive/animations-responsive-perspective.html
@@ -26,11 +26,11 @@ player.currentTime = 5; element.style.fontSize = '40px'; - assert_equals(getComputedStyle(element).perspective, 'none'); + assert_equals(getComputedStyle(element).perspective, '0px'); player.currentTime = 7.5; - assert_equals(getComputedStyle(element).perspective, 'none'); -}, 'perspective clamped to none'); + assert_equals(getComputedStyle(element).perspective, '0px'); +}, 'perspective clamped to 0px'); test(function() { container.style.perspective = 'none';
diff --git a/third_party/blink/web_tests/external/wpt/css/css-animations/simultaneous-animations-crash.html b/third_party/blink/web_tests/external/wpt/css/css-animations/simultaneous-animations-crash.html new file mode 100644 index 0000000..2237411 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-animations/simultaneous-animations-crash.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html class="test-wait"> +<title>CSS animations test: No crash should occur when an animation ends while other animations continue</title> +<link rel="author" title="Philip Rogers" href="mailto:pdr@chromium.org"> +<link rel="help" href="https://crbug.com/1213307"> +<style> + @keyframes animationKeyframes { + from { opacity: 0.1; filter: blur(1px); } + to { opacity: 0.9; filter: blur(5px); } + } +</style> +<div id="longerAnimEl" style="animation: animationKeyframes 64ms;">a</div> +<div id="shorterAnimEl" style="animation: both animationKeyframes 32ms;">b</div> +<script> + longerAnimEl.addEventListener('animationend', () => { + document.documentElement.classList.remove('test-wait'); + }); +</script> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/abspos-in-multicol.html b/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/abspos-in-multicol.html new file mode 100644 index 0000000..ee11148 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/abspos-in-multicol.html
@@ -0,0 +1,38 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" /> +<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring/#candidate-examination"> +<meta name="assert" content="The candidate examination algorithm iterates abspos descendants of the containing block. Being inside a fragmentainer shouldn't break that."> +<style> +html { + column-count: 1; /* Fragmentainer */ +} + +body { + position: relative; /* Containing block */ +} + +div { + position: absolute; /* Abspos */ + font-size: 100px; + width: 200px; + height: 4000px; + line-height: 100px; +} +</style> +<div>abc <b id=b>def</b> ghi</div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +// Tests anchoring to a text node that is moved by preceding text, +// everything in an absolutely positioned element whose containing block +// is inside a multi-column fragmentainer. + +test(() => { + var b = document.querySelector("#b"); + var preText = b.previousSibling; + document.scrollingElement.scrollTop = 150; + preText.nodeValue = "abcd efg "; + assert_equals(document.scrollingElement.scrollTop, 250); +}, "Anchoring with text wrapping changes."); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/baseline-td.html b/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/baseline-td.html index 6676ff6..4090c5db 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/baseline-td.html +++ b/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/baseline-td.html
@@ -5,7 +5,7 @@ <meta name="flags" content="ahem"> <title>TD baseline</title> <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> -<link rel="stylesheet" type="text/css" href="./support/tables-ng.css"> +<link rel="stylesheet" type="text/css" href="./support/table-tentative.css"> <link rel="author" title="Aleks Totic" href="atotic@chromium.org" /> <link rel="help" href="https://drafts.csswg.org/css-tables-3/" /> <link rel="help" href="https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align" /> @@ -104,6 +104,19 @@ </td> </tr> </table> + +<p class="testdesc">Baseline of rowspanned cell +rowspanned td's should contribute to baseline, but not to the row height.</p> +<table class="ahem"> + <tr data-expected-height=100> + <td style="vertical-align:baseline;height:100px;background-color:#DFD;">Xp</td> + <td style="vertical-align:baseline;font-size:40px;line-height:1.5" rowspan=2><div class="m">Xp</div><br>Xp<br>Xp</td> + </tr> + <tr data-expected-height=100> + <td style="vertical-align:baseline;height:100px">Xp</td> + </tr> +</table> + </main> <script> checkLayout("table, .display-table");
diff --git a/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/support/table-tentative.css b/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/support/table-tentative.css index 255ec02..08d65b2 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/support/table-tentative.css +++ b/third_party/blink/web_tests/external/wpt/css/css-tables/tentative/support/table-tentative.css
@@ -3,7 +3,7 @@ Usage: -<link rel="stylesheet" type="text/css" href="./support/tables-ng.css"> +<link rel="stylesheet" type="text/css" href="./support/table-tentative.css"> <p class="testdesc">Short description here Analysis <p class="error">Current disagreements between browsers</p>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transforms/animation/perspective-interpolation-expected.txt b/third_party/blink/web_tests/external/wpt/css/css-transforms/animation/perspective-interpolation-expected.txt deleted file mode 100644 index 26e1427..0000000 --- a/third_party/blink/web_tests/external/wpt/css/css-transforms/animation/perspective-interpolation-expected.txt +++ /dev/null
@@ -1,184 +0,0 @@ -This is a testharness.js-based test. -Found 180 tests; 164 PASS, 16 FAIL, 0 TIMEOUT, 0 NOTRUN. -FAIL CSS Transitions: property <perspective> from neutral to [20px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL CSS Transitions: property <perspective> from neutral to [20px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS CSS Transitions: property <perspective> from neutral to [20px] at (-0.3) should be [7px] -PASS CSS Transitions: property <perspective> from neutral to [20px] at (0) should be [10px] -PASS CSS Transitions: property <perspective> from neutral to [20px] at (0.3) should be [13px] -PASS CSS Transitions: property <perspective> from neutral to [20px] at (0.6) should be [16px] -PASS CSS Transitions: property <perspective> from neutral to [20px] at (1) should be [20px] -PASS CSS Transitions: property <perspective> from neutral to [20px] at (1.5) should be [25px] -FAIL CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (-0.3) should be [7px] -PASS CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (0) should be [10px] -PASS CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (0.3) should be [13px] -PASS CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (0.6) should be [16px] -PASS CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (1) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from neutral to [20px] at (1.5) should be [25px] -FAIL CSS Animations: property <perspective> from neutral to [20px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL CSS Animations: property <perspective> from neutral to [20px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS CSS Animations: property <perspective> from neutral to [20px] at (-0.3) should be [7px] -PASS CSS Animations: property <perspective> from neutral to [20px] at (0) should be [10px] -PASS CSS Animations: property <perspective> from neutral to [20px] at (0.3) should be [13px] -PASS CSS Animations: property <perspective> from neutral to [20px] at (0.6) should be [16px] -PASS CSS Animations: property <perspective> from neutral to [20px] at (1) should be [20px] -PASS CSS Animations: property <perspective> from neutral to [20px] at (1.5) should be [25px] -FAIL Web Animations: property <perspective> from neutral to [20px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL Web Animations: property <perspective> from neutral to [20px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS Web Animations: property <perspective> from neutral to [20px] at (-0.3) should be [7px] -PASS Web Animations: property <perspective> from neutral to [20px] at (0) should be [10px] -PASS Web Animations: property <perspective> from neutral to [20px] at (0.3) should be [13px] -PASS Web Animations: property <perspective> from neutral to [20px] at (0.6) should be [16px] -PASS Web Animations: property <perspective> from neutral to [20px] at (1) should be [20px] -PASS Web Animations: property <perspective> from neutral to [20px] at (1.5) should be [25px] -PASS CSS Transitions: property <perspective> from [initial] to [20px] at (-0.3) should be [20px] -PASS CSS Transitions: property <perspective> from [initial] to [20px] at (0) should be [20px] -PASS CSS Transitions: property <perspective> from [initial] to [20px] at (0.3) should be [20px] -PASS CSS Transitions: property <perspective> from [initial] to [20px] at (0.5) should be [20px] -PASS CSS Transitions: property <perspective> from [initial] to [20px] at (0.6) should be [20px] -PASS CSS Transitions: property <perspective> from [initial] to [20px] at (1) should be [20px] -PASS CSS Transitions: property <perspective> from [initial] to [20px] at (1.5) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [initial] to [20px] at (-0.3) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [initial] to [20px] at (0) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [initial] to [20px] at (0.3) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [initial] to [20px] at (0.5) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [initial] to [20px] at (0.6) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [initial] to [20px] at (1) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [initial] to [20px] at (1.5) should be [20px] -PASS CSS Animations: property <perspective> from [initial] to [20px] at (-0.3) should be [initial] -PASS CSS Animations: property <perspective> from [initial] to [20px] at (0) should be [initial] -PASS CSS Animations: property <perspective> from [initial] to [20px] at (0.3) should be [initial] -PASS CSS Animations: property <perspective> from [initial] to [20px] at (0.5) should be [20px] -PASS CSS Animations: property <perspective> from [initial] to [20px] at (0.6) should be [20px] -PASS CSS Animations: property <perspective> from [initial] to [20px] at (1) should be [20px] -PASS CSS Animations: property <perspective> from [initial] to [20px] at (1.5) should be [20px] -PASS Web Animations: property <perspective> from [initial] to [20px] at (-0.3) should be [initial] -PASS Web Animations: property <perspective> from [initial] to [20px] at (0) should be [initial] -PASS Web Animations: property <perspective> from [initial] to [20px] at (0.3) should be [initial] -PASS Web Animations: property <perspective> from [initial] to [20px] at (0.5) should be [20px] -PASS Web Animations: property <perspective> from [initial] to [20px] at (0.6) should be [20px] -PASS Web Animations: property <perspective> from [initial] to [20px] at (1) should be [20px] -PASS Web Animations: property <perspective> from [initial] to [20px] at (1.5) should be [20px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (-20) should be [230px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (-1) should be [40px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (-0.3) should be [33px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (0) should be [30px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (0.3) should be [27px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (0.6) should be [24px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (1) should be [20px] -PASS CSS Transitions: property <perspective> from [inherit] to [20px] at (1.5) should be [15px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (-20) should be [230px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (-1) should be [40px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (-0.3) should be [33px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (0) should be [30px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (0.3) should be [27px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (0.6) should be [24px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (1) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [inherit] to [20px] at (1.5) should be [15px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (-20) should be [230px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (-1) should be [40px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (-0.3) should be [33px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (0) should be [30px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (0.3) should be [27px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (0.6) should be [24px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (1) should be [20px] -PASS CSS Animations: property <perspective> from [inherit] to [20px] at (1.5) should be [15px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (-20) should be [230px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (-1) should be [40px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (-0.3) should be [33px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (0) should be [30px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (0.3) should be [27px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (0.6) should be [24px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (1) should be [20px] -PASS Web Animations: property <perspective> from [inherit] to [20px] at (1.5) should be [15px] -PASS CSS Transitions: property <perspective> from [unset] to [20px] at (-0.3) should be [20px] -PASS CSS Transitions: property <perspective> from [unset] to [20px] at (0) should be [20px] -PASS CSS Transitions: property <perspective> from [unset] to [20px] at (0.3) should be [20px] -PASS CSS Transitions: property <perspective> from [unset] to [20px] at (0.5) should be [20px] -PASS CSS Transitions: property <perspective> from [unset] to [20px] at (0.6) should be [20px] -PASS CSS Transitions: property <perspective> from [unset] to [20px] at (1) should be [20px] -PASS CSS Transitions: property <perspective> from [unset] to [20px] at (1.5) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [unset] to [20px] at (-0.3) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [unset] to [20px] at (0) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [unset] to [20px] at (0.3) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [unset] to [20px] at (0.5) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [unset] to [20px] at (0.6) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [unset] to [20px] at (1) should be [20px] -PASS CSS Transitions with transition: all: property <perspective> from [unset] to [20px] at (1.5) should be [20px] -PASS CSS Animations: property <perspective> from [unset] to [20px] at (-0.3) should be [unset] -PASS CSS Animations: property <perspective> from [unset] to [20px] at (0) should be [unset] -PASS CSS Animations: property <perspective> from [unset] to [20px] at (0.3) should be [unset] -PASS CSS Animations: property <perspective> from [unset] to [20px] at (0.5) should be [20px] -PASS CSS Animations: property <perspective> from [unset] to [20px] at (0.6) should be [20px] -PASS CSS Animations: property <perspective> from [unset] to [20px] at (1) should be [20px] -PASS CSS Animations: property <perspective> from [unset] to [20px] at (1.5) should be [20px] -PASS Web Animations: property <perspective> from [unset] to [20px] at (-0.3) should be [unset] -PASS Web Animations: property <perspective> from [unset] to [20px] at (0) should be [unset] -PASS Web Animations: property <perspective> from [unset] to [20px] at (0.3) should be [unset] -PASS Web Animations: property <perspective> from [unset] to [20px] at (0.5) should be [20px] -PASS Web Animations: property <perspective> from [unset] to [20px] at (0.6) should be [20px] -PASS Web Animations: property <perspective> from [unset] to [20px] at (1) should be [20px] -PASS Web Animations: property <perspective> from [unset] to [20px] at (1.5) should be [20px] -FAIL CSS Transitions: property <perspective> from [50px] to [100px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL CSS Transitions: property <perspective> from [50px] to [100px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS CSS Transitions: property <perspective> from [50px] to [100px] at (-0.3) should be [35px] -PASS CSS Transitions: property <perspective> from [50px] to [100px] at (0) should be [50px] -PASS CSS Transitions: property <perspective> from [50px] to [100px] at (0.3) should be [65px] -PASS CSS Transitions: property <perspective> from [50px] to [100px] at (0.6) should be [80px] -PASS CSS Transitions: property <perspective> from [50px] to [100px] at (1) should be [100px] -PASS CSS Transitions: property <perspective> from [50px] to [100px] at (1.5) should be [125px] -FAIL CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (-0.3) should be [35px] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (0) should be [50px] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (0.3) should be [65px] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (0.6) should be [80px] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (1) should be [100px] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [100px] at (1.5) should be [125px] -FAIL CSS Animations: property <perspective> from [50px] to [100px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL CSS Animations: property <perspective> from [50px] to [100px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS CSS Animations: property <perspective> from [50px] to [100px] at (-0.3) should be [35px] -PASS CSS Animations: property <perspective> from [50px] to [100px] at (0) should be [50px] -PASS CSS Animations: property <perspective> from [50px] to [100px] at (0.3) should be [65px] -PASS CSS Animations: property <perspective> from [50px] to [100px] at (0.6) should be [80px] -PASS CSS Animations: property <perspective> from [50px] to [100px] at (1) should be [100px] -PASS CSS Animations: property <perspective> from [50px] to [100px] at (1.5) should be [125px] -FAIL Web Animations: property <perspective> from [50px] to [100px] at (-20) should be [0px] assert_equals: expected "10px " but got "none " -FAIL Web Animations: property <perspective> from [50px] to [100px] at (-1) should be [0px] assert_equals: expected "10px " but got "none " -PASS Web Animations: property <perspective> from [50px] to [100px] at (-0.3) should be [35px] -PASS Web Animations: property <perspective> from [50px] to [100px] at (0) should be [50px] -PASS Web Animations: property <perspective> from [50px] to [100px] at (0.3) should be [65px] -PASS Web Animations: property <perspective> from [50px] to [100px] at (0.6) should be [80px] -PASS Web Animations: property <perspective> from [50px] to [100px] at (1) should be [100px] -PASS Web Animations: property <perspective> from [50px] to [100px] at (1.5) should be [125px] -PASS CSS Transitions: property <perspective> from [50px] to [none] at (-0.3) should be [none] -PASS CSS Transitions: property <perspective> from [50px] to [none] at (0) should be [none] -PASS CSS Transitions: property <perspective> from [50px] to [none] at (0.3) should be [none] -PASS CSS Transitions: property <perspective> from [50px] to [none] at (0.5) should be [none] -PASS CSS Transitions: property <perspective> from [50px] to [none] at (0.6) should be [none] -PASS CSS Transitions: property <perspective> from [50px] to [none] at (1) should be [none] -PASS CSS Transitions: property <perspective> from [50px] to [none] at (1.5) should be [none] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [none] at (-0.3) should be [none] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [none] at (0) should be [none] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [none] at (0.3) should be [none] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [none] at (0.5) should be [none] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [none] at (0.6) should be [none] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [none] at (1) should be [none] -PASS CSS Transitions with transition: all: property <perspective> from [50px] to [none] at (1.5) should be [none] -PASS CSS Animations: property <perspective> from [50px] to [none] at (-0.3) should be [50px] -PASS CSS Animations: property <perspective> from [50px] to [none] at (0) should be [50px] -PASS CSS Animations: property <perspective> from [50px] to [none] at (0.3) should be [50px] -PASS CSS Animations: property <perspective> from [50px] to [none] at (0.5) should be [none] -PASS CSS Animations: property <perspective> from [50px] to [none] at (0.6) should be [none] -PASS CSS Animations: property <perspective> from [50px] to [none] at (1) should be [none] -PASS CSS Animations: property <perspective> from [50px] to [none] at (1.5) should be [none] -PASS Web Animations: property <perspective> from [50px] to [none] at (-0.3) should be [50px] -PASS Web Animations: property <perspective> from [50px] to [none] at (0) should be [50px] -PASS Web Animations: property <perspective> from [50px] to [none] at (0.3) should be [50px] -PASS Web Animations: property <perspective> from [50px] to [none] at (0.5) should be [none] -PASS Web Animations: property <perspective> from [50px] to [none] at (0.6) should be [none] -PASS Web Animations: property <perspective> from [50px] to [none] at (1) should be [none] -PASS Web Animations: property <perspective> from [50px] to [none] at (1.5) should be [none] -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transforms/animation/perspective-interpolation.html b/third_party/blink/web_tests/external/wpt/css/css-transforms/animation/perspective-interpolation.html index 93eec76..d3f165d 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-transforms/animation/perspective-interpolation.html +++ b/third_party/blink/web_tests/external/wpt/css/css-transforms/animation/perspective-interpolation.html
@@ -92,6 +92,21 @@ {at: 1.5, expect: '125px'}, ]); +test_interpolation({ + property: 'perspective', + from: '0px', // Test that there's no special handling of 0px, as for perspective() + to: '10px', +}, [ + {at: -20, expect: '0px'}, // perspective does not accept negative values + {at: -1, expect: '0px'}, // perspective does not accept negative values + {at: -0.3, expect: '0px'}, + {at: 0, expect: '0px'}, + {at: 0.3, expect: '3px'}, + {at: 0.6, expect: '6px'}, + {at: 1, expect: '10px'}, + {at: 1.5, expect: '15px'}, +]); + test_no_interpolation({ property: 'perspective', from: '50px',
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2-ref.html b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2-ref.html index 64969c4..bea389a 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2-ref.html +++ b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2-ref.html
@@ -5,18 +5,22 @@ <title>CSS transforms: perspective: 0px reference</title> <link rel="author" title="Miko Mynttinen" href="mailto:mmynttinen@mozilla.com"> <link rel="author" title="Mozilla" href="https://www.mozilla.org"> +<link rel="author" title="L. David Baron" href="https://dbaron.org/"> +<link rel="author" title="Google" href="http://www.google.com/"> <style type="text/css"> .parent { transform: perspective(0px); + transform-style: preserve-3d; + transform-origin: top left; } .parent > div { - width: 200px; - height: 200px; + width: 100px; + height: 100px; position: absolute; } .child-3d { background: green; - transform: translateZ(1px); + transform: translateZ(0.5px); } </style> </head>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2.html b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2.html index 59565ff..a94de82b 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2.html +++ b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-2.html
@@ -5,6 +5,8 @@ <title>CSS transforms: perspective: 0px</title> <link rel="author" title="Miko Mynttinen" href="mailto:mmynttinen@mozilla.com"> <link rel="author" title="Mozilla" href="https://www.mozilla.org"> +<link rel="author" title="L. David Baron" href="https://dbaron.org/"> +<link rel="author" title="Google" href="http://www.google.com/"> <link rel="help" href="https://drafts.csswg.org/css-transforms-2/#propdef-perspective"> <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/413"> <meta name="assert" content="Test checks that perspective: 0px behaves like transform: perspective(0) on parent container"> @@ -12,18 +14,21 @@ <style type="text/css"> .parent { perspective: 0px; + perspective-origin: top left; } .parent > div { - width: 200px; - height: 200px; position: absolute; } .child-2d { background: red; + width: 200px; + height: 200px; } .child-3d { + width: 100px; + height: 100px; background: green; - transform: translateZ(1px); + transform: translateZ(0.5px); } </style> </head>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-3.html b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-3.html new file mode 100644 index 0000000..0c46bd0 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero-3.html
@@ -0,0 +1,28 @@ +<!DOCTYPE html> +<meta charset=UTF-8> +<title>CSS Test: perspective(0)</title> +<link rel="author" title="L. David Baron" href="https://dbaron.org/"> +<link rel="author" title="Google" href="http://www.google.com/"> +<link rel="help" href="https://drafts.csswg.org/css-transforms-2/#perspective-property"> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/413"> +<meta name="assert" content="perspective: 0 should be clamped to 1px"> +<link rel="match" href="reference/green.html"> +<style> +#outer { + width: 100px; + height: 100px; + background: red; + perspective: 0; + perspective-origin: top left; +} +#inner { + width: 50px; + height: 50px; + background: green; + /* perspective: 0 should be treated as perspective(1px), which should + * cause this box to be much larger. */ + transform: translateZ(0.5px); +} +</style> +<p>Pass if there is NO red below:</p> +<div id="outer"><div id="inner"></div></div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero.html b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero.html index f0044ad0..93d2b63 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero.html +++ b/third_party/blink/web_tests/external/wpt/css/css-transforms/perspective-zero.html
@@ -3,29 +3,28 @@ <title>CSS Test: transform: perspective(0)</title> <link rel="author" title="Xidorn Quan" href="https://www.upsuper.org"> <link rel="author" title="Mozilla" href="https://www.mozilla.org"> +<link rel="author" title="L. David Baron" href="https://dbaron.org/"> +<link rel="author" title="Google" href="http://www.google.com/"> <link rel="help" href="https://drafts.csswg.org/css-transforms-2/#funcdef-perspective"> -<meta name="assert" content="perspective(0) should behave like identity transform function."> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/413"> +<meta name="assert" content="perspective(0) should be clamped to 1px"> <link rel="match" href="reference/green.html"> <style> -#cover-me, #test { +#cover-me { width: 100px; height: 100px; -} -#cover-me { background: red; position: relative; margin-bottom: -100px; } #test { background: green; - /* This should be an identity transform, since perspective(0) must be - * treated as perspective(infinity), and consequently translateZ() - * doesn't have any effect, so that it covers up #cover-me. - * If perspective(0) is invalid, #test would not create a stacking - * context, and #cover-me would be placed on top of #test showing red. - * If perspective(0) is handled as perspective(epsilon), #test would - * be invisible. */ - transform: perspective(0) translateZ(50px); + transform-origin: top left; + width: 50px; + height: 50px; + /* perspective(0) should be treated as perspective(1px), which should + * cause this box to be much larger. */ + transform: perspective(0) translateZ(0.5px); } </style> <p>Pass if there is NO red below:</p>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-transforms/transform3d-perspective-005.html b/third_party/blink/web_tests/external/wpt/css/css-transforms/transform3d-perspective-005.html index 92b2efa..f23375d0 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-transforms/transform3d-perspective-005.html +++ b/third_party/blink/web_tests/external/wpt/css/css-transforms/transform3d-perspective-005.html
@@ -4,16 +4,19 @@ <title>CSS Test (Transforms): 'perspective: 1000px' on Grandparent and 'perspective: 0px' on Parent</title> <link rel="author" title="Aryeh Gregor" href="mailto:ayg@aryeh.name"> + <link rel="author" title="L. David Baron" href="https://dbaron.org/"> + <link rel="author" title="Google" href="http://www.google.com/"> <link rel="help" href="http://www.w3.org/TR/css-transforms-2/#perspective-property"> + <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/413"> <meta name="assert" content="This tests that 'perspective: 0px' behaves the - same as no perspective being specified at all (it's a parse error)."> + same as perspective: 1px."> <link rel="match" href="transform-lime-square-ref.html"> </head> <body> <div style="perspective: 1000px"> - <div style="perspective: 0px"> - <div style="height: 100px; width: 100px; background: lime; - transform: rotatex(45deg) scaley(1.41421356); transform-origin: top"> + <div style="perspective: 0px; perspective-origin: 50px bottom"> + <div style="height: 50px; width: 50px; background: lime; + transform: translate3d(25px, 25px, 0.5px)"> </div> </div> </div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/properties/perspective-expected.txt b/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/properties/perspective-expected.txt deleted file mode 100644 index 5b71d48..0000000 --- a/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/properties/perspective-expected.txt +++ /dev/null
@@ -1,15 +0,0 @@ -This is a testharness.js-based test. -PASS Can set 'perspective' to CSS-wide keywords -PASS Can set 'perspective' to var() references -PASS Can set 'perspective' to the 'none' keyword -FAIL Can set 'perspective' to a length assert_equals: expected "CSSUnitValue" but got "CSSKeywordValue" -PASS Setting 'perspective' to a percent throws TypeError -PASS Setting 'perspective' to a time throws TypeError -PASS Setting 'perspective' to an angle throws TypeError -PASS Setting 'perspective' to a flexible length throws TypeError -PASS Setting 'perspective' to a number throws TypeError -PASS Setting 'perspective' to a position throws TypeError -PASS Setting 'perspective' to a URL throws TypeError -PASS Setting 'perspective' to a transform throws TypeError -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/html/dom/elements-embedded.js b/third_party/blink/web_tests/external/wpt/html/dom/elements-embedded.js index c4b572c..c5b4520c 100644 --- a/third_party/blink/web_tests/external/wpt/html/dom/elements-embedded.js +++ b/third_party/blink/web_tests/external/wpt/html/dom/elements-embedded.js
@@ -93,6 +93,7 @@ autoplay: "boolean", loop: "boolean", controls: "boolean", + controlsList: {type: "tokenlist", domAttrName: "controlsList"}, defaultMuted: {type: "boolean", domAttrName: "muted"}, width: "unsigned long",
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/embedded-content/media-elements/controlsList.html b/third_party/blink/web_tests/external/wpt/html/semantics/embedded-content/media-elements/controlsList.html new file mode 100644 index 0000000..db663e0 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/embedded-content/media-elements/controlsList.html
@@ -0,0 +1,31 @@ +<!DOCTYPE html> +<title>Test controlsList attribute</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +const allowedValues = [ + "nodownload", + "nofullscreen", + "noplaybackrate", + "noremoteplayback", +]; + +function testControlsList(tagName) { + const element = document.createElement(tagName); + + // Test that supports() is returning true for allowed values. + for (const value of allowedValues) { + assert_true( + element.controlsList.supports(value), + `tag = ${element.tagName}, value = ${value} must be supported` + ); + } +} + +["audio", "video"].forEach((tagName) => { + test( + () => testControlsList(tagName), + `Test controlsList allowed values for <${tagName}>` + ); +}); +</script> \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/web-animations/animation-model/animation-types/property-types.js b/third_party/blink/web_tests/external/wpt/web-animations/animation-model/animation-types/property-types.js index dba946d..6f39020 100644 --- a/third_party/blink/web_tests/external/wpt/web-animations/animation-model/animation-types/property-types.js +++ b/third_party/blink/web_tests/external/wpt/web-animations/animation-model/animation-types/property-types.js
@@ -1074,6 +1074,7 @@ const target = createTestElement(t, setup); const animation = target.animate( { + // perspective(0) is treated as perspective(1px) [idlName]: ['perspective(0)', 'perspective(10px)'], }, 1000 @@ -1081,7 +1082,7 @@ testAnimationSampleMatrices(animation, idlName, [{ time: 500, expected: [ 1, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 1, -0.05, + 0, 0, 1, -0.55, 0, 0, 0, 1 ] }]); }, `${property}: perspective`);
diff --git a/third_party/blink/web_tests/http/tests/devtools/elements/styles-1/color-nicknames-lowercase-expected.txt b/third_party/blink/web_tests/http/tests/devtools/elements/styles-1/color-nicknames-lowercase-expected.txt deleted file mode 100644 index 5baf68fd..0000000 --- a/third_party/blink/web_tests/http/tests/devtools/elements/styles-1/color-nicknames-lowercase-expected.txt +++ /dev/null
@@ -1,4 +0,0 @@ -Tests that all color nicknames are lowercase to facilitate lookup - -PASSED -
diff --git a/third_party/blink/web_tests/http/tests/devtools/elements/styles-1/color-nicknames-lowercase.js b/third_party/blink/web_tests/http/tests/devtools/elements/styles-1/color-nicknames-lowercase.js deleted file mode 100644 index a819e6d..0000000 --- a/third_party/blink/web_tests/http/tests/devtools/elements/styles-1/color-nicknames-lowercase.js +++ /dev/null
@@ -1,21 +0,0 @@ -// 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. - -(async function() { - TestRunner.addResult(`Tests that all color nicknames are lowercase to facilitate lookup\n`); - await TestRunner.showPanel('elements'); - - var badNames = []; - for (var nickname in Common.Color.Nicknames) { - if (nickname.toLowerCase() !== nickname) - badNames.push(nickname); - } - - if (badNames.length === 0) - TestRunner.addResult('PASSED'); - else - TestRunner.addResult('Non-lowercase color nicknames: ' + badNames.join(', ')); - - TestRunner.completeTest(); -})();
diff --git a/third_party/blink/web_tests/http/tests/media/controls/controls-list-add-hide-expected.txt b/third_party/blink/web_tests/http/tests/media/controls/controls-list-add-hide-expected.txt new file mode 100644 index 0000000..410f636 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/media/controls/controls-list-add-hide-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL Test disabling controls on the video element with all controls. Failed to find overflow item: -internal-media-controls-playback-speed-button +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/http/tests/media/controls/controls-list-add-hide.html b/third_party/blink/web_tests/http/tests/media/controls/controls-list-add-hide.html index f77903c..2a55d72 100644 --- a/third_party/blink/web_tests/http/tests/media/controls/controls-list-add-hide.html +++ b/third_party/blink/web_tests/http/tests/media/controls/controls-list-add-hide.html
@@ -10,19 +10,31 @@ var v = document.getElementById('enabled-controls'); v.addEventListener('canplaythrough', t.step_func(e => { - assert_true(isFullscreenButtonEnabled(v)); assert_true(isDownloadsButtonEnabled(v)); + assert_true(isFullscreenButtonEnabled(v)); + assert_true(isPlaybackSpeedButtonEnabled(v)); v.controlsList.add('nodownload'); runAfterLayoutAndPaint(t.step_func(() => { - assert_true(isFullscreenButtonEnabled(v)); assert_false(isDownloadsButtonEnabled(v)); + assert_true(isFullscreenButtonEnabled(v)); + assert_true(isPlaybackSpeedButtonEnabled(v)); + v.controlsList.add('nofullscreen'); - runAfterLayoutAndPaint(t.step_func_done(() => { - assert_false(isFullscreenButtonEnabled(v)); + runAfterLayoutAndPaint(t.step_func(() => { assert_false(isDownloadsButtonEnabled(v)); + assert_false(isFullscreenButtonEnabled(v)); + assert_true(isPlaybackSpeedButtonEnabled(v)); + + v.controlsList.add('noplaybackrate'); + + runAfterLayoutAndPaint(t.step_func_done(() => { + assert_false(isDownloadsButtonEnabled(v)); + assert_false(isFullscreenButtonEnabled(v)); + assert_false(isPlaybackSpeedButtonEnabled(v)); + })); })); })); }));
diff --git a/third_party/blink/web_tests/http/tests/media/controls/controls-list-remove-show-expected.txt b/third_party/blink/web_tests/http/tests/media/controls/controls-list-remove-show-expected.txt new file mode 100644 index 0000000..84beebb --- /dev/null +++ b/third_party/blink/web_tests/http/tests/media/controls/controls-list-remove-show-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL Test enabling controls on the video element with them enabled. Failed to find overflow item: -internal-media-controls-playback-speed-button +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/http/tests/media/controls/controls-list-remove-show.html b/third_party/blink/web_tests/http/tests/media/controls/controls-list-remove-show.html index 5b25665..a5f7c44 100644 --- a/third_party/blink/web_tests/http/tests/media/controls/controls-list-remove-show.html +++ b/third_party/blink/web_tests/http/tests/media/controls/controls-list-remove-show.html
@@ -4,26 +4,37 @@ <script src="../../resources/testharnessreport.js"></script> <script src="../../resources/run-after-layout-and-paint.js"></script> <script src="../../media-resources/media-controls.js"></script> -<video controlslist="nodownload nofullscreen" id="disabled-controls" width="500px"></video> +<video controlslist="nodownload nofullscreen noplaybackrate" id="disabled-controls" width="500px"></video> <script> async_test(t => { var v = document.getElementById('disabled-controls'); v.addEventListener('canplaythrough', t.step_func(e => { - assert_false(isFullscreenButtonEnabled(v)); assert_false(isDownloadsButtonEnabled(v)); + assert_false(isFullscreenButtonEnabled(v)); + assert_false(isPlaybackSpeedButtonEnabled(v)); v.controlsList.remove('nodownload'); runAfterLayoutAndPaint(t.step_func(() => { - assert_false(isFullscreenButtonEnabled(v)); assert_true(isDownloadsButtonEnabled(v)); + assert_false(isFullscreenButtonEnabled(v)); + assert_false(isPlaybackSpeedButtonEnabled(v)); v.controlsList.remove('nofullscreen'); - runAfterLayoutAndPaint(t.step_func_done(() => { - assert_true(isFullscreenButtonEnabled(v)); + runAfterLayoutAndPaint(t.step_func(() => { assert_true(isDownloadsButtonEnabled(v)); + assert_true(isFullscreenButtonEnabled(v)); + assert_false(isPlaybackSpeedButtonEnabled(v)); + + v.controlsList.remove('noplaybackrate'); + + runAfterLayoutAndPaint(t.step_func_done(() => { + assert_true(isFullscreenButtonEnabled(v)); + assert_true(isDownloadsButtonEnabled(v)); + assert_true(isPlaybackSpeedButtonEnabled(v)); + })); })); })); }));
diff --git a/third_party/blink/web_tests/http/tests/media/controls/video-controls-overflow-menu-correct-ordering-expected.txt b/third_party/blink/web_tests/http/tests/media/controls/video-controls-overflow-menu-correct-ordering-expected.txt new file mode 100644 index 0000000..a65e9b5 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/media/controls/video-controls-overflow-menu-correct-ordering-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL Overflow menu children appear in correct order. assert_equals: expected 8 but got 7 +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/http/tests/media/controls/video-controls-overflow-menu-correct-ordering.html b/third_party/blink/web_tests/http/tests/media/controls/video-controls-overflow-menu-correct-ordering.html index f4326c95..b3c796f 100644 --- a/third_party/blink/web_tests/http/tests/media/controls/video-controls-overflow-menu-correct-ordering.html +++ b/third_party/blink/web_tests/http/tests/media/controls/video-controls-overflow-menu-correct-ordering.html
@@ -25,7 +25,7 @@ // The overflow menu should always have the same number of elements. // Their visibility will change over time based on the size of the video. - assert_equals(children.length, 7); + assert_equals(children.length, 8); // Ensure that all of the buttons are visible in the right order for (var i = 0; i < children.length; i++) {
diff --git a/third_party/blink/web_tests/media/controls/video-controls-overflow-menu-text-expected.txt b/third_party/blink/web_tests/media/controls/video-controls-overflow-menu-text-expected.txt new file mode 100644 index 0000000..4d4f469 --- /dev/null +++ b/third_party/blink/web_tests/media/controls/video-controls-overflow-menu-text-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL Overflow menu displays the correct text. assert_equals: expected "playback speed" but got "picture in picture" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/media/overflow-menu.js b/third_party/blink/web_tests/media/overflow-menu.js index b135997..c165a0d4 100644 --- a/third_party/blink/web_tests/media/overflow-menu.js +++ b/third_party/blink/web_tests/media/overflow-menu.js
@@ -6,6 +6,7 @@ "-webkit-media-controls-mute-button", "-internal-media-controls-cast-button", "-webkit-media-controls-toggle-closed-captions-button", + "-internal-media-controls-playback-speed-button", "-internal-media-controls-picture-in-picture-button", ]; // PseudoID for the overflow button @@ -31,10 +32,11 @@ MUTE: 3, CAST: 4, CLOSED_CAPTIONS: 5, + PLAYBACK_SPEED: 6, }; // Default text within the overflow menu -var overflowMenuText = ["Play", "Fullscreen", "Download", "Mute", "Cast", "CaptionsOff"]; +var overflowMenuText = ["Play", "Fullscreen", "Download", "Mute", "Cast", "CaptionsOff", "Playback speed"]; if (document.pictureInPictureEnabled) overflowMenuText.push('Picture in Picture');
diff --git a/third_party/blink/web_tests/transforms/3d/general/3dtransform-values-expected.txt b/third_party/blink/web_tests/transforms/3d/general/3dtransform-values-expected.txt index 321d233..07fd510c 100644 --- a/third_party/blink/web_tests/transforms/3d/general/3dtransform-values-expected.txt +++ b/third_party/blink/web_tests/transforms/3d/general/3dtransform-values-expected.txt
@@ -15,7 +15,7 @@ transform "perspective(400em)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)" : PASS transform "perspective(50%)" expected "none" : PASS transform "perspective(-400)" expected "none" : PASS -transform "perspective(0)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS +transform "perspective(0)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)" : PASS transform "perspective(400deg)" expected "none" : PASS transform "perspective(banana)" expected "none" : PASS
diff --git a/third_party/blink/web_tests/transforms/3d/general/3dtransform-values.html b/third_party/blink/web_tests/transforms/3d/general/3dtransform-values.html index 78883c57..d256bd7c 100644 --- a/third_party/blink/web_tests/transforms/3d/general/3dtransform-values.html +++ b/third_party/blink/web_tests/transforms/3d/general/3dtransform-values.html
@@ -43,7 +43,7 @@ { 'transform' : 'perspective(400em)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)' }, { 'transform' : 'perspective(50%)', 'result' : 'none' }, { 'transform' : 'perspective(-400)', 'result' : 'none' }, - { 'transform' : 'perspective(0)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' }, + { 'transform' : 'perspective(0)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)' }, { 'transform' : 'perspective(400deg)', 'result' : 'none' }, // unit must be length { 'transform' : 'perspective(banana)', 'result' : 'none' }, // unit must be length ];
diff --git a/third_party/blink/web_tests/transforms/perspective-parsing.html b/third_party/blink/web_tests/transforms/perspective-parsing.html index 276076a..a5e666b 100644 --- a/third_party/blink/web_tests/transforms/perspective-parsing.html +++ b/third_party/blink/web_tests/transforms/perspective-parsing.html
@@ -12,8 +12,8 @@ expect('none').parsesAs('none').isComputedTo('none'); expect('1px').parsesAs('1px').isComputedTo('1px'); -expect('0').isInvalid(); -expect('0px').isInvalid(); +expect('0').parsesAs('0px').isComputedTo('0px'); +expect('0px').parsesAs('0px').isComputedTo('0px'); expect('5').isInvalid(); expect('-1px').isInvalid(); expect('50%').isInvalid();
diff --git a/third_party/blink/web_tests/transforms/webkit-perspective-parsing.html b/third_party/blink/web_tests/transforms/webkit-perspective-parsing.html index fd58244b..749dce9 100644 --- a/third_party/blink/web_tests/transforms/webkit-perspective-parsing.html +++ b/third_party/blink/web_tests/transforms/webkit-perspective-parsing.html
@@ -12,8 +12,8 @@ expect('none').parsesAs('none').isComputedTo('none'); expect('1px').parsesAs('1px').isComputedTo('1px'); -expect('0').isInvalid(); -expect('0px').isInvalid(); +expect('0').parsesAs('0px').isComputedTo('0px'); +expect('0px').parsesAs('0px').isComputedTo('0px'); expect('5').parsesAs('5px'); expect('-1px').isInvalid(); expect('50%').isInvalid(); @@ -21,7 +21,7 @@ expect('calc(0px)').parsesAs('calc(0px)'); expect('calc(1px)').parsesAs('calc(1px)'); expect('calc(-1)').isInvalid(); -expect('calc(0)').isInvalid(); +expect('calc(0)').parsesAs('0px'); expect('calc(1)').parsesAs('1px'); expect('calc(10em - 10px)').parsesAs('calc(10em - 10px)'); </script>
diff --git a/third_party/blink/web_tests/virtual/cors-rfc1918/README.md b/third_party/blink/web_tests/virtual/cors-rfc1918/README.md index 489d641..3150f17 100644 --- a/third_party/blink/web_tests/virtual/cors-rfc1918/README.md +++ b/third_party/blink/web_tests/virtual/cors-rfc1918/README.md
@@ -1,2 +1,6 @@ -This directory is for testing the CORS-RFC1918 implementation. +This directory is a leftover for testing the +[Private Network Access](https://wicg.github.io/private-network-access/) +specififcation (formerly known as CORS-RFC1918). +TODO(https://crbug.com/1204044): Remove all non-WPT web tests running as part +of this virtual test suite and remove this test suite altogether.
diff --git a/third_party/blink/web_tests/virtual/cors-rfc1918/external/wpt/cors-rfc1918/README.md b/third_party/blink/web_tests/virtual/cors-rfc1918/external/wpt/cors-rfc1918/README.md deleted file mode 100644 index 8aef905e..0000000 --- a/third_party/blink/web_tests/virtual/cors-rfc1918/external/wpt/cors-rfc1918/README.md +++ /dev/null
@@ -1 +0,0 @@ -This directory is for testing the CORS-RFC1918 implementation.
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/controls-list-add-hide-expected.txt b/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/controls-list-add-hide-expected.txt new file mode 100644 index 0000000..89fbee5 --- /dev/null +++ b/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/controls-list-add-hide-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS Test disabling controls on the video element with all controls. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/controls-list-remove-show-expected.txt b/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/controls-list-remove-show-expected.txt new file mode 100644 index 0000000..1da368c2 --- /dev/null +++ b/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/controls-list-remove-show-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS Test enabling controls on the video element with them enabled. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/video-controls-overflow-menu-correct-ordering-expected.txt b/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/video-controls-overflow-menu-correct-ordering-expected.txt new file mode 100644 index 0000000..7ec4825 --- /dev/null +++ b/third_party/blink/web_tests/virtual/playback_speed_button/http/tests/media/controls/video-controls-overflow-menu-correct-ordering-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS Overflow menu children appear in correct order. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-button.html b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-button.html index b960c44..642d9b6 100644 --- a/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-button.html +++ b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-button.html
@@ -3,7 +3,7 @@ <script src="../../../../resources/testharness.js"></script> <script src="../../../../resources/testharnessreport.js"></script> <script src="../../../../media/media-controls.js"></script> -<script src="../overflow-menu.js"></script> +<script src="../../../../media/overflow-menu.js"></script> <!--Padding ensures the overflow menu is visible for the tests. --> <body style="padding-top: 200px; padding-left: 100px">
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-list-hide-on-click-outside.html b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-list-hide-on-click-outside.html index 42cedf74..670c5b0a 100644 --- a/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-list-hide-on-click-outside.html +++ b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/playback-speed-list-hide-on-click-outside.html
@@ -3,7 +3,7 @@ <script src="../../../../resources/testharness.js"></script> <script src="../../../../resources/testharnessreport.js"></script> <script src="../../../../media/media-controls.js"></script> -<script src="../overflow-menu.js"></script> +<script src="../../../../media/overflow-menu.js"></script> <!--Padding ensures the overflow menu is visible for the tests. --> <body style="padding-top: 200px; padding-left: 100px">
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/video-controls-overflow-menu-text-expected.txt b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/video-controls-overflow-menu-text-expected.txt new file mode 100644 index 0000000..c7861d9 --- /dev/null +++ b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/video-controls-overflow-menu-text-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS Overflow menu displays the correct text. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/video-controls-overflow-menu-text.html b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/video-controls-overflow-menu-text.html index 7823528..8840272 100644 --- a/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/video-controls-overflow-menu-text.html +++ b/third_party/blink/web_tests/virtual/playback_speed_button/media/controls/video-controls-overflow-menu-text.html
@@ -3,7 +3,7 @@ <script src="../../../../resources/testharness.js"></script> <script src="../../../../resources/testharnessreport.js"></script> <script src="../../../../media/media-controls.js"></script> -<script src="../overflow-menu.js"></script> +<script src="../../../../media/overflow-menu.js"></script> <!--Padding ensures the overflow menu is visible for the tests. --> <body style="padding-top: 200px; padding-left: 100px">
diff --git a/third_party/blink/web_tests/virtual/playback_speed_button/media/overflow-menu.js b/third_party/blink/web_tests/virtual/playback_speed_button/media/overflow-menu.js deleted file mode 100644 index c165a0d4..0000000 --- a/third_party/blink/web_tests/virtual/playback_speed_button/media/overflow-menu.js +++ /dev/null
@@ -1,42 +0,0 @@ -// We expect the items in the overflow to appear in the following ordering. -var overflowButtonsCSS = [ - "-webkit-media-controls-play-button", - "-webkit-media-controls-fullscreen-button", - "-internal-media-controls-download-button", - "-webkit-media-controls-mute-button", - "-internal-media-controls-cast-button", - "-webkit-media-controls-toggle-closed-captions-button", - "-internal-media-controls-playback-speed-button", - "-internal-media-controls-picture-in-picture-button", -]; -// PseudoID for the overflow button -var menuID = "-internal-media-controls-overflow-button"; -// PseudoID for the overflow list -var listID = "-internal-media-controls-overflow-menu-list"; - -// Returns the overflow menu button within the given media element -function getOverflowMenuButton(media) { - return mediaControlsElement(internals.shadowRoot(media).firstChild, menuID); -} - -// Returns the overflow menu list of overflow controls -function getOverflowList(media) { - return mediaControlsElement(internals.shadowRoot(media).firstChild, listID); -} - -// Location of media control element in the overflow button -var OverflowMenuButtons = { - PLAY: 0, - FULLSCREEN: 1, - DOWNLOAD: 2, - MUTE: 3, - CAST: 4, - CLOSED_CAPTIONS: 5, - PLAYBACK_SPEED: 6, -}; - -// Default text within the overflow menu -var overflowMenuText = ["Play", "Fullscreen", "Download", "Mute", "Cast", "CaptionsOff", "Playback speed"]; - -if (document.pictureInPictureEnabled) - overflowMenuText.push('Picture in Picture');
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py index 3dd8c007..9945e70 100644 --- a/tools/json_schema_compiler/cc_generator.py +++ b/tools/json_schema_compiler/cc_generator.py
@@ -309,10 +309,10 @@ """ c = Code() value_var = prop.unix_name + '_value' - c.Append('const base::Value* %(value_var)s = nullptr;') + c.Append('const base::Value* %(value_var)s = %(src)s->FindKey("%(key)s");') if prop.optional: (c.Sblock( - 'if (%(src)s->GetWithoutPathExpansion("%(key)s", &%(value_var)s)) {') + 'if (%(value_var)s) {') .Concat(self._GeneratePopulatePropertyFromValue( prop, value_var, dst, 'false'))) underlying_type = self._type_helper.FollowRef(prop.type_) @@ -327,7 +327,7 @@ c.Eblock('}') else: (c.Sblock( - 'if (!%(src)s->GetWithoutPathExpansion("%(key)s", &%(value_var)s)) {') + 'if (!%(value_var)s) {') .Concat(self._AppendError16('u"\'%%(key)s\' is required"')) .Append('return false;') .Eblock('}')
diff --git a/tools/metrics/actions/PRESUBMIT.py b/tools/metrics/actions/PRESUBMIT.py index b8d4adcb..3a20ef74 100644 --- a/tools/metrics/actions/PRESUBMIT.py +++ b/tools/metrics/actions/PRESUBMIT.py
@@ -8,6 +8,8 @@ for more details on the presubmit API built into depot_tools. """ +USE_PYTHON3 = True + def CheckChange(input_api, output_api): """Checks that actions.xml is up to date and pretty-printed."""
diff --git a/tools/metrics/actions/extract_actions_test.py b/tools/metrics/actions/extract_actions_test.py index e07d7e1e..b795a64 100755 --- a/tools/metrics/actions/extract_actions_test.py +++ b/tools/metrics/actions/extract_actions_test.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -279,7 +279,7 @@ # Clear suffixes and mark actions as not coming from suffixes, so that # the returned XML file is the expanded one. suffixes = [] - for action in actions_dict.itervalues(): + for action in actions_dict.values(): action.from_suffix = False return extract_actions.PrettyPrint(actions_dict, comments, suffixes)
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index d072335..b3d8ed8 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -17919,6 +17919,7 @@ <int value="1" label="kDebugSameDocNavigationDocIdMismatch"/> <int value="2" label="kDebugNonMainFrameWithOldPageInfo"/> <int value="3" label="kDebugBackForwardCacheMetricsMismatch"/> + <int value="4" label="kDebugBrowserVsRendererOriginToCommit"/> </enum> <enum name="DeclarativeAPIFunctionType"> @@ -32834,6 +32835,7 @@ <int value="3927" label="HiddenBackfaceWith3D"/> <int value="3928" label="MainFrameNonSecurePrivateAddressSpace"/> <int value="3929" label="CSSSelectorPseudoHas"/> + <int value="3930" label="HTMLMediaElementControlsListNoPlaybackRate"/> </enum> <enum name="FeaturePolicyAllowlistType"> @@ -46080,6 +46082,7 @@ <int value="-1163777157" label="ContextualSearchSimplifiedServer:disabled"/> <int value="-1162944097" label="enable-color-correct-rendering"/> <int value="-1162636562" label="ReduceHorizontalFlingVelocity:disabled"/> + <int value="-1162151469" label="ProjectorFeaturePod:disabled"/> <int value="-1161409696" label="MediaRemotingEncrypted:enabled"/> <int value="-1161384421" label="ContextualSuggestionsAboveArticles:enabled"/> <int value="-1160941363" label="AffiliationBasedMatching:disabled"/> @@ -46724,6 +46727,7 @@ label="ClickToCallContextMenuForSelectedText:enabled"/> <int value="-613596048" label="new-canvas-2d-api"/> <int value="-613146027" label="ContinuousFeeds:disabled"/> + <int value="-612860466" label="Projector:disabled"/> <int value="-612633819" label="NotificationScrollBar:disabled"/> <int value="-612480090" label="FasterLocationReload:enabled"/> <int value="-610411643" label="enable-printer-app-search"/> @@ -48123,6 +48127,7 @@ <int value="630308195" label="SignInProfileCreation:enabled"/> <int value="630776247" label="USBGuard:disabled"/> <int value="630947363" label="touch-events"/> + <int value="631947048" label="WebRtcAnalogAgcClippingControl:disabled"/> <int value="632324382" label="ExperimentalAccessibilityDictationListening:disabled"/> <int value="632340413" label="network-settings-config"/> @@ -49081,6 +49086,7 @@ label="OmniboxRemoveSuggestionsFromClipboard:disabled"/> <int value="1442798825" label="enable-quic"/> <int value="1442830837" label="MemoryAblation:disabled"/> + <int value="1446066818" label="WebRtcAnalogAgcClippingControl:enabled"/> <int value="1446349255" label="ArcEnableUsap:disabled"/> <int value="1446946673" label="DesktopRestructuredLanguageSettings:disabled"/> <int value="1447295459" label="SyncPseudoUSSApps:enabled"/> @@ -49205,6 +49211,7 @@ <int value="1552753678" label="DnsHttpssvc:disabled"/> <int value="1553310752" label="AccessibilityCursorColor:enabled"/> <int value="1553422694" label="EnablePalmOnMaxTouchMajor:enabled"/> + <int value="1553430984" label="Projector:enabled"/> <int value="1553777815" label="enable-search-prefetch-service"/> <int value="1556554961" label="DriveFsBidirectionalNativeMessaging:enabled"/> <int value="1558410842" label="FilesZipNoNaCl:disabled"/> @@ -49576,6 +49583,7 @@ <int value="1875156497" label="CaptureMode:enabled"/> <int value="1875719680" label="ArcResizeLock:disabled"/> <int value="1878331098" label="GuestViewCrossProcessFrames:enabled"/> + <int value="1880144681" label="ProjectorFeaturePod:enabled"/> <int value="1880955305" label="enable-preconnect-to-search"/> <int value="1881036528" label="disable-multilingual-spellchecker"/> <int value="1881174782" label="disable-brotli"/>
diff --git a/tools/metrics/histograms/histograms_xml/media/histograms.xml b/tools/metrics/histograms/histograms_xml/media/histograms.xml index 789bd3e..11c38588 100644 --- a/tools/metrics/histograms/histograms_xml/media/histograms.xml +++ b/tools/metrics/histograms/histograms_xml/media/histograms.xml
@@ -776,8 +776,9 @@ </histogram> <histogram name="Media.Audio.Render.OutputDeviceAuthorizationTime" units="ms" - expires_after="2020-04-05"> - <owner>maxmorin@chromium.org</owner> + expires_after="2022-01-30"> + <owner>olka@chromium.org</owner> + <owner>henrika@chromium.org</owner> <summary> Similar to Media.Audio.OutputDeviceAuthorizationTime, this histogram measures the time required for device authorization, but it is measured on @@ -785,12 +786,13 @@ the IO thread until it receives OnDeviceAuthorized, also on the IO thread. Note that an authorization timeout will cause OnDeviceAuthorized to be called, so for platforms that use a timeout, very few times will be above - the timeout value. + the timeout value. Warning: this histogram was expired from 2020-04-05 to + 2021-06-04; data may be missing. </summary> </histogram> <histogram name="Media.Audio.Render.OutputDeviceAuthorizationTimedOut" - enum="BooleanTimedOut" expires_after="2021-10-10"> + enum="BooleanTimedOut" expires_after="2022-01-30"> <owner>guidou@chromium.org</owner> <owner>olka@chromium.org</owner> <summary> @@ -810,12 +812,14 @@ </histogram> <histogram name="Media.Audio.Render.OutputStreamDuration" units="ms" - expires_after="2020-04-05"> - <owner>maxmorin@chromium.org</owner> + expires_after="2022-01-30"> + <owner>olka@chromium.org</owner> + <owner>henrika@chromium.org</owner> <summary> This histogram measures the duration of every output stream, as seen from the renderer. It counts from when it has been successfully started, until it - is stopped. Streams that fail to start are not logged. + is stopped. Streams that fail to start are not logged. Warning: this + histogram was expired from 2020-04-05 to 2021-06-04; data may be missing. </summary> </histogram> @@ -974,7 +978,7 @@ </histogram> <histogram name="Media.AudioCapturerMissedReadDeadline" units="%" - expires_after="2021-06-01"> + expires_after="2021-10-04"> <owner>gudou@chromium.org</owner> <owner>olka@chromium.org</owner> <summary> @@ -1035,7 +1039,7 @@ </histogram> <histogram name="Media.AudioOutputController.CallbackError" enum="BooleanError" - expires_after="2021-08-09"> + expires_after="2021-10-09"> <owner>guidou@chromium.org</owner> <owner>olka@chromium.org</owner> <summary> @@ -1108,7 +1112,7 @@ <histogram name="Media.AudioOutputResampler.OpenLowLatencyStream" enum="AudioOutputResamplerLowLatencyOpenStreamResult" - expires_after="2021-08-09"> + expires_after="2021-10-09"> <owner>armax@chromium.org</owner> <owner>guidou@chromium.org</owner> <owner>olka@chromium.org</owner> @@ -2444,11 +2448,13 @@ </histogram> <histogram name="Media.InputStreamDurationWithoutCallback" units="ms" - expires_after="2020-10-11"> - <owner>maxmorin@chromium.org</owner> + expires_after="2021-10-11"> + <owner>olka@chromium.org</owner> + <owner>henrika@chromium.org</owner> <summary> Duration in milliseconds of low-latency audio input streams which never got - any callbacks. + any callbacks. Warning: this histogram was expired from 2020-10-11 to + 2021-06-04; data may be missing. </summary> </histogram>
diff --git a/tools/metrics/histograms/histograms_xml/others/histograms.xml b/tools/metrics/histograms/histograms_xml/others/histograms.xml index 0165677..a5dee8e8 100644 --- a/tools/metrics/histograms/histograms_xml/others/histograms.xml +++ b/tools/metrics/histograms/histograms_xml/others/histograms.xml
@@ -8947,7 +8947,7 @@ <owner>thomasanderson@chromium.org</owner> <summary> The Debian version number (eg. 8: Jessie, 9: Stretch). Logged once on - startup if Linux.Distro is Debian. + startup if Linux.Distro2 is Debian. </summary> </histogram> @@ -8957,7 +8957,7 @@ <owner>thomasanderson@chromium.org</owner> <summary> The Fedora version number (eg. 27, 28) Logged once on startup if - Linux.Distro is Fedora. + Linux.Distro2 is Fedora. </summary> </histogram> @@ -8967,7 +8967,7 @@ <owner>thomasanderson@chromium.org</owner> <summary> The openSUSE Leap version number, logged as 1000*major + minor (eg. 15001 = - 15.1). Logged once on startup if Linux.Distro is openSUSE Leap. + 15.1). Logged once on startup if Linux.Distro2 is openSUSE Leap. </summary> </histogram> @@ -8977,7 +8977,7 @@ <owner>thomasanderson@chromium.org</owner> <summary> The Ubuntu version number, logged as 1000*year + month (eg. 16004 = 16.04 - Xenial). Logged once on startup if Linux.Distro is Ubuntu. + Xenial). Logged once on startup if Linux.Distro2 is Ubuntu. </summary> </histogram>
diff --git a/tools/metrics/ukm/PRESUBMIT.py b/tools/metrics/ukm/PRESUBMIT.py index 28fab1c..99b13be 100644 --- a/tools/metrics/ukm/PRESUBMIT.py +++ b/tools/metrics/ukm/PRESUBMIT.py
@@ -8,6 +8,8 @@ for more details on the presubmit API built into gcl. """ +USE_PYTHON3 = True + UKM_XML = 'ukm.xml'
diff --git a/tools/metrics/ukm/gen_builders_test.py b/tools/metrics/ukm/gen_builders_test.py index 8c37676f..767fd21 100755 --- a/tools/metrics/ukm/gen_builders_test.py +++ b/tools/metrics/ukm/gen_builders_test.py
@@ -25,8 +25,8 @@ def testGenerateCode(self): relpath = '.' - data = ukm_model.UKM_XML_TYPE.Parse( - open('../../tools/metrics/ukm/ukm.xml').read()) + with open('../../tools/metrics/ukm/ukm.xml') as f: + data = ukm_model.UKM_XML_TYPE.Parse(f.read()) event = data[ukm_model._EVENT_TYPE.tag][0] metric = event[ukm_model._METRIC_TYPE.tag][0] self.assertIsNotNone(event)
diff --git a/tools/metrics/ukm/ukm_model.py b/tools/metrics/ukm/ukm_model.py index ec24dd5..b36899d 100644 --- a/tools/metrics/ukm/ukm_model.py +++ b/tools/metrics/ukm/ukm_model.py
@@ -39,15 +39,16 @@ ], single_line=True) -_STATISTICS_TYPE = models.ObjectNodeType( +_STATISTICS_TYPE = models.ObjectNodeType( 'statistics', attributes=[ - ('export', str, r'^(?i)(|true|false)$'), + ('export', str, r'(?i)^(|true|false)$'), ], children=[ models.ChildType(_QUANTILES_TYPE.tag, _QUANTILES_TYPE, multiple=False), - models.ChildType( - _ENUMERATION_TYPE.tag, _ENUMERATION_TYPE, multiple=False), + models.ChildType(_ENUMERATION_TYPE.tag, + _ENUMERATION_TYPE, + multiple=False), ]) _HISTORY_TYPE = models.ObjectNodeType( @@ -90,25 +91,34 @@ _AGGREGATION_TYPE.tag, _AGGREGATION_TYPE, multiple=True), ]) -_EVENT_TYPE = models.ObjectNodeType( - 'event', - attributes=[ - ('name', str, r'^[A-Za-z0-9.]+$'), - ('singular', str, r'^(?i)(|true|false)$'), - ], - alphabetization=[ - (_OBSOLETE_TYPE.tag, _KEEP_ORDER), - (_OWNER_TYPE.tag, _KEEP_ORDER), - (_SUMMARY_TYPE.tag, _KEEP_ORDER), - (_METRIC_TYPE.tag, _LOWERCASE_FN('name')), - ], - extra_newlines=(1, 1, 1), - children=[ - models.ChildType(_OBSOLETE_TYPE.tag, _OBSOLETE_TYPE, multiple=False), - models.ChildType(_OWNER_TYPE.tag, _OWNER_TYPE, multiple=True), - models.ChildType(_SUMMARY_TYPE.tag, _SUMMARY_TYPE, multiple=False), - models.ChildType(_METRIC_TYPE.tag, _METRIC_TYPE, multiple=True), - ]) +_EVENT_TYPE = models.ObjectNodeType('event', + attributes=[ + ('name', str, r'^[A-Za-z0-9.]+$'), + ('singular', str, + r'(?i)^(|true|false)$'), + ], + alphabetization=[ + (_OBSOLETE_TYPE.tag, _KEEP_ORDER), + (_OWNER_TYPE.tag, _KEEP_ORDER), + (_SUMMARY_TYPE.tag, _KEEP_ORDER), + (_METRIC_TYPE.tag, + _LOWERCASE_FN('name')), + ], + extra_newlines=(1, 1, 1), + children=[ + models.ChildType(_OBSOLETE_TYPE.tag, + _OBSOLETE_TYPE, + multiple=False), + models.ChildType(_OWNER_TYPE.tag, + _OWNER_TYPE, + multiple=True), + models.ChildType(_SUMMARY_TYPE.tag, + _SUMMARY_TYPE, + multiple=False), + models.ChildType(_METRIC_TYPE.tag, + _METRIC_TYPE, + multiple=True), + ]) _UKM_CONFIGURATION_TYPE = models.ObjectNodeType( 'ukm-configuration',
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index c2f6891..63dd2ad 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json
@@ -9,8 +9,8 @@ "remote_path": "perfetto_binaries/trace_processor_shell/mac/bae8193de6c017394901163b7817157342914679/trace_processor_shell" }, "linux": { - "hash": "e2b8f1b68d26e0aee99c97b35b56e9b2a3279343", - "remote_path": "perfetto_binaries/trace_processor_shell/linux/ae2171b89cb3e49f73ff100fc1647a93048ca472/trace_processor_shell" + "hash": "8d221c50b417a221909d73b4a830a08bbc5af1e9", + "remote_path": "perfetto_binaries/trace_processor_shell/linux/5874d918cfb305895233228f4307b00fe5ac9c2d/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/tools/style_variable_generator/PRESUBMIT.py b/tools/style_variable_generator/PRESUBMIT.py index 1b0d0ba..35322147 100644 --- a/tools/style_variable_generator/PRESUBMIT.py +++ b/tools/style_variable_generator/PRESUBMIT.py
@@ -6,16 +6,29 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into depot_tools. """ +import os + +USE_PYTHON3 = True TEST_PATTERNS = [r'.+_test.py$'] STYLE_VAR_GEN_INPUTS = [ r'^tools[\\\/]style_variable_generator[\\\/].+\.json5$' ] - def _CommonChecks(input_api, output_api): + env = os.environ + pythonpath = [os.path.join(os.getcwd(), '..')] + if 'PYTHONPATH' in env: + pythonpath.append(env.get('PYTHONPATH')) + env['PYTHONPATH'] = input_api.os_path.pathsep.join((pythonpath)) + results = input_api.canned_checks.RunUnitTestsInDirectory( - input_api, output_api, '.', files_to_check=TEST_PATTERNS) + input_api, + output_api, + '.', + files_to_check=TEST_PATTERNS, + env=env, + run_on_python2=False) try: import sys old_sys_path = sys.path[:]
diff --git a/tools/style_variable_generator/README.md b/tools/style_variable_generator/README.md index 6c8d0b2..65d600e 100644 --- a/tools/style_variable_generator/README.md +++ b/tools/style_variable_generator/README.md
@@ -11,7 +11,7 @@ illustrations of each feature, as well as expected outputs in the corresponding \*_test_expected.\* files. -Run `python style_variable_generator.py -h` for usage details. +Run `./style_variable_generator -h` for usage details. ## Generator Options
diff --git a/tools/style_variable_generator/base_generator.py b/tools/style_variable_generator/base_generator.py index a0d74c6..c5dd130 100644 --- a/tools/style_variable_generator/base_generator.py +++ b/tools/style_variable_generator/base_generator.py
@@ -7,9 +7,9 @@ import collections import re import textwrap -import path_overrides -from color import Color -from opacity import Opacity +from style_variable_generator import path_overrides +from style_variable_generator.color import Color +from style_variable_generator.opacity import Opacity import copy _FILE_PATH = os.path.dirname(os.path.realpath(__file__))
diff --git a/tools/style_variable_generator/base_generator_test.py b/tools/style_variable_generator/base_generator_test.py old mode 100644 new mode 100755 index fbe54bf..fc28e8b --- a/tools/style_variable_generator/base_generator_test.py +++ b/tools/style_variable_generator/base_generator_test.py
@@ -1,8 +1,9 @@ +#!/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. -from base_generator import BaseGenerator, VariableType, Modes +from style_variable_generator.base_generator import BaseGenerator, VariableType, Modes import unittest
diff --git a/tools/style_variable_generator/color.py b/tools/style_variable_generator/color.py index 32e4ab6..792987d 100644 --- a/tools/style_variable_generator/color.py +++ b/tools/style_variable_generator/color.py
@@ -4,7 +4,7 @@ import re import textwrap -from opacity import Opacity +from style_variable_generator.opacity import Opacity class Color:
diff --git a/tools/style_variable_generator/color_test.py b/tools/style_variable_generator/color_test.py old mode 100644 new mode 100755 index 14a7f52..fc8775d4c --- a/tools/style_variable_generator/color_test.py +++ b/tools/style_variable_generator/color_test.py
@@ -1,8 +1,9 @@ +#!/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. -from color import Color +from style_variable_generator.color import Color import unittest
diff --git a/tools/style_variable_generator/colors_test_dark_only_expected.css b/tools/style_variable_generator/colors_test_dark_only_expected.css index 5e1903b..1cf89b1 100644 --- a/tools/style_variable_generator/colors_test_dark_only_expected.css +++ b/tools/style_variable_generator/colors_test_dark_only_expected.css
@@ -3,8 +3,8 @@ * found in the LICENSE file. */ /* This file is generated from: - * colors_test_palette.json5 * colors_test.json5 + * colors_test_palette.json5 */ html:not(body) {
diff --git a/tools/style_variable_generator/colors_test_expected.css b/tools/style_variable_generator/colors_test_expected.css index 2ffc6df..22439af 100644 --- a/tools/style_variable_generator/colors_test_expected.css +++ b/tools/style_variable_generator/colors_test_expected.css
@@ -3,8 +3,8 @@ * found in the LICENSE file. */ /* This file is generated from: - * colors_test_palette.json5 * colors_test.json5 + * colors_test_palette.json5 */ html:not(body) {
diff --git a/tools/style_variable_generator/colors_test_expected.h b/tools/style_variable_generator/colors_test_expected.h index 70d4191..f772e1f5 100644 --- a/tools/style_variable_generator/colors_test_expected.h +++ b/tools/style_variable_generator/colors_test_expected.h
@@ -3,8 +3,8 @@ // found in the LICENSE file. // This file is generated from: -// colors_test_palette.json5 // colors_test.json5 +// colors_test_palette.json5 #ifndef TOOLS_STYLE_VARIABLE_GENERATOR_COLORS_TEST_EXPECTED_H_ #define TOOLS_STYLE_VARIABLE_GENERATOR_COLORS_TEST_EXPECTED_H_
diff --git a/tools/style_variable_generator/colors_test_expected.proto b/tools/style_variable_generator/colors_test_expected.proto index 714ec91a..7f6ac18 100644 --- a/tools/style_variable_generator/colors_test_expected.proto +++ b/tools/style_variable_generator/colors_test_expected.proto
@@ -1,6 +1,6 @@ /* This file is generated from: - * colors_test_palette.json5 * colors_test.json5 + * colors_test_palette.json5 */ syntax = "proto3";
diff --git a/tools/style_variable_generator/colors_test_expected.protojson b/tools/style_variable_generator/colors_test_expected.protojson index fc0f536..4a49a05 100644 --- a/tools/style_variable_generator/colors_test_expected.protojson +++ b/tools/style_variable_generator/colors_test_expected.protojson
@@ -1,7 +1,7 @@ # This file is generated from: # additional_colors_test.json5 -# colors_test_palette.json5 # colors_test.json5 +# colors_test_palette.json5 palette_colors: [ { key: "google_grey_900",
diff --git a/tools/style_variable_generator/css_generator.py b/tools/style_variable_generator/css_generator.py index 293cdad..276f1bf 100644 --- a/tools/style_variable_generator/css_generator.py +++ b/tools/style_variable_generator/css_generator.py
@@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -from base_generator import Color, Modes, BaseGenerator, VariableType +from style_variable_generator.base_generator import Color, Modes, BaseGenerator, VariableType import collections @@ -46,7 +46,7 @@ 'css_color_from_rgb_var': self._CSSColorFromRGBVar, 'in_files': - self.in_file_to_context.keys(), + sorted(self.in_file_to_context.keys()), 'dark_mode_selector': self.generator_options.get('dark_mode_selector', None), 'Modes':
diff --git a/tools/style_variable_generator/find_invalid_css_variables.py b/tools/style_variable_generator/find_invalid_css_variables.py index f29416e..2783920 100644 --- a/tools/style_variable_generator/find_invalid_css_variables.py +++ b/tools/style_variable_generator/find_invalid_css_variables.py
@@ -8,8 +8,8 @@ import os import subprocess import sys -from css_generator import CSSStyleGenerator -from presubmit_support import RunGit +from style_variable_generator.css_generator import CSSStyleGenerator +from style_variable_generator.presubmit_support import RunGit # TODO(calamity): extend this checker to find unused C++ variables
diff --git a/tools/style_variable_generator/find_invalid_css_variables_test.py b/tools/style_variable_generator/find_invalid_css_variables_test.py old mode 100644 new mode 100755 index 0a411d7b..ca6e7e6 --- a/tools/style_variable_generator/find_invalid_css_variables_test.py +++ b/tools/style_variable_generator/find_invalid_css_variables_test.py
@@ -1,8 +1,9 @@ +#!/usr/bin/env python3 # 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. -from find_invalid_css_variables import FindInvalidCSSVariables +from style_variable_generator.find_invalid_css_variables import FindInvalidCSSVariables import unittest
diff --git a/tools/style_variable_generator/style_variable_generator.py b/tools/style_variable_generator/main.py old mode 100644 new mode 100755 similarity index 85% rename from tools/style_variable_generator/style_variable_generator.py rename to tools/style_variable_generator/main.py index 2894fc0..def1bce --- a/tools/style_variable_generator/style_variable_generator.py +++ b/tools/style_variable_generator/main.py
@@ -1,13 +1,18 @@ +#!/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. import argparse import sys -from css_generator import CSSStyleGenerator -from proto_generator import ProtoStyleGenerator, ProtoJSONStyleGenerator -from views_generator import ViewsStyleGenerator -from base_generator import Modes +import os + +sys.path += [os.path.dirname(os.path.dirname(__file__))] + +from style_variable_generator.css_generator import CSSStyleGenerator +from style_variable_generator.proto_generator import ProtoStyleGenerator, ProtoJSONStyleGenerator +from style_variable_generator.views_generator import ViewsStyleGenerator +from style_variable_generator.base_generator import Modes def parseGeneratorOptionList(options):
diff --git a/tools/style_variable_generator/opacity.py b/tools/style_variable_generator/opacity.py index 6f8e12b..cc4c93e3 100644 --- a/tools/style_variable_generator/opacity.py +++ b/tools/style_variable_generator/opacity.py
@@ -5,9 +5,6 @@ import re import sys -# Python3's unicode class is just 'str'. -STRTYPE = str if sys.version_info >= (3, ) else basestring - class Opacity: '''A representation of a single color value. @@ -26,7 +23,7 @@ raise ValueError('Malformed opacity value:' + value) def Parse(self, value): - if isinstance(value, STRTYPE): + if isinstance(value, str): match = re.match('^\$([a-z0-9_]+_opacity)$', value) if match: self.var = match.group(1)
diff --git a/tools/style_variable_generator/presubmit_support.py b/tools/style_variable_generator/presubmit_support.py index adabd79..ff983ca 100644 --- a/tools/style_variable_generator/presubmit_support.py +++ b/tools/style_variable_generator/presubmit_support.py
@@ -6,7 +6,7 @@ import os import subprocess import sys -from css_generator import CSSStyleGenerator +from style_variable_generator.css_generator import CSSStyleGenerator def BuildGrepQuery(deleted_names):
diff --git a/tools/style_variable_generator/proto_generator.py b/tools/style_variable_generator/proto_generator.py index 30fb6b512d..b24261e 100644 --- a/tools/style_variable_generator/proto_generator.py +++ b/tools/style_variable_generator/proto_generator.py
@@ -4,7 +4,7 @@ import os import collections -from base_generator import Color, Modes, BaseGenerator, VariableType +from style_variable_generator.base_generator import Color, Modes, BaseGenerator, VariableType class BaseProtoStyleGenerator(BaseGenerator): @@ -23,7 +23,7 @@ def GetGlobals(self): return { 'Modes': Modes, - 'in_files': self.in_file_to_context.keys(), + 'in_files': sorted(self.in_file_to_context.keys()), } def _CreateFieldList(self):
diff --git a/tools/style_variable_generator/style_variable_generator b/tools/style_variable_generator/style_variable_generator new file mode 100755 index 0000000..420a05c --- /dev/null +++ b/tools/style_variable_generator/style_variable_generator
@@ -0,0 +1,2 @@ +#!/bin/bash +python3 "$(dirname "$(realpath $0)")/main.py" $@
diff --git a/tools/style_variable_generator/style_variable_generator.gni b/tools/style_variable_generator/style_variable_generator.gni index a5d12c4..85b0b48d 100644 --- a/tools/style_variable_generator/style_variable_generator.gni +++ b/tools/style_variable_generator/style_variable_generator.gni
@@ -25,7 +25,7 @@ # foo_protojson # Protobuf JSON value format, contains actual color information template("style_variable_generator") { - script_file = "//tools/style_variable_generator/style_variable_generator.py" + script_file = "//tools/style_variable_generator/main.py" original_target_name = target_name common_inputs = [ "//tools/style_variable_generator/base_generator.py",
diff --git a/tools/style_variable_generator/style_variable_generator_test.py b/tools/style_variable_generator/style_variable_generator_test.py old mode 100644 new mode 100755 index 26cbcb2f..ddf4f34f --- a/tools/style_variable_generator/style_variable_generator_test.py +++ b/tools/style_variable_generator/style_variable_generator_test.py
@@ -1,22 +1,19 @@ +#!/usr/bin/env python3 # 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. -from base_generator import Modes -from css_generator import CSSStyleGenerator -from proto_generator import ProtoStyleGenerator, ProtoJSONStyleGenerator -from views_generator import ViewsStyleGenerator +from style_variable_generator.base_generator import Modes +from style_variable_generator.css_generator import CSSStyleGenerator +from style_variable_generator.proto_generator import ProtoStyleGenerator, ProtoJSONStyleGenerator +from style_variable_generator.views_generator import ViewsStyleGenerator import unittest class BaseStyleGeneratorTest: def assertEqualToFile(self, value, filename): - with open(filename) as f: - contents = f.read() - self.assertEqual( - value, contents, - '\n>>>>>\n%s<<<<<\n\ndoes not match\n\n>>>>>\n%s<<<<<' % - (value, contents)) + with open(filename, 'r') as f: + self.assertEqual(value, f.read()) def testColorTestJSON(self): self.generator.out_file_path = (
diff --git a/tools/style_variable_generator/views_generator.py b/tools/style_variable_generator/views_generator.py index 4e98d64..3d9fbbb 100644 --- a/tools/style_variable_generator/views_generator.py +++ b/tools/style_variable_generator/views_generator.py
@@ -4,7 +4,7 @@ import os import math -from base_generator import Color, Modes, BaseGenerator, VariableType +from style_variable_generator.base_generator import Color, Modes, BaseGenerator, VariableType class ViewsStyleGenerator(BaseGenerator): @@ -38,7 +38,7 @@ 'Modes': Modes, 'out_file_path': None, 'namespace_name': None, - 'in_files': self.in_file_to_context.keys(), + 'in_files': sorted(self.in_file_to_context.keys()), } if self.out_file_path: globals['out_file_path'] = self.out_file_path
diff --git a/ui/accessibility/platform/inspect/ax_event_recorder.cc b/ui/accessibility/platform/inspect/ax_event_recorder.cc index 779652b..90ac9ae 100644 --- a/ui/accessibility/platform/inspect/ax_event_recorder.cc +++ b/ui/accessibility/platform/inspect/ax_event_recorder.cc
@@ -5,6 +5,7 @@ #include "ui/accessibility/platform/inspect/ax_event_recorder.h" #include "base/callback_helpers.h" +#include "base/logging.h" namespace ui { @@ -16,9 +17,35 @@ } void AXEventRecorder::OnEvent(const std::string& event) { + base::AutoLock lock{on_event_lock_}; event_logs_.push_back(event); if (callback_) callback_.Run(event); } +bool AXEventRecorder::IsRunUntilEventSatisfied( + const std::vector<std::string>& run_until) const { + base::AutoLock lock{on_event_lock_}; + // If no @*-RUN-UNTIL-EVENT directives, then having any events is enough. + LOG(ERROR) << "=== IsRunUntilEventSatisfied#1 run_until size=" + << run_until.size(); + if (run_until.empty()) + return true; + + LOG(ERROR) << "=== IsRunUntilEventSatisfied#2 Logs size=" + << event_logs_.size(); + + for (const std::string& event : event_logs_) + for (const std::string& query : run_until) + if (event.find(query) != std::string::npos) + return true; + + return false; +} + +std::vector<std::string> AXEventRecorder::GetEventLogs() const { + base::AutoLock lock{on_event_lock_}; + return event_logs_; +} + } // namespace ui
diff --git a/ui/accessibility/platform/inspect/ax_event_recorder.h b/ui/accessibility/platform/inspect/ax_event_recorder.h index a398cf8..a165b9b 100644 --- a/ui/accessibility/platform/inspect/ax_event_recorder.h +++ b/ui/accessibility/platform/inspect/ax_event_recorder.h
@@ -9,6 +9,7 @@ #include <vector> #include "base/callback.h" +#include "base/synchronization/lock.h" #include "ui/accessibility/ax_export.h" namespace ui { @@ -49,10 +50,15 @@ void StopListeningToEvents(); // Called to ensure the event recorder has finished recording async events. - virtual void FlushAsyncEvents() {} + virtual void WaitForDoneRecording() {} // Access the vector of human-readable event logs, one string per event. - const std::vector<std::string>& EventLogs() { return event_logs_; } + std::vector<std::string> GetEventLogs() const; + + // Returns true if the @*-RUN-UNTIL-EVENT directive is satisfied by the + // currently recorded events for the events in |run_until|. + bool IsRunUntilEventSatisfied( + const std::vector<std::string>& run_until) const; protected: // Called by a derived class which implements platform event handling on @@ -62,6 +68,7 @@ bool only_web_events_ = false; private: + mutable base::Lock on_event_lock_; std::vector<std::string> event_logs_; AXEventCallback callback_;
diff --git a/ui/accessibility/platform/inspect/ax_property_node.cc b/ui/accessibility/platform/inspect/ax_property_node.cc index d21a595e..6543b115 100644 --- a/ui/accessibility/platform/inspect/ax_property_node.cc +++ b/ui/accessibility/platform/inspect/ax_property_node.cc
@@ -19,7 +19,7 @@ const std::string& property_str = filter.property_str; Parse(&root, property_str.begin(), property_str.end()); - AXPropertyNode* node = &root.parameters[0]; + AXPropertyNode* node = &root.arguments[0]; // Expel a trailing wildcard if any. node->original_property = @@ -40,24 +40,9 @@ } AXPropertyNode::AXPropertyNode() = default; -AXPropertyNode::AXPropertyNode(AXPropertyNode&& o) - : key(std::move(o.key)), - target(std::move(o.target)), - name_or_value(std::move(o.name_or_value)), - parameters(std::move(o.parameters)), - original_property(std::move(o.original_property)), - line_indexes(std::move(o.line_indexes)) {} +AXPropertyNode::AXPropertyNode(AXPropertyNode&& o) = default; AXPropertyNode::~AXPropertyNode() = default; - -AXPropertyNode& AXPropertyNode::operator=(AXPropertyNode&& o) { - key = std::move(o.key); - target = std::move(o.target); - name_or_value = std::move(o.name_or_value); - parameters = std::move(o.parameters); - original_property = std::move(o.original_property); - line_indexes = std::move(o.line_indexes); - return *this; -} +AXPropertyNode& AXPropertyNode::operator=(AXPropertyNode&& o) = default; AXPropertyNode::operator bool() const { return !name_or_value.empty(); @@ -87,7 +72,7 @@ } const AXPropertyNode* AXPropertyNode::FindKey(const char* refkey) const { - for (const auto& param : parameters) { + for (const auto& param : arguments) { if (param.key == refkey) { return ¶m; } @@ -97,7 +82,7 @@ absl::optional<std::string> AXPropertyNode::FindStringKey( const char* refkey) const { - for (const auto& param : parameters) { + for (const auto& param : arguments) { if (param.key == refkey) { return param.name_or_value; } @@ -106,7 +91,7 @@ } absl::optional<int> AXPropertyNode::FindIntKey(const char* refkey) const { - for (const auto& param : parameters) { + for (const auto& param : arguments) { if (param.key == refkey) { return param.AsInt(); } @@ -130,51 +115,52 @@ out += key + ": "; } - if (!target.empty()) { - out += target + '.'; - } out += name_or_value; - if (parameters.size()) { + if (arguments.size()) { out += '('; - for (size_t i = 0; i < parameters.size(); i++) { + for (size_t i = 0; i < arguments.size(); i++) { if (i != 0) { out += ", "; } - out += parameters[i].ToString(); + out += arguments[i].ToString(); } out += ')'; } return out; } +std::string AXPropertyNode::ToTreeString(const std::string& indent) const { + std::string out = indent; + out += name_or_value; + if (arguments.size()) { + out += "(\n"; + for (size_t i = 0; i < arguments.size(); i++) { + if (i != 0) { + out += ",\n"; + } + out += arguments[i].ToTreeString(indent + " "); + } + out += '\n' + indent + ')'; + } + if (next) { + out += ".\n" + next->ToTreeString(indent); + } + return out; +} + // private AXPropertyNode::AXPropertyNode(AXPropertyNode::iterator key_begin, AXPropertyNode::iterator key_end, const std::string& name_or_value) - : key(key_begin, key_end) { - Set(name_or_value.begin(), name_or_value.end()); -} + : key(key_begin, key_end), name_or_value(name_or_value) {} AXPropertyNode::AXPropertyNode(AXPropertyNode::iterator begin, - AXPropertyNode::iterator end) { - Set(begin, end); -} + AXPropertyNode::iterator end) + : name_or_value(begin, end) {} AXPropertyNode::AXPropertyNode(AXPropertyNode::iterator key_begin, AXPropertyNode::iterator key_end, AXPropertyNode::iterator value_begin, AXPropertyNode::iterator value_end) : key(key_begin, key_end), name_or_value(value_begin, value_end) { - Set(value_begin, value_end); -} - -void AXPropertyNode::Set(AXPropertyNode::iterator begin, - AXPropertyNode::iterator end) { - AXPropertyNode::iterator dot_operator = std::find(begin, end, '.'); - if (dot_operator != end) { - target = std::string(begin, dot_operator); - name_or_value = std::string(dot_operator + 1, end); - } else { - name_or_value = std::string(begin, end); - } } // private static @@ -183,42 +169,46 @@ AXPropertyNode::iterator end) { auto iter = begin; auto key_begin = end, key_end = end; + bool chained = false; while (iter != end) { // Subnode begins: create a new node, record its name and parse its // arguments. if (*iter == '(') { - node->parameters.push_back( - AXPropertyNode(key_begin, key_end, begin, iter)); + AXPropertyNode* child_node = + node->ConnectTo(chained, key_begin, key_end, begin, iter); + key_begin = key_end = end; - begin = iter = Parse(&node->parameters.back(), ++iter, end); + begin = iter = Parse(child_node, ++iter, end); continue; } // Subnode begins: a special case for arrays, which have [arg1, ..., argN] // form. if (*iter == '[') { - node->parameters.push_back(AXPropertyNode(key_begin, key_end, "[]")); + AXPropertyNode* child_node = + node->AppendToArguments(key_begin, key_end, "[]"); key_begin = key_end = end; - begin = iter = Parse(&node->parameters.back(), ++iter, end); + begin = iter = Parse(child_node, ++iter, end); continue; } // Subnode begins: a special case for dictionaries of {key1: value1, ..., // key2: value2} form. if (*iter == '{') { - node->parameters.push_back(AXPropertyNode(key_begin, key_end, "{}")); + AXPropertyNode* child_node = + node->AppendToArguments(key_begin, key_end, "{}"); key_begin = key_end = end; - begin = iter = Parse(&node->parameters.back(), ++iter, end); + begin = iter = Parse(child_node, ++iter, end); continue; } // Subnode ends. if (*iter == ')' || *iter == ']' || *iter == '}') { if (begin != iter) { - node->parameters.push_back( - AXPropertyNode(key_begin, key_end, begin, iter)); + node->ConnectTo(chained, key_begin, key_end, begin, iter); key_begin = key_end = end; } + chained = false; return ++iter; } @@ -238,13 +228,25 @@ continue; } - // Subsequent scalar param case. - if (*iter == ',' && begin != iter) { - node->parameters.push_back( - AXPropertyNode(key_begin, key_end, begin, iter)); - iter++; - key_begin = key_end = end; - begin = iter; + // Call chains. + if (*iter == '.') { + if (begin != iter) { + node->ConnectTo(chained, key_begin, key_end, begin, iter); + key_begin = key_end = end; + } + begin = ++iter; + chained = true; + continue; + } + + // Subsequent literal case. + if (*iter == ',') { + if (begin != iter) { + node->ConnectTo(chained, key_begin, key_end, begin, iter); + key_begin = key_end = end; + } + chained = false; + begin = ++iter; continue; } @@ -253,7 +255,7 @@ // Single scalar param case. if (begin != iter) { - node->parameters.push_back(AXPropertyNode(begin, iter)); + node->ConnectTo(chained, begin, iter); } return iter; }
diff --git a/ui/accessibility/platform/inspect/ax_property_node.h b/ui/accessibility/platform/inspect/ax_property_node.h index 42e058e..35b8309e 100644 --- a/ui/accessibility/platform/inspect/ax_property_node.h +++ b/ui/accessibility/platform/inspect/ax_property_node.h
@@ -16,7 +16,7 @@ struct AXPropertyFilter; // Property node is a tree-like structure, representing a property or collection -// of properties and its invocation parameters. A collection of properties is +// of properties and its invocation arguments. A collection of properties is // specified by putting a wildcard into a property name, for exampe, AXRole* // will match both AXRole and AXRoleDescription properties. Parameters of a // property are given in parentheses like a conventional function call, for @@ -37,29 +37,50 @@ // Key name in case of { key: value } dictionary. std::string key; - // An object the property should be called for, designated by a line number - // in accessible tree the object is located at. For example, :1 indicates - // that the property should be called for an object located at first line. - std::string target; - - // Value or a property name, for example 3 or AXLineForIndex + // Value or a property(method) name, for example 3 or AXLineForIndex std::string name_or_value; - // Parameters if it's a property, for example, it is a vector of a single + // Arguments if it's a method, for example, it is a vector of a single // value 3 in case of AXLineForIndex(3) - std::vector<AXPropertyNode> parameters; + std::vector<AXPropertyNode> arguments; - // Used to store the origianl unparsed property including invocation - // parameters if any. + // Next property node in a chain if any. + std::unique_ptr<AXPropertyNode> next; + + // Used to store the original unparsed property including invocation + // arguments if any. std::string original_property; // The list of line indexes of accessible objects the property is allowed to // be called for, used if no property target is provided. std::vector<std::string> line_indexes; + template <class... Args> + AXPropertyNode* ConnectTo(bool chained, Args&&... args) { + return chained ? ChainToLastArgument(std::forward<Args>(args)...) + : AppendToArguments(std::forward<Args>(args)...); + } + + template <class... Args> + AXPropertyNode* AppendToArguments(Args&&... args) { + arguments.emplace_back(std::forward<Args>(args)...); + return &arguments.back(); + } + template <class... Args> + AXPropertyNode* ChainToLastArgument(Args&&... args) { + auto* last = &arguments.back(); + while (last->next) { + last = last->next.get(); + } + last->next = std::make_unique<AXPropertyNode>( + AXPropertyNode(std::forward<Args>(args)...)); + return last->next.get(); + } + bool IsMatching(const std::string& pattern) const; // Argument conversion methods. + bool IsTarget() const { return !!next; } bool IsArray() const; bool IsDict() const; absl::optional<int> AsInt() const; @@ -67,7 +88,10 @@ absl::optional<std::string> FindStringKey(const char* refkey) const; absl::optional<int> FindIntKey(const char* key) const; + // Returns a string representation of the node. std::string ToString() const; + // Returns a tree-like string representation of the node. + std::string ToTreeString(const std::string& indent = "") const; private: using iterator = std::string::const_iterator; @@ -81,12 +105,11 @@ iterator value_begin, iterator value_end); - // Helper to set context and name. - void Set(iterator begin, iterator end); - // Builds a property node struct for a string of NAME(ARG1, ..., ARGN) format, // where each ARG is a scalar value or a string of the same format. static iterator Parse(AXPropertyNode* node, iterator begin, iterator end); + + friend class std::allocator<AXPropertyNode>; }; } // namespace ui
diff --git a/ui/accessibility/platform/inspect/ax_property_node_unittest.cc b/ui/accessibility/platform/inspect/ax_property_node_unittest.cc index 198167d..a22ac43 100644 --- a/ui/accessibility/platform/inspect/ax_property_node_unittest.cc +++ b/ui/accessibility/platform/inspect/ax_property_node_unittest.cc
@@ -30,10 +30,10 @@ AXPropertyNode GetArgumentNode(const char* input) { auto got = Parse(input); - if (got.parameters.size() == 0) { + if (got.arguments.size() == 0) { return AXPropertyNode(); } - return std::move(got.parameters[0]); + return std::move(got.arguments[0]); } void ParseAndCheck(const char* input, const char* expected) { @@ -41,24 +41,9 @@ EXPECT_EQ(got, expected); } -struct ProperyNodeCheck { - std::string target; - std::string name_or_value; - std::vector<ProperyNodeCheck> parameters; -}; - -void Check(const AXPropertyNode& got, const ProperyNodeCheck& expected) { - EXPECT_EQ(got.target, expected.target); - EXPECT_EQ(got.name_or_value, expected.name_or_value); - EXPECT_EQ(got.parameters.size(), expected.parameters.size()); - for (auto i = 0U; - i < std::min(expected.parameters.size(), got.parameters.size()); i++) { - Check(got.parameters[i], expected.parameters[i]); - } -} - -void ParseAndCheck(const char* input, const ProperyNodeCheck& expected) { - Check(Parse(input), expected); +void ParseAndCheckTree(const char* input, const char* expected) { + auto got = Parse(input).ToTreeString(); + EXPECT_EQ(got, expected); } TEST_F(AXPropertyNodeTest, ParseProperty) { @@ -88,17 +73,6 @@ // Line indexes filter. ParseAndCheck(":3,:5;AXDOMClassList", ":3,:5;AXDOMClassList"); - // Context object. - ParseAndCheck(":1.AXDOMClassList", ":1.AXDOMClassList"); - ParseAndCheck(":1.AXDOMClassList", {":1", "AXDOMClassList"}); - - ParseAndCheck(":1.AXIndexForTextMarker(:1.AXTextMarkerForIndex(0))", - ":1.AXIndexForTextMarker(:1.AXTextMarkerForIndex(0))"); - ParseAndCheck(":1.AXIndexForTextMarker(:1.AXTextMarkerForIndex(0))", - {":1", - "AXIndexForTextMarker", - {{":1", "AXTextMarkerForIndex", {{"", "0"}}}}}); - // Wrong format. ParseAndCheck("Role(3", "Role(3)"); ParseAndCheck("TableFor(CellBy(id", "TableFor(CellBy(id))"); @@ -144,4 +118,56 @@ "anchor: {}(:2, 1, down)"); } +TEST_F(AXPropertyNodeTest, CallChains) { + ParseAndCheckTree("textbox.name", R"~~(textbox. +name)~~"); + + ParseAndCheckTree("textbox.parent.name", + R"~~(textbox. +parent. +name)~~"); + + ParseAndCheckTree("table.rowAt(row.childIndex)", + R"~~(table. +rowAt( + row. + childIndex +))~~"); + + ParseAndCheckTree(":1.AXDOMClassList", R"~~(:1. +AXDOMClassList)~~"); + + ParseAndCheckTree(":1.AXIndexForTextMarker(:1.AXTextMarkerForIndex(0))", + R"~~(:1. +AXIndexForTextMarker( + :1. + AXTextMarkerForIndex( + 0 + ) +))~~"); + + ParseAndCheckTree("table.cellAt(cell.rowIndex, cell.columnIndex)", + R"~~(table. +cellAt( + cell. + rowIndex, + cell. + columnIndex +))~~"); + + ParseAndCheckTree( + "table.cellAt(table.rowIndexFor(cell), table.columnIndexFor(cell))", + R"~~(table. +cellAt( + table. + rowIndexFor( + cell + ), + table. + columnIndexFor( + cell + ) +))~~"); +} + } // namespace ui
diff --git a/ui/android/javatests/src/org/chromium/ui/test/util/RenderTestRule.java b/ui/android/javatests/src/org/chromium/ui/test/util/RenderTestRule.java index 1d89c2e4..e18d5d71d 100644 --- a/ui/android/javatests/src/org/chromium/ui/test/util/RenderTestRule.java +++ b/ui/android/javatests/src/org/chromium/ui/test/util/RenderTestRule.java
@@ -234,6 +234,8 @@ ((AnimatedVectorDrawableCompat) drawable).stop(); } } + // Scrollbars fade slowly, making tests flaky due to differences in rendered images. + view.setVerticalScrollBarEnabled(false); } /**
diff --git a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc index 2f3d4bb..f8d200a 100644 --- a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc +++ b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
@@ -94,12 +94,17 @@ static_cast<BitmapCursorOzone*>(platform_cursor.get())); } -BitmapCursorOzone::BitmapCursorOzone(mojom::CursorType type) : type_(type) {} +BitmapCursorOzone::BitmapCursorOzone(mojom::CursorType type, + float cursor_image_scale_factor) + : type_(type), cursor_image_scale_factor_(cursor_image_scale_factor) {} BitmapCursorOzone::BitmapCursorOzone(mojom::CursorType type, const SkBitmap& bitmap, - const gfx::Point& hotspot) - : type_(type), hotspot_(hotspot) { + const gfx::Point& hotspot, + float cursor_image_scale_factor) + : type_(type), + hotspot_(hotspot), + cursor_image_scale_factor_(cursor_image_scale_factor) { if (!bitmap.isNull()) bitmaps_.push_back(bitmap); } @@ -107,11 +112,13 @@ BitmapCursorOzone::BitmapCursorOzone(mojom::CursorType type, const std::vector<SkBitmap>& bitmaps, const gfx::Point& hotspot, - base::TimeDelta frame_delay) + base::TimeDelta frame_delay, + float cursor_image_scale_factor) : type_(type), bitmaps_(bitmaps), hotspot_(hotspot), - frame_delay_(frame_delay) { + frame_delay_(frame_delay), + cursor_image_scale_factor_(cursor_image_scale_factor) { DCHECK_LT(0U, bitmaps.size()); DCHECK_LE(base::TimeDelta(), frame_delay); // No null bitmap should be in the list. Blank cursors should just be an empty @@ -122,8 +129,11 @@ } BitmapCursorOzone::BitmapCursorOzone(mojom::CursorType type, - void* platform_data) - : type_(type), platform_data_(platform_data) {} + void* platform_data, + float cursor_image_scale_factor) + : type_(type), + platform_data_(platform_data), + cursor_image_scale_factor_(cursor_image_scale_factor) {} BitmapCursorOzone::~BitmapCursorOzone() = default; @@ -158,7 +168,8 @@ // Lacros uses server-side cursors for most types. These cursors don't // need to load bitmap images on the client. // Similarly, the hidden cursor doesn't use any bitmap. - default_cursors_[type] = base::MakeRefCounted<BitmapCursorOzone>(type); + default_cursors_[type] = + base::MakeRefCounted<BitmapCursorOzone>(type, cursor_scale_factor_); } else { return nullptr; } @@ -171,7 +182,8 @@ mojom::CursorType type, const SkBitmap& bitmap, const gfx::Point& hotspot) { - return base::MakeRefCounted<BitmapCursorOzone>(type, bitmap, hotspot); + return base::MakeRefCounted<BitmapCursorOzone>(type, bitmap, hotspot, + cursor_scale_factor_); } scoped_refptr<PlatformCursor> BitmapCursorFactoryOzone::CreateAnimatedCursor( @@ -180,8 +192,13 @@ const gfx::Point& hotspot, base::TimeDelta frame_delay) { DCHECK_LT(0U, bitmaps.size()); - return base::MakeRefCounted<BitmapCursorOzone>(type, bitmaps, hotspot, - frame_delay); + return base::MakeRefCounted<BitmapCursorOzone>( + type, bitmaps, hotspot, frame_delay, cursor_scale_factor_); +} + +void BitmapCursorFactoryOzone::SetDeviceScaleFactor(float scale) { + DCHECK_GT(scale, 0.f); + cursor_scale_factor_ = scale; } } // namespace ui
diff --git a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h index b217791..3ba4755b 100644 --- a/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h +++ b/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h
@@ -30,21 +30,26 @@ // Creates a cursor that doesn't need backing bitmaps (for example, a // server-side cursor for Lacros). - explicit BitmapCursorOzone(mojom::CursorType type); + explicit BitmapCursorOzone(mojom::CursorType type, + float cursor_image_scale_factor); // Creates a cursor with a single backing bitmap. BitmapCursorOzone(mojom::CursorType type, const SkBitmap& bitmap, - const gfx::Point& hotspot); + const gfx::Point& hotspot, + float cursor_image_scale_factor); // Creates a cursor with multiple bitmaps for animation. BitmapCursorOzone(mojom::CursorType type, const std::vector<SkBitmap>& bitmaps, const gfx::Point& hotspot, - base::TimeDelta frame_delay); + base::TimeDelta frame_delay, + float cursor_image_scale_factor); // Creates a cursor with external storage. - BitmapCursorOzone(mojom::CursorType type, void* platform_data); + BitmapCursorOzone(mojom::CursorType type, + void* platform_data, + float cursor_image_scale_factor); mojom::CursorType type() const { return type_; } const gfx::Point& hotspot(); @@ -57,6 +62,8 @@ // For theme cursors. void* platform_data() { return platform_data_; } + float cursor_image_scale_factor() const { return cursor_image_scale_factor_; } + private: friend class base::RefCounted<PlatformCursor>; ~BitmapCursorOzone() override; @@ -70,6 +77,8 @@ // is supplied by the platform. void* const platform_data_ = nullptr; + float cursor_image_scale_factor_ = 1.f; + DISALLOW_COPY_AND_ASSIGN(BitmapCursorOzone); }; @@ -95,10 +104,12 @@ const std::vector<SkBitmap>& bitmaps, const gfx::Point& hotspot, base::TimeDelta frame_delay) override; + void SetDeviceScaleFactor(float scale) override; private: std::map<mojom::CursorType, scoped_refptr<BitmapCursorOzone>> default_cursors_; + float cursor_scale_factor_ = 1.f; DISALLOW_COPY_AND_ASSIGN(BitmapCursorFactoryOzone); };
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc index 42593b2..a35a9e1 100644 --- a/ui/compositor/layer_unittest.cc +++ b/ui/compositor/layer_unittest.cc
@@ -23,7 +23,9 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/test/bind.h" +#include "base/test/scoped_run_loop_timeout.h" #include "base/test/task_environment.h" +#include "base/test/test_timeouts.h" #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" @@ -1881,13 +1883,12 @@ } // Checks that basic background blur is working. -// TODO(crbug.com/1174372) Flaky on Windows -#if defined(OS_WIN) -#define MAYBE_BackgroundBlur DISABLED_BackgroundBlur -#else -#define MAYBE_BackgroundBlur BackgroundBlur +TEST_F(LayerWithRealCompositorTest, BackgroundBlur) { +#if defined(THREAD_SANITIZER) + const base::test::ScopedRunLoopTimeout increased_run_timeout( + FROM_HERE, TestTimeouts::action_max_timeout()); #endif -TEST_F(LayerWithRealCompositorTest, MAYBE_BackgroundBlur) { + viz::ParentLocalSurfaceIdAllocator allocator; allocator.GenerateId(); GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(200, 200),
diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py index 0713478..8b3d522 100755 --- a/ui/gl/generate_bindings.py +++ b/ui/gl/generate_bindings.py
@@ -2923,6 +2923,7 @@ 'GLES2/gl2extchromium.h' ], [ "GL_ANGLE_robust_resource_initialization", + "GL_ANGLE_webgl_compatibility", "GL_ARB_texture_swizzle", "GL_EXT_texture_swizzle", "GL_EXT_texture_format_BGRA8888",
diff --git a/ui/gl/gl_bindings_autogen_gl.cc b/ui/gl/gl_bindings_autogen_gl.cc index fe40cf0c..a4288491 100644 --- a/ui/gl/gl_bindings_autogen_gl.cc +++ b/ui/gl/gl_bindings_autogen_gl.cc
@@ -309,6 +309,8 @@ gfx::HasExtension(extensions, "GL_ANGLE_texture_external_update"); ext.b_GL_ANGLE_translated_shader_source = gfx::HasExtension(extensions, "GL_ANGLE_translated_shader_source"); + ext.b_GL_ANGLE_webgl_compatibility = + gfx::HasExtension(extensions, "GL_ANGLE_webgl_compatibility"); ext.b_GL_APPLE_fence = gfx::HasExtension(extensions, "GL_APPLE_fence"); ext.b_GL_APPLE_sync = gfx::HasExtension(extensions, "GL_APPLE_sync"); ext.b_GL_APPLE_vertex_array_object =
diff --git a/ui/gl/gl_bindings_autogen_gl.h b/ui/gl/gl_bindings_autogen_gl.h index cf41327ad5..170cf3fd 100644 --- a/ui/gl/gl_bindings_autogen_gl.h +++ b/ui/gl/gl_bindings_autogen_gl.h
@@ -1966,6 +1966,7 @@ bool b_GL_ANGLE_semaphore_fuchsia; bool b_GL_ANGLE_texture_external_update; bool b_GL_ANGLE_translated_shader_source; + bool b_GL_ANGLE_webgl_compatibility; bool b_GL_APPLE_fence; bool b_GL_APPLE_sync; bool b_GL_APPLE_vertex_array_object;
diff --git a/ui/gl/gl_stub_autogen_gl.h b/ui/gl/gl_stub_autogen_gl.h index 84c2e018..72a2fdf 100644 --- a/ui/gl/gl_stub_autogen_gl.h +++ b/ui/gl/gl_stub_autogen_gl.h
@@ -8,8 +8,8 @@ // clang-format -i -style=chromium filename // DO NOT EDIT! -#ifndef UI_GL_GL_STUB_AUTOGEN_GL_H_ -#define UI_GL_GL_STUB_AUTOGEN_GL_H_ +#ifndef UI_GL_GL_STUB_AUTOGEN_H_ +#define UI_GL_GL_STUB_AUTOGEN_H_ void glActiveShaderProgramFn(GLuint pipeline, GLuint program) override {} void glActiveTextureFn(GLenum texture) override {} @@ -1664,4 +1664,4 @@ GLsizei n, const GLint* box) override {} -#endif // UI_GL_GL_STUB_AUTOGEN_GL_H_ +#endif // UI_GL_GL_STUB_AUTOGEN_H_ \ No newline at end of file
diff --git a/ui/gl/gl_utils.cc b/ui/gl/gl_utils.cc index 70fa53a..116f4df 100644 --- a/ui/gl/gl_utils.cc +++ b/ui/gl/gl_utils.cc
@@ -33,6 +33,10 @@ #include "ui/gl/gl_implementation.h" // nogncheck #endif +#if defined(OS_MAC) +#include "ui/gl/gl_bindings.h" +#endif + namespace gl { // Used by chrome://gpucrash and gpu_benchmarking_extension's @@ -186,4 +190,25 @@ } #endif // defined(USE_X11) || BUILDFLAG(OZONE_PLATFORM_X11) +#if defined(OS_MAC) + +ScopedEnableTextureRectangleInShaderCompiler:: + ScopedEnableTextureRectangleInShaderCompiler(gl::GLApi* gl_api) { + if (gl_api) { + DCHECK(!gl_api->glIsEnabledFn(GL_TEXTURE_RECTANGLE_ANGLE)); + gl_api->glEnableFn(GL_TEXTURE_RECTANGLE_ANGLE); + gl_api_ = gl_api; + } else { + gl_api_ = nullptr; // Signal to the destructor that this is a no-op. + } +} + +ScopedEnableTextureRectangleInShaderCompiler:: + ~ScopedEnableTextureRectangleInShaderCompiler() { + if (gl_api_) + gl_api_->glDisableFn(GL_TEXTURE_RECTANGLE_ANGLE); +} + +#endif // defined(OS_MAC) + } // namespace gl
diff --git a/ui/gl/gl_utils.h b/ui/gl/gl_utils.h index 0ac70a4a..b4fdf6d 100644 --- a/ui/gl/gl_utils.h +++ b/ui/gl/gl_utils.h
@@ -31,6 +31,8 @@ #endif namespace gl { +class GLApi; + GL_EXPORT void Crash(); GL_EXPORT void Hang(); @@ -67,6 +69,31 @@ gfx::GpuExtraInfo& info); #endif +// Temporarily allows compilation of shaders that use the +// ARB_texture_rectangle/ANGLE_texture_rectangle extension. We don't want to +// expose the extension to WebGL user shaders but we still need to use it for +// parts of the implementation on macOS. Note that the extension is always +// enabled on macOS and this only controls shader compilation. +class GL_EXPORT ScopedEnableTextureRectangleInShaderCompiler { + public: + ScopedEnableTextureRectangleInShaderCompiler( + const ScopedEnableTextureRectangleInShaderCompiler&) = delete; + ScopedEnableTextureRectangleInShaderCompiler& operator=( + const ScopedEnableTextureRectangleInShaderCompiler&) = delete; + + // This class is a no-op except on macOS. +#if !defined(OS_MAC) + explicit ScopedEnableTextureRectangleInShaderCompiler(gl::GLApi* gl_api) {} + +#else + explicit ScopedEnableTextureRectangleInShaderCompiler(gl::GLApi* gl_api); + ~ScopedEnableTextureRectangleInShaderCompiler(); + + private: + gl::GLApi* gl_api_; +#endif +}; + } // namespace gl #endif // UI_GL_GL_UTILS_H_
diff --git a/ui/gl/yuv_to_rgb_converter.cc b/ui/gl/yuv_to_rgb_converter.cc index e6be831..5ce114f 100644 --- a/ui/gl/yuv_to_rgb_converter.cc +++ b/ui/gl/yuv_to_rgb_converter.cc
@@ -9,6 +9,7 @@ #include "base/strings/stringprintf.h" #include "ui/gfx/color_transform.h" #include "ui/gl/gl_helper.h" +#include "ui/gl/gl_utils.h" #include "ui/gl/gl_version_info.h" #include "ui/gl/scoped_binders.h" @@ -158,17 +159,30 @@ glGenFramebuffersEXT(1, &framebuffer_); - vertex_buffer_ = GLHelper::SetupQuadVertexBuffer(); - vertex_shader_ = GLHelper::LoadShader( - GL_VERTEX_SHADER, - base::StringPrintf("%s\n%s", vertex_header, kVertexShader).c_str()); - fragment_shader_ = GLHelper::LoadShader( - GL_FRAGMENT_SHADER, - base::StringPrintf("%s\n%s\n%s", fragment_header, - do_color_conversion.c_str(), - (is_rect ? kFragmentShaderRect : kFragmentShader2D)) - .c_str()); - program_ = GLHelper::SetupProgram(vertex_shader_, fragment_shader_); + { + // In contexts that are in WebGL compatibility mode, we need to temporarily + // enable GL_ANGLE_TEXTURE_RECTANGLE in order to compile the fragment + // shader. Furthermore, in ES2 contexts, the GL_ANGLE_webgl_compatibility + // extension is required for using GL_ANGLE_TEXTURE_RECTANGLE as an argument + // to glEnable/Disable. Therefore the GL_ANGLE_webgl_compatibility + // extension is a necessary and sufficient condition for determining whether + // GL_ANGLE_TEXTURE_RECTANGLE needs to be temporarily enabled. + ScopedEnableTextureRectangleInShaderCompiler enable( + (is_rect && g_current_gl_driver->ext.b_GL_ANGLE_webgl_compatibility) + ? g_current_gl_context + : nullptr); + vertex_buffer_ = GLHelper::SetupQuadVertexBuffer(); + vertex_shader_ = GLHelper::LoadShader( + GL_VERTEX_SHADER, + base::StringPrintf("%s\n%s", vertex_header, kVertexShader).c_str()); + fragment_shader_ = GLHelper::LoadShader( + GL_FRAGMENT_SHADER, + base::StringPrintf("%s\n%s\n%s", fragment_header, + do_color_conversion.c_str(), + (is_rect ? kFragmentShaderRect : kFragmentShader2D)) + .c_str()); + program_ = GLHelper::SetupProgram(vertex_shader_, fragment_shader_); + } ScopedUseProgram use_program(program_); size_location_ = glGetUniformLocation(program_, "a_texScale");
diff --git a/ui/ozone/platform/wayland/host/wayland_cursor_factory.cc b/ui/ozone/platform/wayland/host/wayland_cursor_factory.cc index 855e347e..130a0b95 100644 --- a/ui/ozone/platform/wayland/host/wayland_cursor_factory.cc +++ b/ui/ozone/platform/wayland/host/wayland_cursor_factory.cc
@@ -58,7 +58,7 @@ continue; current_theme_->cache[type] = - base::MakeRefCounted<BitmapCursorOzone>(type, cursor); + base::MakeRefCounted<BitmapCursorOzone>(type, cursor, scale_); break; } }
diff --git a/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc b/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc index ce0ef4b..d24ffed 100644 --- a/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc
@@ -276,36 +276,49 @@ Mock::VerifyAndClearExpectations(pointer_); } -TEST_P(WaylandPointerTest, SetBitmapOnPointerFocus) { - SkBitmap dummy_cursor; - SkImageInfo info = - SkImageInfo::Make(10, 10, SkColorType::kBGRA_8888_SkColorType, - SkAlphaType::kPremul_SkAlphaType); - dummy_cursor.allocPixels(info, 10 * 4); +// Tests that bitmap is set on pointer focus and the pointer surface respects +// provided scale of the surface image. +TEST_P(WaylandPointerTest, SetBitmapAndScaleOnPointerFocus) { + for (int32_t scale = 1; scale < 5; scale++) { + gfx::Size size = {10 * scale, 10 * scale}; + SkBitmap dummy_cursor; + SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), + SkColorType::kBGRA_8888_SkColorType, + SkAlphaType::kPremul_SkAlphaType); + dummy_cursor.allocPixels(info, size.width() * 4); - BitmapCursorFactoryOzone cursor_factory; - auto cursor = cursor_factory.CreateImageCursor( - mojom::CursorType::kCustom, dummy_cursor, gfx::Point(5, 8)); + BitmapCursorFactoryOzone cursor_factory; + cursor_factory.SetDeviceScaleFactor(scale); + auto cursor = cursor_factory.CreateImageCursor( + mojom::CursorType::kCustom, dummy_cursor, gfx::Point(5, 8)); - EXPECT_CALL(*pointer_, SetCursor(Ne(nullptr), 5, 8)); - window_->SetCursor(cursor); - connection_->ScheduleFlush(); + wl_resource* surface_resource = nullptr; + EXPECT_CALL(*pointer_, SetCursor(Ne(nullptr), 5, 8)) + .WillOnce(SaveArg<0>(&surface_resource)); + window_->SetCursor(cursor); + connection_->ScheduleFlush(); - Sync(); + Sync(); - Mock::VerifyAndClearExpectations(pointer_); + ASSERT_TRUE(surface_resource); + auto* mock_pointer_surface = + wl::MockSurface::FromResource(surface_resource); + EXPECT_EQ(mock_pointer_surface->buffer_scale(), scale); - EXPECT_CALL(*pointer_, SetCursor(Ne(nullptr), 5, 8)); - wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), - wl_fixed_from_int(50), wl_fixed_from_int(75)); + Mock::VerifyAndClearExpectations(pointer_); - Sync(); + EXPECT_CALL(*pointer_, SetCursor(Ne(nullptr), 5, 8)); + wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), + wl_fixed_from_int(50), wl_fixed_from_int(75)); - connection_->ScheduleFlush(); + Sync(); - Sync(); + connection_->ScheduleFlush(); - Mock::VerifyAndClearExpectations(pointer_); + Sync(); + + Mock::VerifyAndClearExpectations(pointer_); + } } #if BUILDFLAG(IS_CHROMEOS_LACROS)
diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc index fc87907ca..58d6c256 100644 --- a/ui/ozone/platform/wayland/host/wayland_window.cc +++ b/ui/ozone/platform/wayland/host/wayland_window.cc
@@ -866,11 +866,15 @@ absl::optional<int32_t> shape = WaylandZcrCursorShapes::ShapeFromType(cursor->type()); + // Round cursor scale factor to ceil as wl_surface.set_buffer_scale accepts + // only integers. if (cursor->type() == CursorType::kNone) { // Hide the cursor. - connection_->SetCursorBitmap({}, gfx::Point(), buffer_scale()); + connection_->SetCursorBitmap( + {}, gfx::Point(), std::ceil(cursor->cursor_image_scale_factor())); } else if (cursor->platform_data()) { // Check for theme-provided cursor. connection_->SetPlatformCursor( - reinterpret_cast<wl_cursor*>(cursor->platform_data()), buffer_scale()); + reinterpret_cast<wl_cursor*>(cursor->platform_data()), + std::ceil(cursor->cursor_image_scale_factor())); } else if (connection_->zcr_cursor_shapes() && shape.has_value()) { // Check for Wayland server-side cursor // support (e.g. exo for lacros). @@ -884,8 +888,9 @@ // Translate physical pixels to DIPs. gfx::Point hotspot_in_dips = gfx::ScaleToRoundedPoint(cursor->hotspot(), 1.0f / ui_scale_); - connection_->SetCursorBitmap(cursor->bitmaps(), hotspot_in_dips, - buffer_scale()); + connection_->SetCursorBitmap( + cursor->bitmaps(), hotspot_in_dips, + std::ceil(cursor->cursor_image_scale_factor())); } // The new cursor needs to be stored last to avoid deleting the old cursor // while it's still in use.
diff --git a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc index 2e358d1..8f96876 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
@@ -61,6 +61,8 @@ namespace { +constexpr float kDefaultCursorScale = 1.f; + struct PopupPosition { gfx::Rect anchor_rect; gfx::Size size; @@ -1031,27 +1033,27 @@ // Verify some commonly-used cursors. EXPECT_CALL(*mock_cursor_shapes, SetCursorShape(ZCR_CURSOR_SHAPES_V1_CURSOR_SHAPE_TYPE_POINTER)); - auto pointer_cursor = - base::MakeRefCounted<BitmapCursorOzone>(mojom::CursorType::kPointer); + auto pointer_cursor = base::MakeRefCounted<BitmapCursorOzone>( + mojom::CursorType::kPointer, kDefaultCursorScale); window_->SetCursor(pointer_cursor.get()); EXPECT_CALL(*mock_cursor_shapes, SetCursorShape(ZCR_CURSOR_SHAPES_V1_CURSOR_SHAPE_TYPE_HAND)); - auto hand_cursor = - base::MakeRefCounted<BitmapCursorOzone>(mojom::CursorType::kHand); + auto hand_cursor = base::MakeRefCounted<BitmapCursorOzone>( + mojom::CursorType::kHand, kDefaultCursorScale); window_->SetCursor(hand_cursor.get()); EXPECT_CALL(*mock_cursor_shapes, SetCursorShape(ZCR_CURSOR_SHAPES_V1_CURSOR_SHAPE_TYPE_IBEAM)); - auto ibeam_cursor = - base::MakeRefCounted<BitmapCursorOzone>(mojom::CursorType::kIBeam); + auto ibeam_cursor = base::MakeRefCounted<BitmapCursorOzone>( + mojom::CursorType::kIBeam, kDefaultCursorScale); window_->SetCursor(ibeam_cursor.get()); } TEST_P(WaylandWindowTest, SetCursorCallsZcrCursorShapesOncePerCursor) { MockZcrCursorShapes* mock_cursor_shapes = InstallMockZcrCursorShapes(); - auto hand_cursor = - base::MakeRefCounted<BitmapCursorOzone>(mojom::CursorType::kHand); + auto hand_cursor = base::MakeRefCounted<BitmapCursorOzone>( + mojom::CursorType::kHand, kDefaultCursorScale); // Setting the same cursor twice on the client only calls the server once. EXPECT_CALL(*mock_cursor_shapes, SetCursorShape(_)).Times(1); window_->SetCursor(hand_cursor.get()); @@ -1061,8 +1063,8 @@ TEST_P(WaylandWindowTest, SetCursorDoesNotUseZcrCursorShapesForNoneCursor) { MockZcrCursorShapes* mock_cursor_shapes = InstallMockZcrCursorShapes(); EXPECT_CALL(*mock_cursor_shapes, SetCursorShape(_)).Times(0); - auto none_cursor = - base::MakeRefCounted<BitmapCursorOzone>(mojom::CursorType::kNone); + auto none_cursor = base::MakeRefCounted<BitmapCursorOzone>( + mojom::CursorType::kNone, kDefaultCursorScale); window_->SetCursor(none_cursor.get()); } @@ -1072,7 +1074,8 @@ // Custom cursors require bitmaps, so they do not use server-side cursors. EXPECT_CALL(*mock_cursor_shapes, SetCursorShape(_)).Times(0); auto custom_cursor = base::MakeRefCounted<BitmapCursorOzone>( - mojom::CursorType::kCustom, SkBitmap(), gfx::Point()); + mojom::CursorType::kCustom, SkBitmap(), gfx::Point(), + kDefaultCursorScale); window_->SetCursor(custom_cursor.get()); }
diff --git a/ui/ozone/platform/wayland/test/mock_surface.cc b/ui/ozone/platform/wayland/test/mock_surface.cc index 2bfc7d1..9ea870d 100644 --- a/ui/ozone/platform/wayland/test/mock_surface.cc +++ b/ui/ozone/platform/wayland/test/mock_surface.cc
@@ -61,7 +61,9 @@ } void SetBufferScale(wl_client* client, wl_resource* resource, int32_t scale) { - GetUserDataAs<MockSurface>(resource)->SetBufferScale(scale); + auto* mock_surface = GetUserDataAs<MockSurface>(resource); + mock_surface->SetBufferScale(scale); + mock_surface->set_buffer_scale(scale); } void DamageBuffer(struct wl_client* client,
diff --git a/ui/ozone/platform/wayland/test/mock_surface.h b/ui/ozone/platform/wayland/test/mock_surface.h index 6648ffe..0eef04df 100644 --- a/ui/ozone/platform/wayland/test/mock_surface.h +++ b/ui/ozone/platform/wayland/test/mock_surface.h
@@ -86,6 +86,9 @@ gfx::GpuFenceHandle release_fence); void SendFrameCallback(); + int32_t buffer_scale() const { return buffer_scale_; } + void set_buffer_scale(int32_t buffer_scale) { buffer_scale_ = buffer_scale; } + private: MockXdgSurface* xdg_surface_ = nullptr; TestSubSurface* sub_surface_ = nullptr; @@ -99,6 +102,8 @@ wl_resource* attached_buffer_ = nullptr; wl_resource* prev_attached_buffer_ = nullptr; + int32_t buffer_scale_ = -1; + DISALLOW_COPY_AND_ASSIGN(MockSurface); };
diff --git a/ui/views/bubble/bubble_dialog_delegate_view.cc b/ui/views/bubble/bubble_dialog_delegate_view.cc index 469bdc91..9a6245a7 100644 --- a/ui/views/bubble/bubble_dialog_delegate_view.cc +++ b/ui/views/bubble/bubble_dialog_delegate_view.cc
@@ -317,8 +317,15 @@ BubbleBorder::Arrow arrow, BubbleBorder::Shadow shadow) : arrow_(arrow), shadow_(shadow) { - SetAnchorView(anchor_view); SetOwnedByWidget(true); + SetAnchorView(anchor_view); + SetArrow(arrow); + SetShowCloseButton(false); + + LayoutProvider* const layout_provider = LayoutProvider::Get(); + set_margins(layout_provider->GetDialogInsetsForContentType( + DialogContentType::kText, DialogContentType::kText)); + set_title_margins(layout_provider->GetInsetsMetric(INSETS_DIALOG_TITLE)); } BubbleDialogDelegate::~BubbleDialogDelegate() { @@ -377,15 +384,6 @@ BubbleBorder::Shadow shadow) : BubbleDialogDelegate(anchor_view, arrow, shadow) { set_owned_by_client(); - WidgetDelegate::SetShowCloseButton(false); - - SetArrow(arrow); - LayoutProvider* provider = LayoutProvider::Get(); - // An individual bubble should override these margins if its layout differs - // from the typical title/text/buttons. - set_margins(provider->GetDialogInsetsForContentType( - DialogContentType::kText, DialogContentType::kText)); - set_title_margins(provider->GetInsetsMetric(INSETS_DIALOG_TITLE)); UMA_HISTOGRAM_BOOLEAN("Dialog.BubbleDialogDelegateView.Create", true); }
diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.h b/ui/views/cocoa/native_widget_mac_ns_window_host.h index c164c3a8..9f5543d 100644 --- a/ui/views/cocoa/native_widget_mac_ns_window_host.h +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h
@@ -220,12 +220,14 @@ // Used by NativeWidgetPrivate::GetGlobalCapture. static NSView* GetGlobalCaptureView(); - // Add and Update the remote window controls overlay view for a PWA. + // Add, update and remove the remote window controls overlay view for a PWA. void AddRemoteWindowControlsOverlayView( remote_cocoa::mojom::WindowControlsOverlayNSViewType overlay_type); void UpdateRemoteWindowControlsOverlayView( const gfx::Rect& bounds, remote_cocoa::mojom::WindowControlsOverlayNSViewType overlay_type); + void RemoveRemoteWindowControlsOverlayView( + remote_cocoa::mojom::WindowControlsOverlayNSViewType overlay_type); private: friend class TextInputHost;
diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.mm b/ui/views/cocoa/native_widget_mac_ns_window_host.mm index d20f9af..a756f7b 100644 --- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
@@ -753,6 +753,10 @@ GetNSWindowMojo()->UpdateWindowControlsOverlayNSView(bounds, overlay_type); } +void NativeWidgetMacNSWindowHost::RemoveRemoteWindowControlsOverlayView( + remote_cocoa::mojom::WindowControlsOverlayNSViewType overlay_type) { + GetNSWindowMojo()->RemoveWindowControlsOverlayNSView(overlay_type); +} //////////////////////////////////////////////////////////////////////////////// // NativeWidgetMacNSWindowHost, remote_cocoa::BridgedNativeWidgetHostHelper:
diff --git a/ui/webui/resources/js/parse_html_subset.js b/ui/webui/resources/js/parse_html_subset.js index 01b33d238..4050ca3 100644 --- a/ui/webui/resources/js/parse_html_subset.js +++ b/ui/webui/resources/js/parse_html_subset.js
@@ -102,7 +102,7 @@ * @type {!Set<string>} * @const */ - const allowedOptionalTags = new Set(['IMG']); + const allowedOptionalTags = new Set(['IMG', 'LI', 'UL']); /** * This policy maps a given string to a `TrustedHTML` object
diff --git a/weblayer/renderer/content_renderer_client_impl.cc b/weblayer/renderer/content_renderer_client_impl.cc index d6a9ff83..b6483bd 100644 --- a/weblayer/renderer/content_renderer_client_impl.cc +++ b/weblayer/renderer/content_renderer_client_impl.cc
@@ -165,9 +165,8 @@ } } -void ContentRendererClientImpl::RenderViewCreated( - content::RenderView* render_view) { - new prerender::NoStatePrefetchClient(render_view->GetWebView()); +void ContentRendererClientImpl::WebViewCreated(blink::WebView* web_view) { + new prerender::NoStatePrefetchClient(web_view); } SkBitmap* ContentRendererClientImpl::GetSadPluginBitmap() {
diff --git a/weblayer/renderer/content_renderer_client_impl.h b/weblayer/renderer/content_renderer_client_impl.h index 32608be..b1d0f72 100644 --- a/weblayer/renderer/content_renderer_client_impl.h +++ b/weblayer/renderer/content_renderer_client_impl.h
@@ -31,7 +31,7 @@ // content::ContentRendererClient: void RenderThreadStarted() override; void RenderFrameCreated(content::RenderFrame* render_frame) override; - void RenderViewCreated(content::RenderView* render_view) override; + void WebViewCreated(blink::WebView* web_view) override; SkBitmap* GetSadPluginBitmap() override; SkBitmap* GetSadWebViewBitmap() override; void PrepareErrorPage(content::RenderFrame* render_frame,