diff --git a/AUTHORS b/AUTHORS index 4811fa1..a31f741 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -1382,6 +1382,7 @@ Utzcoz <utzcoz@gmail.com> UwU UwU <uwu7586@gmail.com> Uzair Jaleel <uzair.jaleel@samsung.com> +Uzochukwu Ochogu <uzochukwu.ochogu@gitstart.dev> Vadim Gorbachev <bmsdave@gmail.com> Vaibhav Agrawal <vaibhav1.a@samsung.com> Valentin Ilie <valentin.ilie@intel.com>
diff --git a/DEPS b/DEPS index f7f4f72..4540be9 100644 --- a/DEPS +++ b/DEPS
@@ -306,7 +306,7 @@ # 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': 'e13594df88a12baf3e1ba7ae8b98feaeb1f5482a', + 'skia_revision': '7903ebbe9a940d5792860cc447e11898253c7858', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -397,7 +397,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': 'c0b9c1d55ce45863d35215f0083917a27a1cbe75', + 'devtools_frontend_revision': '5e6e1f8975c2c9f24262f7b36af820525cb56604', # 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. @@ -421,7 +421,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': '1862fc490314e49777e253499ab3008d88223280', + 'dawn_revision': 'ca401b32db3e3f969c541ecff8bdeff246afd594', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -821,7 +821,7 @@ 'src/clank': { 'url': Var('chrome_git') + '/clank/internal/apps.git' + '@' + - 'f2d6158714d5eda293d2163014080fe65708fde6', + '8f4abea26f41af5854ff7540ca549e90f88c768a', 'condition': 'checkout_android and checkout_src_internal', }, @@ -983,7 +983,7 @@ 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'W4_wcd_lvPKzxsuvKesTIuR3Z1lsOfbmtU4mEXFhQosC', + 'version': 'pSbGRySDDFZqGrNz47N7f9wr2jt9bWBDYwREAzN4jdUC', }, ], 'condition': 'checkout_android', @@ -1201,7 +1201,7 @@ # For Linux and Chromium OS. 'src/third_party/cros_system_api': { - 'url': Var('chromium_git') + '/chromiumos/platform2/system_api.git' + '@' + '209d5157d57fabac8ab61af5be7c5a4770c80436', + 'url': Var('chromium_git') + '/chromiumos/platform2/system_api.git' + '@' + 'ba5195aeb44e0f6659b10c7463f6f2c355fad2dc', 'condition': 'checkout_linux', }, @@ -1221,7 +1221,7 @@ Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), 'src/third_party/devtools-frontend-internal': { - 'url': Var('chrome_git') + '/devtools/devtools-internal.git' + '@' + 'efe97a4717421c08b1724e81f38e4b2aa67fa1a0', + 'url': Var('chrome_git') + '/devtools/devtools-internal.git' + '@' + 'c4374dcc2760704adfbd4df64d14c89faab8ab57', 'condition': 'checkout_src_internal', }, @@ -1686,7 +1686,7 @@ Var('pdfium_git') + '/pdfium.git' + '@' + Var('pdfium_revision'), 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + '41a5723e9fbd48efbe79c8b2d46bf6e13aa67682', + Var('android_git') + '/platform/external/perfetto.git' + '@' + 'f389d82070a13a09ac799e6d8b457d1daf25fb27', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1726,7 +1726,7 @@ 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'vFBpAdZar_sS8W_xKvQThRv5XpFyYZP4bMzjigyTTcwC', + 'version': 'Vjgh6DGZpPhxYqNjulYH9ogpNFhkWn31RDgrWeRQmPcC', }, ], 'condition': 'checkout_android', @@ -1831,7 +1831,7 @@ 'dep_type': 'cipd', }, - 'src/third_party/vulkan-deps': '{chromium_git}/vulkan-deps@fe7ac4762e4704386b0b6b949c720614e0930d5d', + 'src/third_party/vulkan-deps': '{chromium_git}/vulkan-deps@05e2e582257cbeb1303ed863f2f9c412202769c7', 'src/third_party/vulkan_memory_allocator': Var('chromium_git') + '/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git' + '@' + '56300b29fbfcc693ee6609ddad3fdd5b7a449a21', @@ -1868,10 +1868,10 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + 'f4bf599a8b575df685c31d9c4729a70a04e377ed', 'src/third_party/webgpu-cts/src': - Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '35005a9ead81cb87feade372e8d1358dc75f0b17', + Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '591c655330a7611cfbe3167bbd48b1ad2d066151', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + 'd0269937a0e5ddbd9fafd35f2507b5236648edf6', + Var('webrtc_git') + '/src.git' + '@' + '0b78094234ea4eb12ea7b13ee178b4306af519a6', # Wuffs' canonical repository is at github.com/google/wuffs, but we use # Skia's mirror of Wuffs, the same as in upstream Skia's DEPS file. @@ -2038,7 +2038,7 @@ 'packages': [ { 'package': 'chromeos_internal/apps/projector_app/app', - 'version': 'qRHp4tkYM6kv2dRJpe6G1t9O_5nHhKF0NJINS_joaucC', + 'version': 'NzAuP4njlVexmTfcTRHsncoTFtHDRiisfQZvoulG-yEC', }, ], 'condition': 'checkout_chromeos and checkout_src_internal',
diff --git a/build/config/linux/libffi/BUILD.gn b/build/config/linux/libffi/BUILD.gn index 771170c3..6e45f4c2 100644 --- a/build/config/linux/libffi/BUILD.gn +++ b/build/config/linux/libffi/BUILD.gn
@@ -19,6 +19,6 @@ } } else { config("libffi") { - libs = [ ":libffi_pic.a" ] + libs = [ "ffi_pic" ] } }
diff --git a/cc/paint/paint_op_reader.cc b/cc/paint/paint_op_reader.cc index 06536c7..1535757 100644 --- a/cc/paint/paint_op_reader.cc +++ b/cc/paint/paint_op_reader.cc
@@ -200,7 +200,11 @@ // reading as two uint32_ts and combining the result. // https://crbug.com/1429994 uint64_t size64 = static_cast<uint64_t>(hi) << 32 | lo; - *size = base::checked_cast<size_t>(size64); + if (!base::IsValueInRangeForNumericType<size_t>(size64)) { + valid_ = false; + return; + } + *size = static_cast<size_t>(size64); } void PaintOpReader::Read(SkScalar* data) {
diff --git a/cc/raster/one_copy_raster_buffer_provider.cc b/cc/raster/one_copy_raster_buffer_provider.cc index b491cd4..bdf880c7 100644 --- a/cc/raster/one_copy_raster_buffer_provider.cc +++ b/cc/raster/one_copy_raster_buffer_provider.cc
@@ -360,20 +360,20 @@ auto* sii = worker_context_provider_->SharedImageInterface(); // Allocate MappableSharedImage if necessary. - if (staging_buffer->mailbox.IsZero()) { - auto client_shared_image = sii->CreateSharedImage( + if (!staging_buffer->client_shared_image) { + staging_buffer->client_shared_image = sii->CreateSharedImage( format, staging_buffer->size, dst_color_space, kTopLeft_GrSurfaceOrigin, kPremul_SkAlphaType, gpu::SHARED_IMAGE_USAGE_CPU_WRITE, "OneCopyRasterStaging", gpu::kNullSurfaceHandle, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE); - if (!client_shared_image) { + if (!staging_buffer->client_shared_image) { LOG(ERROR) << "Creation of MappableSharedImage failed."; return false; } - staging_buffer->mailbox = client_shared_image->mailbox(); } - mapping = sii->MapSharedImage(staging_buffer->mailbox); + mapping = + sii->MapSharedImage(staging_buffer->client_shared_image->mailbox()); if (!mapping) { LOG(ERROR) << "MapSharedImage Failed."; return false; @@ -450,7 +450,7 @@ DCHECK(sii); if (base::FeatureList::IsEnabled(kAlwaysUseMappableSIForOneCopyRaster)) { - CHECK(!staging_buffer->mailbox.IsZero()); + CHECK(staging_buffer->client_shared_image); } else { CHECK(staging_buffer->gpu_memory_buffer.get()); } @@ -473,16 +473,16 @@ } // Create staging shared image. - if (staging_buffer->mailbox.IsZero()) { + if (!staging_buffer->client_shared_image) { const uint32_t usage = gpu::SHARED_IMAGE_USAGE_CPU_WRITE; - auto client_shared_image = sii->CreateSharedImage( + staging_buffer->client_shared_image = sii->CreateSharedImage( format, resource_size, color_space, kTopLeft_GrSurfaceOrigin, kPremul_SkAlphaType, usage, "OneCopyRasterStaging", staging_buffer->gpu_memory_buffer.get()->CloneHandle()); - CHECK(client_shared_image); - staging_buffer->mailbox = client_shared_image->mailbox(); + CHECK(staging_buffer->client_shared_image); } else { - sii->UpdateSharedImage(staging_buffer->sync_token, staging_buffer->mailbox); + sii->UpdateSharedImage(staging_buffer->sync_token, + staging_buffer->client_shared_image->mailbox()); } viz::RasterContextProvider::ScopedRasterContextLock scoped_context( @@ -552,7 +552,7 @@ DCHECK_GT(rows_to_copy, 0); ri->CopySharedImage( - staging_buffer->mailbox, shared_image->mailbox(), + staging_buffer->client_shared_image->mailbox(), shared_image->mailbox(), mailbox_texture_target, 0, y, 0, y, rect_to_copy.width(), rows_to_copy, false /* unpack_flip_y */, false /* unpack_premultiply_alpha */); y += rows_to_copy;
diff --git a/cc/raster/staging_buffer_pool.cc b/cc/raster/staging_buffer_pool.cc index b19a235..9eb0776 100644 --- a/cc/raster/staging_buffer_pool.cc +++ b/cc/raster/staging_buffer_pool.cc
@@ -77,7 +77,7 @@ : size(size), format(format) {} StagingBuffer::~StagingBuffer() { - DCHECK(mailbox.IsZero()); + DCHECK(!client_shared_image); DCHECK_EQ(query_id, 0u); } @@ -87,9 +87,8 @@ ri->DeleteQueriesEXT(1, &query_id); query_id = 0; } - if (!mailbox.IsZero()) { - sii->DestroySharedImage(sync_token, mailbox); - mailbox.SetZero(); + if (client_shared_image) { + sii->DestroySharedImage(sync_token, std::move(client_shared_image)); } }
diff --git a/cc/raster/staging_buffer_pool.h b/cc/raster/staging_buffer_pool.h index 4445ace..6e08b95 100644 --- a/cc/raster/staging_buffer_pool.h +++ b/cc/raster/staging_buffer_pool.h
@@ -21,6 +21,7 @@ #include "base/trace_event/trace_event.h" #include "cc/cc_export.h" #include "components/viz/common/resources/shared_image_format.h" +#include "gpu/command_buffer/client/client_shared_image.h" #include "gpu/command_buffer/common/gl2_types.h" #include "gpu/command_buffer/common/mailbox.h" #include "gpu/command_buffer/common/sync_token.h" @@ -62,8 +63,8 @@ // GpuMemoryBuffer. std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer; - // Mailbox for the shared image bound to the GpuMemoryBuffer. - gpu::Mailbox mailbox; + // The shared image bound to the GpuMemoryBuffer. + scoped_refptr<gpu::ClientSharedImage> client_shared_image; // Sync token for the last RasterInterface operations using the shared image. gpu::SyncToken sync_token;
diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml index 6a32c6f..d781eb0 100644 --- a/chrome/android/java/res/xml/privacy_preferences.xml +++ b/chrome/android/java/res/xml/privacy_preferences.xml
@@ -34,7 +34,7 @@ android:key="privacy_sandbox" android:title="@string/ad_privacy_link_row_label" android:summary="@string/ad_privacy_link_row_sub_label" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxSettingsFragmentV4" /> + android:fragment="org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsFragmentV4" /> <Preference android:key="do_not_track" android:title="@string/do_not_track_title"
diff --git a/chrome/android/profiles/arm.newest.txt b/chrome/android/profiles/arm.newest.txt index 4b77c6d..7019ad38 100644 --- a/chrome/android/profiles/arm.newest.txt +++ b/chrome/android/profiles/arm.newest.txt
@@ -1 +1 @@ -chromeos-chrome-arm-121.0.6139.0_rc-r1-merged.afdo.bz2 +chromeos-chrome-arm-121.0.6142.0_rc-r2-merged.afdo.bz2
diff --git a/chrome/android/profiles/newest.txt b/chrome/android/profiles/newest.txt index 000f5278..a7e8885 100644 --- a/chrome/android/profiles/newest.txt +++ b/chrome/android/profiles/newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-121.0.6139.0_rc-r1-merged.afdo.bz2 +chromeos-chrome-amd64-121.0.6142.0_rc-r2-merged.afdo.bz2
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 68cea51..f7a9bc4 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -7352,6 +7352,12 @@ Remove </message> + <!-- Shortcut Accessibility Label--> + <message name="IDS_APP_SHORTCUT_ACCESSIBILITY_LABEL" + desc="The accessibility label of an app shortcut. Example: 'Funny Cat Video, Google Chrome'"> + <ph name="SHORTCUT_NAME">$1<ex>Funny Cat Video</ex></ph>, <ph name="APP_FULL_NAME">$2<ex>Google Chrome</ex></ph> + </message> + <!-- Remote activity notification dialog --> <message name="IDS_REMOTE_ACTIVITY_NOTIFICATION_TITLE" desc="Title text displayed to inform the user a remote admin had taken control of the ChromeOS device for maintenance."> Maintenance is done
diff --git a/chrome/app/chromeos_strings_grdp/IDS_APP_SHORTCUT_ACCESSIBILITY_LABEL.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_APP_SHORTCUT_ACCESSIBILITY_LABEL.png.sha1 new file mode 100644 index 0000000..405dd356f --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_APP_SHORTCUT_ACCESSIBILITY_LABEL.png.sha1
@@ -0,0 +1 @@ +a81db948ad6c8580b93f72b21a2e6f2da46f1b09 \ No newline at end of file
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index 735e7346..766da8b 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp
@@ -2230,7 +2230,10 @@ Do Not Track </message> <message name="IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TEXT" desc="The text of a confirmation dialog that confirms that the user want to send the 'Do Not Track' header"> - Enabling "Do Not Track" means that a request will be included with your browsing traffic. Any effect depends on whether a website responds to the request, and how the request is interpreted. For example, some websites may respond to this request by showing you ads that aren't based on other websites you've visited. Many websites will still collect and use your browsing data - for example to improve security, to provide content, services, ads and recommendations on their websites, and to generate reporting statistics. <ph name="BEGIN_LINK"><a target="_blank" href="$1" aria-description="$2"></ph>Learn more<ph name="END_LINK"></a><ex></a></ex></ph> + Enabling "Do Not Track" means that a request will be included with your browsing traffic. Any effect depends on whether a website responds to the request, and how the request is interpreted. For example, some websites may respond to this request by showing you ads that aren't based on other websites you've visited. Many websites will still collect and use your browsing data - for example to improve security, to provide content, services, ads and recommendations on their websites, and to generate reporting statistics. + </message> + <message name="IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_LEARN_MORE_ACCESSIBILITY_LABEL" desc="The accessibility label for a link to learn more about Do Not Track"> + Learn more about Do Not Track </message> <message name="IDS_SETTINGS_PERMISSIONS" desc="Name of the settings page which allows users to manage permissions and site content settings"> Permissions and content settings
diff --git a/chrome/app/settings_strings_grdp/IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_LEARN_MORE_ACCESSIBILITY_LABEL.png.sha1 b/chrome/app/settings_strings_grdp/IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_LEARN_MORE_ACCESSIBILITY_LABEL.png.sha1 new file mode 100644 index 0000000..c0dabad --- /dev/null +++ b/chrome/app/settings_strings_grdp/IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_LEARN_MORE_ACCESSIBILITY_LABEL.png.sha1
@@ -0,0 +1 @@ +155cc728d0aad1fb56be028f1937731037e13609 \ No newline at end of file
diff --git a/chrome/app/settings_strings_grdp/IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TEXT.png.sha1 b/chrome/app/settings_strings_grdp/IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TEXT.png.sha1 new file mode 100644 index 0000000..c0dabad --- /dev/null +++ b/chrome/app/settings_strings_grdp/IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TEXT.png.sha1
@@ -0,0 +1 @@ +155cc728d0aad1fb56be028f1937731037e13609 \ No newline at end of file
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index d1df77fc..680632024 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -6524,6 +6524,12 @@ FEATURE_VALUE_TYPE( optimization_guide::features::kOptimizationGuideModelExecution)}, + {"optimization-guide-on-device-model", + flag_descriptions::kOptimizationGuideOnDeviceModelName, + flag_descriptions::kOptimizationGuideOnDeviceModelDescription, kOsDesktop, + FEATURE_VALUE_TYPE( + optimization_guide::features::kOptimizationGuideOnDeviceModel)}, + {"organic-repeatable-queries", flag_descriptions::kOrganicRepeatableQueriesName, flag_descriptions::kOrganicRepeatableQueriesDescription,
diff --git a/chrome/browser/apps/app_service/app_service_test.cc b/chrome/browser/apps/app_service/app_service_test.cc index cc58663..c3b8e7f 100644 --- a/chrome/browser/apps/app_service/app_service_test.cc +++ b/chrome/browser/apps/app_service/app_service_test.cc
@@ -15,6 +15,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/apps/app_service/publishers/arc_apps.h" #include "chrome/browser/apps/app_service/publishers/arc_apps_factory.h" +#include "components/services/app_service/public/cpp/features.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) namespace apps { @@ -26,6 +27,20 @@ void AppServiceTest::SetUp(Profile* profile) { app_service_proxy_ = AppServiceProxyFactory::GetForProfile(profile); app_service_proxy_->ReinitializeForTesting(profile); + WaitForAppServiceProxyReady(app_service_proxy_); +} + +void AppServiceTest::WaitForAppServiceProxyReady(AppServiceProxy* proxy) { +#if BUILDFLAG(IS_CHROMEOS_ASH) + if (!base::FeatureList::IsEnabled(kAppServiceStorage)) { + return; + } + + base::test::TestFuture<void> result; + CHECK(proxy->OnReady()); + proxy->OnReady()->Post(FROM_HERE, result.GetCallback()); + CHECK(result.Wait()); +#endif } void AppServiceTest::UninstallAllApps(Profile* profile) {
diff --git a/chrome/browser/apps/app_service/app_service_test.h b/chrome/browser/apps/app_service/app_service_test.h index 998f50f1..81493918 100644 --- a/chrome/browser/apps/app_service/app_service_test.h +++ b/chrome/browser/apps/app_service/app_service_test.h
@@ -29,6 +29,8 @@ void SetUp(Profile* profile); + void WaitForAppServiceProxyReady(AppServiceProxy* proxy); + void UninstallAllApps(Profile* profile); std::string GetAppName(const std::string& app_id) const;
diff --git a/chrome/browser/apps/app_service/publishers/standalone_browser_extension_apps.cc b/chrome/browser/apps/app_service/publishers/standalone_browser_extension_apps.cc index 6d87c0f..d3564ac 100644 --- a/chrome/browser/apps/app_service/publishers/standalone_browser_extension_apps.cc +++ b/chrome/browser/apps/app_service/publishers/standalone_browser_extension_apps.cc
@@ -65,8 +65,6 @@ void StandaloneBrowserExtensionApps::RegisterCrosapiHost( mojo::PendingReceiver<crosapi::mojom::AppPublisher> receiver) { - RegisterPublisher(app_type_); - // At the moment the app service publisher will only accept one browser client // publishing apps to ash chrome. Any extra clients will be ignored. // TODO(crbug.com/1174246): Support SxS lacros. @@ -337,6 +335,8 @@ controller_.set_disconnect_handler( base::BindOnce(&StandaloneBrowserExtensionApps::OnControllerDisconnected, weak_factory_.GetWeakPtr())); + RegisterPublisher(app_type_); + if (app_cache_.empty()) { // If there is no apps saved in `app_cache_`, still publish an empty app // list to initialize `app_type_`.
diff --git a/chrome/browser/ash/BUILD.gn b/chrome/browser/ash/BUILD.gn index e9c2c8f23..836dff1 100644 --- a/chrome/browser/ash/BUILD.gn +++ b/chrome/browser/ash/BUILD.gn
@@ -1525,6 +1525,8 @@ "input_method/editor_text_inserter.h", "input_method/editor_text_query_provider.cc", "input_method/editor_text_query_provider.h", + "input_method/editor_text_query_provider_for_testing.cc", + "input_method/editor_text_query_provider_for_testing.h", "input_method/emoji_suggester.cc", "input_method/emoji_suggester.h", "input_method/field_trial.cc",
diff --git a/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.cc b/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.cc index 2ebc2fc..b2daa8d1 100644 --- a/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.cc +++ b/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.cc
@@ -11,13 +11,47 @@ #include "chrome/browser/ash/app_list/app_list_model_updater.h" #include "chrome/browser/ash/app_list/app_service/app_service_shortcut_context_menu.h" #include "chrome/browser/ash/app_list/chrome_app_list_item.h" +#include "chrome/grit/branded_strings.h" +#include "chrome/grit/generated_resources.h" #include "chromeos/constants/chromeos_features.h" +#include "components/app_constants/constants.h" +#include "components/services/app_service/public/cpp/shortcut/shortcut_registry_cache.h" #include "components/services/app_service/public/cpp/shortcut/shortcut_update.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/gfx/image/image_skia_operations.h" // static const char AppServiceShortcutItem::kItemType[] = "AppServiceShortcutItem"; +namespace { +std::string GetAccessibilityLabel(Profile* profile, + const apps::ShortcutId& shortcut_id, + const std::string& shortcut_name) { + std::string host_app_id = apps::AppServiceProxyFactory::GetForProfile(profile) + ->ShortcutRegistryCache() + ->GetShortcutHostAppId(shortcut_id); + std::u16string host_app_name; + // TODO(b/312103925): Currently app service does not publish the ash Chrome + // Browser full name as "Google Chrome", and we don't want to affect other + // usages without auditing. Therefore we hardcoded the full name here (similar + // to the shelf tooltip for Chrome Browser). Will clean this up after auditing + // all use cases and fix the issue in the upstream. + if (host_app_id == app_constants::kChromeAppId) { + host_app_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); + } else { + apps::AppServiceProxyFactory::GetForProfile(profile) + ->AppRegistryCache() + .ForOneApp(host_app_id, + [&host_app_name](const apps::AppUpdate& update) { + host_app_name = base::UTF8ToUTF16(update.Name()); + }); + } + return l10n_util::GetStringFUTF8(IDS_APP_SHORTCUT_ACCESSIBILITY_LABEL, + base::UTF8ToUTF16(shortcut_name), + host_app_name); +} +} // namespace + AppServiceShortcutItem::AppServiceShortcutItem( Profile* profile, AppListModelUpdater* model_updater, @@ -46,6 +80,8 @@ const apps::ShortcutUpdate& update) { if (update.NameChanged()) { SetName(update.Name()); + SetAccessibleName( + GetAccessibilityLabel(profile_, update.ShortcutId(), update.Name())); } if (update.IconKeyChanged()) { IncrementIconVersion(); @@ -59,8 +95,10 @@ const std::string& shortcut_name, const app_list::AppListSyncableService::SyncItem* sync_item) : ChromeAppListItem(profile, shortcut_id.value()), - shortcut_id_(shortcut_id) { + shortcut_id_(shortcut_id), + profile_(profile) { SetName(shortcut_name); + SetAccessibleName(GetAccessibilityLabel(profile, shortcut_id, shortcut_name)); // TODO(crbug.com/1412708): Consider renaming this interface. SetAppStatus(ash::AppStatus::kReady);
diff --git a/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.h b/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.h index 0816e5c..c9d2b8c6 100644 --- a/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.h +++ b/chrome/browser/ash/app_list/app_service/app_service_shortcut_item.h
@@ -13,6 +13,8 @@ #include "components/services/app_service/public/cpp/icon_types.h" #include "components/services/app_service/public/cpp/shortcut/shortcut.h" +class Profile; + namespace apps { class ShortcutUpdate; } // namespace apps @@ -67,6 +69,8 @@ apps::ShortcutId shortcut_id_; + raw_ptr<Profile> profile_; + base::WeakPtrFactory<AppServiceShortcutItem> weak_ptr_factory_{this}; }; #endif // CHROME_BROWSER_ASH_APP_LIST_APP_SERVICE_APP_SERVICE_SHORTCUT_ITEM_H_
diff --git a/chrome/browser/ash/app_list/app_service/app_service_shortcut_item_browsertest.cc b/chrome/browser/ash/app_list/app_service/app_service_shortcut_item_browsertest.cc index 95d7199..ac7a7af 100644 --- a/chrome/browser/ash/app_list/app_service/app_service_shortcut_item_browsertest.cc +++ b/chrome/browser/ash/app_list/app_service/app_service_shortcut_item_browsertest.cc
@@ -32,6 +32,7 @@ #include "chrome/browser/ui/views/apps/app_dialog/shortcut_removal_dialog_view.h" #include "chrome/browser/web_applications/test/web_app_install_test_utils.h" #include "chrome/common/pref_names.h" +#include "chrome/grit/branded_strings.h" #include "chrome/grit/generated_resources.h" #include "chrome/test/base/ui_test_utils.h" #include "chromeos/constants/chromeos_features.h" @@ -129,18 +130,16 @@ sync_processor.get())); content::RunAllTasksUntilIdle(); - // Register a shortcut in the shortcut registry cache. - apps::ShortcutPtr shortcut = - std::make_unique<Shortcut>("host_app_id", "local_id"); - shortcut->shortcut_source = ShortcutSource::kUser; - shortcut->name = "Test"; - cache()->UpdateShortcut(std::move(shortcut)); - + GURL app_url = GURL("https://example.org/"); + std::u16string shortcut_name = u"Example"; apps::ShortcutId shortcut_id = - apps::GenerateShortcutId("host_app_id", "local_id"); + CreateWebAppBasedShortcut(app_url, shortcut_name); + ash::AppListItem* item = GetAppListItem(shortcut_id.value()); ASSERT_TRUE(item); - ASSERT_EQ(item->name(), "Test"); + ASSERT_EQ(item->name(), "Example"); + ASSERT_EQ(item->accessible_name(), + "Example, " + l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)); // Verify that the shortcut item is added to local storage. const base::Value::Dict& local_items =
diff --git a/chrome/browser/ash/app_list/search/essential_search/essential_search_manager.cc b/chrome/browser/ash/app_list/search/essential_search/essential_search_manager.cc new file mode 100644 index 0000000..87412a8 --- /dev/null +++ b/chrome/browser/ash/app_list/search/essential_search/essential_search_manager.cc
@@ -0,0 +1,38 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ash/app_list/search/essential_search/essential_search_manager.h" +#include "chrome/browser/ash/profiles/profile_helper.h" +#include "chrome/browser/profiles/profile.h" +#include "chromeos/constants/chromeos_features.h" +#include "components/session_manager/session_manager_types.h" + +namespace app_list { + +EssentialSearchManager::EssentialSearchManager(Profile* primary_profile) + : primary_profile_(primary_profile) { + scoped_observation_.Observe(ash::SessionController::Get()); +} + +EssentialSearchManager::~EssentialSearchManager() = default; + +// static +std::unique_ptr<EssentialSearchManager> EssentialSearchManager::Create( + Profile* primary_profile) { + return std::make_unique<EssentialSearchManager>(primary_profile); +} + +void EssentialSearchManager::OnSessionStateChanged( + session_manager::SessionState state) { + if (chromeos::features::IsEssentialSearchEnabled() && + state == session_manager::SessionState::ACTIVE) { + FetchSocsCookie(); + } +} + +void EssentialSearchManager::FetchSocsCookie() { + NOTIMPLEMENTED(); +} + +} // namespace app_list
diff --git a/chrome/browser/ash/app_list/search/essential_search/essential_search_manager.h b/chrome/browser/ash/app_list/search/essential_search/essential_search_manager.h new file mode 100644 index 0000000..1baf994 --- /dev/null +++ b/chrome/browser/ash/app_list/search/essential_search/essential_search_manager.h
@@ -0,0 +1,55 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ASH_APP_LIST_SEARCH_ESSENTIAL_SEARCH_ESSENTIAL_SEARCH_MANAGER_H_ +#define CHROME_BROWSER_ASH_APP_LIST_SEARCH_ESSENTIAL_SEARCH_ESSENTIAL_SEARCH_MANAGER_H_ + +#include <vector> + +#include "ash/public/cpp/ash_public_export.h" +#include "ash/public/cpp/session/session_controller.h" +#include "ash/public/cpp/session/session_observer.h" +#include "base/memory/raw_ptr.h" +#include "base/observer_list.h" +#include "base/scoped_observation.h" + +class Profile; + +namespace app_list { + +// This class is responsible for fetching SOCS cookie and adding it to the user +// cookie jar to make sure that search done through google.com would only use +// essential cookie and data. +// EssentialSearchManager is still WIP. +class EssentialSearchManager : public ash::SessionObserver { + public: + explicit EssentialSearchManager(Profile* primary_profile); + ~EssentialSearchManager() override; + + // Disallow copy and assign. + EssentialSearchManager(const EssentialSearchManager&) = delete; + EssentialSearchManager& operator=(const EssentialSearchManager&) = delete; + + // Returns instance of EssentialSearchManager. + static std::unique_ptr<EssentialSearchManager> Create( + Profile* primary_profile); + + // SessionObserver: + void OnSessionStateChanged(session_manager::SessionState state) override; + + private: + void FetchSocsCookie(); + + // Used to observe the change in session state. + base::ScopedObservation<ash::SessionController, ash::SessionObserver> + scoped_observation_{this}; + + const raw_ptr<Profile, ExperimentalAsh> primary_profile_; + + base::WeakPtrFactory<EssentialSearchManager> weak_ptr_factory_{this}; +}; + +} // namespace app_list + +#endif // CHROME_BROWSER_ASH_APP_LIST_SEARCH_ESSENTIAL_SEARCH_ESSENTIAL_SEARCH_MANAGER_H_
diff --git a/chrome/browser/ash/extensions/autotest_private/autotest_private_api.cc b/chrome/browser/ash/extensions/autotest_private/autotest_private_api.cc index 25e05c9..0bde014 100644 --- a/chrome/browser/ash/extensions/autotest_private/autotest_private_api.cc +++ b/chrome/browser/ash/extensions/autotest_private/autotest_private_api.cc
@@ -111,6 +111,7 @@ #include "chrome/browser/ash/fusebox/fusebox_server.h" #include "chrome/browser/ash/guest_os/guest_os_registry_service.h" #include "chrome/browser/ash/guest_os/guest_os_registry_service_factory.h" +#include "chrome/browser/ash/input_method/editor_mediator_factory.h" #include "chrome/browser/ash/login/lock/screen_locker.h" #include "chrome/browser/ash/login/wizard_context.h" #include "chrome/browser/ash/plugin_vm/plugin_vm_installer.h" @@ -122,6 +123,7 @@ #include "chrome/browser/ash/power/ml/smart_dim/ml_agent.h" #include "chrome/browser/ash/printing/cups_printers_manager.h" #include "chrome/browser/ash/printing/cups_printers_manager_factory.h" +#include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ash/settings/cros_settings.h" #include "chrome/browser/ash/settings/stats_reporting_controller.h" #include "chrome/browser/ash/system/input_device_settings.h" @@ -6368,6 +6370,35 @@ } /////////////////////////////////////////////////////////////////////////////// +// AutotestPrivateOverrideOrcaResponseForTestingFunction +////////////////////////////////////////////////////////////////////////////// + +AutotestPrivateOverrideOrcaResponseForTestingFunction:: + AutotestPrivateOverrideOrcaResponseForTestingFunction() = default; + +AutotestPrivateOverrideOrcaResponseForTestingFunction:: + ~AutotestPrivateOverrideOrcaResponseForTestingFunction() = default; + +ExtensionFunction::ResponseAction +AutotestPrivateOverrideOrcaResponseForTestingFunction::Run() { + absl::optional<api::autotest_private::OverrideOrcaResponseForTesting::Params> + params = + api::autotest_private::OverrideOrcaResponseForTesting::Params::Create( + args()); + + EXTENSION_FUNCTION_VALIDATE(params); + + ash::input_method::EditorMediator* editor_mediator = + ash::input_method::EditorMediatorFactory::GetInstance()->GetForProfile( + ash::ProfileHelper::Get()->GetProfileByUser( + user_manager::UserManager::Get()->GetActiveUser())); + + return RespondNow( + WithArguments(editor_mediator->SetTextQueryProviderResponseForTesting( + params->array.responses))); // IN-TEST +} + +/////////////////////////////////////////////////////////////////////////////// // AutotestPrivateMakeFuseboxTempDirFunction ///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ash/extensions/autotest_private/autotest_private_api.h b/chrome/browser/ash/extensions/autotest_private/autotest_private_api.h index c9c212b..3d5bc9fa 100644 --- a/chrome/browser/ash/extensions/autotest_private/autotest_private_api.h +++ b/chrome/browser/ash/extensions/autotest_private/autotest_private_api.h
@@ -1698,6 +1698,18 @@ ResponseAction Run() override; }; +class AutotestPrivateOverrideOrcaResponseForTestingFunction + : public ExtensionFunction { + public: + AutotestPrivateOverrideOrcaResponseForTestingFunction(); + DECLARE_EXTENSION_FUNCTION("autotestPrivate.overrideOrcaResponseForTesting", + AUTOTESTPRIVATE_OVERRIDEORCARESPONSE) + + private: + ~AutotestPrivateOverrideOrcaResponseForTestingFunction() override; + ResponseAction Run() override; +}; + class AutotestPrivateMakeFuseboxTempDirFunction : public ExtensionFunction { public: DECLARE_EXTENSION_FUNCTION("autotestPrivate.makeFuseboxTempDir",
diff --git a/chrome/browser/ash/extensions/file_manager/event_router.cc b/chrome/browser/ash/extensions/file_manager/event_router.cc index 8bfe9b18..07152f4 100644 --- a/chrome/browser/ash/extensions/file_manager/event_router.cc +++ b/chrome/browser/ash/extensions/file_manager/event_router.cc
@@ -1380,6 +1380,12 @@ event_status.pause_params = std::move(pause_params); } + for (const FileSystemURL& skipped_encrypted_file : + status.skipped_encrypted_files) { + event_status.skipped_encrypted_files.push_back( + skipped_encrypted_file.path().BaseName().value()); + } + // The TrashIOTask is the only IOTask that uses the output Entry's, so don't // try to resolve the outputs for all other IOTasks. if (GetIOTaskType(status.type) != fmp::IOTaskType::kTrash ||
diff --git a/chrome/browser/ash/file_manager/copy_or_move_io_task_impl.cc b/chrome/browser/ash/file_manager/copy_or_move_io_task_impl.cc index d93e2be..4f927f4 100644 --- a/chrome/browser/ash/file_manager/copy_or_move_io_task_impl.cc +++ b/chrome/browser/ash/file_manager/copy_or_move_io_task_impl.cc
@@ -826,6 +826,7 @@ void CopyOrMoveIOTaskImpl::OnEncryptedFileSkipped(size_t idx, storage::FileSystemURL url) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + progress_->skipped_encrypted_files.emplace_back(std::move(url)); progress_->sources[idx].error = base::File::FILE_ERROR_FAILED; progress_->outputs[idx].error = base::File::FILE_ERROR_FAILED; }
diff --git a/chrome/browser/ash/file_manager/file_manager_browsertest.cc b/chrome/browser/ash/file_manager/file_manager_browsertest.cc index 057179e1..36cb194 100644 --- a/chrome/browser/ash/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/ash/file_manager/file_manager_browsertest.cc
@@ -2050,7 +2050,8 @@ TestCase("searchFileSystemProvider"), TestCase("searchImageByContent").EnableLocalImageSearch(), TestCase("changingDirectoryClosesSearch"), - TestCase("searchQueryLaunchParam"))); + TestCase("searchQueryLaunchParam"), + TestCase("verifyDriveLocationOption"))); WRAPPED_INSTANTIATE_TEST_SUITE_P( Metrics, /* metrics.js */
diff --git a/chrome/browser/ash/file_manager/file_manager_string_util.cc b/chrome/browser/ash/file_manager/file_manager_string_util.cc index ac5665a..bbfd9f8 100644 --- a/chrome/browser/ash/file_manager/file_manager_string_util.cc +++ b/chrome/browser/ash/file_manager/file_manager_string_util.cc
@@ -464,6 +464,15 @@ SET_STRING("COPY_BUTTON_LABEL", IDS_FILE_BROWSER_COPY_BUTTON_LABEL); SET_STRING("COPY_FILESYSTEM_ERROR", IDS_FILE_BROWSER_COPY_FILESYSTEM_ERROR); + SET_STRING("COPY_SKIPPED_ENCRYPTED_SINGLE_FILE", + IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_SINGLE_FILE); + SET_STRING("MOVE_SKIPPED_ENCRYPTED_SINGLE_FILE", + IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_SINGLE_FILE); + SET_STRING("COPY_SKIPPED_ENCRYPTED_FILES", + IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_FILES); + SET_STRING("MOVE_SKIPPED_ENCRYPTED_FILES", + IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_FILES); + SET_STRING("ENCRYPTED_DETAILS", IDS_FILE_BROWSER_ENCRYPTED_DETAILS); SET_STRING("EMPTY_TRASH_UNEXPECTED_ERROR", IDS_FILE_BROWSER_EMPTY_TRASH_UNEXPECTED_ERROR); SET_STRING("TRASH_UNEXPECTED_ERROR", IDS_FILE_BROWSER_TRASH_UNEXPECTED_ERROR);
diff --git a/chrome/browser/ash/file_manager/io_task.h b/chrome/browser/ash/file_manager/io_task.h index ec41efb..d3bd246 100644 --- a/chrome/browser/ash/file_manager/io_task.h +++ b/chrome/browser/ash/file_manager/io_task.h
@@ -310,6 +310,10 @@ // Whether notifications should be shown on progress status. bool show_notification = true; + // List of files skipped during the operation because we couldn't decrypt + // them. + std::vector<storage::FileSystemURL> skipped_encrypted_files; + private: // Optional destination folder for operations that transfer files to a // directory (e.g. copy or move).
diff --git a/chrome/browser/ash/input_method/editor_mediator.cc b/chrome/browser/ash/input_method/editor_mediator.cc index 3d70e0bd..6d44e33 100644 --- a/chrome/browser/ash/input_method/editor_mediator.cc +++ b/chrome/browser/ash/input_method/editor_mediator.cc
@@ -16,6 +16,8 @@ #include "chrome/browser/ash/input_method/editor_helpers.h" #include "chrome/browser/ash/input_method/editor_metrics_enums.h" #include "chrome/browser/ash/input_method/editor_metrics_recorder.h" +#include "chrome/browser/ash/input_method/editor_text_query_provider.h" +#include "chrome/browser/ash/input_method/editor_text_query_provider_for_testing.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ui/webui/ash/mako/mako_bubble_coordinator.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -59,7 +61,7 @@ text_actuator_ = std::make_unique<EditorTextActuator>( profile_, text_actuator_remote.InitWithNewEndpointAndPassReceiver(), this); - text_query_provider_ = std::make_unique<EditorTextQueryProvider>( + text_query_provider_ = std::make_unique<TextQueryProviderForOrca>( text_query_provider_remote.InitWithNewEndpointAndPassReceiver(), profile_, editor_switch_.get()); editor_client_connector_ = std::make_unique<EditorClientConnector>( @@ -235,4 +237,16 @@ editor_switch_ = nullptr; } +bool EditorMediator::SetTextQueryProviderResponseForTesting( + const std::vector<std::string>& mock_results) { + auto pending_receiver = text_query_provider_->Unbind(); + + if (!pending_receiver.has_value()) { + return false; + } + text_query_provider_ = std::make_unique<TextQueryProviderForTesting>( + std::move(pending_receiver.value()), mock_results); // IN-TEST + return true; +} + } // namespace ash::input_method
diff --git a/chrome/browser/ash/input_method/editor_mediator.h b/chrome/browser/ash/input_method/editor_mediator.h index 97e04d7..702b3a30 100644 --- a/chrome/browser/ash/input_method/editor_mediator.h +++ b/chrome/browser/ash/input_method/editor_mediator.h
@@ -91,6 +91,9 @@ EditorPanelManager* panel_manager() { return &panel_manager_; } + bool SetTextQueryProviderResponseForTesting( + const std::vector<std::string>& mock_results); + private: struct SurroundingText { std::u16string text;
diff --git a/chrome/browser/ash/input_method/editor_text_query_provider.cc b/chrome/browser/ash/input_method/editor_text_query_provider.cc index de58455b..5165df2 100644 --- a/chrome/browser/ash/input_method/editor_text_query_provider.cc +++ b/chrome/browser/ash/input_method/editor_text_query_provider.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/ash/input_method/editor_text_query_provider.h" +#include <optional> + #include "base/metrics/field_trial_params.h" #include "base/notreached.h" #include "base/values.h" @@ -104,7 +106,7 @@ } // namespace -EditorTextQueryProvider::EditorTextQueryProvider( +TextQueryProviderForOrca::TextQueryProviderForOrca( mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider> receiver, Profile* profile, EditorSwitch* editor_switch) @@ -112,14 +114,10 @@ orca_provider_(CreateProvider(profile)), editor_switch_(editor_switch) {} -EditorTextQueryProvider::~EditorTextQueryProvider() = default; +TextQueryProviderForOrca::~TextQueryProviderForOrca() = default; -void EditorTextQueryProvider::OnProfileChanged(Profile* profile) { - orca_provider_ = CreateProvider(profile); -} - -void EditorTextQueryProvider::Process(orca::mojom::TextQueryRequestPtr request, - ProcessCallback callback) { +void TextQueryProviderForOrca::Process(orca::mojom::TextQueryRequestPtr request, + ProcessCallback callback) { if (orca_provider_ == nullptr) { // TODO: b:300557202 - use the right error code auto response = orca::mojom::TextQueryResponse::NewError( @@ -153,4 +151,12 @@ std::move(callback))); } +std::optional<mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider>> +TextQueryProviderForOrca::Unbind() { + if (text_query_provider_receiver_.is_bound()) { + return text_query_provider_receiver_.Unbind(); + } + return std::nullopt; +} + } // namespace ash::input_method
diff --git a/chrome/browser/ash/input_method/editor_text_query_provider.h b/chrome/browser/ash/input_method/editor_text_query_provider.h index de607fc..57ec0c7 100644 --- a/chrome/browser/ash/input_method/editor_text_query_provider.h +++ b/chrome/browser/ash/input_method/editor_text_query_provider.h
@@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_ASH_INPUT_METHOD_EDITOR_TEXT_QUERY_PROVIDER_H_ #define CHROME_BROWSER_ASH_INPUT_METHOD_EDITOR_TEXT_QUERY_PROVIDER_H_ +#include <optional> + #include "chrome/browser/ash/input_method/editor_switch.h" #include "chrome/browser/profiles/profile.h" #include "chromeos/ash/services/orca/public/mojom/orca_service.mojom.h" @@ -15,17 +17,30 @@ class EditorTextQueryProvider : public orca::mojom::TextQueryProvider { public: - EditorTextQueryProvider( + // orca::mojom::TextQueryProvider overrides + void Process(orca::mojom::TextQueryRequestPtr request, + ProcessCallback callback) override = 0; + + virtual std::optional< + mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider>> + Unbind() = 0; +}; + +class TextQueryProviderForOrca : public EditorTextQueryProvider { + public: + TextQueryProviderForOrca( mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider> receiver, Profile* profile, EditorSwitch* editor_switch); - ~EditorTextQueryProvider() override; - // orca::mojom::TextQueryProvider overrides + ~TextQueryProviderForOrca() override; + + // EditorTextQueryProvider overrides void Process(orca::mojom::TextQueryRequestPtr request, ProcessCallback callback) override; - void OnProfileChanged(Profile* profile); + std::optional<mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider>> + Unbind() override; private: mojo::AssociatedReceiver<orca::mojom::TextQueryProvider>
diff --git a/chrome/browser/ash/input_method/editor_text_query_provider_for_testing.cc b/chrome/browser/ash/input_method/editor_text_query_provider_for_testing.cc new file mode 100644 index 0000000..de9a98f --- /dev/null +++ b/chrome/browser/ash/input_method/editor_text_query_provider_for_testing.cc
@@ -0,0 +1,46 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ash/input_method/editor_text_query_provider_for_testing.h" + +#include <optional> + +#include "chromeos/ash/services/orca/public/mojom/orca_service.mojom.h" +#include "mojo/public/cpp/bindings/associated_receiver.h" + +namespace ash::input_method { + +TextQueryProviderForTesting::TextQueryProviderForTesting( + mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider> receiver, + const std::vector<std::string>& mock_responses) + : text_query_provider_receiver_(this, std::move(receiver)), + mock_responses_(mock_responses) {} + +TextQueryProviderForTesting::~TextQueryProviderForTesting() = + default; // IN-TEST + +void TextQueryProviderForTesting::Process( + orca::mojom::TextQueryRequestPtr request, + ProcessCallback callback) { + std::vector<ash::orca::mojom::TextQueryResultPtr> responses; + for (size_t i = 0; i < mock_responses_.size(); ++i) { + // fetch the responses with mock request_id and result_id + responses.push_back(ash::orca::mojom::TextQueryResult::New( + base::StrCat({base::NumberToString(i), ":", base::NumberToString(i)}), + mock_responses_[i])); + } + + auto results = + orca::mojom::TextQueryResponse::NewResults(std::move(responses)); + std::move(callback).Run(std::move(results)); +} + +std::optional<mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider>> +TextQueryProviderForTesting::Unbind() { + if (text_query_provider_receiver_.is_bound()) { + return text_query_provider_receiver_.Unbind(); + } + return std::nullopt; +} +} // namespace ash::input_method
diff --git a/chrome/browser/ash/input_method/editor_text_query_provider_for_testing.h b/chrome/browser/ash/input_method/editor_text_query_provider_for_testing.h new file mode 100644 index 0000000..17af0dd --- /dev/null +++ b/chrome/browser/ash/input_method/editor_text_query_provider_for_testing.h
@@ -0,0 +1,39 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ASH_INPUT_METHOD_EDITOR_TEXT_QUERY_PROVIDER_FOR_TESTING_H_ +#define CHROME_BROWSER_ASH_INPUT_METHOD_EDITOR_TEXT_QUERY_PROVIDER_FOR_TESTING_H_ + +#include <optional> +#include <vector> + +#include "chrome/browser/ash/input_method/editor_text_query_provider.h" +#include "chromeos/ash/services/orca/public/mojom/orca_service.mojom.h" +#include "mojo/public/cpp/bindings/associated_receiver.h" + +namespace ash::input_method { + +class TextQueryProviderForTesting : public EditorTextQueryProvider { + public: + TextQueryProviderForTesting( + mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider> receiver, + const std::vector<std::string>& mock_responses); + + ~TextQueryProviderForTesting() override; + + // EditorTextQueryProvider overrides + void Process(orca::mojom::TextQueryRequestPtr request, + ProcessCallback callback) override; + + std::optional<mojo::PendingAssociatedReceiver<orca::mojom::TextQueryProvider>> + Unbind() override; + + private: + mojo::AssociatedReceiver<orca::mojom::TextQueryProvider> + text_query_provider_receiver_; + std::vector<std::string> mock_responses_; +}; + +} // namespace ash::input_method +#endif // CHROME_BROWSER_ASH_INPUT_METHOD_EDITOR_TEXT_QUERY_PROVIDER_FOR_TESTING_H_
diff --git a/chrome/browser/ash/login/misconfigured_user_browsertest.cc b/chrome/browser/ash/login/misconfigured_user_browsertest.cc index e291e63e..8865ce9 100644 --- a/chrome/browser/ash/login/misconfigured_user_browsertest.cc +++ b/chrome/browser/ash/login/misconfigured_user_browsertest.cc
@@ -3,11 +3,15 @@ // found in the LICENSE file. #include <memory> +#include <utility> + +#include "ash/constants/ash_features.h" #include "ash/public/cpp/login_screen_test_api.h" #include "base/run_loop.h" #include "base/test/test_future.h" #include "chrome/browser/ash/login/auth/chrome_safe_mode_delegate.h" #include "chrome/browser/ash/login/login_manager_test.h" +#include "chrome/browser/ash/login/quick_unlock/quick_unlock_factory.h" #include "chrome/browser/ash/login/session/user_session_manager.h" #include "chrome/browser/ash/login/session/user_session_manager_test_api.h" #include "chrome/browser/ash/login/test/cryptohome_mixin.h" @@ -24,6 +28,8 @@ #include "chromeos/ash/components/login/auth/auth_session_authenticator.h" #include "chromeos/ash/components/login/auth/authenticator_builder.h" #include "chromeos/ash/components/login/auth/public/user_context.h" +#include "chromeos/ash/services/auth_factor_config/auth_factor_config.h" +#include "chromeos/ash/services/auth_factor_config/in_process_instances.h" #include "components/prefs/pref_service.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" @@ -103,12 +109,21 @@ public: void SetUpOnMainThread() override { add_auth_factor_waiter_ = std::make_unique<base::test::TestFuture<void>>(); - user_session_manager_test_api_ = - std::make_unique<test::UserSessionManagerTestApi>( - UserSessionManager::GetInstance()); - user_session_manager_test_api_->InjectAuthenticatorBuilder( - std::make_unique<FakeAuthenticatorBuilder>( - add_auth_factor_waiter_->GetCallback())); + if (ash::features::AreLocalPasswordsEnabledForConsumers()) { + auto test_api = + auth::AuthFactorConfig::TestApi(auth::GetAuthFactorConfigForTesting( + quick_unlock::QuickUnlockFactory::GetDelegate(), + g_browser_process->local_state())); + test_api.SetAddKnowledgeFactorCallback( + add_auth_factor_waiter_->GetCallback()); + } else { + auto user_session_manager_test_api = + std::make_unique<test::UserSessionManagerTestApi>( + UserSessionManager::GetInstance()); + user_session_manager_test_api->InjectAuthenticatorBuilder( + std::make_unique<FakeAuthenticatorBuilder>( + add_auth_factor_waiter_->GetCallback())); + } LoginManagerTest::SetUpOnMainThread(); } @@ -133,8 +148,6 @@ nullptr, &cryptohome_mixin_}; FakeGaiaMixin fake_gaia_mixin_{&mixin_host_}; - std::unique_ptr<test::UserSessionManagerTestApi> - user_session_manager_test_api_; std::unique_ptr<base::test::TestFuture<void>> add_auth_factor_waiter_; };
diff --git a/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.cc b/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.cc index 379cd05..6037426a04 100644 --- a/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.cc +++ b/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.cc
@@ -164,7 +164,7 @@ weak_ptr_factory_.GetWeakPtr(), std::move(callback))); } -void Connection::RequestAccountInfo(base::OnceClosure callback) { +void Connection::RequestAccountInfo(RequestAccountInfoCallback callback) { // During this roundtrip the source device may prompt the user to select an // account before responding, so we will provide a very generous timeout. (In // case, for example, the user has walked away after the verification step.) @@ -265,16 +265,19 @@ } void Connection::OnBootstrapConfigurationsResponse( - base::OnceClosure callback, + RequestAccountInfoCallback callback, mojom::QuickStartMessagePtr quick_start_message) { if (!quick_start_message || !quick_start_message->is_bootstrap_configurations()) { - std::move(callback).Run(); + std::move(callback).Run(""); return; } phone_instance_id_ = quick_start_message->get_bootstrap_configurations()->instance_id; - std::move(callback).Run(); + is_supervised_account_ = quick_start_message->get_bootstrap_configurations() + ->is_supervised_account; + std::move(callback).Run( + quick_start_message->get_bootstrap_configurations()->email); } void Connection::SendMessageAndDecodeResponse(
diff --git a/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.h b/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.h index 38ee5aa..5c25e69 100644 --- a/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.h +++ b/chrome/browser/ash/login/oobe_quick_start/connectivity/connection.h
@@ -120,7 +120,7 @@ // TargetDeviceConnectionBroker::AuthenticatedConnection: void RequestWifiCredentials(RequestWifiCredentialsCallback callback) override; void NotifySourceOfUpdate(NotifySourceOfUpdateCallback callback) override; - void RequestAccountInfo(base::OnceClosure callback) override; + void RequestAccountInfo(RequestAccountInfoCallback callback) override; void RequestAccountTransferAssertion( const Base64UrlString& challenge, RequestAccountTransferAssertionCallback callback) override; @@ -154,7 +154,7 @@ mojom::QuickStartMessagePtr quick_start_message); void OnBootstrapConfigurationsResponse( - base::OnceClosure callback, + RequestAccountInfoCallback callback, mojom::QuickStartMessagePtr quick_start_message); void SendMessageAndDecodeResponse(
diff --git a/chrome/browser/ash/login/oobe_quick_start/connectivity/connection_unittest.cc b/chrome/browser/ash/login/oobe_quick_start/connectivity/connection_unittest.cc index b6dc95a..ae3a070 100644 --- a/chrome/browser/ash/login/oobe_quick_start/connectivity/connection_unittest.cc +++ b/chrome/browser/ash/login/oobe_quick_start/connectivity/connection_unittest.cc
@@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "connection.h" +#include "chrome/browser/ash/login/oobe_quick_start/connectivity/connection.h" + +#include <string> #include "base/base64.h" #include "base/functional/bind.h" @@ -148,18 +150,23 @@ return connection_->client_data_.get(); } - bool SimulateBootstrapConfigurationsResponse( - absl::optional<std::string> instance_id) { - base::test::TestFuture<void> future; - if (instance_id.has_value()) { - connection_->OnBootstrapConfigurationsResponse( - future.GetCallback(), - mojom::QuickStartMessage::NewBootstrapConfigurations( - mojom::BootstrapConfigurations::New(instance_id.value()))); - } else { - connection_->OnBootstrapConfigurationsResponse(future.GetCallback(), - nullptr); - } + bool SimulateBootstrapConfigurationsResponse(std::string instance_id, + bool is_supervised_account) { + base::test::TestFuture<std::string> future; + connection_->OnBootstrapConfigurationsResponse( + future.GetCallback(), + mojom::QuickStartMessage::NewBootstrapConfigurations( + mojom::BootstrapConfigurations::New(instance_id, + is_supervised_account, + /*email=*/""))); + + return future.Wait(); + } + + bool SimulateNullBootstrapConfigurationsResponse() { + base::test::TestFuture<std::string> future; + connection_->OnBootstrapConfigurationsResponse(future.GetCallback(), + nullptr); return future.Wait(); } @@ -410,7 +417,7 @@ TEST_F(ConnectionTest, RequestAccountInfo) { MarkConnectionAuthenticated(); - base::test::TestFuture<void> future; + base::test::TestFuture<std::string> future; authenticated_connection_->RequestAccountInfo(future.GetCallback()); std::vector<uint8_t> bootstrap_options_data = @@ -430,11 +437,12 @@ // Emulate a BootstrapConfigurations response. std::vector<uint8_t> instance_id = {0x01, 0x02, 0x03}; std::string expected_instance_id(instance_id.begin(), instance_id.end()); + std::string email = "fake_email_value"; fake_quick_start_decoder_->SetBootstrapConfigurationsResponse( - expected_instance_id); + expected_instance_id, /*is_supervised_account=*/false, email); fake_nearby_connection_->AppendReadableData(kTestBytes); - ASSERT_TRUE(future.Wait()); + ASSERT_EQ(future.Get(), email); TestMessageMetrics(/*should_succeed=*/true, /*message_type=*/ QuickStartMetrics::MessageType::kBootstrapConfigurations, @@ -850,7 +858,7 @@ std::vector<uint8_t> instance_id = {0x01, 0x02, 0x03}; std::string expected_instance_id(instance_id.begin(), instance_id.end()); fake_quick_start_decoder_->SetBootstrapConfigurationsResponse( - expected_instance_id); + expected_instance_id, /*is_supervised_account=*/false, /*email=*/""); MarkConnectionAuthenticated(); @@ -923,17 +931,22 @@ std::vector<uint8_t> instance_id = {0x01, 0x02, 0x03}; std::string expected_instance_id(instance_id.begin(), instance_id.end()); - ASSERT_TRUE(SimulateBootstrapConfigurationsResponse(expected_instance_id)); + bool is_supervised_account = true; + + ASSERT_TRUE(SimulateBootstrapConfigurationsResponse(expected_instance_id, + is_supervised_account)); EXPECT_EQ(authenticated_connection_->get_phone_instance_id(), expected_instance_id); + EXPECT_EQ(authenticated_connection_->is_supervised_account(), + is_supervised_account); } TEST_F(ConnectionTest, ParseBootstrapConfigurationsHandlesNull) { MarkConnectionAuthenticated(); ASSERT_TRUE(authenticated_connection_->get_phone_instance_id().empty()); - ASSERT_TRUE(SimulateBootstrapConfigurationsResponse(absl::nullopt)); + ASSERT_TRUE(SimulateNullBootstrapConfigurationsResponse()); EXPECT_TRUE(authenticated_connection_->get_phone_instance_id().empty()); }
diff --git a/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.cc b/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.cc index 963df1f4..7673886 100644 --- a/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.cc +++ b/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.cc
@@ -57,7 +57,7 @@ await_user_verification_callback_ = std::move(callback); } -void FakeConnection::RequestAccountInfo(base::OnceClosure callback) { +void FakeConnection::RequestAccountInfo(RequestAccountInfoCallback callback) { request_account_info_callback_ = std::move(callback); } @@ -80,8 +80,8 @@ std::move(await_user_verification_callback_).Run(response); } -void FakeConnection::SendAccountInfo() { - std::move(request_account_info_callback_).Run(); +void FakeConnection::SendAccountInfo(std::string email) { + std::move(request_account_info_callback_).Run(email); } void FakeConnection::SendAccountTransferAssertionInfo(
diff --git a/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.h b/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.h index 877f9b7..6cc8904d 100644 --- a/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.h +++ b/chrome/browser/ash/login/oobe_quick_start/connectivity/fake_connection.h
@@ -46,7 +46,7 @@ HandshakeSuccessCallback callback) override; void RequestWifiCredentials(RequestWifiCredentialsCallback callback) override; void WaitForUserVerification(AwaitUserVerificationCallback callback) override; - void RequestAccountInfo(base::OnceClosure callback) override; + void RequestAccountInfo(RequestAccountInfoCallback callback) override; void RequestAccountTransferAssertion( const Base64UrlString& challenge, RequestAccountTransferAssertionCallback callback) override; @@ -54,7 +54,7 @@ bool WasHandshakeInitiated(); void SendWifiCredentials(absl::optional<mojom::WifiCredentials> credentials); void VerifyUser(absl::optional<mojom::UserVerificationResponse> response); - void SendAccountInfo(); + void SendAccountInfo(std::string email); void SendAccountTransferAssertionInfo( absl::optional<FidoAssertionInfo> assertion_info); void HandleHandshakeResult(bool success); @@ -71,7 +71,7 @@ HandshakeSuccessCallback handshake_success_callback_; RequestWifiCredentialsCallback wifi_credentials_callback_; AwaitUserVerificationCallback await_user_verification_callback_; - base::OnceClosure request_account_info_callback_; + RequestAccountInfoCallback request_account_info_callback_; RequestAccountTransferAssertionCallback request_account_transfer_assertion_callback_;
diff --git a/chrome/browser/ash/login/oobe_quick_start/connectivity/target_device_connection_broker.h b/chrome/browser/ash/login/oobe_quick_start/connectivity/target_device_connection_broker.h index 63ea8c5..e52027d 100644 --- a/chrome/browser/ash/login/oobe_quick_start/connectivity/target_device_connection_broker.h +++ b/chrome/browser/ash/login/oobe_quick_start/connectivity/target_device_connection_broker.h
@@ -64,6 +64,8 @@ base::OnceCallback<void(absl::optional<FidoAssertionInfo>)>; using AwaitUserVerificationCallback = base::OnceCallback<void( absl::optional<mojom::UserVerificationResponse>)>; + using RequestAccountInfoCallback = + base::OnceCallback<void(/*account_email=*/std::string)>; // Close the connection. virtual void Close( @@ -80,7 +82,7 @@ // The first step in the account transfer process which involves retrieving // GAIA account info from the source device. - virtual void RequestAccountInfo(base::OnceClosure callback) = 0; + virtual void RequestAccountInfo(RequestAccountInfoCallback callback) = 0; // Begin the account transfer process and retrieve an Assertion from the // source device. The caller must provide a "challenge" nonce to be sent to @@ -101,11 +103,16 @@ // response. std::string get_phone_instance_id() { return phone_instance_id_; } + // Retrieve boolean value indicating whether the account in question is a + // supervised account (e.g. Unicorn). + bool is_supervised_account() { return is_supervised_account_; } + protected: AuthenticatedConnection() = default; virtual ~AuthenticatedConnection() = default; std::string phone_instance_id_; + bool is_supervised_account_; }; // Clients of TargetDeviceConnectionBroker should implement this interface,
diff --git a/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.cc b/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.cc index 5d1b1b75..27a8d90 100644 --- a/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.cc +++ b/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.cc
@@ -317,9 +317,10 @@ weak_ptr_factory_.GetWeakPtr())); } -void TargetDeviceBootstrapController::OnGoogleAccountInfoReceived() { +void TargetDeviceBootstrapController::OnGoogleAccountInfoReceived( + std::string account_email) { UpdateStatus(/*step=*/Step::GOOGLE_ACCOUNT_INFO_RECEIVED, - /*payload=*/absl::monostate()); + /*payload=*/account_email); } void TargetDeviceBootstrapController::AttemptGoogleAccountTransfer() {
diff --git a/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.h b/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.h index aa5d6afb..ea5ba462 100644 --- a/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.h +++ b/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller.h
@@ -180,7 +180,7 @@ void OnWifiCredentialsReceived( absl::optional<mojom::WifiCredentials> credentials); - void OnGoogleAccountInfoReceived(); + void OnGoogleAccountInfoReceived(std::string account_email); void OnFidoAssertionReceived(absl::optional<FidoAssertionInfo> assertion); void OnChallengeBytesReceived(
diff --git a/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller_unittest.cc b/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller_unittest.cc index 9cf4ece..84c3754 100644 --- a/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller_unittest.cc +++ b/chrome/browser/ash/login/oobe_quick_start/target_device_bootstrap_controller_unittest.cc
@@ -531,12 +531,13 @@ EXPECT_TRUE(absl::holds_alternative<absl::monostate>( fake_observer_->last_status.payload)); - fake_target_device_connection_broker_->GetFakeConnection()->SendAccountInfo(); + std::string email = "fake_test_email"; + fake_target_device_connection_broker_->GetFakeConnection()->SendAccountInfo( + email); EXPECT_EQ(fake_observer_->last_status.step, Step::GOOGLE_ACCOUNT_INFO_RECEIVED); - EXPECT_TRUE(absl::holds_alternative<absl::monostate>( - fake_observer_->last_status.payload)); + EXPECT_EQ(absl::get<std::string>(fake_observer_->last_status.payload), email); } TEST_F(TargetDeviceBootstrapControllerTest,
diff --git a/chrome/browser/autofill/autofill_across_iframes_browsertest.cc b/chrome/browser/autofill/autofill_across_iframes_browsertest.cc index 5d5a410..bbeb292 100644 --- a/chrome/browser/autofill/autofill_across_iframes_browsertest.cc +++ b/chrome/browser/autofill/autofill_across_iframes_browsertest.cc
@@ -773,8 +773,7 @@ // Tests that a deeply nested form where some iframes don't even contain any // fields (but their subframes do) is extracted and filled correctly. IN_PROC_BROWSER_TEST_F(AutofillAcrossIframesTest_NestedAndLargeForm, - // TODO(crbug.com/1393990): Re-enable this test - DISABLED_FlattenFormEvenAcrossFramesWithoutFields) { + FlattenFormEvenAcrossFramesWithoutFields) { SetUrlContent("/", MakeCss(3) + R"(<iframe src="$4/3.html"></iframe> <iframe src="$3/3.html"></iframe> @@ -797,7 +796,7 @@ // and <form> elements. auto name = HtmlFieldType::kCreditCardNameFull; auto num = HtmlFieldType::kCreditCardNumber; - auto exp = HtmlFieldType::kCreditCardExp; + auto exp = HtmlFieldType::kCreditCardExpDate4DigitYear; auto cvc = HtmlFieldType::kCreditCardVerificationCode; auto m = [](HtmlFieldType type) { return Pointee(AllOf(Property(&AutofillField::html_type, Eq(type)),
diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc index ca4850b..5397139 100644 --- a/chrome/browser/autofill/autofill_interactive_uitest.cc +++ b/chrome/browser/autofill/autofill_interactive_uitest.cc
@@ -114,9 +114,15 @@ using base::ASCIIToUTF16; using content::URLLoaderInterceptor; using ::testing::_; +using ::testing::AllOf; using ::testing::AssertionFailure; using ::testing::AssertionResult; using ::testing::AssertionSuccess; +using ::testing::ElementsAre; +using ::testing::Eq; +using ::testing::Field; +using ::testing::StartsWith; +using ::testing::UnorderedElementsAreArray; namespace autofill { @@ -328,20 +334,32 @@ return fields; } +// A generic "map" function, intended to lift values `args...` to a matcher +// `fun(args)...`. For example, `ElementsAreArray(Map({x, y, z}, fun))` is +// `ElementsAreArray({fun(x), fun(y), fun(z)})`. +template <typename Arg, typename Fun> +[[nodiscard]] auto Map(const std::vector<Arg>& args, Fun fun) { + std::vector<decltype(std::invoke(fun, args[0]))> matchers; + for (const Arg& arg : args) { + matchers.push_back(std::invoke(fun, arg)); + } + return matchers; +} + // Matches a container of FieldValues if the `i`th actual FieldValue::value // matches the `i`th `expected` FieldValue::value. // As a sanity check, also requires that the `i`th actual FieldValue::id // starts with the `i`th `expected` FieldValue::id. [[nodiscard]] auto ValuesAre(const std::vector<FieldValue>& expected) { - auto FieldEq = [](const FieldValue& expected) { - return ::testing::AllOf( - ::testing::Field(&FieldValue::id, ::testing::StartsWith(expected.id)), - ::testing::Field(&FieldValue::value, ::testing::Eq(expected.value))); - }; - std::vector<decltype(FieldEq(expected[0]))> matchers; - for (const FieldValue& field : expected) - matchers.push_back(FieldEq(field)); - return ::testing::UnorderedElementsAreArray(matchers); + return UnorderedElementsAreArray( + Map(expected, [](const FieldValue& expected) { + return AllOf(Field(&FieldValue::id, StartsWith(expected.id)), + Field(&FieldValue::value, Eq(expected.value))); + })); +} + +[[nodiscard]] auto FieldsAre(auto matcher) { + return Field(&FormData::fields, ElementsAreArray(matcher)); } // An object that waits for an observed form-control element to change its value @@ -515,26 +533,6 @@ return ValueWaiter(waiterId, execution_target); } -// Matcher for a FormData which checks that the submitted fields correspond -// to the name/value pairs in `expected`. -auto SubmittedValuesAre( - const std::vector<std::u16string FormFieldData::*>& property_accessors, - const std::vector<std::vector<std::u16string>>& expected) { - auto get_submitted_values = [property_accessors](const FormData& form) { - std::vector<std::vector<std::u16string>> result; - for (const auto& field : form.fields) { - std::vector<std::u16string> field_properties; - for (std::u16string FormFieldData::*field_member : property_accessors) { - field_properties.push_back(field.*field_member); - } - result.push_back(field_properties); - } - return result; - }; - return ResultOf("get_submitted_values", get_submitted_values, - ::testing::ContainerEq(expected)); -} - } // namespace // Test fixtures derive from this class. This class hierarchy allows test @@ -1743,7 +1741,7 @@ .ExtractString(), }; - EXPECT_THAT(input_element_events, testing::ElementsAre("input", "change")); + EXPECT_THAT(input_element_events, ElementsAre("input", "change")); EXPECT_EQ(2, content::EvalJs(GetWebContents(), "selectElementEvents.length;")); @@ -1755,7 +1753,7 @@ .ExtractString(), }; - EXPECT_THAT(select_element_events, testing::ElementsAre("input", "change")); + EXPECT_THAT(select_element_events, ElementsAre("input", "change")); } // Test that we can autofill forms distinguished only by their |id| attribute. @@ -3855,14 +3853,33 @@ ASSERT_TRUE(waiter.Wait(num_modified_textfields)); } - std::vector<std::vector<std::u16string>> GetExpectedValues() { - // name, value - return std::vector<std::vector<std::u16string>>{ - {u"name", u"Sarah"}, - {u"address", u"123 Main Road"}, - {u"city", u""}, - {u"zip", u""}, - {u"state", u"WA"}}; + [[nodiscard]] static auto HasExpectedValues() { + struct NameValue { + std::u16string name; + std::u16string value; + }; + std::vector<NameValue> expected = {{u"name", u"Sarah"}, + {u"address", u"123 Main Road"}, + {u"city", u""}, + {u"zip", u""}, + {u"state", u"WA"}}; + return FieldsAre(Map(expected, [](const NameValue& nv) { + return AllOf(Field("name", &FormFieldData::name, nv.name), + Field("value", &FormFieldData::value, nv.value)); + })); + } + + struct NameValueUserInput { + std::u16string name; + std::u16string value; + std::u16string user_input; + }; + [[nodiscard]] static auto HasNameValueUserInput( + const NameValueUserInput& nvu) { + return AllOf( + Field("name", &FormFieldData::name, nvu.name), + Field("value", &FormFieldData::value, nvu.value), + Field("user_input", &FormFieldData::user_input, nvu.user_input)); } void ExecuteScript(const std::string& script) { @@ -3882,12 +3899,10 @@ base::RunLoop run_loop; // Ensure that only expected form submissions are recorded. EXPECT_CALL(*autofill_manager(), OnFormSubmittedImpl).Times(0); - EXPECT_CALL( - *autofill_manager(), - OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value}, - GetExpectedValues()), - /*known_success=*/false, mojom::SubmissionSource::FORM_SUBMISSION)) + EXPECT_CALL(*autofill_manager(), + OnFormSubmittedImpl(HasExpectedValues(), + /*known_success=*/false, + mojom::SubmissionSource::FORM_SUBMISSION)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); ExecuteScript("document.getElementById('shipping').submit();"); @@ -3905,11 +3920,9 @@ EXPECT_CALL(*autofill_manager(), OnFormSubmittedImpl).Times(0); EXPECT_CALL( *autofill_manager(), - OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value}, - GetExpectedValues()), - /*known_success=*/false, - mojom::SubmissionSource::PROBABLY_FORM_SUBMITTED)) + OnFormSubmittedImpl(HasExpectedValues(), + /*known_success=*/false, + mojom::SubmissionSource::PROBABLY_FORM_SUBMITTED)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); // Add a delay before navigating away to avoid race conditions. This is @@ -3929,11 +3942,9 @@ EXPECT_CALL(*autofill_manager(), OnFormSubmittedImpl).Times(0); EXPECT_CALL( *autofill_manager(), - OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value}, - GetExpectedValues()), - /*known_success=*/true, - mojom::SubmissionSource::SAME_DOCUMENT_NAVIGATION)) + OnFormSubmittedImpl(HasExpectedValues(), + /*known_success=*/true, + mojom::SubmissionSource::SAME_DOCUMENT_NAVIGATION)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); @@ -3961,12 +3972,10 @@ // Ensure that only expected form submissions are recorded. EXPECT_CALL(*autofill_manager(), OnFormSubmittedImpl).Times(0); - EXPECT_CALL( - *autofill_manager(), - OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value}, - GetExpectedValues()), - /*known_success=*/true, mojom::SubmissionSource::XHR_SUCCEEDED)) + EXPECT_CALL(*autofill_manager(), + OnFormSubmittedImpl(HasExpectedValues(), + /*known_success=*/true, + mojom::SubmissionSource::XHR_SUCCEEDED)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); @@ -3994,12 +4003,10 @@ // Ensure that only expected form submissions are recorded. EXPECT_CALL(*autofill_manager(), OnFormSubmittedImpl).Times(0); - EXPECT_CALL( - *autofill_manager(), - OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value}, - GetExpectedValues()), - /*known_success=*/true, mojom::SubmissionSource::XHR_SUCCEEDED)) + EXPECT_CALL(*autofill_manager(), + OnFormSubmittedImpl(HasExpectedValues(), + /*known_success=*/true, + mojom::SubmissionSource::XHR_SUCCEEDED)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); @@ -4029,11 +4036,9 @@ EXPECT_CALL(*autofill_manager(), OnFormSubmittedImpl).Times(0); EXPECT_CALL( *autofill_manager(), - OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value}, - GetExpectedValues()), - /*known_success=*/true, - mojom::SubmissionSource::DOM_MUTATION_AFTER_XHR)) + OnFormSubmittedImpl(HasExpectedValues(), + /*known_success=*/true, + mojom::SubmissionSource::DOM_MUTATION_AFTER_XHR)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); @@ -4061,17 +4066,14 @@ // page replaces the <input> value with '***'. IN_PROC_BROWSER_TEST_F(MAYBE_AutofillInteractiveFormSubmissionTest, RememberUserInput) { - EnterValues(); - - // name, value, user_input - const std::vector<std::vector<std::u16string>> kExpectedSubmittedValues{ + const std::vector<NameValueUserInput> kExpectedSubmittedValues{ {u"name", u"JS Modified Name", u"Sarah"}, {u"address", u"JS Modified Address", u"123 Main Road"}, {u"city", u"", u""}, {u"zip", u"", u""}, - // user_input is not set for <select> - {u"state", u"WA", u""}}; + {u"state", u"WA", u""}}; // user_input is not set for <select>. + EnterValues(); ExecuteScript("document.getElementById('name').value = 'JS Modified Name';"); ExecuteScript( "document.getElementById('address').value = 'JS Modified Address';"); @@ -4082,9 +4084,7 @@ EXPECT_CALL( *autofill_manager(), OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value, - &FormFieldData::user_input}, - kExpectedSubmittedValues), + FieldsAre(Map(kExpectedSubmittedValues, HasNameValueUserInput)), /*known_success=*/false, mojom::SubmissionSource::FORM_SUBMISSION)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); @@ -4117,23 +4117,18 @@ {"state", kDefaultAddressValues.state_short}}; EXPECT_THAT(GetFormValues(), ValuesAre(kExpectedAddress)); - std::vector<std::vector<std::u16string>> expected_submitted_values; - for (const FieldValue& field_value : kExpectedAddress) { - expected_submitted_values.push_back( - {/*name=*/base::UTF8ToUTF16(field_value.id), - /*value=*/base::UTF8ToUTF16(field_value.value), - /*user_input=*/u""}); - } - base::RunLoop run_loop; // Ensure that only expected form submissions are recorded. EXPECT_CALL(*autofill_manager(), OnFormSubmittedImpl).Times(0); EXPECT_CALL( *autofill_manager(), OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value, - &FormFieldData::user_input}, - expected_submitted_values), + FieldsAre(Map(kExpectedAddress, + [](const FieldValue& fv) { + return HasNameValueUserInput( + {base::UTF8ToUTF16(fv.id), + base::UTF8ToUTF16(fv.value), u""}); + })), /*known_success=*/false, mojom::SubmissionSource::FORM_SUBMISSION)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure())); @@ -4190,13 +4185,11 @@ {"state", "CA"}}; EXPECT_THAT(GetFormValues(), ValuesAre(kClearedAddress)); - // name, value, user_input - std::vector<std::vector<std::u16string>> kSubmittedValues = { - {u"name", u"", u""}, - {u"address", u"", u""}, - {u"city", u"", u""}, - {u"zip", u"", u""}, - {u"state", u"CA", u""}}; + std::vector<NameValueUserInput> kSubmittedValues = {{u"name", u"", u""}, + {u"address", u"", u""}, + {u"city", u"", u""}, + {u"zip", u"", u""}, + {u"state", u"CA", u""}}; base::RunLoop run_loop; // Ensure that only expected form submissions are recorded. @@ -4204,9 +4197,7 @@ EXPECT_CALL( *autofill_manager(), OnFormSubmittedImpl( - SubmittedValuesAre({&FormFieldData::name, &FormFieldData::value, - &FormFieldData::user_input}, - kSubmittedValues), + FieldsAre(Map(kSubmittedValues, HasNameValueUserInput)), /*known_success=*/false, mojom::SubmissionSource::FORM_SUBMISSION)) .Times(1) .WillRepeatedly(InvokeClosure(run_loop.QuitClosure()));
diff --git a/chrome/browser/chromeos/app_mode/kiosk_browser_session_unittest.cc b/chrome/browser/chromeos/app_mode/kiosk_browser_session_unittest.cc index ade0ad4..24d16e6 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_browser_session_unittest.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_browser_session_unittest.cc
@@ -12,6 +12,7 @@ #include "base/memory/ptr_util.h" #include "base/test/bind.h" #include "base/test/metrics/histogram_tester.h" +#include "base/test/test_future.h" #include "chrome/browser/chromeos/app_mode/kiosk_browser_session.h" #include "chrome/browser/chromeos/app_mode/kiosk_browser_window_handler.h" #include "chrome/browser/chromeos/app_mode/kiosk_metrics_service.h" @@ -466,6 +467,30 @@ histogram()->ExpectTotalCount(kKioskSessionDurationInDaysNormalHistogram, 0); } +TEST_F(KioskBrowserSessionTest, ChromeAppKioskShouldClosePreexistingBrowsers) { + std::unique_ptr<Browser> preexisting_browser = CreateBrowserWithTestWindow(); + base::test::TestFuture<void> closed_future; + + static_cast<TestBrowserWindow*>(preexisting_browser->window()) + ->SetCloseCallback(closed_future.GetCallback()); + + StartChromeAppKioskSession(); + + ASSERT_TRUE(closed_future.IsReady()); +} + +TEST_F(KioskBrowserSessionTest, WebKioskShouldNotClosePreexistingBrowsers) { + std::unique_ptr<Browser> preexisting_browser = CreateBrowserWithTestWindow(); + base::test::TestFuture<void> closed_future; + + static_cast<TestBrowserWindow*>(preexisting_browser->window()) + ->SetCloseCallback(closed_future.GetCallback()); + + StartWebKioskSession(); + + ASSERT_FALSE(closed_future.IsReady()); +} + // Check that sessions list in local_state contains only sessions within the // last 24h. TEST_F(KioskBrowserSessionTest, WebKioskLastDaySessions) {
diff --git a/chrome/browser/chromeos/app_mode/kiosk_browser_window_handler.cc b/chrome/browser/chromeos/app_mode/kiosk_browser_window_handler.cc index 23e4affc0..2fc2f3c 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_browser_window_handler.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_browser_window_handler.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/chromeos/app_mode/kiosk_browser_window_handler.h" #include <memory> +#include "base/check_deref.h" #include "base/metrics/histogram_functions.h" #include "base/task/single_thread_task_runner.h" #include "chrome/browser/chromeos/app_mode/kiosk_policies.h" @@ -45,6 +46,20 @@ #endif } +std::string GetUrlOfActiveTab(const Browser* browser) { + content::WebContents* active_tab = + browser->tab_strip_model()->GetActiveWebContents(); + return active_tab ? active_tab->GetVisibleURL().spec() : std::string(); +} + +void CloseAllBrowserWindows() { + for (auto* browser : CHECK_DEREF(BrowserList::GetInstance())) { + LOG(WARNING) << "kiosk: Closing unexpected browser window with url: " + << GetUrlOfActiveTab(browser); + browser->window()->Close(); + } +} + } // namespace const char kKioskNewBrowserWindowHistogram[] = "Kiosk.NewBrowserWindow"; @@ -76,6 +91,11 @@ weak_ptr_factory_.GetWeakPtr())); #endif // BUILDFLAG(IS_CHROMEOS_LACROS) + if (!web_app_name.has_value()) { + // If this is ChromeApp kiosk, close all preexisting browser windows to + // avoid potential kiosk escapes. + CloseAllBrowserWindows(); + } BrowserList::AddObserver(this); } @@ -84,10 +104,7 @@ } void KioskBrowserWindowHandler::HandleNewBrowserWindow(Browser* browser) { - content::WebContents* active_tab = - browser->tab_strip_model()->GetActiveWebContents(); - std::string url_string = - active_tab ? active_tab->GetVisibleURL().spec() : std::string(); + std::string url_string = GetUrlOfActiveTab(browser); if (KioskSettingsNavigationThrottle::IsSettingsPage(url_string)) { base::UmaHistogramEnumeration(kKioskNewBrowserWindowHistogram,
diff --git a/chrome/browser/devtools/aida_client.cc b/chrome/browser/devtools/aida_client.cc index a22dc50..b72f9f9 100644 --- a/chrome/browser/devtools/aida_client.cc +++ b/chrome/browser/devtools/aida_client.cc
@@ -46,6 +46,11 @@ return; } auto* identity_manager = IdentityManagerFactory::GetForProfile(&*profile_); + if (!identity_manager) { + std::move(callback).Run( + R"([{"error": "IdentityManager is not available"}])"); + return; + } CoreAccountId account_id = identity_manager->GetPrimaryAccountId(signin::ConsentLevel::kSync); access_token_fetcher_ = identity_manager->CreateAccessTokenFetcherForAccount(
diff --git a/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.cc b/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.cc index b0a52d5..341c70cd 100644 --- a/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.cc +++ b/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.cc
@@ -77,15 +77,13 @@ bool ShouldScan(PrintScanningContext context, const ContentAnalysisDelegate::Data& scanning_data) { - return scanning_data.settings.cloud_or_local_settings.is_local_analysis() - ? ShouldDoScan( - base::FeatureList::IsEnabled( - printing::features::kEnableLocalScanAfterPreview), - context) - : ShouldDoScan( - base::FeatureList::IsEnabled( - printing::features::kEnableCloudScanAfterPreview), - context); + return ShouldDoScan( + /*post_dialog_feature_enabled=*/ + scanning_data.settings.cloud_or_local_settings.is_local_analysis() + ? true + : base::FeatureList::IsEnabled( + printing::features::kEnableCloudScanAfterPreview), + context); } void RecordPrintType(PrintScanningContext context,
diff --git a/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.h b/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.h index c368a22..4ea3892 100644 --- a/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.h +++ b/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils.h
@@ -19,8 +19,8 @@ // Represents context for the kind of print workflow that needs to check if // scanning should happen. This is used in conjunction with the -// `kEnableCloudScanAfterPreview` and `kEnableLocalScanAfterPreview` to control -// the timing at which scanning occurs. +// `kEnableCloudScanAfterPreview` to control the timing at which scanning +// occurs. // // +-------------#3-------------+ // | V
diff --git a/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils_unittest.cc b/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils_unittest.cc index bfb72e57..70b8598 100644 --- a/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils_unittest.cc +++ b/chrome/browser/enterprise/connectors/analysis/print_content_analysis_utils_unittest.cc
@@ -142,37 +142,22 @@ class PrintContentAnalysisUtilsTest : public PrintPreviewTest, - public testing::WithParamInterface< - testing::tuple<const char*, bool, bool>> { + public testing::WithParamInterface<testing::tuple<const char*, bool>> { public: PrintContentAnalysisUtilsTest() { - std::vector<base::test::FeatureRefAndParams> enabled_features; - std::vector<base::test::FeatureRef> disabled_features; - if (local_scan_after_preview_feature_enabled()) { - enabled_features.push_back( - {printing::features::kEnableLocalScanAfterPreview, {}}); - } else { - disabled_features.push_back( - printing::features::kEnableLocalScanAfterPreview); - } if (cloud_scan_after_preview_feature_enabled()) { - enabled_features.push_back( - {printing::features::kEnableCloudScanAfterPreview, {}}); + scoped_feature_list_.InitAndEnableFeature( + printing::features::kEnableCloudScanAfterPreview); } else { - disabled_features.push_back( + scoped_feature_list_.InitAndDisableFeature( printing::features::kEnableCloudScanAfterPreview); } - scoped_feature_list_.InitWithFeaturesAndParameters(enabled_features, - disabled_features); ContentAnalysisDelegate::DisableUIForTesting(); } const char* policy_value() const { return std::get<0>(GetParam()); } - bool local_scan_after_preview_feature_enabled() const { - return std::get<1>(GetParam()); - } bool cloud_scan_after_preview_feature_enabled() const { - return std::get<2>(GetParam()); + return std::get<1>(GetParam()); } void SetUp() override { @@ -227,8 +212,7 @@ // Helper that returns true when the policy/feature values should return in // pre-dialog content analysis. bool ExpectPostDialogAnalysis() { - return (policy_value() == kLocalPolicy && - local_scan_after_preview_feature_enabled()) || + return policy_value() == kLocalPolicy || (policy_value() == kCloudPolicy && cloud_scan_after_preview_feature_enabled()); } @@ -842,7 +826,6 @@ PrintContentAnalysisUtilsTest, testing::Combine( /*policy_value=*/testing::Values(kLocalPolicy, kCloudPolicy), - /*local_scan_after_preview_feature_enabled=*/testing::Bool(), /*cloud_scan_after_preview_feature_enabled=*/testing::Bool())); } // namespace enterprise_connectors
diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc index d04bdcf7..e89e3e2 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc
@@ -299,14 +299,6 @@ base::BindRepeating( &PasswordsPrivateDelegateImpl::OnPasswordsExportProgress, base::Unretained(this)))), - password_account_storage_settings_watcher_( - std::make_unique< - password_manager::PasswordAccountStorageSettingsWatcher>( - profile_->GetPrefs(), - SyncServiceFactory::GetForProfile(profile_), - base::BindRepeating(&PasswordsPrivateDelegateImpl:: - OnAccountStorageOptInStateChanged, - base::Unretained(this)))), password_check_delegate_(profile, &saved_passwords_presenter_, &credential_id_generator_), @@ -318,6 +310,11 @@ saved_passwords_presenter_.AddObserver(this); saved_passwords_presenter_.Init(); + if (syncer::SyncService* service = + SyncServiceFactory::GetForProfile(profile_)) { + sync_service_observation_.Observe(service); + } + #if !BUILDFLAG(IS_CHROMEOS) auto* provider = web_app::WebAppProvider::GetForWebApps(profile); install_manager_observation_.Observe(&provider->install_manager()); @@ -1050,7 +1047,8 @@ base::BindOnce(&ConvertImportResults).Then(std::move(results_callback))); } -void PasswordsPrivateDelegateImpl::OnAccountStorageOptInStateChanged() { +void PasswordsPrivateDelegateImpl::OnStateChanged( + syncer::SyncService* sync_service) { PasswordsPrivateEventRouter* router = PasswordsPrivateEventRouterFactory::GetForProfile(profile_); if (router) {
diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h index 73c2d71..b17fa5e 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h
@@ -15,6 +15,7 @@ #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/scoped_observation.h" #include "build/build_config.h" #include "chrome/browser/extensions/api/passwords_private/password_access_auth_timeout_handler.h" #include "chrome/browser/extensions/api/passwords_private/password_check_delegate.h" @@ -28,9 +29,10 @@ #include "components/password_manager/core/browser/export/export_progress_status.h" #include "components/password_manager/core/browser/export/password_manager_exporter.h" #include "components/password_manager/core/browser/sharing/recipients_fetcher.h" -#include "components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h" #include "components/password_manager/core/browser/ui/credential_ui_entry.h" #include "components/password_manager/core/browser/ui/saved_passwords_presenter.h" +#include "components/sync/service/sync_service.h" +#include "components/sync/service/sync_service_observer.h" #include "extensions/browser/extension_function.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -54,6 +56,7 @@ class PasswordsPrivateDelegateImpl : public PasswordsPrivateDelegate, public password_manager::SavedPasswordsPresenter::Observer, + public syncer::SyncServiceObserver, public web_app::WebAppInstallManagerObserver { public: using AuthResultCallback = base::OnceCallback<void(bool)>; @@ -225,7 +228,8 @@ const std::vector<int>& selected_ids, bool authenticated); - void OnAccountStorageOptInStateChanged(); + // SyncServiceObserver overrides. + void OnStateChanged(syncer::SyncService* sync_service) override; void OnFetchingFamilyMembersCompleted( FetchFamilyResultsCallback callback, @@ -264,9 +268,6 @@ PasswordAccessAuthTimeoutHandler auth_timeout_handler_; - std::unique_ptr<password_manager::PasswordAccountStorageSettingsWatcher> - password_account_storage_settings_watcher_; - PasswordCheckDelegate password_check_delegate_; // The current list of entries/exceptions. Cached here so that when new @@ -293,6 +294,9 @@ // Device authenticator used to authenticate users in settings. std::unique_ptr<device_reauth::DeviceAuthenticator> device_authenticator_; + base::ScopedObservation<syncer::SyncService, syncer::SyncServiceObserver> + sync_service_observation_{this}; + base::ScopedObservation<web_app::WebAppInstallManager, web_app::WebAppInstallManagerObserver> install_manager_observation_{this};
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index 2aa6791e8..e4f40fd7 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -6134,6 +6134,11 @@ "expiry_milestone": 125 }, { + "name": "optimization-guide-on-device-model", + "owners": [ "cduvall@chromium.org", "jam@chromium.org", "rockot@chromium.org", "sky@chromium.org", "chrome-intelligence-core@google.com" ], + "expiry_milestone": 150 + }, + { "name": "optimization-guide-personalized-fetching", "owners": [ "sophiechang@chromium.org", "chrome-intelligence-core@google.com", "edmundw@google.com", "gbb-cct-eng@google.com" ], "expiry_milestone": 130
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index 8bd5956..4f92be7 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -2631,6 +2631,11 @@ const char kOptimizationGuideModelExecutionDescription[] = "Enables the optimization guide to execute models."; +const char kOptimizationGuideOnDeviceModelName[] = + "Enables optimization guide on device"; +const char kOptimizationGuideOnDeviceModelDescription[]= + "Enables the optimization guide to execute models on device."; + const char kOptimizationGuidePersonalizedFetchingName[] = "Enable optimization guide personalized fetching"; const char kOptimizationGuidePersonalizedFetchingDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index e0609c3..ca4c8f9 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -1509,6 +1509,9 @@ extern const char kOptimizationGuideModelExecutionName[]; extern const char kOptimizationGuideModelExecutionDescription[]; +extern const char kOptimizationGuideOnDeviceModelName[]; +extern const char kOptimizationGuideOnDeviceModelDescription[]; + extern const char kOptimizationGuidePersonalizedFetchingName[]; extern const char kOptimizationGuidePersonalizedFetchingDescription[];
diff --git a/chrome/browser/password_check/android/password_check_manager.h b/chrome/browser/password_check/android/password_check_manager.h index b05d24e..1834a31 100644 --- a/chrome/browser/password_check/android/password_check_manager.h +++ b/chrome/browser/password_check/android/password_check_manager.h
@@ -23,7 +23,6 @@ #include "components/password_manager/core/browser/ui/credential_ui_entry.h" #include "components/password_manager/core/browser/ui/insecure_credentials_manager.h" #include "components/password_manager/core/browser/ui/saved_passwords_presenter.h" -#include "third_party/abseil-cpp/absl/types/optional.h" class PasswordCheckManager : public password_manager::SavedPasswordsPresenter::Observer,
diff --git a/chrome/browser/password_check/android/password_check_manager_unittest.cc b/chrome/browser/password_check/android/password_check_manager_unittest.cc index 3eb42d2..357fbf6 100644 --- a/chrome/browser/password_check/android/password_check_manager_unittest.cc +++ b/chrome/browser/password_check/android/password_check_manager_unittest.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/password_check/android/password_check_manager.h" #include <memory> +#include <optional> #include "base/functional/bind.h" #include "base/memory/raw_ptr.h" @@ -38,7 +39,6 @@ #include "services/network/test/test_shared_url_loader_factory.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using password_manager::BulkLeakCheckService; using password_manager::InsecureType; @@ -158,8 +158,8 @@ const std::u16string& display_username, const std::u16string& display_origin, const GURL& url, - const absl::optional<std::string>& package_name, - const absl::optional<std::string>& change_password_url, + const std::optional<std::string>& package_name, + const std::optional<std::string>& change_password_url, InsecureType insecure_type) { auto package_name_field_matcher = package_name.has_value() @@ -287,7 +287,7 @@ RunUntilIdle(); EXPECT_THAT(manager().GetCompromisedCredentials(), ElementsAre(ExpectCompromisedCredentialForUI( - kUsername1, u"example.com", GURL(kExampleCom), absl::nullopt, + kUsername1, u"example.com", GURL(kExampleCom), std::nullopt, "https://example.com/.well-known/change-password", InsecureType::kLeaked))); } @@ -318,15 +318,14 @@ store().AddLogin(MakeSavedAndroidPassword(kExampleOrg, kUsername2)); EXPECT_THAT(manager().GetCompromisedCredentialsCount(), 2); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - UnorderedElementsAre( - ExpectCompromisedCredentialForUI( - kUsername1, u"App (com.example.app)", GURL::EmptyGURL(), - "com.example.app", absl::nullopt, InsecureType::kLeaked), - ExpectCompromisedCredentialForUI( - kUsername2, u"Example App", GURL(kExampleCom), "com.example.app", - absl::nullopt, InsecureType::kLeaked))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + UnorderedElementsAre( + ExpectCompromisedCredentialForUI( + kUsername1, u"App (com.example.app)", GURL::EmptyGURL(), + "com.example.app", std::nullopt, InsecureType::kLeaked), + ExpectCompromisedCredentialForUI( + kUsername2, u"Example App", GURL(kExampleCom), + "com.example.app", std::nullopt, InsecureType::kLeaked))); } TEST_F(PasswordCheckManagerTest, SetsTimestampOnSuccessfulCheck) { @@ -370,7 +369,7 @@ EXPECT_THAT(manager().GetCompromisedCredentials(), ElementsAre(ExpectCompromisedCredentialForUI( - kUsername1, u"example.com", GURL(kExampleCom), absl::nullopt, + kUsername1, u"example.com", GURL(kExampleCom), std::nullopt, "https://example.com/.well-known/change-password", InsecureType::kLeaked))); }
diff --git a/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper.h b/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper.h index 77ad730..cfb2dfe 100644 --- a/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper.h +++ b/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper.h
@@ -5,11 +5,12 @@ #ifndef CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_ALL_PASSWORDS_BOTTOM_SHEET_HELPER_H_ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_ALL_PASSWORDS_BOTTOM_SHEET_HELPER_H_ +#include <optional> + #include "base/functional/callback_forward.h" #include "base/memory/weak_ptr.h" #include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h" #include "components/password_manager/core/browser/password_store/password_store_consumer.h" -#include "third_party/abseil-cpp/absl/types/optional.h" // This class helps to determine the visibility of the "All Passwords Sheet" // button by requesting whether there are any passwords stored at all. @@ -28,7 +29,7 @@ // Returns the number of found credentials only if the helper already finished // querying the password store. - absl::optional<size_t> available_credentials() const { + std::optional<size_t> available_credentials() const { return available_credentials_; } @@ -48,7 +49,7 @@ base::OnceClosure update_callback_; // Stores whether the store returned credentials the sheet can show. - absl::optional<size_t> available_credentials_ = absl::nullopt; + std::optional<size_t> available_credentials_ = std::nullopt; // Records the last focused field type to infer whether an update should be // triggered if the store returns suggestions.
diff --git a/chrome/browser/password_manager/android/password_accessory_controller_impl.cc b/chrome/browser/password_manager/android/password_accessory_controller_impl.cc index 24b627f..98a989d9 100644 --- a/chrome/browser/password_manager/android/password_accessory_controller_impl.cc +++ b/chrome/browser/password_manager/android/password_accessory_controller_impl.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/password_manager/android/password_accessory_controller_impl.h" +#include <optional> #include <string> #include <utility> @@ -49,7 +50,6 @@ #include "components/webauthn/android/webauthn_cred_man_delegate.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/l10n/l10n_util.h" using autofill::AccessorySheetData; @@ -150,23 +150,23 @@ source_observer_ = std::move(observer); } -absl::optional<AccessorySheetData> +std::optional<AccessorySheetData> PasswordAccessoryControllerImpl::GetSheetData() const { // Prevent crashing by returning a nullopt if no field was focused yet or if // the frame was (possibly temporarily) unfocused. This signals to the caller // that no sheet is available right now. if (GetWebContents().GetFocusedFrame() == nullptr) { - return absl::nullopt; + return std::nullopt; } if (!last_focused_field_info_) { - return absl::nullopt; + return std::nullopt; } url::Origin origin = GetFocusedFrameOrigin(); // If the focused origin doesn't match the last known origin, it is not safe // to provide any suggestions (because e.g. information about field type isn't // reliable). if (!last_focused_field_info_->origin.IsSameOriginWith(origin)) { - return absl::nullopt; + return std::nullopt; } std::vector<PasskeySection> passkeys_to_add; @@ -431,7 +431,7 @@ bool is_manual_generation_available) { // Discard all frame data. This ensures that the data is never used for an // incorrect frame. - last_focused_field_info_ = absl::nullopt; + last_focused_field_info_ = std::nullopt; all_passwords_helper_.SetLastFocusedFieldType(focused_field_type); // Prevent crashing by not acting at all if frame became unfocused at any
diff --git a/chrome/browser/password_manager/android/password_accessory_controller_impl.h b/chrome/browser/password_manager/android/password_accessory_controller_impl.h index f0c59782..6cb4870 100644 --- a/chrome/browser/password_manager/android/password_accessory_controller_impl.h +++ b/chrome/browser/password_manager/android/password_accessory_controller_impl.h
@@ -55,7 +55,7 @@ // AccessoryController: void RegisterFillingSourceObserver(FillingSourceObserver observer) override; - absl::optional<autofill::AccessorySheetData> GetSheetData() const override; + std::optional<autofill::AccessorySheetData> GetSheetData() const override; void OnFillingTriggered( autofill::FieldGlobalId focused_field_id, const autofill::AccessorySheetField& selection) override; @@ -199,9 +199,9 @@ // Information about the currently focused field. This is the only place // allowed to store frame-specific data. If a new field is focused or focus is - // lost, this data needs to be reset to absl::nullopt to make sure that data + // lost, this data needs to be reset to std::nullopt to make sure that data // related to a former frame isn't displayed incorrectly in a different one. - absl::optional<LastFocusedFieldInfo> last_focused_field_info_ = absl::nullopt; + std::optional<LastFocusedFieldInfo> last_focused_field_info_ = std::nullopt; // The observer to notify if available suggestions change. FillingSourceObserver source_observer_;
diff --git a/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc b/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc index 4410c691..34756b0 100644 --- a/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc +++ b/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc
@@ -96,8 +96,7 @@ constexpr char16_t kExampleDomain[] = u"example.com"; constexpr char16_t kUsername[] = u"alice"; constexpr char16_t kPassword[] = u"password123"; -const absl::optional<std::vector<PasskeyCredential>> kNoPasskeys = - absl::nullopt; +const std::optional<std::vector<PasskeyCredential>> kNoPasskeys = std::nullopt; class MockPasswordGenerationController : public PasswordGenerationControllerImpl { @@ -1225,7 +1224,7 @@ PasskeyCredential::CredentialId({21, 22, 23, 24}), PasskeyCredential::UserId({81, 28, 83, 84}), PasskeyCredential::Username("someone@example.com")); - const absl::optional<std::vector<PasskeyCredential>> kTestPasskeys( + const std::optional<std::vector<PasskeyCredential>> kTestPasskeys( {kTestPasskey}); ON_CALL(*webauthn_credentials_delegate(), GetPasskeys) .WillByDefault(ReturnRef(kTestPasskeys));
diff --git a/chrome/browser/password_manager/android/password_generation_controller_impl_unittest.cc b/chrome/browser/password_manager/android/password_generation_controller_impl_unittest.cc index e145b92..407f49f 100644 --- a/chrome/browser/password_manager/android/password_generation_controller_impl_unittest.cc +++ b/chrome/browser/password_manager/android/password_generation_controller_impl_unittest.cc
@@ -39,7 +39,6 @@ #include "components/prefs/testing_pref_service.h" #include "content/public/browser/web_contents.h" #include "testing/gmock/include/gmock/gmock.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using autofill::password_generation::PasswordGenerationType; using password_manager::metrics_util::GenerationDialogChoice;
diff --git a/chrome/browser/password_manager/android/password_infobar_utils.cc b/chrome/browser/password_manager/android/password_infobar_utils.cc index 6a659224..bba8e5c 100644 --- a/chrome/browser/password_manager/android/password_infobar_utils.cc +++ b/chrome/browser/password_manager/android/password_infobar_utils.cc
@@ -33,7 +33,7 @@ std::string GetDisplayableAccountName(content::WebContents* web_contents) { Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); - absl::optional<AccountInfo> account_info = + std::optional<AccountInfo> account_info = password_manager::GetAccountInfoForPasswordMessages(profile); if (!account_info.has_value()) { return "";
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc index 5c469cd2..439677b 100644 --- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc +++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h" +#include <optional> + #include "base/feature_list.h" #include "base/functional/bind.h" #include "base/logging.h" @@ -22,7 +24,6 @@ #include "components/sync/base/user_selectable_type.h" #include "components/sync/service/sync_service.h" #include "components/sync/service/sync_user_settings.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using password_manager::PasswordManagerSetting; using password_manager::PasswordSettingsUpdaterAndroidBridgeHelper; @@ -181,7 +182,7 @@ pref_service_->SetBoolean(password_manager::prefs::kAutoSignInEnabledGMS, false); - absl::optional<SyncingAccount> account = absl::nullopt; + std::optional<SyncingAccount> account = std::nullopt; // TODO(crbug.com/1466445): Migrate away from `ConsentLevel::kSync` on // Android. if (is_password_sync_enabled_) { @@ -250,12 +251,12 @@ // is absent in GMSCore, the cached setting value is set to the default value, // which is true for both of the password-related settings: AutoSignIn and // OfferToSavePasswords. - WriteToTheCacheAndRegularPref(setting, absl::nullopt); + WriteToTheCacheAndRegularPref(setting, std::nullopt); } void PasswordManagerSettingsServiceAndroidImpl::WriteToTheCacheAndRegularPref( PasswordManagerSetting setting, - absl::optional<bool> value) { + std::optional<bool> value) { const PrefService::Preference* android_pref = GetGMSPrefFromSetting(pref_service_, setting); if (value.has_value()) { @@ -332,7 +333,7 @@ CHECK(bridge_helper_); // This code would not be executed for syncing users who are unenrolled. CHECK(!is_password_sync_enabled_ || !IsCurrentUserEvicted(pref_service_)); - absl::optional<SyncingAccount> account = absl::nullopt; + std::optional<SyncingAccount> account = std::nullopt; bool is_final_fetch_for_local_user_without_upm = fetch_after_sync_status_change_in_progress_ && !is_password_sync_enabled_ &&
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h index aedecffe..42f1623c 100644 --- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h +++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h
@@ -75,7 +75,7 @@ // If the `value` is not given, the prefs will be set to default. void WriteToTheCacheAndRegularPref( password_manager::PasswordManagerSetting setting, - absl::optional<bool> value); + std::optional<bool> value); // syncer::SyncServiceObserver implementation void OnStateChanged(syncer::SyncService* sync) override;
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc index b791b29..fd83223 100644 --- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc +++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h" #include <memory> +#include <optional> #include "base/memory/weak_ptr.h" #include "base/test/metrics/histogram_tester.h" @@ -23,7 +24,6 @@ #include "components/sync/test/test_sync_service.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace { @@ -45,11 +45,11 @@ MOCK_METHOD(void, SetConsumer, (base::WeakPtr<Consumer>), (override)); MOCK_METHOD(void, GetPasswordSettingValue, - (absl::optional<SyncingAccount>, PasswordManagerSetting), + (std::optional<SyncingAccount>, PasswordManagerSetting), (override)); MOCK_METHOD(void, SetPasswordSettingValue, - (absl::optional<SyncingAccount>, PasswordManagerSetting, bool), + (std::optional<SyncingAccount>, PasswordManagerSetting, bool), (override)); }; @@ -72,9 +72,8 @@ void SetPasswordsSync(bool enabled); void SetSettingsSync(bool enabled); - void ExpectSettingsRetrievalFromBackend( - absl::optional<SyncingAccount> account, - size_t times); + void ExpectSettingsRetrievalFromBackend(std::optional<SyncingAccount> account, + size_t times); void ExpectSettingsRetrievalFromBackend(); @@ -188,7 +187,7 @@ } void PasswordManagerSettingsServiceAndroidImplBaseTest:: - ExpectSettingsRetrievalFromBackend(absl::optional<SyncingAccount> account, + ExpectSettingsRetrievalFromBackend(std::optional<SyncingAccount> account, size_t times) { EXPECT_CALL( *bridge_helper(), @@ -1087,7 +1086,7 @@ InitializeSettingsService(/*password_sync_enabled=*/false, /*setting_sync_enabled=*/false); - ExpectSettingsRetrievalFromBackend(absl::nullopt, /*times=*/1); + ExpectSettingsRetrievalFromBackend(std::nullopt, /*times=*/1); lifecycle_helper()->OnForegroundSessionStart(); } @@ -1257,7 +1256,7 @@ InitializeSettingsService(/*password_sync_enabled=*/false, /*setting_sync_enabled=*/false); - ExpectSettingsRetrievalFromBackend(absl::nullopt, /*times=*/1); + ExpectSettingsRetrievalFromBackend(std::nullopt, /*times=*/1); settings_service()->RequestSettingsFromBackend(); } @@ -1274,7 +1273,7 @@ EXPECT_CALL( *bridge_helper(), - SetPasswordSettingValue(Eq(absl::nullopt), + SetPasswordSettingValue(Eq(std::nullopt), Eq(PasswordManagerSetting::kAutoSignIn), false)); settings_service()->TurnOffAutoSignIn(); @@ -1316,7 +1315,7 @@ password_manager::prefs::kAutoSignInEnabledGMS)); // Settings should be requested from GMS Core on sync state change. - ExpectSettingsRetrievalFromBackend(absl::nullopt, /*times=*/1); + ExpectSettingsRetrievalFromBackend(std::nullopt, /*times=*/1); SetPasswordsSync(/*enabled=*/false); sync_service()->FireStateChanged(); @@ -1348,7 +1347,7 @@ password_manager::prefs::kOfferToSavePasswordsEnabledGMS)); // Settings should be requested from GMS Core on sync state change. - ExpectSettingsRetrievalFromBackend(absl::nullopt, /*times=*/1); + ExpectSettingsRetrievalFromBackend(std::nullopt, /*times=*/1); SetPasswordsSync(/*enabled=*/false); sync_service()->FireStateChanged();
diff --git a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper.h b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper.h index de7f13bd..87c2b32 100644 --- a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper.h +++ b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper.h
@@ -5,9 +5,10 @@ #ifndef CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_SETTINGS_UPDATER_ANDROID_BRIDGE_HELPER_H_ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_SETTINGS_UPDATER_ANDROID_BRIDGE_HELPER_H_ +#include <optional> + #include "chrome/browser/password_manager/android/password_settings_updater_android_receiver_bridge.h" #include "components/password_manager/core/browser/password_manager_setting.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -40,10 +41,10 @@ // Password settings accessor bridge operations. Each operation is executed // asynchronously, the result is reported via consumer callback. - virtual void GetPasswordSettingValue(absl::optional<SyncingAccount> account, + virtual void GetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting) = 0; - virtual void SetPasswordSettingValue(absl::optional<SyncingAccount> account, + virtual void SetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting, bool value) = 0; };
diff --git a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.cc b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.cc index 6c2a20b..5930554 100644 --- a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.cc +++ b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.cc
@@ -87,7 +87,7 @@ } void PasswordSettingsUpdaterAndroidBridgeHelperImpl::GetPasswordSettingValue( - absl::optional<SyncingAccount> account, + std::optional<SyncingAccount> account, PasswordManagerSetting setting) { DCHECK_CALLED_ON_VALID_SEQUENCE(main_sequence_checker_); DCHECK(dispatcher_bridge_); @@ -100,7 +100,7 @@ } void PasswordSettingsUpdaterAndroidBridgeHelperImpl::SetPasswordSettingValue( - absl::optional<SyncingAccount> account, + std::optional<SyncingAccount> account, PasswordManagerSetting setting, bool value) { DCHECK_CALLED_ON_VALID_SEQUENCE(main_sequence_checker_);
diff --git a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.h b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.h index d6b3f34..d9435b6 100644 --- a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.h +++ b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl.h
@@ -39,10 +39,10 @@ // PasswordSettingsUpdaterAndroidBridgeHelper implementation void SetConsumer(base::WeakPtr<Consumer> consumer) override; - void GetPasswordSettingValue(absl::optional<SyncingAccount> account, + void GetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting) override; - void SetPasswordSettingValue(absl::optional<SyncingAccount> account, + void SetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting, bool value) override;
diff --git a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl_unittest.cc b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl_unittest.cc index 57d27e7..874393c 100644 --- a/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl_unittest.cc +++ b/chrome/browser/password_manager/android/password_settings_updater_android_bridge_helper_impl_unittest.cc
@@ -59,11 +59,11 @@ (override)); MOCK_METHOD(void, GetPasswordSettingValue, - (absl::optional<SyncingAccount>, PasswordManagerSetting), + (std::optional<SyncingAccount>, PasswordManagerSetting), (override)); MOCK_METHOD(void, SetPasswordSettingValue, - (absl::optional<SyncingAccount>, PasswordManagerSetting, bool), + (std::optional<SyncingAccount>, PasswordManagerSetting, bool), (override)); };
diff --git a/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge.h b/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge.h index b50e02d..c82236e 100644 --- a/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge.h +++ b/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge.h
@@ -5,10 +5,11 @@ #ifndef CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_SETTINGS_UPDATER_ANDROID_DISPATCHER_BRIDGE_H_ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_SETTINGS_UPDATER_ANDROID_DISPATCHER_BRIDGE_H_ +#include <optional> + #include "base/android/scoped_java_ref.h" #include "chrome/browser/password_manager/android/password_settings_updater_android_receiver_bridge.h" #include "components/password_manager/core/browser/password_manager_setting.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -29,13 +30,13 @@ // Asynchronously requests the value of `setting` from Google Mobile Services. // If `account` is not present, the value will be requested from the local // profile (i.e. a profile not tied to any account). - virtual void GetPasswordSettingValue(absl::optional<SyncingAccount> account, + virtual void GetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting) = 0; // Asynchronously sets the `value` of `setting` in Google Mobile Services. // If `account` is not present, the value will be set in the local profile // (i.e. a profile not tied to any account). - virtual void SetPasswordSettingValue(absl::optional<SyncingAccount> account, + virtual void SetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting, bool value) = 0; // Method that checks whether the settings accessor can be created or whether
diff --git a/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.cc b/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.cc index fa82a88..1083b5b 100644 --- a/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.cc +++ b/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.cc
@@ -4,13 +4,14 @@ #include "chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.h" +#include <optional> + #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "chrome/browser/password_manager/android/jni_headers/PasswordSettingsUpdaterDispatcherBridge_jni.h" #include "chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge.h" #include "chrome/browser/password_manager/android/password_settings_updater_android_receiver_bridge.h" #include "components/password_manager/core/browser/password_manager_setting.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -20,7 +21,7 @@ PasswordSettingsUpdaterAndroidDispatcherBridgeImpl::SyncingAccount; base::android::ScopedJavaLocalRef<jstring> GetJavaStringFromAccount( - absl::optional<SyncingAccount> account) { + std::optional<SyncingAccount> account) { if (!account.has_value()) { return nullptr; } @@ -64,7 +65,7 @@ } void PasswordSettingsUpdaterAndroidDispatcherBridgeImpl:: - GetPasswordSettingValue(absl::optional<SyncingAccount> account, + GetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); Java_PasswordSettingsUpdaterDispatcherBridge_getSettingValue( @@ -73,7 +74,7 @@ } void PasswordSettingsUpdaterAndroidDispatcherBridgeImpl:: - SetPasswordSettingValue(absl::optional<SyncingAccount> account, + SetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting, bool value) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
diff --git a/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.h b/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.h index 8c1c617..5074b46 100644 --- a/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.h +++ b/chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge_impl.h
@@ -5,10 +5,11 @@ #ifndef CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_SETTINGS_UPDATER_ANDROID_DISPATCHER_BRIDGE_IMPL_H_ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_SETTINGS_UPDATER_ANDROID_DISPATCHER_BRIDGE_IMPL_H_ +#include <optional> + #include "base/android/scoped_java_ref.h" #include "base/threading/thread_checker.h" #include "chrome/browser/password_manager/android/password_settings_updater_android_dispatcher_bridge.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -30,9 +31,9 @@ base::android::ScopedJavaGlobalRef<jobject> receiver_bridge) override; // PasswordSettingsUpdaterAndroidDispatcherBridge implementation. - void GetPasswordSettingValue(absl::optional<SyncingAccount> account, + void GetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting) override; - void SetPasswordSettingValue(absl::optional<SyncingAccount> account, + void SetPasswordSettingValue(std::optional<SyncingAccount> account, PasswordManagerSetting setting, bool value) override;
diff --git a/chrome/browser/password_manager/android/password_store_android_backend.cc b/chrome/browser/password_manager/android/password_store_android_backend.cc index aed3146..3c089bd 100644 --- a/chrome/browser/password_manager/android/password_store_android_backend.cc +++ b/chrome/browser/password_manager/android/password_store_android_backend.cc
@@ -8,6 +8,7 @@ #include <cmath> #include <list> #include <memory> +#include <optional> #include <string_view> #include <utility> #include <vector> @@ -49,7 +50,6 @@ #include "components/prefs/pref_service.h" #include "components/sync/model/proxy_model_type_controller_delegate.h" #include "components/sync/service/sync_service.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -223,7 +223,7 @@ } PasswordStoreAndroidBackendDispatcherBridge::Account GetAccount( - absl::optional<std::string> syncing_account) { + std::optional<std::string> syncing_account) { if (syncing_account.has_value()) { return PasswordStoreAndroidBackendDispatcherBridge::SyncingAccount( syncing_account.value()); @@ -232,7 +232,7 @@ } SuccessStatus GetSuccessStatusFromError( - const absl::optional<AndroidBackendError>& error) { + const std::optional<AndroidBackendError>& error) { if (!error.has_value()) return SuccessStatus::kSuccess; switch (error.value().type) { @@ -522,7 +522,7 @@ PasswordStoreAndroidBackend::JobReturnHandler::~JobReturnHandler() = default; void PasswordStoreAndroidBackend::JobReturnHandler::RecordMetrics( - absl::optional<AndroidBackendError> error) const { + std::optional<AndroidBackendError> error) const { SuccessStatus sucess_status = GetSuccessStatusFromError(error); metrics_recorder_.RecordMetrics(sucess_status, std::move(error)); } @@ -643,7 +643,7 @@ } void PasswordStoreAndroidBackend::GetAllLoginsForAccountAsync( - absl::optional<std::string> account, + std::optional<std::string> account, LoginsOrErrorReply callback) { DCHECK(account.has_value()); GetAllLoginsForAccount(GetAccount(account), std::move(callback)); @@ -833,7 +833,7 @@ // TODO(https://crbug.com/1278807): Implement error handling, when // actual store changes will be received from the store. metrics_recorder.RecordMetrics(SuccessStatus::kSuccess, - /*error=*/absl::nullopt); + /*error=*/std::nullopt); std::move(completion).Run(); }, PasswordStoreBackendMetricsRecorder( @@ -926,14 +926,14 @@ JobId job_id, std::vector<PasswordForm> passwords) { DCHECK_CALLED_ON_VALID_SEQUENCE(main_sequence_checker_); - absl::optional<JobReturnHandler> reply = GetAndEraseJob(job_id); + std::optional<JobReturnHandler> reply = GetAndEraseJob(job_id); if (!reply.has_value()) return; // Task cleaned up after returning from background. // Since the API call has succeeded, it's safe to reenable saving. prefs_->SetBoolean(prefs::kSavePasswordsSuspendedByError, false); - reply->RecordMetrics(/*error=*/absl::nullopt); + reply->RecordMetrics(/*error=*/std::nullopt); DCHECK(reply->Holds<LoginsOrErrorReply>()); main_task_runner_->PostTask( FROM_HERE, base::BindOnce(std::move(*reply).Get<LoginsOrErrorReply>(), @@ -943,10 +943,10 @@ void PasswordStoreAndroidBackend::OnLoginsChanged(JobId job_id, PasswordChanges changes) { DCHECK_CALLED_ON_VALID_SEQUENCE(main_sequence_checker_); - absl::optional<JobReturnHandler> reply = GetAndEraseJob(job_id); + std::optional<JobReturnHandler> reply = GetAndEraseJob(job_id); if (!reply.has_value()) return; // Task cleaned up after returning from background. - reply->RecordMetrics(/*error=*/absl::nullopt); + reply->RecordMetrics(/*error=*/std::nullopt); DCHECK(reply->Holds<PasswordChangesOrErrorReply>()); // Since the API call has succeeded, it's safe to reenable saving. @@ -961,7 +961,7 @@ void PasswordStoreAndroidBackend::OnError(JobId job_id, AndroidBackendError error) { DCHECK_CALLED_ON_VALID_SEQUENCE(main_sequence_checker_); - absl::optional<JobReturnHandler> reply = GetAndEraseJob(job_id); + std::optional<JobReturnHandler> reply = GetAndEraseJob(job_id); if (!reply.has_value()) return; // Task cleaned up after returning from background. PasswordStoreOperation operation = reply->GetOperation(); @@ -1069,12 +1069,12 @@ delay, operation)); } -absl::optional<PasswordStoreAndroidBackend::JobReturnHandler> +std::optional<PasswordStoreAndroidBackend::JobReturnHandler> PasswordStoreAndroidBackend::GetAndEraseJob(JobId job_id) { DCHECK_CALLED_ON_VALID_SEQUENCE(main_sequence_checker_); auto iter = request_for_job_.find(job_id); if (iter == request_for_job_.end()) - return absl::nullopt; + return std::nullopt; JobReturnHandler reply = std::move(iter->second); request_for_job_.erase(iter); return reply; @@ -1144,7 +1144,7 @@ absl::holds_alternative<PasswordStoreBackendError>(results) ? SuccessStatus::kError : SuccessStatus::kSuccess, - /*error=*/absl::nullopt); + /*error=*/std::nullopt); std::move(callback).Run(std::move(results)); }, PasswordStoreBackendMetricsRecorder(BackendInfix("AndroidBackend"), @@ -1166,7 +1166,7 @@ // TODO(https://crbug.com/1278807): Implement error handling, when // actual store changes will be received from the store. metrics_recorder.RecordMetrics(SuccessStatus::kSuccess, - /*error=*/absl::nullopt); + /*error=*/std::nullopt); std::move(callback).Run(std::move(results)); }, PasswordStoreBackendMetricsRecorder(BackendInfix("AndroidBackend"), @@ -1205,7 +1205,7 @@ if (should_delay_refresh_on_foregrounding_) { should_delay_refresh_on_foregrounding_ = false; base::SequencedTaskRunner::GetCurrentDefault()->PostDelayedTask( - FROM_HERE, base::BindOnce(stored_passwords_changed_, absl::nullopt), + FROM_HERE, base::BindOnce(stored_passwords_changed_, std::nullopt), kPasswordStoreCallDelaySeconds); return; } @@ -1213,7 +1213,7 @@ // Calling the remote form changes with a nullopt means that changes are not // available and the store should request all logins asynchronously to // invoke `PasswordStoreInterface::Observer::OnLoginsRetained`. - stored_passwords_changed_.Run(absl::nullopt); + stored_passwords_changed_.Run(std::nullopt); } void PasswordStoreAndroidBackend::ClearZombieTasks() {
diff --git a/chrome/browser/password_manager/android/password_store_android_backend.h b/chrome/browser/password_manager/android/password_store_android_backend.h index 0e6a5ba..66c3a6c 100644 --- a/chrome/browser/password_manager/android/password_store_android_backend.h +++ b/chrome/browser/password_manager/android/password_store_android_backend.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_STORE_ANDROID_BACKEND_H_ #include <memory> +#include <optional> #include <unordered_map> #include "base/containers/small_map.h" @@ -23,7 +24,6 @@ #include "chrome/browser/password_manager/android/password_sync_controller_delegate_android.h" #include "components/password_manager/core/browser/password_store/password_store_backend.h" #include "components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/abseil-cpp/absl/types/variant.h" class PrefService; @@ -146,7 +146,7 @@ return std::move(absl::get<T>(success_callback_)); } - void RecordMetrics(absl::optional<AndroidBackendError> error) const; + void RecordMetrics(std::optional<AndroidBackendError> error) const; base::TimeDelta GetElapsedTimeSinceStart() const; base::TimeDelta GetDelay(); @@ -176,7 +176,7 @@ void GetAllLoginsWithAffiliationAndBrandingAsync( LoginsOrErrorReply callback) override; void GetAutofillableLoginsAsync(LoginsOrErrorReply callback) override; - void GetAllLoginsForAccountAsync(absl::optional<std::string> account, + void GetAllLoginsForAccountAsync(std::optional<std::string> account, LoginsOrErrorReply callback) override; void FillMatchingLoginsAsync( LoginsOrErrorReply callback, @@ -266,7 +266,7 @@ MetricInfix metric_infix, PasswordStoreOperation operation, base::TimeDelta delay); - absl::optional<JobReturnHandler> GetAndEraseJob(JobId job_id); + std::optional<JobReturnHandler> GetAndEraseJob(JobId job_id); // Gets logins matching |form|. void GetLoginsAsync(const PasswordFormDigest& form,
diff --git a/chrome/browser/password_manager/android/password_store_android_backend_dispatcher_bridge.h b/chrome/browser/password_manager/android/password_store_android_backend_dispatcher_bridge.h index 56158da7..c45c01a 100644 --- a/chrome/browser/password_manager/android/password_store_android_backend_dispatcher_bridge.h +++ b/chrome/browser/password_manager/android/password_store_android_backend_dispatcher_bridge.h
@@ -42,21 +42,21 @@ // registered `Consumer` is notified with `OnCompleteWithLogins` via the // receiver bridge when the job with the given JobId succeeds. // `syncing_account` is used to decide which storage to use. If - // `syncing_account` is absl::nullopt local storage will be used. + // `syncing_account` is std::nullopt local storage will be used. virtual void GetAllLogins(JobId job_id, Account account) = 0; // Triggers an asynchronous request to retrieve all stored passwords with // branding info (App display name and icon). The registered `Consumer` is // notified with `OnCompleteWithBrandedLogins` via the receiver bridge when // the job with the given JobId succeeds. `account` is used to decide which - // storage to use. If `account` is absl::nullopt local storage will be used. + // storage to use. If `account` is std::nullopt local storage will be used. virtual void GetAllLoginsWithBrandingInfo(JobId job_id, Account account) = 0; // Triggers an asynchronous request to retrieve all autofillable // (non-blocklisted) passwords. The registered `Consumer` is notified with // `OnCompleteWithLogins` via the receiver bridge when the job with the // given JobId succeeds. `syncing_account` is used to decide which storage - // to use. If `syncing_account` is absl::nullopt local storage will be used. + // to use. If `syncing_account` is std::nullopt local storage will be used. virtual void GetAutofillableLogins(JobId job_id, Account account) = 0; // Triggers an asynchronous request to retrieve stored passwords with @@ -65,7 +65,7 @@ // The registered `Consumer` is notified with `OnCompleteWithLogins` via the // receiver bridge when the job with the given JobId succeeds. // `syncing_account` is used to decide which storage to use. If - // `syncing_account` is absl::nullopt local storage will be used. + // `syncing_account` is std::nullopt local storage will be used. virtual void GetLoginsForSignonRealm(JobId job_id, const std::string& signon_realm, Account account) = 0; @@ -75,7 +75,7 @@ // |signon_realm|. The registered `Consumer` is notified with // `OnCompleteWithLogins` via the receiver bridge when the job with the given // JobId succeeds. `syncing_account` is used to decide which storage to use. - // If `syncing_account` is absl::nullopt local storage will be used. + // If `syncing_account` is std::nullopt local storage will be used. virtual void GetAffiliatedLoginsForSignonRealm( JobId job_id, const std::string& signon_realm, @@ -84,7 +84,7 @@ // Triggers an asynchronous request to add |form| to store. The // registered `Consumer` is notified with `OnLoginsChanged` via the receiver // bridge when the job with the given JobId succeeds. `syncing_account` is - // used to decide which storage to use. If `syncing_account` is absl::nullopt + // used to decide which storage to use. If `syncing_account` is std::nullopt // local storage will be used. virtual void AddLogin(JobId job_id, const PasswordForm& form, @@ -93,7 +93,7 @@ // Triggers an asynchronous request to update |form| in store. The // registered `Consumer` is notified with `OnLoginsChanged` via the receiver // bridge when the job with the given JobId succeeds. `syncing_account` is - // used to decide which storage to use. If `syncing_account` is absl::nullopt + // used to decide which storage to use. If `syncing_account` is std::nullopt // local storage will be used. virtual void UpdateLogin(JobId job_id, const PasswordForm& form, @@ -102,7 +102,7 @@ // Triggers an asynchronous request to remove |form| from store. The // registered `Consumer` is notified with `OnLoginsChanged` via the receiver // bridge when the job with the given JobId succeeds. `syncing_account` is - // used to decide which storage to use. If `syncing_account` is absl::nullopt + // used to decide which storage to use. If `syncing_account` is std::nullopt // local storage will be used. virtual void RemoveLogin(JobId job_id, const PasswordForm& form,
diff --git a/chrome/browser/password_manager/android/password_store_android_backend_receiver_bridge_impl.cc b/chrome/browser/password_manager/android/password_store_android_backend_receiver_bridge_impl.cc index 491e2475..f1dd76e 100644 --- a/chrome/browser/password_manager/android/password_store_android_backend_receiver_bridge_impl.cc +++ b/chrome/browser/password_manager/android/password_store_android_backend_receiver_bridge_impl.cc
@@ -142,7 +142,7 @@ DCHECK(consumer_); // Notifying that a login changed without providing a changelist prompts the // caller to explicitly check the remaining logins. - consumer_->OnLoginsChanged(JobId(job_id), absl::nullopt); + consumer_->OnLoginsChanged(JobId(job_id), std::nullopt); } } // namespace password_manager
diff --git a/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc b/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc index 0690a94..6020899 100644 --- a/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc +++ b/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc
@@ -493,7 +493,7 @@ base::NullCallback(), base::DoNothing()); base::MockCallback<LoginsOrErrorReply> mock_reply; EXPECT_CALL(*bridge_helper(), GetAllLogins).WillOnce(Return(kJobId)); - absl::optional<std::string> account = "mytestemail@gmail.com"; + std::optional<std::string> account = "mytestemail@gmail.com"; backend().GetAllLoginsForAccountAsync(account, mock_reply.Get()); EXPECT_CALL( @@ -696,7 +696,7 @@ // Simulate receiving INTERNAL_ERROR code. int kInternalErrorCode = static_cast<int>(AndroidBackendAPIErrorCode::kInternalError); - error.api_error_code = absl::optional<int>(kInternalErrorCode); + error.api_error_code = std::optional<int>(kInternalErrorCode); consumer().OnError(kJobId, std::move(error)); RunUntilIdle(); @@ -740,7 +740,7 @@ // Simulate receiving AUTH_ERROR_RESOLVABLE code. int kAuthErrorResolvableCode = static_cast<int>(AndroidBackendAPIErrorCode::kAuthErrorResolvable); - error.api_error_code = absl::optional<int>(kAuthErrorResolvableCode); + error.api_error_code = std::optional<int>(kAuthErrorResolvableCode); consumer().OnError(kJobId, std::move(error)); RunUntilIdle(); @@ -783,7 +783,7 @@ AndroidBackendError error{AndroidBackendErrorType::kExternalError}; // Simulate receiving NETWORK_ERROR code. - error.api_error_code = absl::optional<int>(kNetworkErrorCode); + error.api_error_code = std::optional<int>(kNetworkErrorCode); // AddLogin operation is non-retriable, so the returned error should not be // indicated as retriable even if the error itself is retriable. @@ -992,7 +992,7 @@ // Simulate receiving AUTH_ERROR_UNRESOLVABLE code. int kUnresolvableAuthErrorCode = static_cast<int>(AndroidBackendAPIErrorCode::kAuthErrorUnresolvable); - error.api_error_code = absl::optional<int>(kUnresolvableAuthErrorCode); + error.api_error_code = std::optional<int>(kUnresolvableAuthErrorCode); consumer().OnError(kJobId, std::move(error)); RunUntilIdle(); @@ -1041,7 +1041,7 @@ // Simulate receiving PASSPHRASE_REQUIRED code. int kPassphraseRequiredErrorCode = static_cast<int>(AndroidBackendAPIErrorCode::kPassphraseRequired); - error.api_error_code = absl::optional<int>(kPassphraseRequiredErrorCode); + error.api_error_code = std::optional<int>(kPassphraseRequiredErrorCode); consumer().OnError(kJobId, std::move(error)); RunUntilIdle(); @@ -1089,7 +1089,7 @@ // Simulate receiving INTERNAL_ERROR code. int kInternalErrorCode = static_cast<int>(AndroidBackendAPIErrorCode::kInternalError); - error.api_error_code = absl::optional<int>(kInternalErrorCode); + error.api_error_code = std::optional<int>(kInternalErrorCode); consumer().OnError(kJobId, std::move(error)); RunUntilIdle(); } @@ -1116,7 +1116,7 @@ // Simulate receiving INTERNAL_ERROR code. int kInternalErrorCode = static_cast<int>(AndroidBackendAPIErrorCode::kInternalError); - error.api_error_code = absl::optional<int>(kInternalErrorCode); + error.api_error_code = std::optional<int>(kInternalErrorCode); consumer().OnError(kJobId, std::move(error)); RunUntilIdle(); } @@ -1214,11 +1214,11 @@ EXPECT_CALL(store_notification_trigger, Run(_)).Times(0); lifecycle_helper()->OnForegroundSessionStart(); - EXPECT_CALL(store_notification_trigger, Run(Eq(absl::nullopt))); + EXPECT_CALL(store_notification_trigger, Run(Eq(std::nullopt))); task_environment_.FastForwardBy(base::Seconds(5)); // Subsequent foregroundings should issue immediate notifications. - EXPECT_CALL(store_notification_trigger, Run(Eq(absl::nullopt))); + EXPECT_CALL(store_notification_trigger, Run(Eq(std::nullopt))); lifecycle_helper()->OnForegroundSessionStart(); } @@ -1268,7 +1268,7 @@ // Clear the task queue to verify that a late answer doesn't record again. // Can be delayed or never happen. - consumer().OnLoginsChanged(kJobId, absl::nullopt); + consumer().OnLoginsChanged(kJobId, std::nullopt); task_environment_.FastForwardUntilNoTasksRemain(); // For would-be response. histogram_tester.ExpectTotalCount(kDurationMetric, 0); @@ -1304,7 +1304,7 @@ ElementsAre(base::Bucket(/* Requested */ 0, 1))); task_environment_.FastForwardUntilNoTasksRemain(); - consumer().OnLoginsChanged(kJobId, absl::nullopt); + consumer().OnLoginsChanged(kJobId, std::nullopt); // After execution, check that request is logged again. EXPECT_THAT(histogram_tester.GetAllSamples(kStartedMetric), @@ -1615,7 +1615,7 @@ } else { AndroidBackendError error{kExternalErrorType}; // Simulate receiving INTERNAL_ERROR code. - error.api_error_code = absl::optional<int>(kInternalApiErrorCode); + error.api_error_code = std::optional<int>(kInternalApiErrorCode); consumer().OnError(kJobId, std::move(error)); } RunUntilIdle(); @@ -1657,11 +1657,11 @@ task_environment_.FastForwardBy(kTestLatencyDelta); if (ShouldSucceed()) { - consumer().OnLoginsChanged(kJobId, absl::nullopt); + consumer().OnLoginsChanged(kJobId, std::nullopt); } else { AndroidBackendError error{kExternalErrorType}; // Simulate receiving INTERNAL_ERROR code. - error.api_error_code = absl::optional<int>(kInternalApiErrorCode); + error.api_error_code = std::optional<int>(kInternalApiErrorCode); consumer().OnError(kJobId, std::move(error)); } RunUntilIdle(); @@ -1705,11 +1705,11 @@ task_environment_.FastForwardBy(kTestLatencyDelta); if (ShouldSucceed()) { - consumer().OnLoginsChanged(kJobId, absl::nullopt); + consumer().OnLoginsChanged(kJobId, std::nullopt); } else { AndroidBackendError error{kExternalErrorType}; // Simulate receiving INTERNAL_ERROR code. - error.api_error_code = absl::optional<int>(kInternalApiErrorCode); + error.api_error_code = std::optional<int>(kInternalApiErrorCode); consumer().OnError(kJobId, std::move(error)); } RunUntilIdle(); @@ -1753,11 +1753,11 @@ task_environment_.FastForwardBy(kTestLatencyDelta); if (ShouldSucceed()) { - consumer().OnLoginsChanged(kJobId, absl::nullopt); + consumer().OnLoginsChanged(kJobId, std::nullopt); } else { AndroidBackendError error{kExternalErrorType}; // Simulate receiving INTERNAL_ERROR code. - error.api_error_code = absl::optional<int>(kInternalApiErrorCode); + error.api_error_code = std::optional<int>(kInternalApiErrorCode); consumer().OnError(kJobId, std::move(error)); } RunUntilIdle(); @@ -1804,7 +1804,7 @@ } else { AndroidBackendError error{kExternalErrorType}; // Simulate receiving INTERNAL_ERROR code. - error.api_error_code = absl::optional<int>(kInternalApiErrorCode); + error.api_error_code = std::optional<int>(kInternalApiErrorCode); consumer().OnError(kJobId, std::move(error)); } RunUntilIdle();
diff --git a/chrome/browser/password_manager/android/password_store_backend_migration_decorator.cc b/chrome/browser/password_manager/android/password_store_backend_migration_decorator.cc index 3aedae12..e729f36 100644 --- a/chrome/browser/password_manager/android/password_store_backend_migration_decorator.cc +++ b/chrome/browser/password_manager/android/password_store_backend_migration_decorator.cc
@@ -221,7 +221,7 @@ } void PasswordStoreBackendMigrationDecorator::GetAllLoginsForAccountAsync( - absl::optional<std::string> account, + std::optional<std::string> account, LoginsOrErrorReply callback) { NOTREACHED(); }
diff --git a/chrome/browser/password_manager/android/password_store_backend_migration_decorator.h b/chrome/browser/password_manager/android/password_store_backend_migration_decorator.h index 955f782..c5d5b8f 100644 --- a/chrome/browser/password_manager/android/password_store_backend_migration_decorator.h +++ b/chrome/browser/password_manager/android/password_store_backend_migration_decorator.h
@@ -101,7 +101,7 @@ void GetAllLoginsWithAffiliationAndBrandingAsync( LoginsOrErrorReply callback) override; void GetAutofillableLoginsAsync(LoginsOrErrorReply callback) override; - void GetAllLoginsForAccountAsync(absl::optional<std::string> account, + void GetAllLoginsForAccountAsync(std::optional<std::string> account, LoginsOrErrorReply callback) override; void FillMatchingLoginsAsync( LoginsOrErrorReply callback,
diff --git a/chrome/browser/password_manager/android/password_store_proxy_backend.cc b/chrome/browser/password_manager/android/password_store_proxy_backend.cc index f544781..0da79202 100644 --- a/chrome/browser/password_manager/android/password_store_proxy_backend.cc +++ b/chrome/browser/password_manager/android/password_store_proxy_backend.cc
@@ -128,7 +128,7 @@ } void PasswordStoreProxyBackend::GetAllLoginsForAccountAsync( - absl::optional<std::string> account, + std::optional<std::string> account, LoginsOrErrorReply callback) { NOTREACHED(); } @@ -336,7 +336,7 @@ void PasswordStoreProxyBackend::OnRemoteFormChangesReceived( CallbackOriginatesFromAndroidBackend originates_from_android, RemoteChangesReceived remote_form_changes_received, - absl::optional<PasswordStoreChangeList> changes) { + std::optional<PasswordStoreChangeList> changes) { // `remote_form_changes_received` is used to inform observers about changes in // the backend. This check guarantees observers are informed only about // changes in the main backend.
diff --git a/chrome/browser/password_manager/android/password_store_proxy_backend.h b/chrome/browser/password_manager/android/password_store_proxy_backend.h index e116352..9e797eec 100644 --- a/chrome/browser/password_manager/android/password_store_proxy_backend.h +++ b/chrome/browser/password_manager/android/password_store_proxy_backend.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_STORE_PROXY_BACKEND_H_ #include <memory> +#include <optional> #include "base/functional/callback_forward.h" #include "base/memory/raw_ptr.h" @@ -14,7 +15,6 @@ #include "components/password_manager/core/browser/password_store/password_store.h" #include "components/password_manager/core/browser/password_store/password_store_backend.h" #include "components/password_manager/core/browser/password_store/password_store_change.h" -#include "third_party/abseil-cpp/absl/types/optional.h" class PrefService; @@ -52,7 +52,7 @@ void GetAllLoginsWithAffiliationAndBrandingAsync( LoginsOrErrorReply callback) override; void GetAutofillableLoginsAsync(LoginsOrErrorReply callback) override; - void GetAllLoginsForAccountAsync(absl::optional<std::string> account, + void GetAllLoginsForAccountAsync(std::optional<std::string> account, LoginsOrErrorReply callback) override; void FillMatchingLoginsAsync( LoginsOrErrorReply callback, @@ -89,7 +89,7 @@ void OnRemoteFormChangesReceived( CallbackOriginatesFromAndroidBackend originatesFromAndroid, RemoteChangesReceived remote_form_changes_received, - absl::optional<PasswordStoreChangeList> changes); + std::optional<PasswordStoreChangeList> changes); // Forwards sync status changes by the backend facilitating them. void OnSyncEnabledOrDisabled(
diff --git a/chrome/browser/password_manager/android/password_store_proxy_backend_unittest.cc b/chrome/browser/password_manager/android/password_store_proxy_backend_unittest.cc index d44c3b4..03ce76d 100644 --- a/chrome/browser/password_manager/android/password_store_proxy_backend_unittest.cc +++ b/chrome/browser/password_manager/android/password_store_proxy_backend_unittest.cc
@@ -220,11 +220,11 @@ // With sync enabled, only the android backend calls the original callback. EnablePasswordSync(); EXPECT_CALL(original_callback, Run); - android_remote_changes_callback.Run(absl::nullopt); + android_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); EXPECT_CALL(original_callback, Run).Times(0); - built_in_remote_changes_callback.Run(absl::nullopt); + built_in_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); // As soon as sync is disabled, only the built-in backend calls the original @@ -232,11 +232,11 @@ DisablePasswordSync(); EXPECT_CALL(original_callback, Run).Times(0); - android_remote_changes_callback.Run(absl::nullopt); + android_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); EXPECT_CALL(original_callback, Run); - built_in_remote_changes_callback.Run(absl::nullopt); + built_in_remote_changes_callback.Run(std::nullopt); } TEST_F(PasswordStoreProxyBackendBaseTest, @@ -259,11 +259,11 @@ // With sync enabled, only the android backend calls the original callback. EnablePasswordSync(); EXPECT_CALL(original_callback, Run); - android_remote_changes_callback.Run(absl::nullopt); + android_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); EXPECT_CALL(original_callback, Run).Times(0); - built_in_remote_changes_callback.Run(absl::nullopt); + built_in_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); // With sync disabled, the profile store still only services the local @@ -271,11 +271,11 @@ DisablePasswordSync(); EXPECT_CALL(original_callback, Run); - android_remote_changes_callback.Run(absl::nullopt); + android_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); EXPECT_CALL(original_callback, Run).Times(0); - built_in_remote_changes_callback.Run(absl::nullopt); + built_in_remote_changes_callback.Run(std::nullopt); } TEST_F(PasswordStoreProxyBackendBaseTest, @@ -309,11 +309,11 @@ // Only the android backend should report that logins have changed to avoid // duplicate notifications. EXPECT_CALL(original_callback, Run); - android_remote_changes_callback.Run(absl::nullopt); + android_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); EXPECT_CALL(original_callback, Run).Times(0); - built_in_remote_changes_callback.Run(absl::nullopt); + built_in_remote_changes_callback.Run(std::nullopt); testing::Mock::VerifyAndClearExpectations(&original_callback); }
diff --git a/chrome/browser/password_manager/android/password_sync_controller_delegate_android.cc b/chrome/browser/password_manager/android/password_sync_controller_delegate_android.cc index 997e120..eb52549 100644 --- a/chrome/browser/password_manager/android/password_sync_controller_delegate_android.cc +++ b/chrome/browser/password_manager/android/password_sync_controller_delegate_android.cc
@@ -188,7 +188,7 @@ return weak_ptr_factory_.GetWeakPtr(); } -void PasswordSyncControllerDelegateAndroid::ClearMetadataWhileStopped() { +void PasswordSyncControllerDelegateAndroid::ClearMetadataIfStopped() { // If this method is being called, this means sync was permanently disabled, // either fully or specifically for passwords. This also includes more // advanced cases like the user having cleared all sync data in the dashboard
diff --git a/chrome/browser/password_manager/android/password_sync_controller_delegate_android.h b/chrome/browser/password_manager/android/password_sync_controller_delegate_android.h index 2eb6d39..816a9b98 100644 --- a/chrome/browser/password_manager/android/password_sync_controller_delegate_android.h +++ b/chrome/browser/password_manager/android/password_sync_controller_delegate_android.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_PASSWORD_SYNC_CONTROLLER_DELEGATE_ANDROID_H_ #include <memory> +#include <optional> #include <string> #include "base/functional/callback.h" @@ -18,7 +19,6 @@ #include "components/sync/model/model_type_controller_delegate.h" #include "components/sync/service/sync_service.h" #include "components/sync/service/sync_service_observer.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace syncer { class ModelTypeControllerDelegate; @@ -53,7 +53,7 @@ base::OnceCallback<void(const syncer::TypeEntitiesCount&)> callback) const override; void RecordMemoryUsageAndCountsHistograms() override; - void ClearMetadataWhileStopped() override; + void ClearMetadataIfStopped() override; // syncer::SyncServiceObserver implementation. void OnStateChanged(syncer::SyncService* sync) override; @@ -81,13 +81,13 @@ const std::unique_ptr<PasswordSyncControllerDelegateBridge> bridge_; - // Current sync status, absl::nullopt until OnSyncServiceInitialized() is + // Current sync status, std::nullopt until OnSyncServiceInitialized() is // called. This value is used to distinguish between sync setup on startup and // when user turns on sync manually. - absl::optional<IsSyncEnabled> is_sync_enabled_; + std::optional<IsSyncEnabled> is_sync_enabled_; // Last sync status set in CredentialManager. - absl::optional<IsSyncEnabled> credential_manager_sync_setting_; + std::optional<IsSyncEnabled> credential_manager_sync_setting_; base::OnceClosure on_sync_shutdown_;
diff --git a/chrome/browser/password_manager/android/save_update_password_message_delegate.cc b/chrome/browser/password_manager/android/save_update_password_message_delegate.cc index 0568f03..ee5196f 100644 --- a/chrome/browser/password_manager/android/save_update_password_message_delegate.cc +++ b/chrome/browser/password_manager/android/save_update_password_message_delegate.cc
@@ -149,7 +149,7 @@ Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); - absl::optional<AccountInfo> account_info = + std::optional<AccountInfo> account_info = password_manager::GetAccountInfoForPasswordMessages(profile); DisplaySaveUpdatePasswordPromptInternal( web_contents, std::move(form_to_save), std::move(account_info), @@ -174,7 +174,7 @@ void SaveUpdatePasswordMessageDelegate::DisplaySaveUpdatePasswordPromptInternal( content::WebContents* web_contents, std::unique_ptr<password_manager::PasswordFormManagerForUI> form_to_save, - absl::optional<AccountInfo> account_info, + std::optional<AccountInfo> account_info, bool update_password, password_manager::PasswordManagerClient* password_manager_client) { // Dismiss previous message if it is displayed. @@ -561,7 +561,7 @@ ui_dismissal_reason); } else { password_manager::metrics_util::LogSaveUIDismissalReason( - ui_dismissal_reason, /*user_state=*/absl::nullopt); + ui_dismissal_reason, /*user_state=*/std::nullopt); } if (auto* recorder = passwords_state_.form_manager()->GetMetricsRecorder()) { recorder->RecordUIDismissalReason(ui_dismissal_reason);
diff --git a/chrome/browser/password_manager/android/save_update_password_message_delegate.h b/chrome/browser/password_manager/android/save_update_password_message_delegate.h index db97b7d6..2fdc50f 100644 --- a/chrome/browser/password_manager/android/save_update_password_message_delegate.h +++ b/chrome/browser/password_manager/android/save_update_password_message_delegate.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_PASSWORD_MANAGER_ANDROID_SAVE_UPDATE_PASSWORD_MESSAGE_DELEGATE_H_ #include <memory> +#include <optional> #include "base/functional/callback.h" #include "base/functional/callback_forward.h" @@ -20,7 +21,6 @@ #include "components/password_manager/core/browser/password_form_manager_for_ui.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/signin/public/identity_manager/account_info.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace content { class WebContents; @@ -108,7 +108,7 @@ void DisplaySaveUpdatePasswordPromptInternal( content::WebContents* web_contents, std::unique_ptr<password_manager::PasswordFormManagerForUI> form_to_save, - absl::optional<AccountInfo> account_info, + std::optional<AccountInfo> account_info, bool update_password, password_manager::PasswordManagerClient* password_manager_client); void CreateMessage(bool update_password);
diff --git a/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc b/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc index d07040c..2ddafc90 100644 --- a/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc +++ b/chrome/browser/password_manager/android/save_update_password_message_delegate_unittest.cc
@@ -159,7 +159,7 @@ void EnqueueMessage(std::unique_ptr<PasswordFormManagerForUI> form_to_save, bool user_signed_in, bool update_password, - absl::optional<AccountInfo> account_info = {}); + std::optional<AccountInfo> account_info = {}); void TriggerActionClick(); void TriggerActionClick(messages::DismissReason dismiss_reason); void TriggerPasswordEditDialog(bool update_password); @@ -331,7 +331,7 @@ std::unique_ptr<PasswordFormManagerForUI> form_to_save, bool user_signed_in, bool update_password, - absl::optional<AccountInfo> account_info) { + std::optional<AccountInfo> account_info) { if (user_signed_in && !account_info) { account_info = AccountInfo(); account_info.value().email = kAccountEmail; @@ -1454,7 +1454,7 @@ const bool is_signed_in = true; const bool is_update = false; - absl::optional<AccountInfo> account_info; + std::optional<AccountInfo> account_info; account_info = AccountInfo(); account_info.value().email = kAccountEmail; account_info.value().full_name = kAccountFullName; @@ -1499,7 +1499,7 @@ const bool is_signed_in = true; const bool is_update = true; - absl::optional<AccountInfo> account_info; + std::optional<AccountInfo> account_info; account_info = AccountInfo(); account_info.value().email = kAccountEmail; account_info.value().full_name = kAccountFullName;
diff --git a/chrome/browser/password_manager/android/unified_password_manager_proto_utils.cc b/chrome/browser/password_manager/android/unified_password_manager_proto_utils.cc index abb7ba9..03759f8 100644 --- a/chrome/browser/password_manager/android/unified_password_manager_proto_utils.cc +++ b/chrome/browser/password_manager/android/unified_password_manager_proto_utils.cc
@@ -68,14 +68,14 @@ return serialized_local_data; } -absl::optional<FormData> DeserializeFormData( +std::optional<FormData> DeserializeFormData( base::Value::Dict& serialized_data) { std::string* form_name = serialized_data.FindString(kNameKey); std::string* form_url = serialized_data.FindString(kUrlKey); std::string* form_action = serialized_data.FindString(kActionKey); base::Value::List* fields = serialized_data.FindList(kFieldsKey); if (!form_name || !form_url || !form_action || !fields) { - return absl::nullopt; + return std::nullopt; } FormData form_data; form_data.name = base::UTF8ToUTF16(*form_name); @@ -86,14 +86,14 @@ base::Value::Dict* serialized_field_dictionary = serialized_field.GetIfDict(); if (!serialized_field_dictionary) { - return absl::nullopt; + return std::nullopt; } FormFieldData field; std::string* field_name = serialized_field_dictionary->FindString(kNameKey); std::string* field_type = serialized_field_dictionary->FindString(kFormControlTypeKey); if (!field_name || !field_type) { - return absl::nullopt; + return std::nullopt; } field.name = base::UTF8ToUTF16(*field_name); // TODO(crbug.com/1353392,crbug.com/1482526): Why does the Password Manager @@ -121,7 +121,7 @@ if (!skip_zero_click.has_value() || !serialized_form_data) { return; } - absl::optional<FormData> form_data = + std::optional<FormData> form_data = DeserializeFormData(*serialized_form_data); if (!form_data.has_value()) { return;
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc index 317c8718..e7d117f8 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/password_manager/chrome_password_manager_client.h" #include <memory> +#include <optional> #include <string> #include <utility> @@ -105,7 +106,6 @@ #include "services/metrics/public/cpp/metrics_utils.h" #include "services/metrics/public/cpp/ukm_recorder.h" #include "services/network/public/cpp/is_potentially_trustworthy.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if BUILDFLAG(SAFE_BROWSING_AVAILABLE) #include "chrome/browser/safe_browsing/advanced_protection_status_manager.h" @@ -1424,7 +1424,7 @@ return; } - absl::optional<autofill::RendererFormsWithServerPredictions> + std::optional<autofill::RendererFormsWithServerPredictions> forms_and_predictions = autofill::RendererFormsWithServerPredictions::FromBrowserForm( manager, form_id); @@ -1540,7 +1540,7 @@ void ChromePasswordManagerClient::GenerationResultAvailable( PasswordGenerationType type, base::WeakPtr<password_manager::ContentPasswordManagerDriver> driver, - const absl::optional< + const std::optional< autofill::password_generation::PasswordGenerationUIData>& ui_data) { if (!ui_data || !driver) return;
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.h b/chrome/browser/password_manager/chrome_password_manager_client.h index 04a9d7a..3b81289 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.h +++ b/chrome/browser/password_manager/chrome_password_manager_client.h
@@ -7,6 +7,7 @@ #include <map> #include <memory> +#include <optional> #include <string> #include <vector> @@ -36,7 +37,6 @@ #include "content/public/browser/render_frame_host_receiver_set.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" #if BUILDFLAG(IS_ANDROID) @@ -371,7 +371,7 @@ void GenerationResultAvailable( autofill::password_generation::PasswordGenerationType type, base::WeakPtr<password_manager::ContentPasswordManagerDriver> driver, - const absl::optional< + const std::optional< autofill::password_generation::PasswordGenerationUIData>& ui_data); void ShowPasswordGenerationPopup( @@ -459,7 +459,7 @@ // Recorder of metrics that is associated with the last committed navigation // of the WebContents owning this ChromePasswordManagerClient. May be unset at // times. Sends statistics on destruction. - absl::optional<password_manager::PasswordManagerMetricsRecorder> + std::optional<password_manager::PasswordManagerMetricsRecorder> metrics_recorder_; // Whether navigator.credentials.store() was ever called from this @@ -473,8 +473,8 @@ #if BUILDFLAG(IS_ANDROID) // Username filled by Touch To Fill and the timestamp. Used to collect // metrics. TODO(crbug.com/1299394): Remove after the launch. - absl::optional<std::pair<std::u16string, base::Time>> - username_filled_by_touch_to_fill_ = absl::nullopt; + std::optional<std::pair<std::u16string, base::Time>> + username_filled_by_touch_to_fill_ = std::nullopt; // Launcher used to trigger the password migration warning once passwords // have been fetched. Only invoked once on startup.
diff --git a/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.cc b/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.cc index 31309f3..7f832039 100644 --- a/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.cc +++ b/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.cc
@@ -4,13 +4,14 @@ #include "chrome/browser/password_manager/chrome_webauthn_credentials_delegate.h" +#include <optional> + #include "base/base64.h" #include "base/functional/callback.h" #include "build/build_config.h" #include "components/password_manager/core/browser/passkey_credential.h" #include "components/password_manager/core/browser/password_ui_utils.h" #include "content/public/browser/web_contents.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/l10n/l10n_util.h" #if !BUILDFLAG(IS_ANDROID) @@ -46,7 +47,7 @@ const std::string& backend_id) { // `backend_id` is the base64-encoded credential ID. See `PasskeyCredential` // for where these are encoded. - absl::optional<std::vector<uint8_t>> selected_credential_id = + std::optional<std::vector<uint8_t>> selected_credential_id = base::Base64Decode(backend_id); DCHECK(selected_credential_id); @@ -68,7 +69,7 @@ #endif // BUILDFLAG(IS_ANDROID) } -const absl::optional<std::vector<PasskeyCredential>>& +const std::optional<std::vector<PasskeyCredential>>& ChromeWebAuthnCredentialsDelegate::GetPasskeys() const { return passkeys_; } @@ -100,7 +101,7 @@ } void ChromeWebAuthnCredentialsDelegate::NotifyWebAuthnRequestAborted() { - passkeys_ = absl::nullopt; + passkeys_ = std::nullopt; if (retrieve_passkeys_callback_) { std::move(retrieve_passkeys_callback_).Run(); }
diff --git a/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.h b/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.h index 10d53694..b555a12c 100644 --- a/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.h +++ b/chrome/browser/password_manager/chrome_webauthn_credentials_delegate.h
@@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_PASSWORD_MANAGER_CHROME_WEBAUTHN_CREDENTIALS_DELEGATE_H_ #define CHROME_BROWSER_PASSWORD_MANAGER_CHROME_WEBAUTHN_CREDENTIALS_DELEGATE_H_ +#include <optional> + #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" @@ -12,7 +14,6 @@ #include "build/build_config.h" #include "components/password_manager/core/browser/passkey_credential.h" #include "components/password_manager/core/browser/webauthn_credentials_delegate.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace content { class WebContents; @@ -36,7 +37,7 @@ // password_manager::WebAuthnCredentialsDelegate: void LaunchWebAuthnFlow() override; void SelectPasskey(const std::string& backend_id) override; - const absl::optional<std::vector<password_manager::PasskeyCredential>>& + const std::optional<std::vector<password_manager::PasskeyCredential>>& GetPasskeys() const override; bool OfferPasskeysFromAnotherDeviceOption() const override; void RetrievePasskeys(base::OnceClosure callback) override; @@ -72,7 +73,7 @@ // RetrievePasskeys, and returned to the client via GetPasskeys. // |passkeys_| is nullopt until populated by a WebAuthn request, and reset // to nullopt when the request is cancelled. - absl::optional<std::vector<password_manager::PasskeyCredential>> passkeys_; + std::optional<std::vector<password_manager::PasskeyCredential>> passkeys_; bool offer_passkey_from_another_device_ = true; base::OnceClosure retrieve_passkeys_callback_;
diff --git a/chrome/browser/password_manager/chrome_webauthn_credentials_delegate_unittest.cc b/chrome/browser/password_manager/chrome_webauthn_credentials_delegate_unittest.cc index 312f7b9..6cad7a1f 100644 --- a/chrome/browser/password_manager/chrome_webauthn_credentials_delegate_unittest.cc +++ b/chrome/browser/password_manager/chrome_webauthn_credentials_delegate_unittest.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/password_manager/chrome_webauthn_credentials_delegate.h" #include <memory> +#include <optional> #include <string> #include <vector> @@ -27,7 +28,6 @@ #include "device/fido/test_callback_receiver.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" @@ -123,7 +123,7 @@ selected_id_ = std::move(id); } - absl::optional<std::vector<uint8_t>> GetSelectedId() { + std::optional<std::vector<uint8_t>> GetSelectedId() { return std::move(selected_id_); } #endif @@ -138,7 +138,7 @@ authenticator_request_delegate_; #else raw_ptr<WebAuthnRequestDelegateAndroid> delegate_; - absl::optional<std::vector<uint8_t>> selected_id_; + std::optional<std::vector<uint8_t>> selected_id_; #endif }; @@ -199,12 +199,12 @@ device::fido_parsing_utils::Materialize(kCredId1), device::PublicKeyCredentialUserEntity( device::fido_parsing_utils::Materialize(kUserId), - kUserName1, /*display_name=*/absl::nullopt)); + kUserName1, /*display_name=*/std::nullopt)); users.emplace_back(device::AuthenticatorType::kOther, kRpId, device::fido_parsing_utils::Materialize(kCredId2), device::PublicKeyCredentialUserEntity( device::fido_parsing_utils::Materialize(kUserId), - kUserName2, /*display_name=*/absl::nullopt)); + kUserName2, /*display_name=*/std::nullopt)); SetCredList(users);
diff --git a/chrome/browser/password_manager/multi_profile_credentials_filter.cc b/chrome/browser/password_manager/multi_profile_credentials_filter.cc index c321922c..2f17817 100644 --- a/chrome/browser/password_manager/multi_profile_credentials_filter.cc +++ b/chrome/browser/password_manager/multi_profile_credentials_filter.cc
@@ -4,12 +4,13 @@ #include "chrome/browser/password_manager/multi_profile_credentials_filter.h" +#include <optional> + #include "base/strings/utf_string_conversions.h" #include "chrome/browser/signin/dice_web_signin_interceptor.h" #include "components/autofill/core/browser/validation.h" #include "components/password_manager/core/browser/password_sync_util.h" #include "google_apis/gaia/gaia_auth_util.h" -#include "third_party/abseil-cpp/absl/types/optional.h" MultiProfileCredentialsFilter::MultiProfileCredentialsFilter( password_manager::PasswordManagerClient* client, @@ -50,7 +51,7 @@ // moved to another profile. If the interception outcome is not available, // then signin interception is very likely, and the password bubble is // suppressed as well. - absl::optional<SigninInterceptionHeuristicOutcome> heuristic_outcome = + std::optional<SigninInterceptionHeuristicOutcome> heuristic_outcome = dice_web_signin_interceptor_->GetHeuristicOutcome( // At this time, it's not possible to know whether the account is new // (whether it's a reauth). To be conservative and avoid showing both
diff --git a/chrome/browser/password_manager/password_manager_signin_intercept_test_helper.cc b/chrome/browser/password_manager/password_manager_signin_intercept_test_helper.cc index 20bd6965a..64775106 100644 --- a/chrome/browser/password_manager/password_manager_signin_intercept_test_helper.cc +++ b/chrome/browser/password_manager/password_manager_signin_intercept_test_helper.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/password_manager/password_manager_signin_intercept_test_helper.h" +#include <optional> + #include "base/check.h" #include "base/command_line.h" #include "base/strings/utf_string_conversions.h" @@ -29,7 +31,6 @@ #include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_switches.h" #include "google_apis/gaia/gaia_urls.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace { @@ -106,7 +107,7 @@ profile_storage->AddProfile(std::move(params)); // Check that the signin qualifies for interception. - absl::optional<SigninInterceptionHeuristicOutcome> outcome = + std::optional<SigninInterceptionHeuristicOutcome> outcome = GetSigninInterceptor(current_profile) ->GetHeuristicOutcome( /*is_new_account=*/true, /*is_sync_signin=*/false, kGaiaUsername);
diff --git a/chrome/browser/password_manager/password_manager_test_base.cc b/chrome/browser/password_manager/password_manager_test_base.cc index cab5256..38e226f8 100644 --- a/chrome/browser/password_manager/password_manager_test_base.cc +++ b/chrome/browser/password_manager/password_manager_test_base.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/password_manager/password_manager_test_base.h" #include <map> +#include <optional> #include <string> #include <utility> #include <vector> @@ -45,7 +46,6 @@ #include "net/test/embedded_test_server/embedded_test_server.h" #include "services/network/public/mojom/network_context.mojom.h" #include "testing/gmock/include/gmock/gmock.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/switches.h" namespace { @@ -122,7 +122,7 @@ raw_ptr<base::RunLoop> run_loop_; // The state CustomManagePasswordsUIController is currently waiting for. - absl::optional<password_manager::ui::State> target_state_; + std::optional<password_manager::ui::State> target_state_; // True iff showing fallback is waited. bool wait_for_fallback_;
diff --git a/chrome/browser/password_manager/web_app_profile_switcher.cc b/chrome/browser/password_manager/web_app_profile_switcher.cc index 86ed7eb..35e2b57c 100644 --- a/chrome/browser/password_manager/web_app_profile_switcher.cc +++ b/chrome/browser/password_manager/web_app_profile_switcher.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/password_manager/web_app_profile_switcher.h" +#include <optional> + #include "base/command_line.h" #include "base/files/file_path.h" #include "base/metrics/histogram_macros.h" @@ -24,7 +26,6 @@ #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/webapps/browser/install_result_code.h" #include "content/public/browser/browser_thread.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace { @@ -168,9 +169,9 @@ ->scheduler() .LaunchApp(app_id, *base::CommandLine::ForCurrentProcess(), /*current_directory=*/base::FilePath(), - /*url_handler_launch_url=*/absl::nullopt, - /*protocol_handler_launch_url=*/absl::nullopt, - /*file_launch_url=*/absl::nullopt, /*launch_files=*/{}, + /*url_handler_launch_url=*/std::nullopt, + /*protocol_handler_launch_url=*/std::nullopt, + /*file_launch_url=*/std::nullopt, /*launch_files=*/{}, base::IgnoreArgs<base::WeakPtr<Browser>, base::WeakPtr<content::WebContents>, apps::LaunchContainer>(base::BindOnce(
diff --git a/chrome/browser/password_manager/web_app_profile_switcher_interactive_uitest.cc b/chrome/browser/password_manager/web_app_profile_switcher_interactive_uitest.cc index 40b5903..4f2a5b8 100644 --- a/chrome/browser/password_manager/web_app_profile_switcher_interactive_uitest.cc +++ b/chrome/browser/password_manager/web_app_profile_switcher_interactive_uitest.cc
@@ -107,7 +107,7 @@ EXPECT_EQ(new_browser->tab_strip_model()->GetActiveWebContents(), new_web_contents); - absl::optional<webapps::AppId> app_id = + std::optional<webapps::AppId> app_id = web_app::FindInstalledAppWithUrlInScope(second_profile, GURL(kTestWebUIAppURL)); ASSERT_TRUE(app_id);
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 9030309..a123b7be 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc
@@ -2605,6 +2605,12 @@ profile_prefs->ClearPref(kUserGeolocationAllowed); #endif // BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) + // Added 11/2023. + password_manager::features_util::MigrateOptInPrefToSyncSelectedTypes( + profile_prefs); +#endif // !BUILDFLAG(IS_ANDROID) + // Deprecated 11/2023. profile_prefs->ClearPref(kPasswordChangeSuccessTrackerFlows); profile_prefs->ClearPref(kPasswordChangeSuccessTrackerVersion);
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc index 8ca3ebc..3b3d376 100644 --- a/chrome/browser/printing/print_view_manager_base.cc +++ b/chrome/browser/printing/print_view_manager_base.cc
@@ -172,11 +172,9 @@ scanning_data.settings.cloud_or_local_settings.is_cloud_analysis() && base::FeatureList::IsEnabled( printing::features::kEnableCloudScanAfterPreview); - bool local_analysis_after_dialog = - scanning_data.settings.cloud_or_local_settings.is_local_analysis() && - base::FeatureList::IsEnabled( - printing::features::kEnableLocalScanAfterPreview); - return cloud_analysis_after_dialog || local_analysis_after_dialog; + // Local content analysis is always after the dialog. + return cloud_analysis_after_dialog || + scanning_data.settings.cloud_or_local_settings.is_local_analysis(); } #endif
diff --git a/chrome/browser/printing/system_access_process_print_browsertest.cc b/chrome/browser/printing/system_access_process_print_browsertest.cc index 1065b09a..89e5ff27 100644 --- a/chrome/browser/printing/system_access_process_print_browsertest.cc +++ b/chrome/browser/printing/system_access_process_print_browsertest.cc
@@ -455,9 +455,8 @@ #if BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS) // Only of interest for content analysis tests. This will enable/disable the - // kEnableLocalScanAfterPreview and kEnableCloudScanAfterPreview features so - // that content analysis is done after the printing settings are picked from a - // dialog. + // kEnableCloudScanAfterPreview features so that content analysis is done + // after the printing settings are picked from a dialog. virtual bool EnableContentAnalysisAfterDialog() = 0; #endif @@ -466,10 +465,8 @@ std::vector<base::test::FeatureRef> disabled_features; #if BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS) if (EnableContentAnalysisAfterDialog()) { - enabled_features.push_back({features::kEnableLocalScanAfterPreview, {}}); enabled_features.push_back({features::kEnableCloudScanAfterPreview, {}}); } else { - disabled_features.push_back(features::kEnableLocalScanAfterPreview); disabled_features.push_back(features::kEnableCloudScanAfterPreview); } #endif @@ -4127,14 +4124,8 @@ All, ContentAnalysisBeforePrintPreviewBrowserTest, testing::Combine( -#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS) - /*policy_value=*/testing::Values(kCloudAnalysisBlockingPolicy, - kCloudAnalysisNonBlockingPolicy, - kLocalAnalysisPolicy), -#else /*policy_value=*/testing::Values(kCloudAnalysisBlockingPolicy, kCloudAnalysisNonBlockingPolicy), -#endif /*content_analysis_allows_print=*/testing::Bool(), /*oop_enabled=*/testing::Bool())); @@ -4158,14 +4149,8 @@ All, ContentAnalysisScriptedPreviewlessPrintBeforeDialogBrowserTest, testing::Combine( -#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS) - /*policy_value=*/testing::Values(kCloudAnalysisBlockingPolicy, - kCloudAnalysisNonBlockingPolicy, - kLocalAnalysisPolicy), -#else /*policy_value=*/testing::Values(kCloudAnalysisBlockingPolicy, kCloudAnalysisNonBlockingPolicy), -#endif /*content_analysis_allows_print=*/testing::Bool(), /*oop_enabled=*/testing::Bool()));
diff --git a/chrome/browser/privacy_sandbox/android/BUILD.gn b/chrome/browser/privacy_sandbox/android/BUILD.gn index fea1084..f5b83e6b 100644 --- a/chrome/browser/privacy_sandbox/android/BUILD.gn +++ b/chrome/browser/privacy_sandbox/android/BUILD.gn
@@ -14,31 +14,31 @@ android_library("java") { sources = [ + "java/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeAllSitesFragmentV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeBlockedSitesFragmentV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeLearnMoreFragment.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/FledgePreference.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/PreferenceCategoryWithClickableSummary.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxBridge.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogConsentEEAV4.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogController.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeEEAV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeROWV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeRestrictedV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogUtils.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxHelpers.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxReferrer.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsBaseFragment.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSnackbarController.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/Topic.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/TopicPreference.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsBlockedFragmentV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsLearnMoreFragment.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/TrackingProtectionBridge.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeAllSitesFragmentV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeBlockedSitesFragmentV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeLearnMoreFragment.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PreferenceCategoryWithClickableSummary.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeROWV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeRestrictedV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsBlockedFragmentV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4.java", - "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsLearnMoreFragment.java", ] deps = [ ":java_resources", @@ -84,16 +84,16 @@ testonly = true resources_package = "org.chromium.chrome.browser.privacy_sandbox" sources = [ + "javatests/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4Test.java", "javatests/src/org/chromium/chrome/browser/privacy_sandbox/FakePrivacySandboxBridge.java", "javatests/src/org/chromium/chrome/browser/privacy_sandbox/FakeTrackingProtectionBridge.java", + "javatests/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4Test.java", "javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxBridgeTest.java", "javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java", + "javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4Test.java", "javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxTestUtils.java", + "javatests/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4Test.java", "javatests/src/org/chromium/chrome/browser/privacy_sandbox/TrackingProtectionNoticeTest.java", - "javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4Test.java", - "javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4Test.java", - "javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4Test.java", - "javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4Test.java", ] deps = [ ":java",
diff --git a/chrome/browser/privacy_sandbox/android/java/res/xml/fledge_preference_v4.xml b/chrome/browser/privacy_sandbox/android/java/res/xml/fledge_preference_v4.xml index 33c76f4..bccbcfde 100644 --- a/chrome/browser/privacy_sandbox/android/java/res/xml/fledge_preference_v4.xml +++ b/chrome/browser/privacy_sandbox/android/java/res/xml/fledge_preference_v4.xml
@@ -12,7 +12,7 @@ android:title="@string/settings_fledge_page_toggle_label" android:summary="@string/settings_fledge_page_toggle_sub_label" /> - <org.chromium.chrome.browser.privacy_sandbox.v4.PreferenceCategoryWithClickableSummary + <org.chromium.chrome.browser.privacy_sandbox.PreferenceCategoryWithClickableSummary android:key="fledge_heading" android:title="@string/settings_fledge_page_current_sites_heading" android:summary="@string/settings_fledge_page_current_sites_description" /> @@ -32,12 +32,12 @@ <org.chromium.components.browser_ui.settings.ChromeBasePreference android:key="fledge_all_sites" android:title="@string/settings_fledge_page_see_all_sites_label" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.FledgeAllSitesFragmentV4" + android:fragment="org.chromium.chrome.browser.privacy_sandbox.FledgeAllSitesFragmentV4" app:userAction="Settings.PrivacySandbox.Fledge.AllSitesOpened"/> <org.chromium.components.browser_ui.settings.ChromeBasePreference android:key="fledge_blocked_sites" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.FledgeBlockedSitesFragmentV4" + android:fragment="org.chromium.chrome.browser.privacy_sandbox.FledgeBlockedSitesFragmentV4" android:title="@string/settings_fledge_page_blocked_sites_heading" app:userAction="Settings.PrivacySandbox.Fledge.BlockedSitesOpened" />
diff --git a/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences.xml b/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences.xml index 39bf9e5..603cde9a 100644 --- a/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences.xml +++ b/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences.xml
@@ -10,21 +10,21 @@ android:key="topics" android:title="@string/ad_privacy_page_topics_link_row_label" android:icon="@drawable/ic_interests_24dp" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.TopicsFragmentV4" + android:fragment="org.chromium.chrome.browser.privacy_sandbox.TopicsFragmentV4" app:iconTint="@macro/default_icon_color" app:userAction="Settings.PrivacySandbox.Topics.Opened" /> <org.chromium.components.browser_ui.settings.ChromeBasePreference android:key="fledge" android:title="@string/ad_privacy_page_fledge_link_row_label" android:icon="@drawable/ic_checklist_24dp" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.FledgeFragmentV4" + android:fragment="org.chromium.chrome.browser.privacy_sandbox.FledgeFragmentV4" app:iconTint="@macro/default_icon_color" app:userAction="Settings.PrivacySandbox.Fledge.Opened" /> <org.chromium.components.browser_ui.settings.ChromeBasePreference android:key="ad_measurement" android:title="@string/ad_privacy_page_ad_measurement_link_row_label" android:icon="@drawable/ic_bar_chart_24dp" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.AdMeasurementFragmentV4" + android:fragment="org.chromium.chrome.browser.privacy_sandbox.AdMeasurementFragmentV4" app:iconTint="@macro/default_icon_color" app:userAction="Settings.PrivacySandbox.AdMeasurement.Opened" app:allowDividerBelow="false" />
diff --git a/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences_restricted.xml b/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences_restricted.xml index 3a5fee46..a9fbd73 100644 --- a/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences_restricted.xml +++ b/chrome/browser/privacy_sandbox/android/java/res/xml/privacy_sandbox_preferences_restricted.xml
@@ -11,7 +11,7 @@ android:key="ad_measurement" android:title="@string/ad_privacy_page_ad_measurement_link_row_label" android:icon="@drawable/ic_bar_chart_24dp" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.AdMeasurementFragmentV4" + android:fragment="org.chromium.chrome.browser.privacy_sandbox.AdMeasurementFragmentV4" app:iconTint="@macro/default_icon_color" app:userAction="Settings.PrivacySandbox.AdMeasurement.Opened" app:allowDividerBelow="false" />
diff --git a/chrome/browser/privacy_sandbox/android/java/res/xml/topics_preference_v4.xml b/chrome/browser/privacy_sandbox/android/java/res/xml/topics_preference_v4.xml index 0c66b96..77ccf3b0 100644 --- a/chrome/browser/privacy_sandbox/android/java/res/xml/topics_preference_v4.xml +++ b/chrome/browser/privacy_sandbox/android/java/res/xml/topics_preference_v4.xml
@@ -12,7 +12,7 @@ android:title="@string/settings_topics_page_toggle_label" android:summary="@string/settings_topics_page_toggle_sub_label" /> - <org.chromium.chrome.browser.privacy_sandbox.v4.PreferenceCategoryWithClickableSummary + <org.chromium.chrome.browser.privacy_sandbox.PreferenceCategoryWithClickableSummary android:key="topics_heading" android:title="@string/settings_topics_page_current_topics_heading" android:summary="@string/settings_topics_page_current_topics_description" /> @@ -32,7 +32,7 @@ <org.chromium.components.browser_ui.settings.ChromeBasePreference android:key="blocked_topics" android:title="@string/settings_topics_page_blocked_topics_heading" - android:fragment="org.chromium.chrome.browser.privacy_sandbox.v4.TopicsBlockedFragmentV4" + android:fragment="org.chromium.chrome.browser.privacy_sandbox.TopicsBlockedFragmentV4" app:userAction="Settings.PrivacySandbox.Topics.BlockedTopicsOpened" /> <org.chromium.components.browser_ui.settings.ClickableSpansTextMessagePreference
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4.java similarity index 94% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4.java index 50c1c0b..88dc67c 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; @@ -12,8 +12,6 @@ import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.preferences.Pref; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate; import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/AdPersonalizationRemovedFragment.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/AdPersonalizationRemovedFragment.java deleted file mode 100644 index 4ed4430..0000000 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/AdPersonalizationRemovedFragment.java +++ /dev/null
@@ -1,156 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.chrome.browser.privacy_sandbox; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.preference.Preference; -import androidx.preference.PreferenceCategory; - -import org.chromium.base.metrics.RecordUserAction; -import org.chromium.chrome.browser.flags.ChromeFeatureList; -import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; -import org.chromium.components.browser_ui.settings.FragmentSettingsLauncher; -import org.chromium.components.browser_ui.settings.SettingsLauncher; -import org.chromium.components.browser_ui.settings.SettingsUtils; -import org.chromium.components.favicon.LargeIconBridge; - -/** - * Settings fragment for privacy sandbox settings. - */ -public class AdPersonalizationRemovedFragment extends PrivacySandboxSettingsBaseFragment - implements Preference.OnPreferenceClickListener, FragmentSettingsLauncher { - private static final String TOPICS_CATEGORY_PREFERENCE = "topic_interests"; - private static final String EMPTY_TOPICS_PREFERENCE = "empty_topics"; - private static final String FLEDGE_CATEGORY_PREFERENCE = "fledge_interests"; - private static final String EMPTY_FLEDGE_PREFERENCE = "empty_fledge"; - - private PreferenceCategory mTopicsCategory; - private Preference mEmptyTopicsPreference; - private PreferenceCategory mFledgeCategory; - private Preference mEmptyFledgePreference; - private LargeIconBridge mLargeIconBridge; - private SettingsLauncher mSettingsLauncher; - - @Override - public void setSettingsLauncher(SettingsLauncher settingsLauncher) { - mSettingsLauncher = settingsLauncher; - } - - /** - * Initializes all the objects related to the preferences page. - */ - @Override - public void onCreatePreferences(Bundle bundle, String s) { - assert (!ChromeFeatureList.isEnabled(ChromeFeatureList.PRIVACY_SANDBOX_SETTINGS_4)); - - super.onCreatePreferences(bundle, s); - getActivity().setTitle(R.string.privacy_sandbox_remove_interest_title); - - SettingsUtils.addPreferencesFromResource(this, R.xml.ad_personalization_removed_preference); - mTopicsCategory = findPreference(TOPICS_CATEGORY_PREFERENCE); - assert mTopicsCategory != null; - mEmptyTopicsPreference = findPreference(EMPTY_TOPICS_PREFERENCE); - assert mEmptyTopicsPreference != null; - - mFledgeCategory = findPreference(FLEDGE_CATEGORY_PREFERENCE); - assert mFledgeCategory != null; - mEmptyFledgePreference = findPreference(EMPTY_FLEDGE_PREFERENCE); - assert mEmptyFledgePreference != null; - - if (mLargeIconBridge == null) { - mLargeIconBridge = new LargeIconBridge(getProfile()); - } - - for (Topic topic : PrivacySandboxBridge.getBlockedTopics()) { - TopicPreference preference = new TopicPreference(getContext(), topic); - preference.setImage(R.drawable.ic_add, - getResources().getString( - R.string.privacy_sandbox_add_interest_button_description, - topic.getName())); - preference.setDividerAllowedBelow(false); - preference.setOnPreferenceClickListener(this); - mTopicsCategory.addPreference(preference); - } - for (String site : PrivacySandboxBridge.getBlockedFledgeJoiningTopFramesForDisplay()) { - FledgePreference preference = - new FledgePreference(getContext(), site, mLargeIconBridge); - preference.setImage(R.drawable.ic_add, - getResources().getString( - R.string.privacy_sandbox_add_site_button_description, site)); - preference.setDividerAllowedBelow(false); - preference.setOnPreferenceClickListener(this); - mFledgeCategory.addPreference(preference); - } - updateEmptyState(); - } - - @NonNull - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { - View view = super.onCreateView(inflater, container, savedInstanceState); - getListView().setItemAnimator(null); - return view; - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - if (mLargeIconBridge != null) { - mLargeIconBridge.destroy(); - mLargeIconBridge = null; - } - } - - private void allowTopic(Topic topic) { - PrivacySandboxBridge.setTopicAllowed(topic, true); - } - - private void allowFledge(String site) { - PrivacySandboxBridge.setFledgeJoiningAllowed(site, true); - } - - @Override - public boolean onPreferenceClick(@NonNull Preference preference) { - if (preference instanceof TopicPreference) { - allowTopic(((TopicPreference) preference).getTopic()); - mTopicsCategory.removePreference(preference); - showSnackbar(R.string.privacy_sandbox_add_interest_snackbar, null, Snackbar.TYPE_ACTION, - Snackbar.UMA_PRIVACY_SANDBOX_ADD_INTEREST); - RecordUserAction.record("Settings.PrivacySandbox.RemovedInterests.TopicAdded"); - } else if (preference instanceof FledgePreference) { - allowFledge(((FledgePreference) preference).getSite()); - mFledgeCategory.removePreference(preference); - showSnackbar(R.string.privacy_sandbox_add_site_snackbar, null, Snackbar.TYPE_ACTION, - Snackbar.UMA_PRIVACY_SANDBOX_ADD_SITE); - RecordUserAction.record("Settings.PrivacySandbox.RemovedInterests.SiteAdded"); - } else { - assert false; // NOTREACHED - } - updateEmptyState(); - return true; - } - - private void updateEmptyState() { - mEmptyTopicsPreference.setVisible(mTopicsCategory.getPreferenceCount() == 0); - mEmptyFledgePreference.setVisible(mFledgeCategory.getPreferenceCount() == 0); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == R.id.menu_id_targeted_help) { - // Override action for the help button. - return true; - } - return false; - } -}
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeAllSitesFragmentV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeAllSitesFragmentV4.java similarity index 90% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeAllSitesFragmentV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeAllSitesFragmentV4.java index a6ff0130..f70e98e 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeAllSitesFragmentV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeAllSitesFragmentV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.content.Context; import android.os.Bundle; @@ -14,10 +14,6 @@ import androidx.preference.PreferenceScreen; import org.chromium.base.metrics.RecordUserAction; -import org.chromium.chrome.browser.privacy_sandbox.FledgePreference; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.components.favicon.LargeIconBridge;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeBlockedSitesFragmentV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeBlockedSitesFragmentV4.java similarity index 91% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeBlockedSitesFragmentV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeBlockedSitesFragmentV4.java index bc0b9b38..12473e49 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeBlockedSitesFragmentV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeBlockedSitesFragmentV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; import android.view.View; @@ -13,10 +13,6 @@ import androidx.preference.PreferenceCategory; import org.chromium.base.metrics.RecordUserAction; -import org.chromium.chrome.browser.privacy_sandbox.FledgePreference; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.components.browser_ui.settings.SettingsUtils; import org.chromium.components.favicon.LargeIconBridge;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4.java similarity index 96% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4.java index 8cb3a79..a083dde 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; import android.view.View; @@ -15,10 +15,6 @@ import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.preferences.Pref; -import org.chromium.chrome.browser.privacy_sandbox.FledgePreference; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeLearnMoreFragment.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeLearnMoreFragment.java similarity index 90% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeLearnMoreFragment.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeLearnMoreFragment.java index 4a5f11e..dbe0021f 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeLearnMoreFragment.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/FledgeLearnMoreFragment.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; import android.view.Menu; @@ -11,8 +11,6 @@ import androidx.annotation.NonNull; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.SettingsUtils; import org.chromium.components.browser_ui.settings.TextMessagePreference; import org.chromium.ui.text.NoUnderlineClickableSpan;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PreferenceCategoryWithClickableSummary.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PreferenceCategoryWithClickableSummary.java similarity index 91% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PreferenceCategoryWithClickableSummary.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PreferenceCategoryWithClickableSummary.java index 8dc4815..d8ed78da 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PreferenceCategoryWithClickableSummary.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PreferenceCategoryWithClickableSummary.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.content.Context; import android.text.method.LinkMovementMethod; @@ -13,7 +13,6 @@ import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceViewHolder; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.ui.widget.TextViewWithClickableSpans; /**
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogConsentEEAV4.java similarity index 95% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogConsentEEAV4.java index fd090cc..bd9aeed 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogConsentEEAV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.content.Context; import android.content.DialogInterface; @@ -14,10 +14,6 @@ import androidx.annotation.NonNull; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxDialogController; -import org.chromium.chrome.browser.privacy_sandbox.PromptAction; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.SettingsLauncher; import org.chromium.components.browser_ui.widget.ChromeDialog; import org.chromium.ui.widget.ButtonCompat;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogController.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogController.java index 2a23b04..9aa2e56 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogController.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogController.java
@@ -9,10 +9,6 @@ import androidx.annotation.NonNull; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogConsentEEAV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeEEAV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeROWV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeRestrictedV4; import org.chromium.components.browser_ui.settings.SettingsLauncher; import java.lang.ref.WeakReference;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeEEAV4.java similarity index 94% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeEEAV4.java index 3482472..b8c2675 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeEEAV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.content.Context; import android.content.DialogInterface; @@ -13,11 +13,6 @@ import androidx.annotation.NonNull; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxReferrer; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.PromptAction; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.SettingsLauncher; import org.chromium.components.browser_ui.widget.ChromeDialog; import org.chromium.ui.widget.ButtonCompat;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeROWV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeROWV4.java similarity index 94% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeROWV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeROWV4.java index 5e7e676..1821e9c3 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeROWV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeROWV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.content.Context; import android.content.DialogInterface; @@ -13,11 +13,6 @@ import androidx.annotation.NonNull; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxReferrer; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.PromptAction; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.SettingsLauncher; import org.chromium.components.browser_ui.widget.ChromeDialog; import org.chromium.ui.widget.ButtonCompat;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeRestrictedV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeRestrictedV4.java similarity index 94% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeRestrictedV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeRestrictedV4.java index 6ae54df..9bfbdd3 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeRestrictedV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogNoticeRestrictedV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.content.Context; import android.content.DialogInterface; @@ -13,9 +13,6 @@ import androidx.annotation.NonNull; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PromptAction; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.SettingsLauncher; import org.chromium.components.browser_ui.widget.ChromeDialog; import org.chromium.ui.widget.ButtonCompat;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogUtils.java similarity index 97% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogUtils.java index f176ad9..d1ca2e649 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogUtils.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.content.Context; import android.graphics.drawable.Drawable; @@ -17,7 +17,6 @@ import androidx.appcompat.content.res.AppCompatResources; import androidx.core.graphics.drawable.DrawableCompat; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.ui.drawable.StateListDrawableBuilder; import org.chromium.ui.text.SpanApplier; import org.chromium.ui.widget.ChromeBulletSpan;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsBaseFragment.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsBaseFragment.java index f4ede7d..05ea718 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsBaseFragment.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsBaseFragment.java
@@ -20,7 +20,6 @@ import org.chromium.base.IntentUtils; import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordUserAction; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxSettingsFragmentV4; import org.chromium.chrome.browser.settings.ChromeBaseSettingsFragment; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4.java similarity index 91% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4.java index c92f0fa6..abed7f3 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4.java
@@ -2,15 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; import androidx.annotation.Nullable; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.ChromeBasePreference; import org.chromium.components.browser_ui.settings.SettingsUtils;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsBlockedFragmentV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsBlockedFragmentV4.java similarity index 89% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsBlockedFragmentV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsBlockedFragmentV4.java index 34c3775..6a4edeac 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsBlockedFragmentV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsBlockedFragmentV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; import android.view.View; @@ -13,11 +13,6 @@ import androidx.preference.PreferenceCategory; import org.chromium.base.metrics.RecordUserAction; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; -import org.chromium.chrome.browser.privacy_sandbox.Topic; -import org.chromium.chrome.browser.privacy_sandbox.TopicPreference; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.components.browser_ui.settings.SettingsUtils;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4.java similarity index 95% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4.java index 5a6a8244..55fc9ad 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; import android.view.View; @@ -14,11 +14,6 @@ import org.chromium.base.metrics.RecordUserAction; import org.chromium.chrome.browser.preferences.Pref; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; -import org.chromium.chrome.browser.privacy_sandbox.Topic; -import org.chromium.chrome.browser.privacy_sandbox.TopicPreference; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar;
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsLearnMoreFragment.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsLearnMoreFragment.java similarity index 90% rename from chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsLearnMoreFragment.java rename to chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsLearnMoreFragment.java index 736d027..ceb5b91dc 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsLearnMoreFragment.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/TopicsLearnMoreFragment.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import android.os.Bundle; import android.view.Menu; @@ -11,8 +11,6 @@ import androidx.annotation.NonNull; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.SettingsUtils; import org.chromium.components.browser_ui.settings.TextMessagePreference; import org.chromium.ui.text.NoUnderlineClickableSpan;
diff --git a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4Test.java b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4Test.java similarity index 98% rename from chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4Test.java rename to chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4Test.java index e165843e..e46f537 100644 --- a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4Test.java +++ b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/AdMeasurementFragmentV4Test.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; @@ -38,7 +38,6 @@ import org.chromium.base.test.util.UserActionTester; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.preferences.Pref; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.settings.SettingsActivityTestRule; import org.chromium.chrome.test.ChromeBrowserTestRule;
diff --git a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4Test.java b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4Test.java similarity index 98% rename from chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4Test.java rename to chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4Test.java index 1564037..1e84e61 100644 --- a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4Test.java +++ b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/FledgeFragmentV4Test.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.Espresso.pressBack; @@ -48,9 +48,6 @@ import org.chromium.base.test.util.UserActionTester; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.preferences.Pref; -import org.chromium.chrome.browser.privacy_sandbox.FakePrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridgeJni; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.settings.SettingsActivityTestRule; import org.chromium.chrome.test.ChromeBrowserTestRule;
diff --git a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java index beb2bfd..15540ea 100644 --- a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java +++ b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java
@@ -44,12 +44,6 @@ import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.JniMocker; import org.chromium.chrome.browser.flags.ChromeSwitches; -import org.chromium.chrome.browser.privacy_sandbox.v4.AdMeasurementFragmentV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogConsentEEAV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeEEAV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeROWV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeRestrictedV4; -import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxSettingsFragmentV4; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.batch.BlankCTATabInitialStateRule;
diff --git a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4Test.java b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4Test.java similarity index 93% rename from chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4Test.java rename to chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4Test.java index 3ce920ed..5af9456 100644 --- a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxSettingsFragmentV4Test.java +++ b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxSettingsFragmentV4Test.java
@@ -1,7 +1,7 @@ // Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; @@ -13,9 +13,9 @@ import static org.hamcrest.Matchers.hasItems; import static org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxTestUtils.getRootViewSanitized; -import static org.chromium.chrome.browser.privacy_sandbox.v4.AdMeasurementFragmentV4.setAdMeasurementPrefEnabled; -import static org.chromium.chrome.browser.privacy_sandbox.v4.FledgeFragmentV4.setFledgePrefEnabled; -import static org.chromium.chrome.browser.privacy_sandbox.v4.TopicsFragmentV4.setTopicsPrefEnabled; +import static org.chromium.chrome.browser.privacy_sandbox.AdMeasurementFragmentV4.setAdMeasurementPrefEnabled; +import static org.chromium.chrome.browser.privacy_sandbox.FledgeFragmentV4.setFledgePrefEnabled; +import static org.chromium.chrome.browser.privacy_sandbox.TopicsFragmentV4.setTopicsPrefEnabled; import static org.chromium.content_public.browser.test.util.TestThreadUtils.runOnUiThreadBlocking; import static org.chromium.ui.test.util.ViewUtils.onViewWaiting; @@ -35,8 +35,6 @@ import org.chromium.base.test.util.UserActionTester; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.preferences.Pref; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxReferrer; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.settings.SettingsActivityTestRule; import org.chromium.chrome.test.ChromeBrowserTestRule;
diff --git a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4Test.java b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4Test.java similarity index 98% rename from chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4Test.java rename to chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4Test.java index c0e1e6f..ab24229 100644 --- a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/v4/TopicsFragmentV4Test.java +++ b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/TopicsFragmentV4Test.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.chrome.browser.privacy_sandbox.v4; +package org.chromium.chrome.browser.privacy_sandbox; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.Espresso.pressBack; @@ -47,9 +47,6 @@ import org.chromium.base.test.util.UserActionTester; import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.preferences.Pref; -import org.chromium.chrome.browser.privacy_sandbox.FakePrivacySandboxBridge; -import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxBridgeJni; -import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.settings.SettingsActivityTestRule; import org.chromium.chrome.test.ChromeBrowserTestRule;
diff --git a/chrome/browser/resources/chromeos/login/components/oobe_icons.html b/chrome/browser/resources/chromeos/login/components/oobe_icons.html index ceada77..10f41d4 100644 --- a/chrome/browser/resources/chromeos/login/components/oobe_icons.html +++ b/chrome/browser/resources/chromeos/login/components/oobe_icons.html
@@ -27,31 +27,22 @@ </path> </g> <g id="quick-start-android-device" fill-rule="evenodd"> - <path clip-rule="evenodd" - d="M10 0.01L2 0C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H10C11.1 18 12 17.1 12 16V2C12 0.9 11.1 0.01 10 0.01ZM10 16H2V15H10V16ZM10 13H2V5H10V13ZM2 3V2H10V3H2Z"> + <path clip-rule="evenodd" d="M10 0.01L2 0C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H10C11.1 18 12 17.1 12 16V2C12 0.9 11.1 0.01 10 0.01ZM10 16H2V15H10V16ZM10 13H2V5H10V13ZM2 3V2H10V3H2Z"></path> </g> <g id="quick-start-camera-icon" fill-rule="evenodd" viewBox="0 0 15 14"> - <path fill="var(--cros-sys-primary)" - d="M7.5 10.3684C8.88071 10.3684 10 9.24912 10 7.86841C10 6.4877 8.88071 5.36841 7.5 5.36841C6.11929 5.36841 5 6.4877 5 7.86841C5 9.24912 6.11929 10.3684 7.5 10.3684Z" /> - <path fill-rule="evenodd" clip-rule="evenodd" fill="var(--cros-sys-primary)" - d="M9.5 0.368408H5.5L3.5 2.36841H1.5C0.947715 2.36841 0.5 2.81612 0.5 3.36841V12.3684C0.5 12.9207 0.947716 13.3684 1.5 13.3684H13.5C14.0523 13.3684 14.5 12.9207 14.5 12.3684V3.36841C14.5 2.81612 14.0523 2.36841 13.5 2.36841H11.5L9.5 0.368408ZM2.5 4.36841H12.5V11.3684H2.5V4.36841Z" /> + <path d="M7.5 10.3684C8.88071 10.3684 10 9.24912 10 7.86841C10 6.4877 8.88071 5.36841 7.5 5.36841C6.11929 5.36841 5 6.4877 5 7.86841C5 9.24912 6.11929 10.3684 7.5 10.3684Z"></path> + <path fill-rule="evenodd" clip-rule="evenodd" d="M9.5 0.368408H5.5L3.5 2.36841H1.5C0.947715 2.36841 0.5 2.81612 0.5 3.36841V12.3684C0.5 12.9207 0.947716 13.3684 1.5 13.3684H13.5C14.0523 13.3684 14.5 12.9207 14.5 12.3684V3.36841C14.5 2.81612 14.0523 2.36841 13.5 2.36841H11.5L9.5 0.368408ZM2.5 4.36841H12.5V11.3684H2.5V4.36841Z"></path> </g> <g id="quick-start-bluetooth-icon" fill-rule="evenodd" viewBox="0 0 21 21"> - <path fill-rule="evenodd" clip-rule="evenodd" fill="var(--cros-sys-primary)" - d="M11.0993 10.8236L14.2706 7.63955C14.6174 7.2905 14.6164 6.72954 14.2685 6.38165L10.4501 2.56335C10.0921 2.22908 9.53129 2.24871 9.19813 2.60794C9.04593 2.77224 8.96073 2.98826 8.96026 3.2118L8.96943 8.68535L5.53285 5.24888C5.18495 4.90099 4.63432 4.90191 4.28759 5.25097C3.94086 5.60002 3.94178 6.15248 4.28968 6.50036L8.60876 10.8278L4.30419 15.1612C3.95746 15.5102 3.95839 16.0627 4.30629 16.4106C4.65419 16.7584 5.20481 16.7575 5.55155 16.4085L8.97659 12.9605L8.98578 18.4426C8.9866 18.9313 9.38201 19.3258 9.86826 19.325C10.091 19.3246 10.3061 19.2393 10.4693 19.086L14.2834 15.2464C14.6301 14.8974 14.6292 14.3364 14.2813 13.9885L11.0993 10.8236ZM10.6621 12.7962L12.4864 14.6205L10.6682 16.4509L10.6621 12.7962ZM10.6493 5.18928L12.4737 7.01358L10.6554 8.84399L10.6493 5.18928Z" /> - <path fill="var(--cros-sys-primary)" - d="M3.97359 9.51686L4.85374 10.3941C5.09679 10.6363 5.09744 11.0297 4.85521 11.2727L3.97801 12.1529C3.73577 12.3959 3.34237 12.3966 3.09933 12.1544L2.21918 11.2772C1.97613 11.0349 1.97547 10.6415 2.2177 10.3985L3.09491 9.51833C3.33714 9.27528 3.73054 9.27462 3.97359 9.51686Z" /> - <path fill="var(--cros-sys-primary)" - d="M17.3537 10.3731L16.4736 9.49591C16.2305 9.25368 15.8371 9.25434 15.5949 9.49738L14.7177 10.3775C14.4755 10.6206 14.4761 11.014 14.7192 11.2562L15.5993 12.1334C15.8424 12.3757 16.2358 12.375 16.478 12.1319L17.3552 11.2518C17.5974 11.0087 17.5968 10.6154 17.3537 10.3731Z" /> + <path fill-rule="evenodd" clip-rule="evenodd" d="M11.0993 10.8236L14.2706 7.63955C14.6174 7.2905 14.6164 6.72954 14.2685 6.38165L10.4501 2.56335C10.0921 2.22908 9.53129 2.24871 9.19813 2.60794C9.04593 2.77224 8.96073 2.98826 8.96026 3.2118L8.96943 8.68535L5.53285 5.24888C5.18495 4.90099 4.63432 4.90191 4.28759 5.25097C3.94086 5.60002 3.94178 6.15248 4.28968 6.50036L8.60876 10.8278L4.30419 15.1612C3.95746 15.5102 3.95839 16.0627 4.30629 16.4106C4.65419 16.7584 5.20481 16.7575 5.55155 16.4085L8.97659 12.9605L8.98578 18.4426C8.9866 18.9313 9.38201 19.3258 9.86826 19.325C10.091 19.3246 10.3061 19.2393 10.4693 19.086L14.2834 15.2464C14.6301 14.8974 14.6292 14.3364 14.2813 13.9885L11.0993 10.8236ZM10.6621 12.7962L12.4864 14.6205L10.6682 16.4509L10.6621 12.7962ZM10.6493 5.18928L12.4737 7.01358L10.6554 8.84399L10.6493 5.18928Z"></path> + <path d="M3.97359 9.51686L4.85374 10.3941C5.09679 10.6363 5.09744 11.0297 4.85521 11.2727L3.97801 12.1529C3.73577 12.3959 3.34237 12.3966 3.09933 12.1544L2.21918 11.2772C1.97613 11.0349 1.97547 10.6415 2.2177 10.3985L3.09491 9.51833C3.33714 9.27528 3.73054 9.27462 3.97359 9.51686Z"></path> + <path d="M17.3537 10.3731L16.4736 9.49591C16.2305 9.25368 15.8371 9.25434 15.5949 9.49738L14.7177 10.3775C14.4755 10.6206 14.4761 11.014 14.7192 11.2562L15.5993 12.1334C15.8424 12.3757 16.2358 12.375 16.478 12.1319L17.3552 11.2518C17.5974 11.0087 17.5968 10.6154 17.3537 10.3731Z"></path> </g> <g id="quick-start-wifi" viewBox="0 0 28 24" fill-rule="evenodd"> - <path clip-rule="evenodd" - d="M27.3327 6.82473C27.7768 6.25416 27.6543 5.41959 27.0693 5.00669C25.0427 3.57653 20.3461 0.800049 14.0004 0.800049C7.65585 0.800049 2.95812 3.57653 0.931461 5.00669C0.34652 5.41959 0.22395 6.25416 0.668116 6.82473L13.0526 22.7316C13.538 23.356 14.4591 23.356 14.9445 22.7329L27.3327 6.82473Z"> + <path clip-rule="evenodd" d="M27.3327 6.82473C27.7768 6.25416 27.6543 5.41959 27.0693 5.00669C25.0427 3.57653 20.3461 0.800049 14.0004 0.800049C7.65585 0.800049 2.95812 3.57653 0.931461 5.00669C0.34652 5.41959 0.22395 6.25416 0.668116 6.82473L13.0526 22.7316C13.538 23.356 14.4591 23.356 14.9445 22.7329L27.3327 6.82473Z"></path> </g> <g id="quick-start-wifi-grey" fill-rule="evenodd"> - <path clip-rule="evenodd" - d="M1 9.00001L3 11C7.97 6.03001 16.03 6.03001 21 11L23 9.00001C16.93 2.93001 7.08 2.93001 1 9.00001ZM9 17L12 20L15 17C13.35 15.34 10.66 15.34 9 17ZM7 15L5 13C8.87 9.14001 15.14 9.14001 19 13L17 15C14.24 12.24 9.76 12.24 7 15Z" - fill="#616161"> + <path clip-rule="evenodd" fill="#616161" d="M1 9.00001L3 11C7.97 6.03001 16.03 6.03001 21 11L23 9.00001C16.93 2.93001 7.08 2.93001 1 9.00001ZM9 17L12 20L15 17C13.35 15.34 10.66 15.34 9 17ZM7 15L5 13C8.87 9.14001 15.14 9.14001 19 13L17 15C14.24 12.24 9.76 12.24 7 15Z"></path> </g> <g id="hid-touchscreen" fill="none"> <path fill-rule="evenodd" clip-rule="evenodd" d="M4 6.288C4 8.343 5.22 10.125 7 11v1.071c-1.166-.379-2.162-.571-3-.571a1 1 0 00-.832.445l-1 1.5a1 1 0 00.08 1.213l3.5 4A1 1 0 006.5 19h7a1 1 0 00.894-.553l2.5-5A.999.999 0 0017 13c0-.734-.408-1.244-1.257-1.911a91.893 91.893 0 00-1.999-1.437A5.145 5.145 0 0015 6.288C15 3.368 12.538 1 9.5 1S4 3.368 4 6.288zm8 2.356V6.5a2.5 2.5 0 00-5 0V11 8.644a3.29 3.29 0 01-1-2.356C6 4.43 7.567 2.923 9.5 2.923S13 4.43 13 6.288a3.29 3.29 0 01-1 2.356zM9 13.5a1 1 0 01-1.371.928c-1.269-.507-2.312-.803-3.115-.896l-.257.386L6.954 17h5.928l2.006-4.012a4.803 4.803 0 00-.38-.327c-.285-.223-1.718-1.235-2.323-1.661H10V6.5a.5.5 0 00-1 0v7z" fill="#5F6368">
diff --git a/chrome/browser/resources/chromeos/login/screens/common/user_creation.html b/chrome/browser/resources/chromeos/login/screens/common/user_creation.html index 24818d24..c8c4651c 100644 --- a/chrome/browser/resources/chromeos/login/screens/common/user_creation.html +++ b/chrome/browser/resources/chromeos/login/screens/common/user_creation.html
@@ -95,8 +95,7 @@ </oobe-back-button> </div> <div slot="bottom-buttons"> - <oobe-next-button id="nextButton" - class="focus-on-show" on-click="onNextClicked_" + <oobe-next-button id="nextButton" on-click="onNextClicked_" disabled="[[!isNextButtonEnabled_(selectedUserType, isOobeLoaded_)]]"> </oobe-next-button> </div>
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/quick_start.html b/chrome/browser/resources/chromeos/login/screens/oobe/quick_start.html index fd0d3504..85add7fb 100644 --- a/chrome/browser/resources/chromeos/login/screens/oobe/quick_start.html +++ b/chrome/browser/resources/chromeos/login/screens/oobe/quick_start.html
@@ -48,6 +48,7 @@ } .content-icon { + --iron-icon-fill-color: var(--oobe-adaptive-dialog-icon-fill-color); width: 20px; height: auto; }
diff --git a/chrome/browser/resources/gaia_auth_host/PRESUBMIT.py b/chrome/browser/resources/gaia_auth_host/PRESUBMIT.py index 3d09423..9372116 100644 --- a/chrome/browser/resources/gaia_auth_host/PRESUBMIT.py +++ b/chrome/browser/resources/gaia_auth_host/PRESUBMIT.py
@@ -20,16 +20,16 @@ return sum(matcher.search(line) != None for line in contents) def _CheckSamlHandlerApiCallErrors(input_api, output_api): - """Checks that the number of "console.error('SamlHandler.onAPICall_" + """Checks that the number of "console.warn('SamlHandler.onAPICall_" statements stays the same. """ - matcher = input_api.re.compile(r'console\.error\(\'SamlHandler\.onAPICall_') + matcher = input_api.re.compile(r'console\.warn\(\'SamlHandler\.onAPICall_') for f in input_api.AffectedFiles(_FilterFile): new_occurences = _CountOccurences(matcher, f.NewContents()) old_occurences = _CountOccurences(matcher, f.OldContents()) if new_occurences < old_occurences: return [output_api.PresubmitPromptWarning( - 'Seems that you\'re modifiying an error log ' + 'Seems that you\'re modifiying a warn log ' '\'SamlHandler\.onAPICall_\' which is used as a signal for a ' 'tast test. Please make sure the `login.ChromeGaiaAPI` test and' ' this presubmit check stays functional') ]
diff --git a/chrome/browser/resources/gaia_auth_host/authenticator.js b/chrome/browser/resources/gaia_auth_host/authenticator.js index 1e8dc86..17532df 100644 --- a/chrome/browser/resources/gaia_auth_host/authenticator.js +++ b/chrome/browser/resources/gaia_auth_host/authenticator.js
@@ -1485,7 +1485,8 @@ if (this.waitApiPasswordConfirm_) { // Log duplicates the log from the saml handler. The message is used by // the tast test to catch failures. - console.error('SamlHandler.onAPICall_: API password was not confirmed'); + console.warn('SamlHandler.onAPICall_: API password was not confirmed'); + this.samlHandler_.recordPasswordNotConfirmedError(); this.waitApiPasswordConfirm_ = false; }
diff --git a/chrome/browser/resources/gaia_auth_host/saml_handler.js b/chrome/browser/resources/gaia_auth_host/saml_handler.js index 870e5a3..036ac41 100644 --- a/chrome/browser/resources/gaia_auth_host/saml_handler.js +++ b/chrome/browser/resources/gaia_auth_host/saml_handler.js
@@ -53,6 +53,9 @@ /** @const */ const injectedScriptName = 'samlInjected'; + /** @const */ + const SAML_API_Error = 'ChromeOS.SAML.APIError'; + /** * The script to inject into webview and its sub frames. * @type {string} @@ -146,6 +149,31 @@ }; /** + * This enum is tied directly to a UMA enum defined in + * //tools/metrics/histograms/metadata/chromeos/enums.xml, and should + * always reflect it (do not change one without changing the other). These + * values are persisted to logs. Entries should not be renumbered and + * numeric values should never be reused. + * @enum {number} + */ + SamlHandler.ApiErrorType = { + // IdP sent unsupported key type. + UNSUPPORTED_KEY: 0, + // Gaia wanted to create an account while feature is not supported. + UNSUPPORTED_MESSAGE: 1, + // Gaia wanted to create an account for a user that wasn't added. + CREATE_TOKEN_MISMATCH: 2, + // IdP confirmed token that wasn't added. + CONFIRM_TOKEN_MISMATCH: 3, + // IdP sent a message that isn't supported in SAML API. + UNKNOWN_MESSAGE: 4, + // IdP didn't send user's password confirmation. + PASSWORD_NOT_CONFIRMED: 5, + // Enum Max value. + MAX: 6, + }; + + /** * The webview that serves IdP pages. * @private {!WebView} */ @@ -444,8 +472,7 @@ * Resets all auth states */ reset() { - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.reset: resets all auth states'); + console.info('SamlHandler.reset: resets all auth states'); this.isSamlPage_ = this.startsOnSamlPage_; this.pendingIsSamlPage_ = this.startsOnSamlPage_; this.passwordStore_ = {}; @@ -777,12 +804,10 @@ if (headerName === SAML_HEADER) { const action = header.value.toLowerCase(); if (action === 'start') { - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.onHeadersReceived_: SAML flow start'); + console.info('SamlHandler.onHeadersReceived_: SAML flow start'); this.pendingIsSamlPage_ = true; } else if (action === 'end') { - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.onHeadersReceived_: SAML flow end'); + console.info('SamlHandler.onHeadersReceived_: SAML flow end'); this.pendingIsSamlPage_ = false; } } @@ -842,6 +867,25 @@ } /** + * Invoked to record value in ChromeOS.SAML.APIError metric. + * @private + */ + recordInAPIErrorHistogram_(value) { + chrome.send( + 'metricsHandler:recordInHistogram', + [SAML_API_Error, value, SamlHandler.ApiErrorType.MAX]); + } + + /** + * Invoked to record that password wasn't confirmed in + * ChromeOS.SAML.APIError metric. + */ + recordPasswordNotConfirmedError() { + this.recordInAPIErrorHistogram_( + SamlHandler.ApiErrorType.PASSWORD_NOT_CONFIRMED); + } + + /** * Handlers for channel messages. * @param {Channel} channel A channel to send back response. * @param {ApiCallMessage} msg Received message. @@ -849,59 +893,66 @@ */ onAPICall_(channel, msg) { const call = msg.call; - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.onAPICall_: call.method = ' + call.method); + console.info('SamlHandler.onAPICall_: call.method = ' + call.method); if (call.method === 'initialize') { if (!Number.isInteger(call.requestedVersion) || call.requestedVersion < MIN_API_VERSION_VERSION) { this.sendInitializationFailure_(channel); + this.recordInAPIErrorHistogram_( + SamlHandler.ApiErrorType.UNSUPPORTED_KEY); return; } this.apiVersion_ = Math.min(call.requestedVersion, MAX_API_VERSION_VERSION); this.apiInitialized_ = true; - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.onAPICall_ is initialized successfully'); + console.info('SamlHandler.onAPICall_ is initialized successfully'); this.sendInitializationSuccess_(channel); return; } if (call.method === 'add') { if (API_KEY_TYPES.indexOf(call.keyType) === -1) { - console.error('SamlHandler.onAPICall_: unsupported key type'); + console.warn('SamlHandler.onAPICall_: unsupported key type'); + this.recordInAPIErrorHistogram_( + SamlHandler.ApiErrorType.UNSUPPORTED_KEY); return; } // Not setting |email_| and |gaiaId_| because this API call will // eventually be followed by onCompleteLogin_() which does set it. this.apiTokenStore_[call.token] = call; this.lastApiPasswordBytes_ = call.passwordBytes; - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.onAPICall_: password added'); + console.info('SamlHandler.onAPICall_: password added'); this.dispatchEvent(new CustomEvent('apiPasswordAdded')); } else if (call.method === 'createaccount') { if (!this.shouldHandleAccountCreationMessage) { console.warn('SamlHandler.onAPICall_: message not supported'); + this.recordInAPIErrorHistogram_( + SamlHandler.ApiErrorType.UNSUPPORTED_MESSAGE); return; } if (!(call.token in this.apiTokenStore_)) { - console.error('SamlHandler.onAPICall_: token mismatch'); + console.warn('SamlHandler.onAPICall_: token mismatch'); + this.recordInAPIErrorHistogram_( + SamlHandler.ApiErrorType.CREATE_TOKEN_MISMATCH); return; } - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.onAPICall_: new account created'); + console.info('SamlHandler.onAPICall_: new account created'); this.dispatchEvent(new CustomEvent('apiAccountCreated')); } else if (call.method === 'confirm') { if (!(call.token in this.apiTokenStore_)) { - console.error('SamlHandler.onAPICall_: token mismatch'); + console.warn('SamlHandler.onAPICall_: token mismatch'); + this.recordInAPIErrorHistogram_( + SamlHandler.ApiErrorType.CONFIRM_TOKEN_MISMATCH); } else { this.confirmToken_ = call.token; - // TODO(b/261613412): Change warn to info. - console.warn('SamlHandler.onAPICall_: password confirmed'); + console.info('SamlHandler.onAPICall_: password confirmed'); this.dispatchEvent(new CustomEvent('apiPasswordConfirmed')); } } else { - console.error('SamlHandler.onAPICall_: unknown message'); + console.warn('SamlHandler.onAPICall_: unknown message'); + this.recordInAPIErrorHistogram_( + SamlHandler.ApiErrorType.UNKNOWN_MESSAGE); } }
diff --git a/chrome/browser/resources/settings/privacy_page/do_not_track_toggle.html b/chrome/browser/resources/settings/privacy_page/do_not_track_toggle.html index 959d9b7e..2d0e3ca 100644 --- a/chrome/browser/resources/settings/privacy_page/do_not_track_toggle.html +++ b/chrome/browser/resources/settings/privacy_page/do_not_track_toggle.html
@@ -27,7 +27,13 @@ close-text="$i18n{close}" on-cancel="onDialogCancel_" on-close="onDialogClosed_"> <div slot="title">$i18n{doNotTrackDialogTitle}</div> - <div slot="body">$i18nRaw{doNotTrackDialogMessage}</div> + <div slot="body">$i18n{doNotTrackDialogMessage} + <a href="$i18nRaw{doNotTrackLearnMoreURL}" target="_blank" + aria-description="$i18n{opensInNewTab}" + aria-label="$i18n{doNotTrackDialogLearnMoreA11yLabel}"> + $i18n{learnMore} + </a> + </div> <div slot="button-container"> <cr-button class="cancel-button" on-click="onDialogCancel_">
diff --git a/chrome/browser/sync/test/integration/password_manager_sync_test.cc b/chrome/browser/sync/test/integration/password_manager_sync_test.cc index ee31fb70..64f823d 100644 --- a/chrome/browser/sync/test/integration/password_manager_sync_test.cc +++ b/chrome/browser/sync/test/integration/password_manager_sync_test.cc
@@ -1012,15 +1012,16 @@ SignIn("first@gmail.com"); password_manager::features_util::OptInToAccountStorage( GetProfile(0)->GetPrefs(), GetSyncService(0)); - std::string first_gaia_id = GetSyncService(0)->GetAccountInfo().gaia; + auto first_gaia_id_hash = + signin::GaiaIdHash::FromGaiaId(GetSyncService(0)->GetAccountInfo().gaia); SignOut(); SignIn("second@gmail.com"); password_manager::features_util::OptInToAccountStorage( GetProfile(0)->GetPrefs(), GetSyncService(0)); SignOut(); - password_manager::features_util::KeepAccountStorageSettingsOnlyForUsers( - GetProfile(0)->GetPrefs(), {first_gaia_id}); + GetSyncService(0)->GetUserSettings()->KeepAccountSettingsPrefsOnlyForUsers( + {first_gaia_id_hash}); SignIn("first@gmail.com"); EXPECT_TRUE(password_manager::features_util::IsOptedInForAccountStorage( @@ -1107,7 +1108,7 @@ ASSERT_TRUE(prefs.has_value()); ASSERT_TRUE(prefs->is_dict()); ASSERT_TRUE(prefs->GetDict().RemoveByDottedPath( - password_manager::prefs::kAccountStoragePerAccountSettings)); + syncer::prefs::internal::kSelectedTypesPerAccount)); ASSERT_TRUE(base::JSONWriter::Write(*prefs, &json)); ASSERT_TRUE(base::WriteFile(json_path, json)); }
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 496be7b..35953c19 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -2331,6 +2331,8 @@ "../ash/app_list/search/common/types_util.h", "../ash/app_list/search/desks_admin_template_provider.cc", "../ash/app_list/search/desks_admin_template_provider.h", + "../ash/app_list/search/essential_search/essential_search_manager.cc", + "../ash/app_list/search/essential_search/essential_search_manager.h", "../ash/app_list/search/federated_metrics_manager.cc", "../ash/app_list/search/federated_metrics_manager.h", "../ash/app_list/search/files/drive_search_provider.cc", @@ -4022,8 +4024,6 @@ "views/hats/hats_next_web_dialog.h", "views/privacy_sandbox/privacy_sandbox_dialog_view.cc", "views/privacy_sandbox/privacy_sandbox_dialog_view.h", - "views/privacy_sandbox/privacy_sandbox_notice_bubble.cc", - "views/privacy_sandbox/privacy_sandbox_notice_bubble.h", "views/profiles/incognito_menu_view.cc", "views/profiles/incognito_menu_view.h", "views/profiles/profile_menu_coordinator.cc",
diff --git a/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc b/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc index 712009f1..29639ce 100644 --- a/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc +++ b/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc
@@ -53,7 +53,7 @@ Profile* profile = Profile::FromBrowserContext( controller_->web_contents()->GetBrowserContext()); - absl::optional<AccountInfo> account_info = + std::optional<AccountInfo> account_info = password_manager::GetAccountInfoForPasswordMessages(profile); std::u16string explanation_text;
diff --git a/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.cc b/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.cc index 9a86484..9d82088 100644 --- a/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.cc +++ b/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.cc
@@ -32,8 +32,8 @@ // Reports a metric based on the change between the `current_note` and the // `updated_note`. void LogNoteChangesInPasswordManagementBubble( - const absl::optional<std::u16string>& current_note, - const absl::optional<std::u16string>& updated_note) { + const std::optional<std::u16string>& current_note, + const std::optional<std::u16string>& updated_note) { std::u16string current_note_value = current_note.value_or(std::u16string()); std::u16string updated_note_value = updated_note.value_or(std::u16string()); if (current_note_value == updated_note_value) {
diff --git a/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.h b/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.h index 3db8768..ba615080 100644 --- a/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.h +++ b/chrome/browser/ui/passwords/bubble_controllers/manage_passwords_bubble_controller.h
@@ -77,11 +77,11 @@ bool UsernameExists(const std::u16string& username); void set_currently_selected_password( - const absl::optional<password_manager::PasswordForm>& password) { + const std::optional<password_manager::PasswordForm>& password) { currently_selected_password_ = password; } - absl::optional<password_manager::PasswordForm> + std::optional<password_manager::PasswordForm> get_currently_selected_password() { return currently_selected_password_; } @@ -118,7 +118,7 @@ // If not set, the bubble displays the list of all credentials stored for the // current domain. When set, the bubble displays the password details of the // currently selected password. - absl::optional<password_manager::PasswordForm> currently_selected_password_; + std::optional<password_manager::PasswordForm> currently_selected_password_; base::WeakPtrFactory<ManagePasswordsBubbleController> weak_ptr_factory_{this}; };
diff --git a/chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.cc b/chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.cc index 3863718..fb377b4 100644 --- a/chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.cc +++ b/chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.cc
@@ -340,8 +340,8 @@ if (GetState() == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { metrics_util::LogUpdateUIDismissalReason(GetDismissalReason()); } else if (GetState() == password_manager::ui::PENDING_PASSWORD_STATE) { - absl::optional<features_util::PasswordAccountStorageUserState> user_state = - absl::nullopt; + std::optional<features_util::PasswordAccountStorageUserState> user_state = + std::nullopt; Profile* profile = GetProfile(); if (profile) { user_state = password_manager::features_util::
diff --git a/chrome/browser/ui/passwords/password_manager_navigation_throttle_unittest.cc b/chrome/browser/ui/passwords/password_manager_navigation_throttle_unittest.cc index 396e4793..c7d3f0f 100644 --- a/chrome/browser/ui/passwords/password_manager_navigation_throttle_unittest.cc +++ b/chrome/browser/ui/passwords/password_manager_navigation_throttle_unittest.cc
@@ -3,6 +3,8 @@ // found in the LICENSE file. #include "chrome/browser/ui/passwords/password_manager_navigation_throttle.h" +#include <optional> + #include "base/memory/raw_ptr.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "components/password_manager/core/browser/password_manager_constants.h" @@ -13,7 +15,6 @@ #include "content/public/test/navigation_simulator.h" #include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/features.h" #include "ui/base/page_transition_types.h" #include "url/gurl.h" @@ -26,7 +27,7 @@ GURL url; raw_ptr<content::RenderFrameHost> rfh = nullptr; ui::PageTransition page_transition = ui::PAGE_TRANSITION_FROM_API; - absl::optional<url::Origin> initiator_origin; + std::optional<url::Origin> initiator_origin; }; } // namespace
diff --git a/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_browsertest.cc b/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_browsertest.cc index 108b62bb..ac4cd43 100644 --- a/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_browsertest.cc +++ b/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_browsertest.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/ui/passwords/well_known_change_password_navigation_throttle.h" #include <map> +#include <optional> #include <utility> #include "base/callback_list.h" @@ -46,7 +47,6 @@ #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/page_transition_types.h" #include "url/gurl.h" #include "url/origin.h" @@ -155,7 +155,7 @@ void TestNavigationThrottle( const GURL& navigate_url, const GURL& expected_url, - absl::optional<url::Origin> initiator_origin = absl::nullopt) { + std::optional<url::Origin> initiator_origin = std::nullopt) { AddHttpsCertificate(); NavigateParams params(browser(), navigate_url, page_transition());
diff --git a/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_unittest.cc b/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_unittest.cc index 953c841f..da1e76f 100644 --- a/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_unittest.cc +++ b/chrome/browser/ui/passwords/well_known_change_password_navigation_throttle_unittest.cc
@@ -3,6 +3,8 @@ // found in the LICENSE file. #include "chrome/browser/ui/passwords/well_known_change_password_navigation_throttle.h" +#include <optional> + #include "base/memory/raw_ptr.h" #include "base/test/scoped_feature_list.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" @@ -13,7 +15,6 @@ #include "content/public/test/navigation_simulator.h" #include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/features.h" #include "ui/base/page_transition_types.h" #include "url/gurl.h" @@ -26,7 +27,7 @@ GURL url; raw_ptr<content::RenderFrameHost> rfh = nullptr; ui::PageTransition page_transition = ui::PAGE_TRANSITION_FROM_API; - absl::optional<url::Origin> initiator_origin; + std::optional<url::Origin> initiator_origin; }; } // namespace
diff --git a/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.cc b/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.cc index d5bc6dc..6acad28 100644 --- a/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.cc +++ b/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.cc
@@ -8,9 +8,5 @@ void ShowPrivacySandboxPrompt(Browser* browser, PrivacySandboxService::PromptType prompt_type) { - if (prompt_type == PrivacySandboxService::PromptType::kNotice) { - ShowPrivacySandboxNoticeBubble(browser); - } else { ShowPrivacySandboxDialog(browser, prompt_type); - } }
diff --git a/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h b/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h index 43eba89..9dcb09b 100644 --- a/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h +++ b/chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h
@@ -20,10 +20,6 @@ void ShowPrivacySandboxDialog(Browser* browser, PrivacySandboxService::PromptType prompt_type); -// Creates and shows a bubble for |browser| displaying the Privacy Sandbox -// notice the user. -void ShowPrivacySandboxNoticeBubble(Browser* browser); - // Returns whether a Privacy Sandbox prompt can be shown in the |browser|. // Checks if the maximum dialog height fits the prompt height. bool CanWindowHeightFitPrivacySandboxPrompt(Browser* browser);
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_details_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_details_view.cc index 764073e5..54d86f3c 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_details_view.cc +++ b/chrome/browser/ui/views/passwords/manage_passwords_details_view.cc
@@ -602,20 +602,20 @@ on_activity_callback_.Run(); } -absl::optional<std::u16string> +std::optional<std::u16string> ManagePasswordsDetailsView::GetUserEnteredUsernameValue() const { if (username_textfield_) { return username_textfield_->GetText(); } - return absl::nullopt; + return std::nullopt; } -absl::optional<std::u16string> +std::optional<std::u16string> ManagePasswordsDetailsView::GetUserEnteredPasswordNoteValue() const { if (note_textarea_) { return note_textarea_->GetText(); } - return absl::nullopt; + return std::nullopt; } void ManagePasswordsDetailsView::SwitchToEditUsernameMode() {
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_details_view.h b/chrome/browser/ui/views/passwords/manage_passwords_details_view.h index ec7b502..8ae3dc2 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_details_view.h +++ b/chrome/browser/ui/views/passwords/manage_passwords_details_view.h
@@ -63,8 +63,8 @@ // In edit mode, those method return the current value entered by the user. // Return nullopt if the correposnding fields are in the reading mode. - absl::optional<std::u16string> GetUserEnteredUsernameValue() const; - absl::optional<std::u16string> GetUserEnteredPasswordNoteValue() const; + std::optional<std::u16string> GetUserEnteredUsernameValue() const; + std::optional<std::u16string> GetUserEnteredPasswordNoteValue() const; private: void SwitchToEditUsernameMode();
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc b/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc index fa49cc6..681e48eb 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc +++ b/chrome/browser/ui/views/passwords/manage_passwords_icon_views.cc
@@ -30,7 +30,7 @@ // Password icon should not be mirrored in RTL. image()->SetFlipCanvasOnPaintForRTLUI(false); SetProperty(views::kElementIdentifierKey, kPasswordsOmniboxKeyIconElementId); - SetAccessibilityProperties(/*role*/ absl::nullopt, + SetAccessibilityProperties(/*role*/ std::nullopt, GetTextForTooltipAndAccessibleName()); }
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_list_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_list_view.cc index 7b72019..4e7397d 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_list_view.cc +++ b/chrome/browser/ui/views/passwords/manage_passwords_list_view.cc
@@ -33,7 +33,7 @@ SetOrientation(views::BoxLayout::Orientation::kVertical); for (const std::unique_ptr<password_manager::PasswordForm>& password_form : credentials) { - absl::optional<ui::ImageModel> store_icon = absl::nullopt; + std::optional<ui::ImageModel> store_icon = std::nullopt; if (password_form->IsUsingAccountStore()) { store_icon = ui::ImageModel::FromVectorIcon( #if BUILDFLAG(GOOGLE_CHROME_BRANDING) @@ -96,7 +96,7 @@ ui::ImageModel::FromVectorIcon( vector_icons::kLaunchIcon, ui::kColorIconSecondary, GetLayoutConstant(PAGE_INFO_ICON_SIZE)), - /*state_icon=*/absl::nullopt)); + /*state_icon=*/std::nullopt)); manage_passwords_button->SetID(static_cast<int>( password_manager::ManagePasswordsViewIDs::kManagePasswordsButton));
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_view.cc index 83878ca4..922f55b 100644 --- a/chrome/browser/ui/views/passwords/manage_passwords_view.cc +++ b/chrome/browser/ui/views/passwords/manage_passwords_view.cc
@@ -101,12 +101,12 @@ DCHECK(controller_.get_currently_selected_password().has_value()); password_manager::PasswordForm updated_form = controller_.get_currently_selected_password().value(); - absl::optional<std::u16string> updated_username = + std::optional<std::u16string> updated_username = password_details_view_->GetUserEnteredUsernameValue(); if (updated_username.has_value()) { updated_form.username_value = updated_username.value(); } - absl::optional<std::u16string> updated_note = + std::optional<std::u16string> updated_note = password_details_view_->GetUserEnteredPasswordNoteValue(); if (updated_note.has_value()) { updated_form.SetNoteWithEmptyUniqueDisplayName(updated_note.value()); @@ -262,7 +262,7 @@ void ManagePasswordsView::SwitchToListView() { auth_timer_.Stop(); SetButtons(ui::DIALOG_BUTTON_NONE); - controller_.set_currently_selected_password(absl::nullopt); + controller_.set_currently_selected_password(std::nullopt); RecreateLayout(); }
diff --git a/chrome/browser/ui/views/passwords/move_to_account_store_bubble_view.cc b/chrome/browser/ui/views/passwords/move_to_account_store_bubble_view.cc index e9405668..deb242b 100644 --- a/chrome/browser/ui/views/passwords/move_to_account_store_bubble_view.cc +++ b/chrome/browser/ui/views/passwords/move_to_account_store_bubble_view.cc
@@ -51,7 +51,7 @@ public: BackgroundBorderAdderImageSource(const gfx::ImageSkia& image, bool add_background, - absl::optional<SkColor> background_color, + std::optional<SkColor> background_color, SkColor border_color, int radius) : gfx::CanvasImageSource(gfx::Size(radius, radius)), @@ -66,7 +66,7 @@ private: const gfx::ImageSkia image_; const bool add_background_; - const absl::optional<SkColor> background_color_; + const std::optional<SkColor> background_color_; const SkColor border_color_; }; @@ -120,8 +120,8 @@ void Render(); raw_ptr<const gfx::VectorIcon> main_vector_icon_ = nullptr; - absl::optional<gfx::ImageSkia> main_image_skia_; - absl::optional<gfx::ImageSkia> badge_image_skia_; + std::optional<gfx::ImageSkia> main_image_skia_; + std::optional<gfx::ImageSkia> badge_image_skia_; }; ImageWithBadge::ImageWithBadge(const gfx::ImageSkia& main_image) @@ -176,7 +176,7 @@ gfx::ImageSkia main_image_with_border = gfx::CanvasImageSource::MakeImageSkia<BackgroundBorderAdderImageSource>( GetMainImage(), /*add_background=*/false, - /*background_color=*/absl::nullopt, kBorderColor, kImageSize); + /*background_color=*/std::nullopt, kBorderColor, kImageSize); gfx::ImageSkia badged_image = gfx::ImageSkiaOperations::CreateIconWithBadge( main_image_with_border, rounded_badge_with_background_and_border);
diff --git a/chrome/browser/ui/views/passwords/password_save_update_view.h b/chrome/browser/ui/views/passwords/password_save_update_view.h index bd138da0..73e08ba 100644 --- a/chrome/browser/ui/views/passwords/password_save_update_view.h +++ b/chrome/browser/ui/views/passwords/password_save_update_view.h
@@ -11,7 +11,6 @@ #include "chrome/browser/ui/passwords/bubble_controllers/save_update_bubble_controller.h" #include "chrome/browser/ui/views/passwords/password_bubble_view_base.h" #include "components/user_education/common/help_bubble.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/views/layout/animating_layout_manager.h" #include "ui/views/view.h"
diff --git a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.cc b/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.cc deleted file mode 100644 index 7561228..0000000 --- a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.cc +++ /dev/null
@@ -1,156 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.h" - -#include "base/memory/raw_ptr.h" -#include "chrome/browser/privacy_sandbox/privacy_sandbox_service.h" -#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/chrome_pages.h" -#include "chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h" -#include "chrome/browser/ui/views/bubble_anchor_util_views.h" -#include "chrome/grit/generated_resources.h" -#include "chrome/grit/theme_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/models/dialog_model.h" -#include "ui/base/models/dialog_model_field.h" -#include "ui/views/accessibility/view_accessibility.h" -#include "ui/views/bubble/bubble_dialog_model_host.h" - -using PromptAction = PrivacySandboxService::PromptAction; - -namespace { - -class PrivacySandboxNoticeBubbleModelDelegate : public ui::DialogModelDelegate { - public: - explicit PrivacySandboxNoticeBubbleModelDelegate(Browser* browser) - : browser_(browser) { - // Saving a reference to the service as an attempt to fix crashes when - // getting a service later on (crbug.com/1379327, crbug.com/1380342, - // crbug.com/1370708). Crashes seem to be caused by browser_ reference not - // being valid. - privacy_sandbox_service_ = - PrivacySandboxServiceFactory::GetForProfile(browser_->profile()); - - NotifyServiceAboutPromptAction(PromptAction::kNoticeShown); - } - - void OnDialogDestroying() { - if (!has_user_interacted_) - NotifyServiceAboutPromptAction(PromptAction::kNoticeClosedNoInteraction); - - if (privacy_sandbox_service_) - privacy_sandbox_service_->PromptClosedForBrowser(browser_); - } - - void OnOkButtonPressed() { - has_user_interacted_ = true; - NotifyServiceAboutPromptAction(PromptAction::kNoticeAcknowledge); - } - - void OnSettingsLinkPressed() { - has_user_interacted_ = true; - chrome::ShowPrivacySandboxSettings(browser_); - NotifyServiceAboutPromptAction(PromptAction::kNoticeOpenSettings); - } - - void OnLearnMoreLinkPressed() { - has_user_interacted_ = true; - chrome::ShowPrivacySandboxLearnMore(browser_); - NotifyServiceAboutPromptAction(PromptAction::kNoticeLearnMore); - } - - void OnDialogExplicitlyClosed() { - if (!has_user_interacted_) - NotifyServiceAboutPromptAction(PromptAction::kNoticeDismiss); - has_user_interacted_ = true; - } - - void NotifyServiceAboutPromptAction(PromptAction action) { - if (privacy_sandbox_service_) - privacy_sandbox_service_->PromptActionOccurred(action); - } - - private: - raw_ptr<Browser> browser_; - raw_ptr<PrivacySandboxService> privacy_sandbox_service_; - bool has_user_interacted_ = false; -}; - -} // namespace - -DEFINE_ELEMENT_IDENTIFIER_VALUE(kPrivacySandboxLearnMoreTextForTesting); - -// static -void ShowPrivacySandboxNoticeBubble(Browser* browser) { - auto bubble_delegate_unique = - std::make_unique<PrivacySandboxNoticeBubbleModelDelegate>(browser); - PrivacySandboxNoticeBubbleModelDelegate* bubble_delegate = - bubble_delegate_unique.get(); - auto& bundle = ui::ResourceBundle::GetSharedInstance(); - auto dialog_model = - ui::DialogModel::Builder(std::move(bubble_delegate_unique)) - .SetTitle(l10n_util::GetStringUTF16( - IDS_PRIVACY_SANDBOX_BUBBLE_NOTICE_TITLE)) - .SetInternalName(kPrivacySandboxNoticeBubbleName) - .SetIsAlertDialog() - .SetIcon(ui::ImageModel::FromImageSkia(*bundle.GetImageSkiaNamed( - IDR_PRIVACY_SANDBOX_CONFIRMATION_BANNER)), - ui::ImageModel::FromImageSkia(*bundle.GetImageSkiaNamed( - IDR_PRIVACY_SANDBOX_CONFIRMATION_BANNER_DARK))) - .AddParagraph( - ui::DialogModelLabel::CreateWithReplacement( - IDS_PRIVACY_SANDBOX_BUBBLE_NOTICE_DESCRIPTION, - ui::DialogModelLabel::CreateLink( - IDS_PRIVACY_SANDBOX_BUBBLE_NOTICE_DESCRIPTION_ESTIMATES_INTERESTS_LINK, - base::BindRepeating( - &PrivacySandboxNoticeBubbleModelDelegate:: - OnLearnMoreLinkPressed, - base::Unretained(bubble_delegate)), - l10n_util::GetStringUTF16( - IDS_PRIVACY_SANDBOX_BUBBLE_NOTICE_DESCRIPTION_ESTIMATES_INTERESTS_LINK_A11Y_NAME))), - std::u16string(), kPrivacySandboxLearnMoreTextForTesting) - .AddOkButton( - base::BindRepeating( - &PrivacySandboxNoticeBubbleModelDelegate::OnOkButtonPressed, - base::Unretained(bubble_delegate)), - ui::DialogModelButton::Params().SetLabel( - l10n_util::GetStringUTF16( - IDS_PRIVACY_SANDBOX_DIALOG_NOTICE_ACKNOWLEDGE_BUTTON))) - .AddExtraLink(ui::DialogModelLabel::CreateLink( - IDS_PRIVACY_SANDBOX_BUBBLE_NOTICE_SETTINGS_LINK, - base::BindRepeating(&PrivacySandboxNoticeBubbleModelDelegate:: - OnSettingsLinkPressed, - base::Unretained(bubble_delegate)))) - .SetCloseActionCallback( - base::BindOnce(&PrivacySandboxNoticeBubbleModelDelegate:: - OnDialogExplicitlyClosed, - base::Unretained(bubble_delegate))) - .SetDialogDestroyingCallback(base::BindOnce( - &PrivacySandboxNoticeBubbleModelDelegate::OnDialogDestroying, - base::Unretained(bubble_delegate))) - .Build(); - - bubble_anchor_util::AnchorConfiguration configuration = - bubble_anchor_util::GetAppMenuAnchorConfiguration(browser); - auto bubble = std::make_unique<views::BubbleDialogModelHost>( - std::move(dialog_model), configuration.anchor_view, - configuration.bubble_arrow); - views::Widget* const widget = - views::BubbleDialogDelegate::CreateBubble(std::move(bubble)); - // The bubble isn't opened as a result of a user action. It shouldn't take the - // focus away from the current task. Open the bubble starting as inactive - // also avoids unintentionally closing it due to focus loss until the user has - // interacted with it. After a user interaction, it may be closed on focus - // loss. - widget->ShowInactive(); - widget->GetRootView()->GetViewAccessibility().AnnounceText( - l10n_util::GetStringUTF16(IDS_SHOW_BUBBLE_INACTIVE_DESCRIPTION)); - - if (auto* privacy_sandbox_service = - PrivacySandboxServiceFactory::GetForProfile(browser->profile())) { - privacy_sandbox_service->PromptOpenedForBrowser(browser, widget); - } -}
diff --git a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.h b/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.h deleted file mode 100644 index fb2f1962..0000000 --- a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.h +++ /dev/null
@@ -1,15 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_VIEWS_PRIVACY_SANDBOX_PRIVACY_SANDBOX_NOTICE_BUBBLE_H_ -#define CHROME_BROWSER_UI_VIEWS_PRIVACY_SANDBOX_PRIVACY_SANDBOX_NOTICE_BUBBLE_H_ - -#include "ui/base/interaction/element_identifier.h" - -static constexpr char kPrivacySandboxNoticeBubbleName[] = - "PrivacySandboxNoticeBubble"; - -DECLARE_ELEMENT_IDENTIFIER_VALUE(kPrivacySandboxLearnMoreTextForTesting); - -#endif // CHROME_BROWSER_UI_VIEWS_PRIVACY_SANDBOX_PRIVACY_SANDBOX_NOTICE_BUBBLE_H_
diff --git a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_browsertest.cc b/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_browsertest.cc deleted file mode 100644 index ae6b40e..0000000 --- a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_browsertest.cc +++ /dev/null
@@ -1,77 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/test/scoped_feature_list.h" -#include "build/build_config.h" -#include "chrome/browser/privacy_sandbox/mock_privacy_sandbox_service.h" -#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/ui/test/test_browser_dialog.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.h" -#include "chrome/common/webui_url_constants.h" -#include "chrome/test/base/ui_test_utils.h" -#include "components/privacy_sandbox/privacy_sandbox_features.h" -#include "components/privacy_sandbox/privacy_sandbox_prefs.h" -#include "content/public/browser/web_contents.h" -#include "content/public/test/browser_test.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "ui/events/base_event_utils.h" -#include "ui/views/controls/button/label_button.h" -#include "ui/views/controls/styled_label.h" -#include "ui/views/interaction/element_tracker_views.h" -#include "ui/views/test/widget_test.h" -#include "ui/views/widget/any_widget_observer.h" -#include "ui/views/widget/widget.h" - -namespace { - -views::Widget* ShowBubble(Browser* browser) { - views::NamedWidgetShownWaiter waiter(views::test::AnyWidgetTestPasskey{}, - kPrivacySandboxNoticeBubbleName); - ShowPrivacySandboxPrompt(browser, PrivacySandboxService::PromptType::kNotice); - auto* bubble = waiter.WaitIfNeededAndGet(); - // The bubble shouldn't close on focus loss, it may lead to unexpected - // behaviour in browser tests which run in parallel. - auto* bubble_delegate = bubble->widget_delegate()->AsBubbleDialogDelegate(); - bubble_delegate->set_close_on_deactivate(false); - return bubble; -} - -} // namespace - -class PrivacySandboxNoticeBubbleBrowserTest : public DialogBrowserTest { - public: - void SetUpOnMainThread() override { - mock_service_ = static_cast<MockPrivacySandboxService*>( - PrivacySandboxServiceFactory::GetInstance()->SetTestingFactoryAndUse( - browser()->profile(), - base::BindRepeating(&BuildMockPrivacySandboxService))); - } - - // DialogBrowserTest: - void ShowUi(const std::string& name) override { ShowBubble(browser()); } - - MockPrivacySandboxService* mock_service() { return mock_service_; } - - private: - raw_ptr<MockPrivacySandboxService, DanglingUntriaged> mock_service_; - base::test::ScopedFeatureList feature_list_; -}; - -IN_PROC_BROWSER_TEST_F(PrivacySandboxNoticeBubbleBrowserTest, - InvokeUi_NoticeBubble) { - EXPECT_CALL( - *mock_service(), - PromptActionOccurred(PrivacySandboxService::PromptAction::kNoticeShown)); - EXPECT_CALL( - *mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeClosedNoInteraction)); - ShowAndVerifyUi(); -}
diff --git a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_interactive_ui_test.cc b/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_interactive_ui_test.cc deleted file mode 100644 index ed0177c..0000000 --- a/chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_interactive_ui_test.cc +++ /dev/null
@@ -1,169 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/test/scoped_feature_list.h" -#include "build/build_config.h" -#include "chrome/browser/privacy_sandbox/mock_privacy_sandbox_service.h" -#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/ui/test/test_browser_dialog.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble.h" -#include "chrome/common/webui_url_constants.h" -#include "chrome/test/base/interactive_test_utils.h" -#include "chrome/test/base/ui_test_utils.h" -#include "components/privacy_sandbox/privacy_sandbox_features.h" -#include "components/privacy_sandbox/privacy_sandbox_prefs.h" -#include "content/public/browser/web_contents.h" -#include "content/public/test/browser_test.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "ui/events/base_event_utils.h" -#include "ui/views/controls/button/label_button.h" -#include "ui/views/controls/styled_label.h" -#include "ui/views/interaction/element_tracker_views.h" -#include "ui/views/test/widget_test.h" -#include "ui/views/widget/any_widget_observer.h" -#include "ui/views/widget/widget.h" - -namespace { - -views::Widget* ShowBubble(Browser* browser) { - views::NamedWidgetShownWaiter waiter(views::test::AnyWidgetTestPasskey{}, - kPrivacySandboxNoticeBubbleName); - ShowPrivacySandboxPrompt(browser, PrivacySandboxService::PromptType::kNotice); - return waiter.WaitIfNeededAndGet(); -} - -void ClickOnViewInBubble(views::BubbleDialogDelegate* bubble_delegate, - views::View* button) { - // Reset the timer to make sure that test click isn't discarded as possibly - // unintended. - bubble_delegate->ResetViewShownTimeStampForTesting(); - ui_test_utils::ClickOnView(button); -} - -} // namespace - -class PrivacySandboxNoticeBubbleInteractiveUiTest - : public InProcessBrowserTest { - public: - void SetUpOnMainThread() override { - mock_service_ = static_cast<MockPrivacySandboxService*>( - PrivacySandboxServiceFactory::GetInstance()->SetTestingFactoryAndUse( - browser()->profile(), - base::BindRepeating(&BuildMockPrivacySandboxService))); - } - - MockPrivacySandboxService* mock_service() { return mock_service_; } - - ui::TrackedElement* GetElement(ui::ElementIdentifier id) { - return ui::ElementTracker::GetElementTracker()->GetFirstMatchingElement( - id, browser()->window()->GetElementContext()); - } - - private: - raw_ptr<MockPrivacySandboxService> mock_service_; - base::test::ScopedFeatureList feature_list_; -}; - -IN_PROC_BROWSER_TEST_F(PrivacySandboxNoticeBubbleInteractiveUiTest, - // TODO(crbug.com/1356871): Re-enable this test - DISABLED_AcknowledgeNotice) { - EXPECT_CALL( - *mock_service(), - PromptActionOccurred(PrivacySandboxService::PromptAction::kNoticeShown)); - EXPECT_CALL(*mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeAcknowledge)); - EXPECT_CALL( - *mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeClosedNoInteraction)) - .Times(0); - - auto* bubble = ShowBubble(browser()); - auto* bubble_delegate = bubble->widget_delegate()->AsBubbleDialogDelegate(); - views::test::WidgetDestroyedWaiter observer(bubble); - ClickOnViewInBubble(bubble_delegate, bubble_delegate->GetOkButton()); - observer.Wait(); - testing::Mock::VerifyAndClearExpectations(mock_service()); -} - -IN_PROC_BROWSER_TEST_F(PrivacySandboxNoticeBubbleInteractiveUiTest, - // TODO(crbug.com/1356871): Re-enable this test - DISABLED_OpenSettingsNotice) { - EXPECT_CALL( - *mock_service(), - PromptActionOccurred(PrivacySandboxService::PromptAction::kNoticeShown)); - EXPECT_CALL(*mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeOpenSettings)); - EXPECT_CALL( - *mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeClosedNoInteraction)) - .Times(0); - - auto* bubble = ShowBubble(browser()); - auto* bubble_delegate = bubble->widget_delegate()->AsBubbleDialogDelegate(); - views::test::WidgetDestroyedWaiter observer(bubble); - ClickOnViewInBubble(bubble_delegate, bubble_delegate->GetExtraView()); - observer.Wait(); - testing::Mock::VerifyAndClearExpectations(mock_service()); -} - -IN_PROC_BROWSER_TEST_F(PrivacySandboxNoticeBubbleInteractiveUiTest, - // TODO(crbug.com/1356871): Re-enable this test - DISABLED_OpenLearnMoreNotice) { - EXPECT_CALL( - *mock_service(), - PromptActionOccurred(PrivacySandboxService::PromptAction::kNoticeShown)); - EXPECT_CALL(*mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeLearnMore)); - EXPECT_CALL( - *mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeClosedNoInteraction)) - .Times(0); - - auto* bubble = ShowBubble(browser()); - auto* bubble_delegate = bubble->widget_delegate()->AsBubbleDialogDelegate(); - bubble->GetRootView()->RequestFocus(); - auto* view = GetElement(kPrivacySandboxLearnMoreTextForTesting) - ->AsA<views::TrackedElementViews>() - ->view(); - views::test::WidgetDestroyedWaiter observer(bubble); - ClickOnViewInBubble( - bubble_delegate, - static_cast<views::StyledLabel*>(view)->GetFirstLinkForTesting()); - observer.Wait(); - testing::Mock::VerifyAndClearExpectations(mock_service()); -} - -IN_PROC_BROWSER_TEST_F(PrivacySandboxNoticeBubbleInteractiveUiTest, - // TODO(crbug.com/1356871): Re-enable this test - DISABLED_EscapeClosesNotice) { - // Check that when the escape key is pressed, the notice bubble is closed. - EXPECT_CALL( - *mock_service(), - PromptActionOccurred(PrivacySandboxService::PromptAction::kNoticeShown)); - EXPECT_CALL(*mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeDismiss)); - EXPECT_CALL( - *mock_service(), - PromptActionOccurred( - PrivacySandboxService::PromptAction::kNoticeClosedNoInteraction)) - .Times(0); - auto* bubble = ShowBubble(browser()); - views::test::WidgetDestroyedWaiter observer(bubble); - bubble->CloseWithReason(views::Widget::ClosedReason::kEscKeyPressed); - observer.Wait(); - testing::Mock::VerifyAndClearExpectations(mock_service()); -}
diff --git a/chrome/browser/ui/webui/password_manager/promo_card.h b/chrome/browser/ui/webui/password_manager/promo_card.h index b874be61..c1e0658 100644 --- a/chrome/browser/ui/webui/password_manager/promo_card.h +++ b/chrome/browser/ui/webui/password_manager/promo_card.h
@@ -10,7 +10,6 @@ #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" -#include "third_party/abseil-cpp/absl/types/optional.h" class PrefService;
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc index ad5e9215..f177e51 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
@@ -1605,10 +1605,6 @@ : public PrintPreviewHandlerTest, public testing::WithParamInterface<bool> { public: - ContentAnalysisPrintPreviewHandlerTest() { - feature_list_.InitAndEnableFeature(features::kEnableLocalScanAfterPreview); - } - void SetUp() override { enterprise_connectors::ContentAnalysisDelegate::SetFactoryForTesting( base::BindRepeating( @@ -1668,7 +1664,6 @@ void WaitForScan() { run_loop_.Run(); } private: - base::test::ScopedFeatureList feature_list_; base::RunLoop run_loop_; // This installs a fake SDK manager that creates fake SDK clients when
diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index 4e2118e7..db93aac 100644 --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
@@ -1605,6 +1605,9 @@ {"privacyPageMore", IDS_SETTINGS_PRIVACY_MORE}, {"doNotTrack", IDS_SETTINGS_ENABLE_DO_NOT_TRACK}, {"doNotTrackDialogTitle", IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TITLE}, + {"doNotTrackDialogMessage", IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TEXT}, + {"doNotTrackDialogLearnMoreA11yLabel", + IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_LEARN_MORE_ACCESSIBILITY_LABEL}, // TODO(crbug.com/1062607): This string is no longer used. Remove. {"permissionsPageTitle", IDS_SETTINGS_PERMISSIONS}, {"permissionsPageDescription", IDS_SETTINGS_PERMISSIONS_DESCRIPTION}, @@ -1818,12 +1821,8 @@ html_source->AddString("syncAndGoogleServicesLearnMoreURL", chrome::kSyncAndGoogleServicesLearnMoreURL); - html_source->AddString( - "doNotTrackDialogMessage", - l10n_util::GetStringFUTF16( - IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TEXT, - chrome::kDoNotTrackLearnMoreURL, - l10n_util::GetStringUTF16(IDS_SETTINGS_OPENS_IN_NEW_TAB))); + html_source->AddString("doNotTrackLearnMoreURL", + chrome::kDoNotTrackLearnMoreURL); html_source->AddString("exceptionsLearnMoreURL", chrome::kContentSettingsExceptionsLearnMoreURL); html_source->AddBoolean(
diff --git a/chrome/build/android-arm32.pgo.txt b/chrome/build/android-arm32.pgo.txt index 726a0b6..1cd391e 100644 --- a/chrome/build/android-arm32.pgo.txt +++ b/chrome/build/android-arm32.pgo.txt
@@ -1 +1 @@ -chrome-android32-main-1700719039-d3cb2bb3707daf204ca8e872cf46f646c43ef25d.profdata +chrome-android32-main-1700740428-d678fae2bf392545c11fed9964028cd05bb92756.profdata
diff --git a/chrome/build/android-arm64.pgo.txt b/chrome/build/android-arm64.pgo.txt index f9813ca3..eb267ed4 100644 --- a/chrome/build/android-arm64.pgo.txt +++ b/chrome/build/android-arm64.pgo.txt
@@ -1 +1 @@ -chrome-android64-main-1700675975-b3d8dffb5375fa00735a3a9dee72262084b3cacb.profdata +chrome-android64-main-1700740428-0d643a779e85e2c39d3727b6f3da16caa66b1852.profdata
diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index 2451b64..c009083 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt
@@ -1 +1 @@ -chrome-linux-main-1700697479-e722343e26c9e679e449f36a248e5883434c162a.profdata +chrome-linux-main-1700719039-1bad624579399145236097035f3f9a13afc09df1.profdata
diff --git a/chrome/build/mac-arm.pgo.txt b/chrome/build/mac-arm.pgo.txt index caf0a1a..8c32257 100644 --- a/chrome/build/mac-arm.pgo.txt +++ b/chrome/build/mac-arm.pgo.txt
@@ -1 +1 @@ -chrome-mac-arm-main-1700711903-20e6fa4e74c91a419ed430a417676ab591b32fc0.profdata +chrome-mac-arm-main-1700733369-238d565a00c4a6341b441830ecdf68490966afc1.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index f4b4d88..ab16a86 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1700697479-c3a3ce293ea111039b6b465e589df355a3fb3d5c.profdata +chrome-mac-main-1700719039-160425022f7e73071f497ccdd1317000bd14721b.profdata
diff --git a/chrome/build/win-arm64.pgo.txt b/chrome/build/win-arm64.pgo.txt index cd4e3e29..cf1c3fb 100644 --- a/chrome/build/win-arm64.pgo.txt +++ b/chrome/build/win-arm64.pgo.txt
@@ -1 +1 @@ -chrome-win-arm64-main-1700697479-48f8d98f6bb82ec49521d06ca11c7da0f85762a7.profdata +chrome-win-arm64-main-1700740428-12a099da90ab3eb205973fbbbadf7446cad33070.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index 7f63f2b5..74c8e7b 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1700707113-6b831281ed97ab10826ce47660c3d5f20e8b0260.profdata +chrome-win32-main-1700729876-1d7912d0a1845941f4b6c5b98abaf3e0ee07d48b.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index d20aecf5..ff257d0 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1700707113-842c2693b8d0cbfa138d2e64317ef7cf71c575dd.profdata +chrome-win64-main-1700729876-2e1f702ffa1420aa3fef2be91055cc8257b526a0.profdata
diff --git a/chrome/common/extensions/api/autotest_private.idl b/chrome/common/extensions/api/autotest_private.idl index 338e7b6..8e10144 100644 --- a/chrome/common/extensions/api/autotest_private.idl +++ b/chrome/common/extensions/api/autotest_private.idl
@@ -836,6 +836,14 @@ // Response callback to report if a field trial exists and has been activated. callback IsFieldTrialActiveCallback = void(boolean active); + // Request data containing the mock responses from + // overrideOrcaResponseForTesting. + dictionary OrcaResponseArray { + DOMString[] responses; + }; + + callback OverrideOrcaResponseForTestingCallback = void(boolean success); + interface Functions { // Must be called to allow autotestPrivateAPI events to be fired. static void initializeEvents(); @@ -1593,6 +1601,12 @@ [supportsPromises] static void getCurrentInputMethodDescriptor( GetCurrentInputMethodDescriptorCallback callback); + // Overrides the response from Orca Provider and returns the boolean value + // that indicates if the overriding is successful or not. + [supportsPromises] static void overrideOrcaResponseForTesting( + OrcaResponseArray array, + OverrideOrcaResponseForTestingCallback callback); + // ARC set interactive enable/disable state. // |enabled|: Enable ARC interactive. // |callback|: Called when the operation sent to ARC by mojo.
diff --git a/chrome/common/extensions/api/file_manager_private.idl b/chrome/common/extensions/api/file_manager_private.idl index a4d12b3e..ec161b61 100644 --- a/chrome/common/extensions/api/file_manager_private.idl +++ b/chrome/common/extensions/api/file_manager_private.idl
@@ -1231,6 +1231,10 @@ // The files affected by the IOTask. Currently only returned for TrashIOTask. [instanceOf=Entry] object[]? outputs; + // List of files skipped during the operation because we couldn't decrypt + // them. + DOMString[] skippedEncryptedFiles; + // Volume id of the destination for operations that transfer files to a // directory (e.g. copy or move). DOMString destinationVolumeId;
diff --git a/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder.cc b/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder.cc index edd3fbe..b296ff99 100644 --- a/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder.cc +++ b/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder.cc
@@ -33,7 +33,12 @@ constexpr int kExpectedResponseSize = 2; constexpr char kCredentialIdKey[] = "id"; constexpr char kEntitiyIdMapKey[] = "id"; +constexpr char kBootstrapConfigurationsKey[] = "bootstrapConfigurations"; constexpr char kDeviceDetailsKey[] = "deviceDetails"; +constexpr char kSecondDeviceAuthPayloadKey[] = "secondDeviceAuthPayload"; +constexpr char kIsTransferUnicornKey[] = "isTransferUnicorn"; +constexpr char kBootstrapAccountsKey[] = "bootstrapAccounts"; +constexpr char kNameKey[] = "name"; constexpr char kInstanceIdKey[] = "instanceId"; constexpr uint8_t kCtapDeviceResponseSuccess = 0x00; constexpr int kCborDecoderNoError = 0; @@ -98,6 +103,79 @@ return std::make_pair(kCborDecoderNoError, std::move(cbor)); } +std::string FindInstanceIdInBootstrapConfigurations( + const base::Value::Dict& payload) { + const base::Value::Dict* bootstrap_configurations = + payload.FindDict(kBootstrapConfigurationsKey); + CHECK(bootstrap_configurations); + + const base::Value::Dict* device_details = + bootstrap_configurations->FindDict(kDeviceDetailsKey); + if (!device_details) { + LOG(WARNING) << "DeviceDetails not found within BootstrapConfigurations."; + return ""; + } + + const std::string* instance_id_ptr = + device_details->FindString(kInstanceIdKey); + return instance_id_ptr ? *instance_id_ptr : ""; +} + +std::string FindEmailInBootstrapConfigurations( + const base::Value::Dict& payload) { + const base::Value::Dict* bootstrap_configurations = + payload.FindDict(kBootstrapConfigurationsKey); + CHECK(bootstrap_configurations); + + const base::Value::List* accounts = + bootstrap_configurations->FindList(kBootstrapAccountsKey); + if (!accounts) { + LOG(WARNING) + << "BootstrapAccounts not found within BootstrapConfigurations."; + return ""; + } + + if (accounts->empty()) { + LOG(WARNING) << "Empty accounts list received from source device."; + return ""; + } + + const base::Value::Dict* first_account = accounts->front().GetIfDict(); + if (!first_account) { + LOG(WARNING) << "Invalid value for account received from source device."; + return ""; + } + + const std::string* email_ptr = first_account->FindString(kNameKey); + if (!email_ptr) { + LOG(WARNING) << "Email missing from account received from source device."; + return ""; + } + + return *email_ptr; +} + +bool FindIsSupervisedAccountInBootstrapConfigurations( + const base::Value::Dict& payload) { + const base::Value::Dict* second_device_auth_payload = + payload.FindDict(kSecondDeviceAuthPayloadKey); + if (!second_device_auth_payload) { + LOG(WARNING) << "SecondDeviceAuthPayload not found in " + "BootstrapConfigurations message."; + return false; + } + + absl::optional<bool> is_supervised_account_optional = + second_device_auth_payload->FindBool(kIsTransferUnicornKey); + if (!is_supervised_account_optional.has_value()) { + LOG(WARNING) << "Supervised account boolean not found in " + "BootstrapConfigurations message."; + return false; + } + + return is_supervised_account_optional.value(); +} + } // namespace QuickStartDecoder::QuickStartDecoder( @@ -458,23 +536,11 @@ base::expected<mojom::QuickStartMessagePtr, mojom::QuickStartDecoderError> QuickStartDecoder::DecodeBootstrapConfigurations( const base::Value::Dict& payload) { - const base::Value::Dict* device_details = payload.FindDict(kDeviceDetailsKey); - if (!device_details) { - LOG(WARNING) - << "DeviceDetails cannot be found within BootstrapConfigurations."; - return mojom::QuickStartMessage::NewBootstrapConfigurations( - mojom::BootstrapConfigurations::New(/*instance_id=*/"")); - } - - const std::string* instance_id_ptr = - device_details->FindString(kInstanceIdKey); - if (!instance_id_ptr) { - LOG(WARNING) << "InstanceId for the Android Device could not be found."; - return mojom::QuickStartMessage::NewBootstrapConfigurations( - mojom::BootstrapConfigurations::New(/*instance_id=*/"")); - } return mojom::QuickStartMessage::NewBootstrapConfigurations( - mojom::BootstrapConfigurations::New(*instance_id_ptr)); + mojom::BootstrapConfigurations::New( + FindInstanceIdInBootstrapConfigurations(payload), + FindIsSupervisedAccountInBootstrapConfigurations(payload), + FindEmailInBootstrapConfigurations(payload))); } } // namespace ash::quick_start
diff --git a/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder_unittest.cc b/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder_unittest.cc index 0ab8c469..ce02078 100644 --- a/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder_unittest.cc +++ b/chrome/services/sharing/nearby/quick_start_decoder/quick_start_decoder_unittest.cc
@@ -32,6 +32,11 @@ constexpr char kDeviceDetailsKey[] = "deviceDetails"; constexpr char kInstanceIdKey[] = "instanceId"; constexpr char kExampleInstanceId[] = "helloworld"; +constexpr char kNameKey[] = "name"; +constexpr char kExampleEmail[] = "fakeEmail"; +constexpr char kBootstrapAccountsKey[] = "bootstrapAccounts"; +constexpr char kIsTransferUnicornKey[] = "isTransferUnicorn"; +constexpr char kSecondDeviceAuthPayloadKey[] = "secondDeviceAuthPayload"; constexpr char kFidoMessageKey[] = "fidoMessage"; constexpr uint8_t kSuccess = 0x00; @@ -602,9 +607,8 @@ EXPECT_EQ(future.Get<1>(), absl::nullopt); } -TEST_F(QuickStartDecoderTest, DecodeBootstrapConfigurations_EmptyInstanceId) { +TEST_F(QuickStartDecoderTest, DecodeBootstrapConfigurations_EmptyValues) { base::Value::Dict device_details; - device_details.Set(kInstanceIdKey, ""); base::Value::Dict bootstrap_configurations; bootstrap_configurations.Set(kDeviceDetailsKey, std::move(device_details)); @@ -622,6 +626,8 @@ EXPECT_FALSE(future.Get<0>().is_null()); EXPECT_EQ(future.Get<0>()->instance_id, ""); + EXPECT_EQ(future.Get<0>()->is_supervised_account, false); + EXPECT_EQ(future.Get<0>()->email, ""); EXPECT_EQ(future.Get<1>(), absl::nullopt); } @@ -632,10 +638,22 @@ base::Value::Dict bootstrap_configurations; bootstrap_configurations.Set(kDeviceDetailsKey, std::move(device_details)); + base::Value::Dict account; + account.Set(kNameKey, kExampleEmail); + base::Value::List accounts_list; + accounts_list.Append(std::move(account)); + bootstrap_configurations.Set(kBootstrapAccountsKey, std::move(accounts_list)); + QuickStartMessage message(QuickStartMessageType::kBootstrapConfigurations); message.GetPayload()->Set(kBootstrapConfigurationsKey, std::move(bootstrap_configurations)); + base::Value::Dict second_device_auth_payload; + bool is_supervised_account = true; + second_device_auth_payload.Set(kIsTransferUnicornKey, is_supervised_account); + message.GetPayload()->Set(kSecondDeviceAuthPayloadKey, + std::move(second_device_auth_payload)); + base::test::TestFuture< ::ash::quick_start::mojom::BootstrapConfigurationsPtr, absl::optional<::ash::quick_start::mojom::QuickStartDecoderError>> @@ -645,6 +663,8 @@ future.GetCallback()); EXPECT_FALSE(future.Get<0>().is_null()); EXPECT_EQ(future.Get<0>()->instance_id, kExampleInstanceId); + EXPECT_EQ(future.Get<0>()->is_supervised_account, is_supervised_account); + EXPECT_EQ(future.Get<0>()->email, kExampleEmail); EXPECT_EQ(future.Get<1>(), absl::nullopt); }
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index ba73abe..d49c5cc 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -2749,7 +2749,6 @@ "../browser/ui/views/intent_picker_dialog_browsertest.cc", "../browser/ui/views/plus_addresses/plus_address_creation_dialog_browsertest.cc", "../browser/ui/views/privacy_sandbox/privacy_sandbox_dialog_view_browsertest.cc", - "../browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_browsertest.cc", "../browser/ui/views/reader_mode/reader_mode_icon_view_browsertest.cc", "../browser/ui/views/sharing/remote_copy_browsertest.cc", "../browser/ui/views/sharing/shared_clipboard_browsertest.cc", @@ -10709,7 +10708,6 @@ "../browser/ui/views/page_info/page_info_bubble_view_interactive_uitest.cc", "../browser/ui/views/permissions/permissions_flow_interactive_uitest.cc", "../browser/ui/views/privacy_sandbox/privacy_sandbox_dialog_view_interactive_ui_test.cc", - "../browser/ui/views/privacy_sandbox/privacy_sandbox_notice_bubble_interactive_ui_test.cc", "../browser/ui/views/side_panel/read_anything/read_anything_toolbar_view_browsertest.cc", "../browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_interactive_uitest.cc", "../browser/ui/views/web_dialog_view_browsertest.cc",
diff --git a/chromeos/ash/components/quick_start/fake_quick_start_decoder.cc b/chromeos/ash/components/quick_start/fake_quick_start_decoder.cc index 8f34fe92..891e9ce 100644 --- a/chromeos/ash/components/quick_start/fake_quick_start_decoder.cc +++ b/chromeos/ash/components/quick_start/fake_quick_start_decoder.cc
@@ -74,9 +74,12 @@ } void FakeQuickStartDecoder::SetBootstrapConfigurationsResponse( - const std::string& instance_id) { + const std::string& instance_id, + const bool is_supervised_account, + const std::string& email) { SetQuickStartMessage(mojom::QuickStartMessage::NewBootstrapConfigurations( - mojom::BootstrapConfigurations::New(instance_id))); + mojom::BootstrapConfigurations::New(instance_id, is_supervised_account, + email))); } void FakeQuickStartDecoder::SetQuickStartMessage(
diff --git a/chromeos/ash/components/quick_start/fake_quick_start_decoder.h b/chromeos/ash/components/quick_start/fake_quick_start_decoder.h index 6c641ef..838dd75 100644 --- a/chromeos/ash/components/quick_start/fake_quick_start_decoder.h +++ b/chromeos/ash/components/quick_start/fake_quick_start_decoder.h
@@ -45,7 +45,9 @@ void SetNotifySourceOfUpdateResponse( mojom::NotifySourceOfUpdateResponsePtr notify_source_of_update_response); - void SetBootstrapConfigurationsResponse(const std::string& instance_id); + void SetBootstrapConfigurationsResponse(const std::string& instance_id, + const bool is_supervised_account, + const std::string& email); void SetQuickStartMessage(mojom::QuickStartMessagePtr quick_start_message);
diff --git a/chromeos/ash/components/quick_start/quick_start_message.cc b/chromeos/ash/components/quick_start/quick_start_message.cc index 8fb077d..ce66e14 100644 --- a/chromeos/ash/components/quick_start/quick_start_message.cc +++ b/chromeos/ash/components/quick_start/quick_start_message.cc
@@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "quick_start_message.h" +#include "chromeos/ash/components/quick_start/quick_start_message.h" + #include <memory> + #include "base/base64.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -94,13 +96,13 @@ base::Value::Dict* payload; std::string* encoded_json_payload; - if ((payload = message.FindDict(kBootstrapConfigurationsPayloadKey))) { + if (message.FindDict(kBootstrapConfigurationsPayloadKey)) { // BootstrapConfigurations needs to have a higher precedence than // QuickStartPayload since a BootstrapConfigurations message may also // contain a QuickStartPayload. return std::make_unique<QuickStartMessage>( ash::quick_start::QuickStartMessageType::kBootstrapConfigurations, - payload->Clone()); + message.Clone()); } else if ((encoded_json_payload = message.FindString(kQuickStartPayloadKey))) { std::string json_payload;
diff --git a/chromeos/ash/components/quick_start/quick_start_message_unittest.cc b/chromeos/ash/components/quick_start/quick_start_message_unittest.cc index 58cd27a..bc503961 100644 --- a/chromeos/ash/components/quick_start/quick_start_message_unittest.cc +++ b/chromeos/ash/components/quick_start/quick_start_message_unittest.cc
@@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "quick_start_message.h" +#include "chromeos/ash/components/quick_start/quick_start_message.h" + #include "base/base64.h" #include "base/json/json_writer.h" #include "base/values.h" @@ -50,10 +51,15 @@ ASSERT_TRUE(result.has_value()); ASSERT_NE(result.value(), nullptr); - ASSERT_EQ(*result.value() - ->GetPayload() - ->FindString("key"), - "value"); + + base::Value::Dict* bootstrap_configurations_ptr = + result.value()->GetPayload()->FindDict( + kBootstrapConfigurationsPayloadKey); + ASSERT_NE(bootstrap_configurations_ptr, nullptr); + + std::string* value_ptr = bootstrap_configurations_ptr->FindString("key"); + ASSERT_NE(value_ptr, nullptr); + ASSERT_EQ(*value_ptr, "value"); } TEST_F(QuickStartMessageTest, ReadMessageFailsForUnexpectedMessageType) {
diff --git a/chromeos/ash/services/auth_factor_config/auth_factor_config.cc b/chromeos/ash/services/auth_factor_config/auth_factor_config.cc index 997347e..d3dfa07 100644 --- a/chromeos/ash/services/auth_factor_config/auth_factor_config.cc +++ b/chromeos/ash/services/auth_factor_config/auth_factor_config.cc
@@ -81,6 +81,11 @@ } void AuthFactorConfig::OnUserHasKnowledgeFactor(const UserContext& context) { + if (add_knowledge_factor_callback_) { + std::move(add_knowledge_factor_callback_).Run(); + return; + } + user_manager::UserDirectoryIntegrityManager(local_state_).ClearPrefs(); } @@ -392,4 +397,9 @@ } } +void AuthFactorConfig::SetAddKnowledgeFactorCallbackForTesting( + base::OnceClosure callback) { + add_knowledge_factor_callback_ = std::move(callback); +} + } // namespace ash::auth
diff --git a/chromeos/ash/services/auth_factor_config/auth_factor_config.h b/chromeos/ash/services/auth_factor_config/auth_factor_config.h index 0c872c7..d2154f8 100644 --- a/chromeos/ash/services/auth_factor_config/auth_factor_config.h +++ b/chromeos/ash/services/auth_factor_config/auth_factor_config.h
@@ -6,6 +6,7 @@ #define CHROMEOS_ASH_SERVICES_AUTH_FACTOR_CONFIG_AUTH_FACTOR_CONFIG_H_ #include "base/containers/enum_set.h" +#include "base/functional/callback_forward.h" #include "chromeos/ash/components/login/auth/auth_factor_editor.h" #include "chromeos/ash/components/login/auth/public/authentication_error.h" #include "chromeos/ash/services/auth_factor_config/chrome_browser_delegates.h" @@ -22,6 +23,22 @@ // The implementation of the AuthFactorConfig service. class AuthFactorConfig : public mojom::AuthFactorConfig { public: + class TestApi { + public: + explicit TestApi(AuthFactorConfig& auth_factor_config) + : auth_factor_config_(auth_factor_config) {} + + // Injects a callback that gets invoked after knowledge factor + // is added. + void SetAddKnowledgeFactorCallback(base::OnceClosure callback) { + auth_factor_config_.SetAddKnowledgeFactorCallbackForTesting( + std::move(callback)); + } + + private: + AuthFactorConfig& auth_factor_config_; + }; + using AuthFactorSet = base::EnumSet<mojom::AuthFactor, mojom::AuthFactor::kMinValue, mojom::AuthFactor::kMaxValue>; @@ -84,6 +101,8 @@ void OnUserHasKnowledgeFactor(const UserContext& context); private: + friend class TestApi; + void ObtainContext( const std::string& auth_token, base::OnceCallback<void(std::unique_ptr<UserContext>)> callback); @@ -105,6 +124,7 @@ const std::string& auth_token, std::unique_ptr<UserContext> context, absl::optional<AuthenticationError> error); + void SetAddKnowledgeFactorCallbackForTesting(base::OnceClosure callback); raw_ptr<QuickUnlockStorageDelegate> quick_unlock_storage_; // This instance is held by browser process (see in_process_instances) @@ -115,6 +135,10 @@ mojo::ReceiverSet<mojom::AuthFactorConfig> receivers_; mojo::RemoteSet<mojom::FactorObserver> observers_; AuthFactorEditor auth_factor_editor_; + + // Used for testing, invoked when a knowledge factor is added. + base::OnceClosure add_knowledge_factor_callback_; + base::WeakPtrFactory<AuthFactorConfig> weak_factory_{this}; };
diff --git a/chromeos/ash/services/auth_factor_config/in_process_instances.cc b/chromeos/ash/services/auth_factor_config/in_process_instances.cc index 072debf..1bf4afa 100644 --- a/chromeos/ash/services/auth_factor_config/in_process_instances.cc +++ b/chromeos/ash/services/auth_factor_config/in_process_instances.cc
@@ -70,6 +70,14 @@ return GetAuthFactorConfigImpl(delegate, local_state); } +// Used to acquire a reference to the implementation of the +// `mojom::AuthFactorConfig` for injecting callbacks in tests. +AuthFactorConfig& GetAuthFactorConfigForTesting( // IN-TEST + QuickUnlockStorageDelegate& delegate, + PrefService* local_state) { + return GetAuthFactorConfigImpl(delegate, local_state); +} + void BindToRecoveryFactorEditor( mojo::PendingReceiver<mojom::RecoveryFactorEditor> receiver, QuickUnlockStorageDelegate& delegate,
diff --git a/chromeos/ash/services/auth_factor_config/in_process_instances.h b/chromeos/ash/services/auth_factor_config/in_process_instances.h index c5949a89..f974a99 100644 --- a/chromeos/ash/services/auth_factor_config/in_process_instances.h +++ b/chromeos/ash/services/auth_factor_config/in_process_instances.h
@@ -27,6 +27,8 @@ PrefService* local_state); mojom::AuthFactorConfig& GetAuthFactorConfig(QuickUnlockStorageDelegate&, PrefService* local_state); +AuthFactorConfig& GetAuthFactorConfigForTesting(QuickUnlockStorageDelegate&, + PrefService* local_state); void BindToRecoveryFactorEditor( mojo::PendingReceiver<mojom::RecoveryFactorEditor> receiver,
diff --git a/chromeos/ash/services/nearby/public/mojom/quick_start_decoder_types.mojom b/chromeos/ash/services/nearby/public/mojom/quick_start_decoder_types.mojom index a4b7e70..3295f20 100644 --- a/chromeos/ash/services/nearby/public/mojom/quick_start_decoder_types.mojom +++ b/chromeos/ash/services/nearby/public/mojom/quick_start_decoder_types.mojom
@@ -7,6 +7,13 @@ struct BootstrapConfigurations { // Instance ID can be empty even with a valid BootstrapConfigurations. string instance_id; + + // Indicates whether the account in question is a supervised account + // (Unicorn, Geller, etc.). + bool is_supervised_account; + + // Email address for the account in question. + string email; }; enum WifiSecurityType {
diff --git a/chromeos/constants/chromeos_features.cc b/chromeos/constants/chromeos_features.cc index 3924e96..dc17049a 100644 --- a/chromeos/constants/chromeos_features.cc +++ b/chromeos/constants/chromeos_features.cc
@@ -117,6 +117,11 @@ "DisableQuickAnswersV2Translation", base::FEATURE_DISABLED_BY_DEFAULT); +// Enables Essential Search in Omnibox for both launcher and browser. +BASE_FEATURE(kEssentialSearch, + "EssentialSearch", + base::FEATURE_DISABLED_BY_DEFAULT); + // Enable experimental goldfish web app isolation. BASE_FEATURE(kExperimentalWebAppStoragePartitionIsolation, "ExperimentalWebAppStoragePartitionIsolation", @@ -259,6 +264,10 @@ #endif } +bool IsEssentialSearchEnabled() { + return base::FeatureList::IsEnabled(kEssentialSearch); +} + bool IsIWAForTelemetryExtensionAPIEnabled() { return base::FeatureList::IsEnabled(kIWAForTelemetryExtensionAPI); }
diff --git a/chromeos/constants/chromeos_features.h b/chromeos/constants/chromeos_features.h index 89415729..d2febd4a 100644 --- a/chromeos/constants/chromeos_features.h +++ b/chromeos/constants/chromeos_features.h
@@ -55,6 +55,7 @@ BASE_DECLARE_FEATURE(kDisableOfficeEditingComponentApp); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kDisableQuickAnswersV2Translation); +COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kEssentialSearch); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kExperimentalWebAppStoragePartitionIsolation); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) @@ -94,6 +95,7 @@ bool IsDataControlsFileAccessDefaultDenyEnabled(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsDeskProfilesEnabled(); +COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsEssentialSearchEnabled(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsIWAForTelemetryExtensionAPIEnabled(); COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsJellyEnabled();
diff --git a/chromeos/dbus/dlp/dlp_client.cc b/chromeos/dbus/dlp/dlp_client.cc index 0687020..3acec0f 100644 --- a/chromeos/dbus/dlp/dlp_client.cc +++ b/chromeos/dbus/dlp/dlp_client.cc
@@ -167,6 +167,17 @@ weak_factory_.GetWeakPtr(), std::move(callback))); } + void GetDatabaseEntries(GetDatabaseEntriesCallback callback) override { + dbus::MethodCall method_call(dlp::kDlpInterface, + dlp::kGetDatabaseEntriesMethod); + dbus::MessageWriter writer(&method_call); + + proxy_->CallMethod( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::BindOnce(&DlpClientImpl::HandleGetDatabaseEntriesResponse, + weak_factory_.GetWeakPtr(), std::move(callback))); + } + bool IsAlive() const override { return is_alive_; } void AddObserver(Observer* observer) override { @@ -260,6 +271,16 @@ std::move(callback).Run(response_proto, std::move(fd)); } + void HandleGetDatabaseEntriesResponse(GetDatabaseEntriesCallback callback, + dbus::Response* response) { + dlp::GetDatabaseEntriesResponse response_proto; + const char* error_message = DeserializeProto(response, &response_proto); + if (error_message) { + response_proto.set_error_message(error_message); + } + std::move(callback).Run(response_proto); + } + void NameOwnerChangedReceived(const std::string& old_owner, const std::string& new_owner) { is_alive_ = false;
diff --git a/chromeos/dbus/dlp/dlp_client.h b/chromeos/dbus/dlp/dlp_client.h index 47e4315..0965b37 100644 --- a/chromeos/dbus/dlp/dlp_client.h +++ b/chromeos/dbus/dlp/dlp_client.h
@@ -61,6 +61,9 @@ base::RepeatingCallback<void(const dlp::CheckFilesTransferRequest, CheckFilesTransferCallback)>; + using GetDatabaseEntriesCallback = + base::OnceCallback<void(const dlp::GetDatabaseEntriesResponse response)>; + // Interface with testing functionality. Accessed through // GetTestInterface(), only implemented in the fake implementation. class TestInterface { @@ -130,6 +133,7 @@ CheckFilesTransferCallback callback) = 0; virtual void RequestFileAccess(const dlp::RequestFileAccessRequest request, RequestFileAccessCallback callback) = 0; + virtual void GetDatabaseEntries(GetDatabaseEntriesCallback callback) = 0; virtual bool IsAlive() const = 0;
diff --git a/chromeos/dbus/dlp/fake_dlp_client.cc b/chromeos/dbus/dlp/fake_dlp_client.cc index cca8f98..06027b3 100644 --- a/chromeos/dbus/dlp/fake_dlp_client.cc +++ b/chromeos/dbus/dlp/fake_dlp_client.cc
@@ -101,6 +101,17 @@ std::move(callback).Run(response, base::ScopedFD()); } +void FakeDlpClient::GetDatabaseEntries(GetDatabaseEntriesCallback callback) { + dlp::GetDatabaseEntriesResponse response; + for (auto& [path, urls] : files_database_) { + auto* file_entry = response.add_files_entries(); + file_entry->set_source_url(urls.first); + file_entry->set_referrer_url(urls.second); + file_entry->set_path(path); + } + std::move(callback).Run(response); +} + bool FakeDlpClient::IsAlive() const { return is_alive_; }
diff --git a/chromeos/dbus/dlp/fake_dlp_client.h b/chromeos/dbus/dlp/fake_dlp_client.h index 40c2dfee..f7d43832 100644 --- a/chromeos/dbus/dlp/fake_dlp_client.h +++ b/chromeos/dbus/dlp/fake_dlp_client.h
@@ -35,6 +35,7 @@ CheckFilesTransferCallback callback) override; void RequestFileAccess(const dlp::RequestFileAccessRequest request, RequestFileAccessCallback callback) override; + void GetDatabaseEntries(GetDatabaseEntriesCallback callback) override; bool IsAlive() const override; void AddObserver(Observer* observer) override; void RemoveObserver(Observer* observer) override;
diff --git a/clank b/clank index f2d61587..8f4abea 160000 --- a/clank +++ b/clank
@@ -1 +1 @@ -Subproject commit f2d6158714d5eda293d2163014080fe65708fde6 +Subproject commit 8f4abea26f41af5854ff7540ca549e90f88c768a
diff --git a/components/android_system_error_page/resources/supervised_user_url_blocked.html b/components/android_system_error_page/resources/supervised_user_url_blocked.html index e25786a..83442407 100644 --- a/components/android_system_error_page/resources/supervised_user_url_blocked.html +++ b/components/android_system_error_page/resources/supervised_user_url_blocked.html
@@ -5,21 +5,14 @@ <style> body { /* Light mode is the default, media queries handle dark mode switching. */ - --gray-900: #202124; - --gray-500: #9AA0A6; - --gray-light: #F7F7F7; - --text-color-light: var(--gray-900); - --text-color-dark: var(--gray-500); - --text-color: var(--text-color-light); - --background-color-light: var(--gray-light); - --background-color-dark: var(--gray-900); - --background-color: var(--background-color-light); - --icon-color-light: black; - --icon-color-dark: white; - --icon-color: var(--icon-color-light); + --foreground-color-light-mode: #9A9C9B; + --foreground-color-dark-mode: #DFE1E0; + --foreground-color: var(--foreground-color-light-mode); + --background-color-light-mode: #E1E3E1; + --background-color-dark-mode: #444746; + --background-color: var(--background-color-light-mode); --icon-size-large: 48px; --icon-size-small: 24px; - --icon-size: var(--icon-size-large); margin: 0; padding: 0; @@ -42,17 +35,26 @@ gap: 8px; } - #icon { - width: var(--icon-size); - height: var(--icon-size); - fill: var(--icon-color); - opacity: 0.54; + .icon { + fill: var(--foreground-color); + } + + #icon-large { + display: block; + width: var(--icon-size-large); + height: var(--icon-size-large); + } + + #icon-small { + display: none; + width: var(--icon-size-small); + height: var(--icon-size-small); } #message { - font: 14px/21px Roboto, Arial, sans-serif; + font: 14px/20px Google Sans, Roboto, Arial, sans-serif; text-align: center; - color: var(--text-color); + color: var(--foreground-color); } /* Media queries for resizing */ @@ -61,35 +63,41 @@ /* is used for everything */ /* Default size has large icon and visible text set up */ - /* Smallest size, no icon, no text */ - @media (max-width: 30px), - (max-height: 30px) { - #icon { - display: none; - } - } - /* Medium size, small icon, no text */ @media (max-width: 280px) and (max-height: 168px), (max-width: 168px) and (max-height: 280px), (max-width: 75px), (max-height: 75px) { - body { - --icon-size: var(--icon-size-small); + #icon-large { + display: none; } + + #icon-small { + display: block; + } + #message { display: none; } + #wrapper { padding: 0; } } + /* Smallest size, no icon, no text */ + @media (max-width: 30px), + (max-height: 30px) { + #icon-large, + #icon-small { + display: none; + } + } + @media (prefers-color-scheme: dark) { body { - --text-color: var(--text-color-dark); - --background-color: var(--background-color-dark); - --icon-color: var(--icon-color-dark); + --foreground-color: var(--foreground-color-dark-mode); + --background-color: var(--background-color-dark-mode); } } </style> @@ -97,8 +105,12 @@ <body> <div id="wrapper"> <div id="content"> - <svg id="icon" viewBox="0 0 40 40"> - <path d="M20 40C17.2333 40 14.6333 39.4833 12.2 38.45C9.76667 37.3833 7.65 35.95 5.85 34.15C4.05 32.35 2.61667 30.2333 1.55 27.8C0.516667 25.3667 1.19209e-07 22.7667 1.19209e-07 20C1.19209e-07 17.2333 0.516667 14.6333 1.55 12.2C2.61667 9.76666 4.05 7.65 5.85 5.85C7.65 4.05 9.76667 2.63333 12.2 1.6C14.6333 0.533332 17.2333 -9.53674e-07 20 -9.53674e-07C22.7667 -9.53674e-07 25.3667 0.533332 27.8 1.6C30.2333 2.63333 32.35 4.05 34.15 5.85C35.95 7.65 37.3667 9.76666 38.4 12.2C39.4667 14.6333 40 17.2333 40 20C40 22.7667 39.4667 25.3667 38.4 27.8C37.3667 30.2333 35.95 32.35 34.15 34.15C32.35 35.95 30.2333 37.3833 27.8 38.45C25.3667 39.4833 22.7667 40 20 40ZM20 37C22.0333 37 23.9833 36.6667 25.85 36C27.75 35.3 29.45 34.3 30.95 33L7 9.05C5.73333 10.5833 4.75 12.2833 4.05 14.15C3.35 16.0167 3 17.9667 3 20C3 24.7333 4.65 28.75 7.95 32.05C11.25 35.35 15.2667 37 20 37ZM32.95 30.95C34.1833 29.45 35.1667 27.7667 35.9 25.9C36.6333 24 37 22.0333 37 20C37 15.2667 35.35 11.25 32.05 7.95C28.75 4.65 24.7333 3 20 3C17.9667 3 16.0167 3.35 14.15 4.05C12.2833 4.75 10.5833 5.75 9.05 7.05L32.95 30.95Z" fill-opacity="0.2"> + <svg id="icon-large" class="icon" viewBox="0 0 40 40"> + <path d="M20 40C17.2333 40 14.6333 39.4833 12.2 38.45C9.76667 37.3833 7.65 35.95 5.85 34.15C4.05 32.35 2.61667 30.2333 1.55 27.8C0.516667 25.3667 1.19209e-07 22.7667 1.19209e-07 20C1.19209e-07 17.2333 0.516667 14.6333 1.55 12.2C2.61667 9.76666 4.05 7.65 5.85 5.85C7.65 4.05 9.76667 2.63333 12.2 1.6C14.6333 0.533332 17.2333 -9.53674e-07 20 -9.53674e-07C22.7667 -9.53674e-07 25.3667 0.533332 27.8 1.6C30.2333 2.63333 32.35 4.05 34.15 5.85C35.95 7.65 37.3667 9.76666 38.4 12.2C39.4667 14.6333 40 17.2333 40 20C40 22.7667 39.4667 25.3667 38.4 27.8C37.3667 30.2333 35.95 32.35 34.15 34.15C32.35 35.95 30.2333 37.3833 27.8 38.45C25.3667 39.4833 22.7667 40 20 40ZM20 37C22.0333 37 23.9833 36.6667 25.85 36C27.75 35.3 29.45 34.3 30.95 33L7 9.05C5.73333 10.5833 4.75 12.2833 4.05 14.15C3.35 16.0167 3 17.9667 3 20C3 24.7333 4.65 28.75 7.95 32.05C11.25 35.35 15.2667 37 20 37ZM32.95 30.95C34.1833 29.45 35.1667 27.7667 35.9 25.9C36.6333 24 37 22.0333 37 20C37 15.2667 35.35 11.25 32.05 7.95C28.75 4.65 24.7333 3 20 3C17.9667 3 16.0167 3.35 14.15 4.05C12.2833 4.75 10.5833 5.75 9.05 7.05L32.95 30.95Z"> + </svg> + <svg id="icon-small" class="icon" viewBox="0 0 40 40" role="img"> + <title>$1</title> + <path d="M20 40C17.2333 40 14.6333 39.4833 12.2 38.45C9.76667 37.3833 7.65 35.95 5.85 34.15C4.05 32.35 2.61667 30.2333 1.55 27.8C0.516667 25.3667 1.19209e-07 22.7667 1.19209e-07 20C1.19209e-07 17.2333 0.516667 14.6333 1.55 12.2C2.61667 9.76666 4.05 7.65 5.85 5.85C7.65 4.05 9.76667 2.63333 12.2 1.6C14.6333 0.533332 17.2333 -9.53674e-07 20 -9.53674e-07C22.7667 -9.53674e-07 25.3667 0.533332 27.8 1.6C30.2333 2.63333 32.35 4.05 34.15 5.85C35.95 7.65 37.3667 9.76666 38.4 12.2C39.4667 14.6333 40 17.2333 40 20C40 22.7667 39.4667 25.3667 38.4 27.8C37.3667 30.2333 35.95 32.35 34.15 34.15C32.35 35.95 30.2333 37.3833 27.8 38.45C25.3667 39.4833 22.7667 40 20 40ZM20 37C22.0333 37 23.9833 36.6667 25.85 36C27.75 35.3 29.45 34.3 30.95 33L7 9.05C5.73333 10.5833 4.75 12.2833 4.05 14.15C3.35 16.0167 3 17.9667 3 20C3 24.7333 4.65 28.75 7.95 32.05C11.25 35.35 15.2667 37 20 37ZM32.95 30.95C34.1833 29.45 35.1667 27.7667 35.9 25.9C36.6333 24 37 22.0333 37 20C37 15.2667 35.35 11.25 32.05 7.95C28.75 4.65 24.7333 3 20 3C17.9667 3 16.0167 3.35 14.15 4.05C12.2833 4.75 10.5833 5.75 9.05 7.05L32.95 30.95Z"> </svg> <div id="message">$1</div> </div>
diff --git a/components/autofill/core/browser/autofill_experiments_unittest.cc b/components/autofill/core/browser/autofill_experiments_unittest.cc index 8646e349..c5c29db 100644 --- a/components/autofill/core/browser/autofill_experiments_unittest.cc +++ b/components/autofill/core/browser/autofill_experiments_unittest.cc
@@ -240,13 +240,13 @@ sync_service_.SetHasSyncConsent(false); EXPECT_TRUE(IsCreditCardUploadEnabled( - "john.smith@gmail.com", - AutofillMetrics::PaymentsSigninState::kSignedInAndSyncFeatureEnabled)); + "john.smith@gmail.com", AutofillMetrics::PaymentsSigninState:: + kSignedInAndWalletSyncTransportEnabled)); histogram_tester.ExpectUniqueSample( "Autofill.CardUploadEnabled", autofill_metrics::CardUploadEnabled::kEnabledForCountry, 1); histogram_tester.ExpectUniqueSample( - "Autofill.CardUploadEnabled.SignedInAndSyncFeatureEnabled", + "Autofill.CardUploadEnabled.SignedInAndWalletSyncTransportEnabled", autofill_metrics::CardUploadEnabled::kEnabledForCountry, 1); } @@ -267,13 +267,14 @@ /*types=*/{syncer::UserSelectableType::kAutofill, syncer::UserSelectableType::kPayments}); - EXPECT_TRUE(IsCreditCardUploadEnabled( - AutofillMetrics::PaymentsSigninState::kSignedInAndSyncFeatureEnabled)); + EXPECT_TRUE( + IsCreditCardUploadEnabled(AutofillMetrics::PaymentsSigninState:: + kSignedInAndWalletSyncTransportEnabled)); histogram_tester.ExpectUniqueSample( "Autofill.CardUploadEnabled", autofill_metrics::CardUploadEnabled::kEnabledForCountry, 1); histogram_tester.ExpectUniqueSample( - "Autofill.CardUploadEnabled.SignedInAndSyncFeatureEnabled", + "Autofill.CardUploadEnabled.SignedInAndWalletSyncTransportEnabled", autofill_metrics::CardUploadEnabled::kEnabledForCountry, 1); }
diff --git a/components/autofill/core/browser/browser_autofill_manager.cc b/components/autofill/core/browser/browser_autofill_manager.cc index 6455136..859975f 100644 --- a/components/autofill/core/browser/browser_autofill_manager.cc +++ b/components/autofill/core/browser/browser_autofill_manager.cc
@@ -2555,8 +2555,11 @@ // This will hold the fields (and autofill_fields) in the intersection of // safe_fields and newly_filled_fields_id. - std::vector<const FormFieldData*> safe_newly_filled_fields; - std::vector<const AutofillField*> safe_newly_filled_autofill_fields; + struct { + std::vector<const FormFieldData*> old_values; + std::vector<const FormFieldData*> new_values; + std::vector<const AutofillField*> cached; + } safe_newly_filled_fields; // Report the fields that were not filled due to the iframe security policy. for (FieldGlobalId newly_filled_field_id : newly_filled_field_ids) { @@ -2564,9 +2567,11 @@ // A safe field was filled. Both functions will not return a nullptr // because they passed the `FieldFillingSkipReason::kFormChanged` // condition. - safe_newly_filled_fields.push_back( + safe_newly_filled_fields.old_values.push_back( form.FindFieldByGlobalId(newly_filled_field_id)); - safe_newly_filled_autofill_fields.push_back( + safe_newly_filled_fields.new_values.push_back( + result.FindFieldByGlobalId(newly_filled_field_id)); + safe_newly_filled_fields.cached.push_back( form_structure->GetFieldById(newly_filled_field_id)); continue; } @@ -2584,8 +2589,9 @@ // Save filling history to support undoing it later if needed. if (action_persistence == mojom::ActionPersistence::kFill) { - form_autofill_history_.AddFormFillEntry( - safe_newly_filled_fields, safe_newly_filled_autofill_fields, is_refill); + form_autofill_history_.AddFormFillEntry(safe_newly_filled_fields.old_values, + safe_newly_filled_fields.cached, + is_refill); } LOG_AF(buffer) << CTag{"table"}; @@ -2594,7 +2600,7 @@ << std::move(buffer); NotifyObservers(&Observer::OnFillOrPreviewDataModelForm, form.global_id(), - action_persistence, safe_newly_filled_fields, + action_persistence, safe_newly_filled_fields.new_values, profile_or_credit_card); // Call OnDidFillSuggestion() to log the metrics.
diff --git a/components/browser_sync/sync_to_signin_migration.cc b/components/browser_sync/sync_to_signin_migration.cc index 908abb5..3474297cf 100644 --- a/components/browser_sync/sync_to_signin_migration.cc +++ b/components/browser_sync/sync_to_signin_migration.cc
@@ -10,10 +10,12 @@ #include "base/metrics/histogram_functions.h" #include "base/strings/strcat.h" #include "components/prefs/pref_service.h" +#include "components/signin/public/base/gaia_id_hash.h" #include "components/signin/public/base/signin_pref_names.h" #include "components/sync/base/model_type.h" #include "components/sync/base/pref_names.h" #include "components/sync/service/sync_feature_status_for_migrations_recorder.h" +#include "components/sync/service/sync_prefs.h" namespace browser_sync { @@ -123,6 +125,10 @@ } // namespace void MaybeMigrateSyncingUserToSignedIn(PrefService* pref_service) { + // ====================================== + // Global migration decision and metrics. + // ====================================== + const SyncToSigninMigrationDecision decision = ShouldMigrateSyncingUserToSignedIn(pref_service); base::UmaHistogramEnumeration("Sync.SyncToSigninMigrationDecision", decision); @@ -141,6 +147,10 @@ break; } + // =================================================== + // Data-type-specific migration decisions and metrics. + // =================================================== + const bool doing_migration = decision == SyncToSigninMigrationDecision::kMigrate; @@ -178,7 +188,49 @@ return; } - // TODO(crbug.com/1486420): Add actual migration logic. + // ========================= + // Global (prefs) migration. + // ========================= + + // The account identifier of an account is its Gaia ID. So + // `kGoogleServicesAccountId` stores the Gaia ID of the syncing account. + const std::string gaia_id = + pref_service->GetString(prefs::kGoogleServicesAccountId); + // Guaranteed to be non-empty by ShouldMigrateSyncingUserToSignedIn(). + CHECK(!gaia_id.empty()); + + // Remove ConsentLevel::kSync. This also ensures that the whole migration will + // not run a second time. + // Note that it's important to explicitly set this pref to false (not just + // clear it), since the signin code treats "unset" differently. + pref_service->SetBoolean(prefs::kGoogleServicesConsentedToSync, false); + // Save the ID and username of the migrated account, to be able to revert the + // migration if necessary. + pref_service->SetString(prefs::kGoogleServicesSyncingGaiaIdMigratedToSignedIn, + gaia_id); + pref_service->SetString( + prefs::kGoogleServicesSyncingUsernameMigratedToSignedIn, + pref_service->GetString(prefs::kGoogleServicesLastSyncingUsername)); + // Clear the "previously syncing user" prefs, to prevent accidental misuse. + pref_service->ClearPref(prefs::kGoogleServicesLastSyncingAccountIdDeprecated); + pref_service->ClearPref(prefs::kGoogleServicesLastSyncingGaiaId); + pref_service->ClearPref(prefs::kGoogleServicesLastSyncingUsername); + + // Migrate the global data type prefs (used for Sync-the-feature) over to the + // account-specific ones. + signin::GaiaIdHash gaia_id_hash = signin::GaiaIdHash::FromGaiaId(gaia_id); + syncer::SyncPrefs::MigrateGlobalDataTypePrefsToAccount(pref_service, + gaia_id_hash); + + // Ensure the prefs changes are persisted as soon as possible. (They get + // persisted on shutdown anyway, but better make sure.) + pref_service->CommitPendingWrite(); + + // ============================== + // Data-type-specific migrations. + // ============================== + + // TODO(crbug.com/1486420): Add actual data type migration logic. NOTIMPLEMENTED(); }
diff --git a/components/browser_sync/sync_to_signin_migration_unittest.cc b/components/browser_sync/sync_to_signin_migration_unittest.cc index eeb7dd5..256f6777 100644 --- a/components/browser_sync/sync_to_signin_migration_unittest.cc +++ b/components/browser_sync/sync_to_signin_migration_unittest.cc
@@ -14,6 +14,7 @@ #include "components/signin/public/base/signin_pref_names.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "components/sync/base/model_type.h" +#include "components/sync/base/pref_names.h" #include "components/sync/base/user_selectable_type.h" #include "components/sync/service/sync_feature_status_for_migrations_recorder.h" #include "components/sync/service/sync_prefs.h" @@ -48,6 +49,10 @@ sync_service_.GetAccountInfo().gaia); pref_service_.SetBoolean(prefs::kGoogleServicesConsentedToSync, sync_service_.HasSyncConsent()); + pref_service_.SetString(prefs::kGoogleServicesLastSyncingGaiaId, + sync_service_.GetAccountInfo().gaia); + pref_service_.SetString(prefs::kGoogleServicesLastSyncingUsername, + sync_service_.GetAccountInfo().email); // Populate sync prefs. The TestSyncService doesn't write these, so they // have to be set manually here. @@ -79,6 +84,217 @@ syncer::TestSyncService sync_service_; }; +class SyncToSigninMigrationTest : public SyncToSigninMigrationTestBase, + public testing::Test { + public: + SyncToSigninMigrationTest() + : SyncToSigninMigrationTestBase( + /*migration_feature_enabled=*/true) {} +}; + +TEST_F(SyncToSigninMigrationTest, SyncActive) { + // Sync is active. + ASSERT_EQ(sync_service_.GetTransportState(), + syncer::SyncService::TransportState::ACTIVE); + ASSERT_TRUE(sync_service_.HasSyncConsent()); + + const std::string gaia_id = sync_service_.GetAccountInfo().gaia; + const std::string email = sync_service_.GetAccountInfo().email; + + // Save the above state to prefs. + RecordStateToPrefs(); + + // Before the migration, there are no per-account selected types. + ASSERT_TRUE( + pref_service_.GetDict(syncer::prefs::internal::kSelectedTypesPerAccount) + .empty()); + + // Run the migration. This should change the user to be non-syncing. + MaybeMigrateSyncingUserToSignedIn(&pref_service_); + + // Note that TestSyncService doesn't consume the prefs, so verify the prefs + // directly here. + // The user should still be signed in. + EXPECT_EQ(pref_service_.GetString(prefs::kGoogleServicesAccountId), gaia_id); + // But not syncing anymore. + EXPECT_FALSE(pref_service_.GetBoolean(prefs::kGoogleServicesConsentedToSync)); + // The fact that the user was migrated should be recorded in prefs. + EXPECT_EQ(pref_service_.GetString( + prefs::kGoogleServicesSyncingGaiaIdMigratedToSignedIn), + gaia_id); + EXPECT_EQ(pref_service_.GetString( + prefs::kGoogleServicesSyncingUsernameMigratedToSignedIn), + email); + + // There should be per-account selected types now. The details of this are + // covered in SyncPrefs unit tests. + EXPECT_FALSE( + pref_service_.GetDict(syncer::prefs::internal::kSelectedTypesPerAccount) + .empty()); +} + +TEST_F(SyncToSigninMigrationTest, SyncStatusPrefsUnset) { + // Everything is active. + ASSERT_EQ(sync_service_.GetTransportState(), + syncer::SyncService::TransportState::ACTIVE); + ASSERT_TRUE(sync_service_.HasSyncConsent()); + + // Save the Sync configuration (enabled data types etc) to prefs, but not the + // migration-specific status prefs. This simulates the case of an old client + // which has never written those prefs. + RecordStateToPrefs(/*include_status_recorder=*/false); + + // Take a copy of all current pref values, to verify that the migration + // doesn't modify any of them. + const base::Value::Dict all_prefs = + pref_service_.user_prefs_store()->GetValues(); + + // Trigger the migration - it should NOT actually run in this state. + MaybeMigrateSyncingUserToSignedIn(&pref_service_); + + // Note that TestSyncService doesn't consume the prefs, so verify the prefs + // directly here. + // Since the migration didn't actually run, the prefs should be unmodified. + EXPECT_EQ(pref_service_.user_prefs_store()->GetValues(), all_prefs); +} + +TEST_F(SyncToSigninMigrationTest, SyncTransport) { + // There's no Sync consent, but otherwise everything is active (running in + // transport mode). + sync_service_.SetHasSyncConsent(false); + ASSERT_EQ(sync_service_.GetTransportState(), + syncer::SyncService::TransportState::ACTIVE); + + // Save the above state to prefs. + RecordStateToPrefs(); + + // Take a copy of all current pref values, to verify that the migration + // doesn't modify any of them. + const base::Value::Dict all_prefs = + pref_service_.user_prefs_store()->GetValues(); + + // Trigger the migration - it should NOT actually run in this state. + MaybeMigrateSyncingUserToSignedIn(&pref_service_); + + // Note that TestSyncService doesn't consume the prefs, so verify the prefs + // directly here. + // Since the migration didn't actually run, the prefs should be unmodified. + EXPECT_EQ(pref_service_.user_prefs_store()->GetValues(), all_prefs); +} + +TEST_F(SyncToSigninMigrationTest, SyncDisabledByPolicy) { + // The user is signed in and opted in to Sync, but Sync is disabled via + // enterprise policy. + sync_service_.SetDisableReasons( + {syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY}); + ASSERT_EQ(sync_service_.GetTransportState(), + syncer::SyncService::TransportState::DISABLED); + ASSERT_TRUE(sync_service_.HasSyncConsent()); + + const std::string gaia_id = sync_service_.GetAccountInfo().gaia; + const std::string email = sync_service_.GetAccountInfo().email; + + // Save the above state to prefs. + RecordStateToPrefs(); + + // Before the migration, there are no per-account selected types. + ASSERT_TRUE( + pref_service_.GetDict(syncer::prefs::internal::kSelectedTypesPerAccount) + .empty()); + + // Run the migration. This should change the user to be non-syncing (even + // though Sync wasn't actually active). + MaybeMigrateSyncingUserToSignedIn(&pref_service_); + + // Note that TestSyncService doesn't consume the prefs, so verify the prefs + // directly here. + // The user should still be signed in. + EXPECT_EQ(pref_service_.GetString(prefs::kGoogleServicesAccountId), gaia_id); + // But not syncing anymore. + EXPECT_FALSE(pref_service_.GetBoolean(prefs::kGoogleServicesConsentedToSync)); + // The fact that the user was migrated should be recorded in prefs. + EXPECT_EQ(pref_service_.GetString( + prefs::kGoogleServicesSyncingGaiaIdMigratedToSignedIn), + gaia_id); + EXPECT_EQ(pref_service_.GetString( + prefs::kGoogleServicesSyncingUsernameMigratedToSignedIn), + email); + + // There should be per-account selected types now. The details of this are + // covered in SyncPrefs unit tests. + EXPECT_FALSE( + pref_service_.GetDict(syncer::prefs::internal::kSelectedTypesPerAccount) + .empty()); +} + +TEST_F(SyncToSigninMigrationTest, SyncPaused) { + // Sync-the-feature is enabled, but in the "paused" state due to a persistent + // auth error. + sync_service_.SetPersistentAuthError(); + ASSERT_EQ(sync_service_.GetTransportState(), + syncer::SyncService::TransportState::PAUSED); + ASSERT_TRUE(sync_service_.HasSyncConsent()); + ASSERT_TRUE(sync_service_.GetActiveDataTypes().Empty()); + + const std::string gaia_id = sync_service_.GetAccountInfo().gaia; + const std::string email = sync_service_.GetAccountInfo().email; + + // Save the above state to prefs. + RecordStateToPrefs(); + + // Before the migration, there are no per-account selected types. + ASSERT_TRUE( + pref_service_.GetDict(syncer::prefs::internal::kSelectedTypesPerAccount) + .empty()); + + // Run the migration. This should change the user to be non-syncing (even + // though Sync wasn't actually active). + MaybeMigrateSyncingUserToSignedIn(&pref_service_); + + // Note that TestSyncService doesn't consume the prefs, so verify the prefs + // directly here. + // The user should still be signed in. + EXPECT_EQ(pref_service_.GetString(prefs::kGoogleServicesAccountId), gaia_id); + // But not syncing anymore. + EXPECT_FALSE(pref_service_.GetBoolean(prefs::kGoogleServicesConsentedToSync)); + // The fact that the user was migrated should be recorded in prefs. + EXPECT_EQ(pref_service_.GetString( + prefs::kGoogleServicesSyncingGaiaIdMigratedToSignedIn), + gaia_id); + EXPECT_EQ(pref_service_.GetString( + prefs::kGoogleServicesSyncingUsernameMigratedToSignedIn), + email); + + // There should be per-account selected types now. The details of this are + // covered in SyncPrefs unit tests. + EXPECT_FALSE( + pref_service_.GetDict(syncer::prefs::internal::kSelectedTypesPerAccount) + .empty()); +} + +TEST_F(SyncToSigninMigrationTest, SyncInitializing) { + // The user is signed in and opted in to Sync, but Sync is still initializing. + sync_service_.SetTransportState( + syncer::SyncService::TransportState::INITIALIZING); + ASSERT_TRUE(sync_service_.HasSyncConsent()); + + // Save the above state to prefs. + RecordStateToPrefs(); + + // Take a copy of all current pref values, to verify that the migration + // doesn't modify any of them. + const base::Value::Dict all_prefs = + pref_service_.user_prefs_store()->GetValues(); + + // Trigger the migration - it should NOT actually run in this state. + MaybeMigrateSyncingUserToSignedIn(&pref_service_); + + // Note that TestSyncService doesn't consume the prefs, so verify the prefs + // directly here. + // Since the migration didn't actually run, the prefs should be unmodified. + EXPECT_EQ(pref_service_.user_prefs_store()->GetValues(), all_prefs); +} + // Fixture for tests covering migration metrics. The test param determines // whether the feature flag is enabled or not. class SyncToSigninMigrationMetricsTest : public SyncToSigninMigrationTestBase,
diff --git a/components/certificate_transparency/data/log_list.json b/components/certificate_transparency/data/log_list.json index e3a75d23..e09f7868 100644 --- a/components/certificate_transparency/data/log_list.json +++ b/components/certificate_transparency/data/log_list.json
@@ -1,6 +1,6 @@ { - "version": "26.52", - "log_list_timestamp": "2023-11-22T12:54:17Z", + "version": "26.53", + "log_list_timestamp": "2023-11-23T12:55:55Z", "operators": [ { "name": "Google",
diff --git a/components/password_manager/content/common/credential_manager_mojom_traits.h b/components/password_manager/content/common/credential_manager_mojom_traits.h index ac544bd8..deb77fd7 100644 --- a/components/password_manager/content/common/credential_manager_mojom_traits.h +++ b/components/password_manager/content/common/credential_manager_mojom_traits.h
@@ -5,11 +5,11 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_COMMON_CREDENTIAL_MANAGER_MOJOM_TRAITS_H_ #define COMPONENTS_PASSWORD_MANAGER_CONTENT_COMMON_CREDENTIAL_MANAGER_MOJOM_TRAITS_H_ +#include <optional> #include <string> #include "components/password_manager/core/common/credential_manager_types.h" #include "mojo/public/cpp/bindings/struct_traits.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/mojom/credentialmanagement/credential_manager.mojom.h" namespace mojo { @@ -50,12 +50,12 @@ return r.type; } - static const absl::optional<std::u16string>& id( + static const std::optional<std::u16string>& id( const password_manager::CredentialInfo& r) { return r.id; } - static const absl::optional<std::u16string>& name( + static const std::optional<std::u16string>& name( const password_manager::CredentialInfo& r) { return r.name; } @@ -64,7 +64,7 @@ return r.icon; } - static const absl::optional<std::u16string>& password( + static const std::optional<std::u16string>& password( const password_manager::CredentialInfo& r) { return r.password; }
diff --git a/components/password_manager/core/browser/affiliation/affiliated_match_helper.h b/components/password_manager/core/browser/affiliation/affiliated_match_helper.h index dcbe8d5..f480570 100644 --- a/components/password_manager/core/browser/affiliation/affiliated_match_helper.h +++ b/components/password_manager/core/browser/affiliation/affiliated_match_helper.h
@@ -89,7 +89,7 @@ const raw_ptr<AffiliationService> affiliation_service_; - absl::optional<base::flat_set<std::string>> psl_extensions_; + std::optional<base::flat_set<std::string>> psl_extensions_; std::vector<PSLExtensionCallback> psl_extensions_callbacks_;
diff --git a/components/password_manager/core/browser/affiliation/affiliations_prefetcher.cc b/components/password_manager/core/browser/affiliation/affiliations_prefetcher.cc index 1ddc6ea4..2548c07 100644 --- a/components/password_manager/core/browser/affiliation/affiliations_prefetcher.cc +++ b/components/password_manager/core/browser/affiliation/affiliations_prefetcher.cc
@@ -5,6 +5,7 @@ #include "components/password_manager/core/browser/affiliation/affiliations_prefetcher.h" #include <algorithm> +#include <optional> #include <utility> #include "base/barrier_callback.h" @@ -37,16 +38,16 @@ #endif } -absl::optional<FacetURI> FacetURIFromPasskey( +std::optional<FacetURI> FacetURIFromPasskey( const sync_pb::WebauthnCredentialSpecifics& passkey) { std::string as_url = base::StrCat( {url::kHttpsScheme, url::kStandardSchemeSeparator, passkey.rp_id()}); FacetURI facet_uri = FacetURI::FromPotentiallyInvalidSpec(as_url); if (!facet_uri.is_valid()) { - return absl::nullopt; + return std::nullopt; } if (!IsFacetValidForAffiliation(facet_uri)) { - return absl::nullopt; + return std::nullopt; } return facet_uri; } @@ -90,7 +91,7 @@ // info for all passkeys. if (is_ready_) { for (const auto& passkey : passkey_model->GetAllPasskeys()) { - absl::optional<FacetURI> facet = FacetURIFromPasskey(passkey); + std::optional<FacetURI> facet = FacetURIFromPasskey(passkey); if (facet) { affiliation_service_->Prefetch(std::move(*facet), base::Time::Max()); } @@ -171,7 +172,7 @@ const std::vector<webauthn::PasskeyModelChange>& changes) { std::vector<FacetURI> facet_uris_to_trim; for (const webauthn::PasskeyModelChange& change : changes) { - absl::optional<FacetURI> facet = FacetURIFromPasskey(change.passkey()); + std::optional<FacetURI> facet = FacetURIFromPasskey(change.passkey()); if (!facet) { continue; } @@ -226,7 +227,7 @@ if (passkey_model_observation_.IsObserving()) { for (const auto& passkey : passkey_model_observation_.GetSource()->GetAllPasskeys()) { - absl::optional<FacetURI> facet = FacetURIFromPasskey(passkey); + std::optional<FacetURI> facet = FacetURIFromPasskey(passkey); if (facet) { facets.push_back(std::move(*facet)); }
diff --git a/components/password_manager/core/browser/browser_save_password_progress_logger.cc b/components/password_manager/core/browser/browser_save_password_progress_logger.cc index 9d56fc3..a14af9a 100644 --- a/components/password_manager/core/browser/browser_save_password_progress_logger.cc +++ b/components/password_manager/core/browser/browser_save_password_progress_logger.cc
@@ -250,7 +250,7 @@ std::string BrowserSavePasswordProgressLogger::FormStructurePasswordAttributesLogString( const FormStructure& form) { - const absl::optional<std::pair<PasswordAttribute, bool>> attribute_vote = + const std::optional<std::pair<PasswordAttribute, bool>> attribute_vote = form.get_password_attributes_vote(); if (!attribute_vote.has_value()) return std::string();
diff --git a/components/password_manager/core/browser/credential_manager_impl.cc b/components/password_manager/core/browser/credential_manager_impl.cc index 6c93068..3257b14 100644 --- a/components/password_manager/core/browser/credential_manager_impl.cc +++ b/components/password_manager/core/browser/credential_manager_impl.cc
@@ -110,7 +110,7 @@ std::move(callback).Run( pending_request_ ? CredentialManagerError::PENDING_REQUEST : CredentialManagerError::PASSWORDSTOREUNAVAILABLE, - absl::nullopt); + std::nullopt); LogCredentialManagerGetResult( metrics_util::CredentialManagerGetResult::kRejected, mediation); return;
diff --git a/components/password_manager/core/browser/credential_manager_impl.h b/components/password_manager/core/browser/credential_manager_impl.h index bdadb3fa..373b4dd 100644 --- a/components/password_manager/core/browser/credential_manager_impl.h +++ b/components/password_manager/core/browser/credential_manager_impl.h
@@ -24,7 +24,7 @@ using PreventSilentAccessCallback = base::OnceCallback<void()>; using GetCallback = base::OnceCallback<void(CredentialManagerError, - const absl::optional<CredentialInfo>&)>; + const std::optional<CredentialInfo>&)>; // Class implementing Credential Manager methods Store, PreventSilentAccess // and Get in a platform independent way. Each method takes a callback as an
diff --git a/components/password_manager/core/browser/credential_manager_impl_unittest.cc b/components/password_manager/core/browser/credential_manager_impl_unittest.cc index 4c80370..787151d2 100644 --- a/components/password_manager/core/browser/credential_manager_impl_unittest.cc +++ b/components/password_manager/core/browser/credential_manager_impl_unittest.cc
@@ -201,9 +201,9 @@ void GetCredentialCallback(bool* called, CredentialManagerError* out_error, - absl::optional<CredentialInfo>* out_info, + std::optional<CredentialInfo>* out_info, CredentialManagerError error, - const absl::optional<CredentialInfo>& info) { + const std::optional<CredentialInfo>& info) { *called = true; *out_error = error; *out_info = info; @@ -331,7 +331,7 @@ const std::vector<GURL>& federations) { bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr).Times(0); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr).Times(0); CallGet( @@ -351,7 +351,7 @@ CredentialType type) { bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr).Times(0); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr); CallGet( @@ -371,7 +371,7 @@ CredentialType type) { bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; CallGet( mediation, include_passwords, federations, base::BindOnce(&GetCredentialCallback, &called, &error, &credential)); @@ -744,7 +744,7 @@ bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; CallGet(CredentialMediationRequirement::kOptional, true, federations, base::BindOnce(&GetCredentialCallback, &called, &error, &credential)); @@ -845,7 +845,7 @@ bool called = false; CredentialManagerError error; std::vector<GURL> federations; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; CallGet(CredentialMediationRequirement::kOptional, true, federations, base::BindOnce(&GetCredentialCallback, &called, &error, &credential)); RunAllPendingTasks(); @@ -1003,7 +1003,7 @@ bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; std::vector<GURL> federations; federations.emplace_back("https://google.com/"); CallGet(CredentialMediationRequirement::kOptional, true, federations, @@ -1036,7 +1036,7 @@ bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; CallGet(CredentialMediationRequirement::kOptional, true, federations, base::BindOnce(&GetCredentialCallback, &called, &error, &credential)); @@ -1289,14 +1289,14 @@ // 1st request. bool called_1 = false; CredentialManagerError error_1; - absl::optional<CredentialInfo> credential_1; + std::optional<CredentialInfo> credential_1; CallGet(CredentialMediationRequirement::kOptional, true, federations, base::BindOnce(&GetCredentialCallback, &called_1, &error_1, &credential_1)); // 2nd request. bool called_2 = false; CredentialManagerError error_2; - absl::optional<CredentialInfo> credential_2; + std::optional<CredentialInfo> credential_2; CallGet(CredentialMediationRequirement::kOptional, true, federations, base::BindOnce(&GetCredentialCallback, &called_2, &error_2, &credential_2)); @@ -1352,7 +1352,7 @@ bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; CallGet(CredentialMediationRequirement::kOptional, true, federations, base::BindOnce(&GetCredentialCallback, &called, &error, &credential)); @@ -1391,7 +1391,7 @@ bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; CallGet(CredentialMediationRequirement::kOptional, true, /*federations=*/{}, base::BindOnce(&GetCredentialCallback, &called, &error, &credential)); @@ -1432,7 +1432,7 @@ bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; CallGet(CredentialMediationRequirement::kOptional, true, /*federations=*/{}, base::BindOnce(&GetCredentialCallback, &called, &error, &credential)); @@ -1590,7 +1590,7 @@ std::vector<GURL> federations; bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr).Times(0); @@ -1737,7 +1737,7 @@ bool called = false; CredentialManagerError error; - absl::optional<CredentialInfo> credential; + std::optional<CredentialInfo> credential; std::vector<GURL> federations; federations.emplace_back("https://google.com/");
diff --git a/components/password_manager/core/browser/credential_manager_utils.cc b/components/password_manager/core/browser/credential_manager_utils.cc index 1d9ec8d7..92547ab 100644 --- a/components/password_manager/core/browser/credential_manager_utils.cc +++ b/components/password_manager/core/browser/credential_manager_utils.cc
@@ -5,11 +5,11 @@ #include "components/password_manager/core/browser/credential_manager_utils.h" #include <memory> +#include <optional> #include <string> #include "components/password_manager/core/browser/password_form.h" #include "components/password_manager/core/common/credential_manager_types.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h"
diff --git a/components/password_manager/core/browser/fake_form_fetcher.cc b/components/password_manager/core/browser/fake_form_fetcher.cc index c38173b9..cbfd00d 100644 --- a/components/password_manager/core/browser/fake_form_fetcher.cc +++ b/components/password_manager/core/browser/fake_form_fetcher.cc
@@ -119,13 +119,13 @@ consumer.OnFetchCompleted(); } -absl::optional<PasswordStoreBackendError> +std::optional<PasswordStoreBackendError> FakeFormFetcher::GetProfileStoreBackendError() const { return profile_store_backend_error_; } void FakeFormFetcher::SetProfileStoreBackendError( - absl::optional<PasswordStoreBackendError> error) { + std::optional<PasswordStoreBackendError> error) { profile_store_backend_error_ = error; }
diff --git a/components/password_manager/core/browser/fake_form_fetcher.h b/components/password_manager/core/browser/fake_form_fetcher.h index 7bc8ada..d834380 100644 --- a/components/password_manager/core/browser/fake_form_fetcher.h +++ b/components/password_manager/core/browser/fake_form_fetcher.h
@@ -54,7 +54,7 @@ const PasswordForm* GetPreferredMatch() const override; // Returns a new FakeFormFetcher. std::unique_ptr<FormFetcher> Clone() override; - absl::optional<PasswordStoreBackendError> GetProfileStoreBackendError() + std::optional<PasswordStoreBackendError> GetProfileStoreBackendError() const override; void set_stats(const std::vector<InteractionsStats>& stats) { @@ -81,7 +81,7 @@ void NotifyFetchCompleted(); void SetProfileStoreBackendError( - absl::optional<PasswordStoreBackendError> error); + std::optional<PasswordStoreBackendError> error); private: base::ObserverList<Consumer> consumers_; @@ -94,7 +94,7 @@ std::vector<const PasswordForm*> best_matches_; std::vector<const PasswordForm*> insecure_credentials_; bool is_blocklisted_ = false; - absl::optional<PasswordStoreBackendError> profile_store_backend_error_; + std::optional<PasswordStoreBackendError> profile_store_backend_error_; }; } // namespace password_manager
diff --git a/components/password_manager/core/browser/features/password_manager_features_util.h b/components/password_manager/core/browser/features/password_manager_features_util.h index faa7f6b..a7f0e281 100644 --- a/components/password_manager/core/browser/features/password_manager_features_util.h +++ b/components/password_manager/core/browser/features/password_manager_features_util.h
@@ -79,6 +79,8 @@ // |sync_service| may be null (commonly the case in incognito mode), in which // case this will simply return false. // See PasswordFeatureManager::IsOptedInForAccountStorage. +// TODO(crbug.com/1484531): Remove the `pref_service` parameter, it's unused +// now. Possibly also from other functions in this file. bool IsOptedInForAccountStorage(const PrefService* pref_service, const syncer::SyncService* sync_service); @@ -158,16 +160,17 @@ // |pref_service| and |sync_service| must not be null. // See PasswordFeatureManager::OptInToAccountStorage. void OptInToAccountStorage(PrefService* pref_service, - const syncer::SyncService* sync_service); + syncer::SyncService* sync_service); // Clears the opt-in to using account storage for passwords for the // current signed-in user (unconsented primary account), as well as all other // associated settings (e.g. default store choice). +// WARNING: this does not clear the account key from prefs like +// KeepAccountStorageSettingsOnlyForUsers(). // |pref_service| and |sync_service| must not be null. // See PasswordFeatureManager::OptOutOfAccountStorageAndClearSettings. -void OptOutOfAccountStorageAndClearSettings( - PrefService* pref_service, - const syncer::SyncService* sync_service); +void OptOutOfAccountStorageAndClearSettings(PrefService* pref_service, + syncer::SyncService* sync_service); // Sets the default storage location for signed-in but non-syncing users. This // store is used for saving new credentials and adding blacking listing entries. @@ -178,8 +181,8 @@ PasswordForm::Store default_store); // Clears all account-storage-related settings for all users *except* the ones -// in the passed-in |gaia_ids|. Most notably, this includes the opt-in, but also -// all other related settings like the default password store. +// in the passed-in |gaia_ids|. Most notably, the default password store. +// WARNING: this does not clear the opt-in! // |pref_service| must not be null. void KeepAccountStorageSettingsOnlyForUsers( PrefService* pref_service, @@ -201,6 +204,11 @@ int GetMoveOfferedToNonOptedInUserCount( const PrefService* pref_service, const syncer::SyncService* sync_service); + +// Migrates the old password_manager account storage opt-in pref to +// SyncUserSettings::GetSelectedTypes(), see crbug.com/1484531. +// TODO(crbug.com/1503112): Delete the migration when appropriate, see bug. +void MigrateOptInPrefToSyncSelectedTypes(PrefService* pref_service); #endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) } // namespace password_manager::features_util
diff --git a/components/password_manager/core/browser/features/password_manager_features_util_common.cc b/components/password_manager/core/browser/features/password_manager_features_util_common.cc index ad4a1ed..7256f32 100644 --- a/components/password_manager/core/browser/features/password_manager_features_util_common.cc +++ b/components/password_manager/core/browser/features/password_manager_features_util_common.cc
@@ -76,6 +76,42 @@ } // namespace internal +bool IsOptedInForAccountStorage(const PrefService* pref_service, + const syncer::SyncService* sync_service) { + DCHECK(pref_service); + + if (!internal::IsUserEligibleForAccountStorage(sync_service)) { + return false; + } + + if (!sync_service->GetUserSettings()->GetSelectedTypes().Has( + syncer::UserSelectableType::kPasswords)) { + return false; + } + +// TODO(crbug.com/1430075): Enable the checks below on Desktop too. +#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID) + // From this point on, we want to check for encryption errors, which we can + // only do when the engine is initialized. In that meantime, we give it the + // benefit of the doubt and say the user is opted in. + if (!sync_service->IsEngineInitialized()) { + return true; + } + + // Encryption errors mean the account store can't upload data, which is bad. + // Worse: in some cases sign-out might not clear the store. If another user + // signs in later, the leftover data might end up in their account, see + // crbug.com/1426774. + // TODO(crbug.com/1428598): Hook this code to IsTrackingMetadata(). + if (sync_service->GetUserSettings()->IsPassphraseRequired() || + sync_service->GetUserSettings()->IsTrustedVaultKeyRequired()) { + return false; + } +#endif + + return true; +} + bool ShouldShowAccountStorageBubbleUi(const PrefService* pref_service, const syncer::SyncService* sync_service) { // Opted in implies eligible, so that case is covered here too.
diff --git a/components/password_manager/core/browser/features/password_manager_features_util_desktop.cc b/components/password_manager/core/browser/features/password_manager_features_util_desktop.cc index 7b8a71f..d70aab4 100644 --- a/components/password_manager/core/browser/features/password_manager_features_util_desktop.cc +++ b/components/password_manager/core/browser/features/password_manager_features_util_desktop.cc
@@ -16,7 +16,10 @@ #include "components/prefs/scoped_user_pref_update.h" #include "components/signin/public/base/gaia_id_hash.h" #include "components/signin/public/identity_manager/account_info.h" +#include "components/sync/base/pref_names.h" +#include "components/sync/base/user_selectable_type.h" #include "components/sync/service/sync_service.h" +#include "components/sync/service/sync_user_settings.h" #include "google_apis/gaia/gaia_auth_util.h" using signin::GaiaIdHash; @@ -35,27 +38,10 @@ return PasswordForm::Store::kNotSet; } -const char kAccountStorageOptedInKey[] = "opted_in"; const char kAccountStorageDefaultStoreKey[] = "default_store"; const char kMoveToAccountStoreOfferedCountKey[] = "move_to_account_store_refused_count"; -// Returns the total number of accounts for which an opt-in to the account -// storage exists. Used for metrics. -int GetNumberOfOptedInAccounts(const PrefService* pref_service) { - const base::Value::Dict& global_pref = - pref_service->GetDict(prefs::kAccountStoragePerAccountSettings); - int count = 0; - for (auto entry : global_pref) { - if (entry.second.GetDict() - .FindBool(kAccountStorageOptedInKey) - .value_or(false)) { - ++count; - } - } - return count; -} - // Helper class for reading account storage settings for a given account. class AccountStorageSettingsReader { public: @@ -66,19 +52,11 @@ account_settings_ = global_pref.FindDict(gaia_id_hash.ToBase64()); } - bool IsOptedIn() { - if (!account_settings_) { - return false; - } - return account_settings_->FindBool(kAccountStorageOptedInKey) - .value_or(false); - } - PasswordForm::Store GetDefaultStore() const { if (!account_settings_) { return PasswordForm::Store::kNotSet; } - absl::optional<int> value = + std::optional<int> value = account_settings_->FindInt(kAccountStorageDefaultStoreKey); if (!value) { return PasswordForm::Store::kNotSet; @@ -113,11 +91,9 @@ return update_->EnsureDict(account_hash_); } - void SetOptedIn() { + void ResetMoveToAccountStoreOfferedCount() { base::Value::Dict* account_settings = GetOrCreateAccountSettings(); - // The count of refusals is only tracked when the user is not opted-in. account_settings->Remove(kMoveToAccountStoreOfferedCountKey); - account_settings->Set(kAccountStorageOptedInKey, true); } void SetDefaultStore(PasswordForm::Store default_store) { @@ -142,25 +118,6 @@ } // namespace -bool IsOptedInForAccountStorage(const PrefService* pref_service, - const syncer::SyncService* sync_service) { - DCHECK(pref_service); - - if (!internal::IsUserEligibleForAccountStorage(sync_service)) { - return false; - } - - // If there's no signed-in account, there can be no opt-in. - std::string gaia_id = sync_service->GetAccountInfo().gaia; - if (gaia_id.empty()) { - return false; - } - - return AccountStorageSettingsReader(pref_service, - GaiaIdHash::FromGaiaId(gaia_id)) - .IsOptedIn(); -} - bool ShouldShowAccountStorageOptIn(const PrefService* pref_service, const syncer::SyncService* sync_service) { DCHECK(pref_service); @@ -194,13 +151,8 @@ // Show the opt-in if any known previous user opted into using the account // storage before and might want to access it again. - return base::ranges::any_of( - pref_service->GetDict(prefs::kAccountStoragePerAccountSettings), - [](const std::pair<std::string, const base::Value&>& p) { - return p.second.GetDict() - .FindBool(kAccountStorageOptedInKey) - .value_or(false); - }); + return sync_service->GetUserSettings() + ->GetNumberOfAccountsWithPasswordsSelected() > 0; } PasswordForm::Store GetDefaultPasswordStore( @@ -258,7 +210,7 @@ } void OptInToAccountStorage(PrefService* pref_service, - const syncer::SyncService* sync_service) { + syncer::SyncService* sync_service) { DCHECK(pref_service); DCHECK(sync_service); DCHECK( @@ -270,19 +222,27 @@ // rare, but is ultimately harmless - just do nothing here. return; } + if (sync_service->IsSyncFeatureEnabled()) { + // Same as above, maybe the user enabled sync since the UI was shown. This + // should be rare, but is ultimately harmless - just do nothing here. + return; + } + syncer::SyncUserSettings* sync_user_settings = + sync_service->GetUserSettings(); + sync_user_settings->SetSelectedType(syncer::UserSelectableType::kPasswords, + /*is_type_on=*/true); ScopedAccountStorageSettingsUpdate(pref_service, GaiaIdHash::FromGaiaId(gaia_id)) - .SetOptedIn(); + .ResetMoveToAccountStoreOfferedCount(); // Record the total number of (now) opted-in accounts. base::UmaHistogramExactLinear( "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptIn", - GetNumberOfOptedInAccounts(pref_service), 10); + sync_user_settings->GetNumberOfAccountsWithPasswordsSelected(), 10); } -void OptOutOfAccountStorageAndClearSettings( - PrefService* pref_service, - const syncer::SyncService* sync_service) { +void OptOutOfAccountStorageAndClearSettings(PrefService* pref_service, + syncer::SyncService* sync_service) { DCHECK(pref_service); DCHECK(sync_service); DCHECK( @@ -295,6 +255,12 @@ return; } + // Note SyncUserSettings::SetSelectedType() won't clear the gaia id hash + // but that's not required here. + syncer::SyncUserSettings* sync_user_settings = + sync_service->GetUserSettings(); + sync_user_settings->SetSelectedType(syncer::UserSelectableType::kPasswords, + false); ScopedAccountStorageSettingsUpdate(pref_service, GaiaIdHash::FromGaiaId(gaia_id)) .ClearAllSettings(); @@ -302,7 +268,7 @@ // Record the total number of (still) opted-in accounts. base::UmaHistogramExactLinear( "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptOut", - GetNumberOfOptedInAccounts(pref_service), 10); + sync_user_settings->GetNumberOfAccountsWithPasswordsSelected(), 10); } void SetDefaultPasswordStore(PrefService* pref_service, @@ -362,9 +328,7 @@ DCHECK(sync_service); std::string gaia_id = sync_service->GetAccountInfo().gaia; DCHECK(!gaia_id.empty()); - DCHECK(!AccountStorageSettingsReader(pref_service, - GaiaIdHash::FromGaiaId(gaia_id)) - .IsOptedIn()); + DCHECK(!IsOptedInForAccountStorage(pref_service, sync_service)); ScopedAccountStorageSettingsUpdate(pref_service, GaiaIdHash::FromGaiaId(gaia_id)) .RecordMoveOfferedToNonOptedInUser(); @@ -377,12 +341,38 @@ DCHECK(sync_service); std::string gaia_id = sync_service->GetAccountInfo().gaia; DCHECK(!gaia_id.empty()); + DCHECK(!IsOptedInForAccountStorage(pref_service, sync_service)); AccountStorageSettingsReader reader(pref_service, GaiaIdHash::FromGaiaId(gaia_id)); - DCHECK(!reader.IsOptedIn()); return reader.GetMoveOfferedToNonOptedInUserCount(); } +void MigrateOptInPrefToSyncSelectedTypes(PrefService* pref_service) { + const char kLegacyAccountStorageOptedInKey[] = "opted_in"; + + ScopedDictPrefUpdate legacy_pref_update( + pref_service, prefs::kAccountStoragePerAccountSettings); + ScopedDictPrefUpdate new_pref_update( + pref_service, syncer::prefs::internal::kSelectedTypesPerAccount); + for (auto [serialized_gaia_id_hash, settings] : *legacy_pref_update) { + // `settings` should be a dict but check to avoid a possible startup crash. + if (!settings.is_dict()) { + continue; + } + if (settings.GetDict() + .FindBool(kLegacyAccountStorageOptedInKey) + .value_or(false)) { + // Sync doesn't expose an API to set selected types for an arbitrary + // account, so manipulate the underlying prefs directly. The serialization + // for the gaia id hash is indeed the same, unit tests verify that by + // invoking GetSelectedTypes() after the migration. + new_pref_update->EnsureDict(serialized_gaia_id_hash) + ->Set(syncer::prefs::internal::kSyncPasswords, true); + } + settings.GetDict().Remove(kLegacyAccountStorageOptedInKey); + } +} + // Note: See also password_manager_features_util_common.cc for shared // (cross-platform) and password_manager_features_util_mobile.cc for // mobile-specific implementations.
diff --git a/components/password_manager/core/browser/features/password_manager_features_util_mobile.cc b/components/password_manager/core/browser/features/password_manager_features_util_mobile.cc index 1f3b2aed..7b1f425 100644 --- a/components/password_manager/core/browser/features/password_manager_features_util_mobile.cc +++ b/components/password_manager/core/browser/features/password_manager_features_util_mobile.cc
@@ -12,41 +12,6 @@ namespace password_manager::features_util { -bool IsOptedInForAccountStorage(const PrefService* pref_service, - const syncer::SyncService* sync_service) { - DCHECK(pref_service); - - if (!internal::IsUserEligibleForAccountStorage(sync_service)) { - return false; - } - - // On Android and iOS, there is no explicit opt-in - this is handled through - // Sync's selected data types instead. - if (!sync_service->GetUserSettings()->GetSelectedTypes().Has( - syncer::UserSelectableType::kPasswords)) { - return false; - } - - // From this point on, we want to check for encryption errors, which we can - // only do when the engine is initialized. In that meantime, we give it the - // benefit of the doubt and say the user is opted in. - if (!sync_service->IsEngineInitialized()) { - return true; - } - - // Encryption errors mean the account store can't upload data, which is bad. - // Worse: in some cases sign-out might not clear the store. If another user - // signs in later, the leftover data might end up in their account, see - // crbug.com/1426774. - // TODO(crbug.com/1426774): Hook this code to IsTrackingMetadata(). - if (sync_service->GetUserSettings()->IsPassphraseRequired() || - sync_service->GetUserSettings()->IsTrustedVaultKeyRequired()) { - return false; - } - - return true; -} - bool ShouldShowAccountStorageOptIn(const PrefService* pref_service, const syncer::SyncService* sync_service) { return false;
diff --git a/components/password_manager/core/browser/features/password_manager_features_util_unittest.cc b/components/password_manager/core/browser/features/password_manager_features_util_unittest.cc index f2224c3..66bb52b 100644 --- a/components/password_manager/core/browser/features/password_manager_features_util_unittest.cc +++ b/components/password_manager/core/browser/features/password_manager_features_util_unittest.cc
@@ -13,23 +13,11 @@ #include "components/prefs/pref_registry_simple.h" #include "components/prefs/testing_pref_service.h" #include "components/signin/public/identity_manager/account_info.h" +#include "components/sync/service/sync_prefs.h" #include "components/sync/test/test_sync_service.h" #include "testing/gtest/include/gtest/gtest.h" namespace password_manager::features_util { -namespace { - -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) -base::Value::Dict CreateOptedInAccountPref() { - base::Value::Dict global_pref; - base::Value::Dict account_pref; - account_pref.Set("opted_in", true); - global_pref.Set("some_gaia_hash", std::move(account_pref)); - return global_pref; -} -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - -} // namespace class PasswordManagerFeaturesUtilTestBase { public: @@ -37,6 +25,11 @@ #if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) pref_service_.registry()->RegisterDictionaryPref( prefs::kAccountStoragePerAccountSettings); + + // Passwords starts enabled default in TestSyncUserSettings, so disable it + // to mimic production behavior. + sync_service_.GetUserSettings()->SetSelectedType( + syncer::UserSelectableType::kPasswords, false); #endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) } @@ -104,10 +97,10 @@ }; TEST_F(PasswordManagerFeaturesUtilWithoutAccountStorageTest, - AccountStoragePerAccountSettings) { + AccountStorageOptIn) { CoreAccountInfo account; - account.email = "first@account.com"; - account.gaia = "first"; + account.email = "foo@account.com"; + account.gaia = "foo"; account.account_id = CoreAccountId::FromGaiaId(account.gaia); // SyncService is running in transport mode with |account|. @@ -127,108 +120,12 @@ PasswordForm::Store::kProfileStore); } -TEST_F(PasswordManagerFeaturesUtilTest, ShowAccountStorageResignIn) { #if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - // Add an account to prefs which opted into using the account-storage. - pref_service_.SetDict(prefs::kAccountStoragePerAccountSettings, - CreateOptedInAccountPref()); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - - // SyncService is not running (because no user is signed-in). - SetSyncStateNotSignedIn(); - -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - EXPECT_TRUE( - ShouldShowAccountStorageReSignin(&pref_service_, &sync_service_, GURL())); -#else - // The re-signin doesn't exist on mobile. - EXPECT_FALSE( - ShouldShowAccountStorageReSignin(&pref_service_, &sync_service_, GURL())); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) -} - -TEST_F(PasswordManagerFeaturesUtilWithoutAccountStorageTest, - ShowAccountStorageReSignin) { -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - // Add an account to prefs which opted into using the account-storage. - pref_service_.SetDict(prefs::kAccountStoragePerAccountSettings, - CreateOptedInAccountPref()); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - - // SyncService is not running (because no user is signed-in). - SetSyncStateNotSignedIn(); - - EXPECT_FALSE( - ShouldShowAccountStorageReSignin(&pref_service_, &sync_service_, GURL())); -} - -TEST_F(PasswordManagerFeaturesUtilTest, - DontShowAccountStorageResignIn_SyncActive) { -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - // Add an account to prefs which opted into using the account-storage. - pref_service_.SetDict(prefs::kAccountStoragePerAccountSettings, - CreateOptedInAccountPref()); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - - // SyncService is running (for a different signed-in user). +TEST_F(PasswordManagerFeaturesUtilTest, AccountStorageOptIn) { CoreAccountInfo account; - account.email = "name@account.com"; - account.gaia = "name"; + account.email = "foo@account.com"; + account.gaia = "foo"; account.account_id = CoreAccountId::FromGaiaId(account.gaia); - SetSyncStateTransportActive(account); - - EXPECT_FALSE( - ShouldShowAccountStorageReSignin(&pref_service_, &sync_service_, GURL())); -} - -TEST_F(PasswordManagerFeaturesUtilTest, - DontShowAccountStorageResignIn_NoPrefs) { - // Pref is not set for any account. - - // SyncService is not running (because no user is signed-in). - SetSyncStateNotSignedIn(); - - EXPECT_FALSE( - ShouldShowAccountStorageReSignin(&pref_service_, &sync_service_, GURL())); -} - -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) -TEST_F(PasswordManagerFeaturesUtilTest, - DontShowAccountStorageResignIn_GaiaUrl) { - // Add an account to prefs which opted into using the account-storage. - pref_service_.SetDict(prefs::kAccountStoragePerAccountSettings, - CreateOptedInAccountPref()); - - // SyncService is not running (because no user is signed-in). - SetSyncStateNotSignedIn(); - - // The re-signin promo should show up in contexts without a URL (e.g. native - // UI). - EXPECT_TRUE( - ShouldShowAccountStorageReSignin(&pref_service_, &sync_service_, GURL())); - // The re-signin promo should show up on all regular pages. - EXPECT_TRUE(ShouldShowAccountStorageReSignin(&pref_service_, &sync_service_, - GURL("http://www.example.com"))); - EXPECT_TRUE(ShouldShowAccountStorageReSignin( - &pref_service_, &sync_service_, GURL("https://www.example.com"))); - // The re-signin promo should NOT show up on Google sign-in pages. - EXPECT_FALSE(ShouldShowAccountStorageReSignin( - &pref_service_, &sync_service_, GURL("https://accounts.google.com"))); - EXPECT_FALSE(ShouldShowAccountStorageReSignin( - &pref_service_, &sync_service_, - GURL("https://accounts.google.com/some/path"))); -} - -TEST_F(PasswordManagerFeaturesUtilTest, AccountStoragePerAccountSettings) { - CoreAccountInfo first_account; - first_account.email = "first@account.com"; - first_account.gaia = "first"; - first_account.account_id = CoreAccountId::FromGaiaId(first_account.gaia); - - CoreAccountInfo second_account; - second_account.email = "second@account.com"; - second_account.gaia = "second"; - second_account.account_id = CoreAccountId::FromGaiaId(second_account.gaia); SetSyncStateNotSignedIn(); @@ -240,8 +137,8 @@ EXPECT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), PasswordForm::Store::kProfileStore); - // Now let SyncService run in transport mode with |first_account|. - SetSyncStateTransportActive(first_account); + // Now let SyncService run in transport mode with |account|. + SetSyncStateTransportActive(account); // By default, the user is not opted in, but eligible. EXPECT_FALSE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); @@ -266,22 +163,6 @@ EXPECT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), PasswordForm::Store::kProfileStore); - // Change to |second_account|. The opt-in for |first_account|, and its store - // choice, should not apply. - SetSyncStateTransportActive(second_account); - EXPECT_FALSE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); - EXPECT_TRUE(ShouldShowAccountStorageOptIn(&pref_service_, &sync_service_)); - EXPECT_FALSE(IsDefaultPasswordStoreSet(&pref_service_, &sync_service_)); - - // Change back to |first_account|. The previous opt-in and chosen default - // store should now apply again. - SetSyncStateTransportActive(first_account); - EXPECT_TRUE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); - EXPECT_FALSE(ShouldShowAccountStorageOptIn(&pref_service_, &sync_service_)); - EXPECT_TRUE(IsDefaultPasswordStoreSet(&pref_service_, &sync_service_)); - EXPECT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), - PasswordForm::Store::kProfileStore); - // Sign out. Now the settings should have reasonable default values (not opted // in, save to profile store). SetSyncStateNotSignedIn(); @@ -304,30 +185,40 @@ second_account.gaia = "second"; second_account.account_id = CoreAccountId::FromGaiaId(second_account.gaia); - // Let SyncService run in transport mode with |first_account| and opt in. + // Let SyncService run in transport mode with |first_account|, opt in and + // set the profile store as default. SetSyncStateTransportActive(first_account); OptInToAccountStorage(&pref_service_, &sync_service_); - ASSERT_TRUE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); + SetDefaultPasswordStore(&pref_service_, &sync_service_, + PasswordForm::Store::kProfileStore); + ASSERT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), + PasswordForm::Store::kProfileStore); - // Switch to |second_account| and again opt in. + // Switch to |second_account| and do the same. SetSyncStateTransportActive(second_account); OptInToAccountStorage(&pref_service_, &sync_service_); - ASSERT_TRUE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); + SetDefaultPasswordStore(&pref_service_, &sync_service_, + PasswordForm::Store::kProfileStore); + ASSERT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), + PasswordForm::Store::kProfileStore); - // Sign out. The opt-in still exists, but doesn't apply anymore. + // Sign out. The store settings still exist, but don't apply anymore. SetSyncStateNotSignedIn(); ASSERT_FALSE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); - // Keep the opt-in only for |first_account| (and some unknown other user). + // Keep the settings only for |first_account| (and some unknown other user). KeepAccountStorageSettingsOnlyForUsers(&pref_service_, {first_account.gaia, "other_gaia_id"}); - // The first account should still be opted in, but not the second. + // The first account should still have kProfileStore as the default store, + // but not the second. SetSyncStateTransportActive(first_account); - EXPECT_TRUE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); + EXPECT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), + PasswordForm::Store::kProfileStore); SetSyncStateTransportActive(second_account); - EXPECT_FALSE(IsOptedInForAccountStorage(&pref_service_, &sync_service_)); + EXPECT_NE(GetDefaultPasswordStore(&pref_service_, &sync_service_), + PasswordForm::Store::kProfileStore); } TEST_F(PasswordManagerFeaturesUtilTest, SyncSuppressesAccountStorageOptIn) { @@ -500,57 +391,6 @@ PasswordForm::Store::kProfileStore, 1); } -TEST_F(PasswordManagerFeaturesUtilTest, OptInOutHistograms) { - base::HistogramTester histogram_tester; - - CoreAccountInfo first_account; - first_account.email = "first@account.com"; - first_account.gaia = "first"; - first_account.account_id = CoreAccountId::FromGaiaId(first_account.gaia); - - CoreAccountInfo second_account; - second_account.email = "second@account.com"; - second_account.gaia = "second"; - second_account.account_id = CoreAccountId::FromGaiaId(second_account.gaia); - - // Opt in with the first account. - SetSyncStateTransportActive(first_account); - OptInToAccountStorage(&pref_service_, &sync_service_); - // There is now 1 opt-in. - histogram_tester.ExpectTotalCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptIn", 1); - histogram_tester.ExpectBucketCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptIn", 1, 1); - - // Opt in with the second account. - SetSyncStateTransportActive(second_account); - OptInToAccountStorage(&pref_service_, &sync_service_); - // There are now 2 opt-ins. - histogram_tester.ExpectTotalCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptIn", 2); - histogram_tester.ExpectBucketCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptIn", 2, 1); - - // Out out of the second account again. - OptOutOfAccountStorageAndClearSettings(&pref_service_, &sync_service_); - // The OptedIn histogram is unchanged. - histogram_tester.ExpectTotalCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptIn", 2); - // There is now an OptedOut sample; there is 1 opt-in left. - histogram_tester.ExpectTotalCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptOut", 1); - histogram_tester.ExpectBucketCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptOut", 1, 1); - - // Clear all remaining opt-ins (which is just one). - KeepAccountStorageSettingsOnlyForUsers(&pref_service_, {}); - // The OptedIn/OptedOut histograms are unchanged. - histogram_tester.ExpectTotalCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptIn", 2); - histogram_tester.ExpectTotalCount( - "PasswordManager.AccountStorage.NumOptedInAccountsAfterOptOut", 1); -} - TEST_F(PasswordManagerFeaturesUtilTest, MovePasswordToAccountStoreOfferedCount) { // Set up a user signed-in, not syncing and not opted-in. @@ -570,6 +410,49 @@ EXPECT_EQ( 2, GetMoveOfferedToNonOptedInUserCount(&pref_service_, &sync_service_)); } + +TEST_F(PasswordManagerFeaturesUtilTest, MigrateOptInPrefToSyncSelectedTypes) { + syncer::SyncPrefs::RegisterProfilePrefs(pref_service_.registry()); + CoreAccountInfo account1; + account1.gaia = "gaia1"; + auto gaia1_hash = signin::GaiaIdHash::FromGaiaId(account1.gaia); + CoreAccountInfo account2; + account2.gaia = "gaia2"; + auto gaia2_hash = signin::GaiaIdHash::FromGaiaId(account2.gaia); + pref_service_.SetDict( + prefs::kAccountStoragePerAccountSettings, + base::Value::Dict() + .Set(gaia1_hash.ToBase64(), + base::Value::Dict() + .Set("opted_in", true) + .Set("default_store", + static_cast<int>(PasswordForm::Store::kAccountStore))) + .Set(gaia2_hash.ToBase64(), + base::Value::Dict() + .Set("opted_in", true) + .Set("default_store", + static_cast<int>(PasswordForm::Store::kProfileStore)))); + + MigrateOptInPrefToSyncSelectedTypes(&pref_service_); + + syncer::SyncPrefs sync_prefs(&pref_service_); + EXPECT_TRUE(sync_prefs.GetSelectedTypesForAccount(gaia1_hash) + .Has(syncer::UserSelectableType::kPasswords)); + EXPECT_TRUE(sync_prefs.GetSelectedTypesForAccount(gaia2_hash) + .Has(syncer::UserSelectableType::kPasswords)); + EXPECT_FALSE( + sync_prefs + .GetSelectedTypesForAccount(signin::GaiaIdHash::FromGaiaId("other")) + .Has(syncer::UserSelectableType::kPasswords)); + + // Verify the default store settings are unnaffected. + SetSyncStateTransportActive(account1); + EXPECT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), + PasswordForm::Store::kAccountStore); + SetSyncStateTransportActive(account2); + EXPECT_EQ(GetDefaultPasswordStore(&pref_service_, &sync_service_), + PasswordForm::Store::kProfileStore); +} #endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) } // namespace password_manager::features_util
diff --git a/components/password_manager/core/browser/field_info_manager.cc b/components/password_manager/core/browser/field_info_manager.cc index 7811aa8..84b1539 100644 --- a/components/password_manager/core/browser/field_info_manager.cc +++ b/components/password_manager/core/browser/field_info_manager.cc
@@ -61,7 +61,7 @@ void FieldInfoManager::AddFieldInfo( const FieldInfo& new_info, - const absl::optional<FormPredictions>& predictions) { + const std::optional<FormPredictions>& predictions) { if (!field_info_cache_.empty() && IsSameField(field_info_cache_.back().field_info, new_info)) { // The method can be called on every keystroke while the user modifies
diff --git a/components/password_manager/core/browser/field_info_manager.h b/components/password_manager/core/browser/field_info_manager.h index cf84bd9..5721460b 100644 --- a/components/password_manager/core/browser/field_info_manager.h +++ b/components/password_manager/core/browser/field_info_manager.h
@@ -46,7 +46,7 @@ autofill::ServerFieldType type = autofill::ServerFieldType::UNKNOWN_TYPE; // Predictions for the form containing the field. - absl::optional<FormPredictions> stored_predictions; + std::optional<FormPredictions> stored_predictions; FieldInfo(int driver_id, autofill::FieldRendererId field_id, @@ -70,7 +70,7 @@ // Caches |info|. void AddFieldInfo(const FieldInfo& new_info, - const absl::optional<FormPredictions>& predictions); + const std::optional<FormPredictions>& predictions); // Retrieves field info for the given |signon_realm|. std::vector<FieldInfo> GetFieldInfo(const std::string& signon_realm);
diff --git a/components/password_manager/core/browser/field_info_manager_unittest.cc b/components/password_manager/core/browser/field_info_manager_unittest.cc index 77a2555f4..6114ab0 100644 --- a/components/password_manager/core/browser/field_info_manager_unittest.cc +++ b/components/password_manager/core/browser/field_info_manager_unittest.cc
@@ -71,7 +71,7 @@ TEST_F(FieldInfoManagerTest, InfoAddedRetrievedAndExpired) { FieldInfo info(kTestDriverId, kTestFieldId, kTestDomain, u"value", /*is_likely_otp=*/false); - manager_->AddFieldInfo(info, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info, /*predictions=*/std::nullopt); std::vector<FieldInfo> expected_info = {info}; EXPECT_EQ(manager_->GetFieldInfo(kTestDomain), expected_info); EXPECT_TRUE(manager_->GetFieldInfo(kAnotherDomain).empty()); @@ -88,10 +88,10 @@ TEST_F(FieldInfoManagerTest, InfoOverwrittenWithNewField) { FieldInfo info1(kTestDriverId, FieldRendererId(1), kTestDomain, u"value1", /*is_likely_otp=*/false); - manager_->AddFieldInfo(info1, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info1, /*predictions=*/std::nullopt); FieldInfo info2(kTestDriverId, FieldRendererId(2), kTestDomain, u"value2", /*is_likely_otp=*/false); - manager_->AddFieldInfo(info2, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info2, /*predictions=*/std::nullopt); std::vector<FieldInfo> expected_info = {info1, info2}; EXPECT_EQ(manager_->GetFieldInfo(kTestDomain), expected_info); @@ -99,7 +99,7 @@ // The third info should dismiss the first one. FieldInfo info3(kTestDriverId, FieldRendererId(3), kTestDomain, u"value3", /*is_likely_otp=*/false); - manager_->AddFieldInfo(info3, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info3, /*predictions=*/std::nullopt); expected_info = {info2, info3}; EXPECT_EQ(manager_->GetFieldInfo(kTestDomain), expected_info); @@ -108,12 +108,12 @@ TEST_F(FieldInfoManagerTest, InfoUpdatedWithNewValue) { FieldInfo info1(kTestDriverId, kTestFieldId, kTestDomain, u"value", /*is_likely_otp=*/false); - manager_->AddFieldInfo(info1, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info1, /*predictions=*/std::nullopt); // The value should not be stored twice for the same field. FieldInfo info2 = info1; info2.value = u"new_value"; - manager_->AddFieldInfo(info2, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info2, /*predictions=*/std::nullopt); std::vector<FieldInfo> expected_info = {info2}; EXPECT_EQ(manager_->GetFieldInfo(kTestDomain), expected_info); @@ -144,7 +144,7 @@ TEST_F(FieldInfoManagerTest, ProcessServerPredictions) { FieldInfo info(kTestDriverId, kTestFieldId, kTestDomain, u"value", /*is_likely_otp=*/false); - manager_->AddFieldInfo(info, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info, /*predictions=*/std::nullopt); // Create test predictions. std::map<autofill::FormSignature, FormPredictions> predictions; @@ -179,7 +179,7 @@ FieldInfo info(kTestDriverId, kTestFieldId, "https://main.domain.com", u"value", /*is_likely_otp=*/false); - manager_->AddFieldInfo(info, /*predictions=*/absl::nullopt); + manager_->AddFieldInfo(info, /*predictions=*/std::nullopt); std::vector<FieldInfo> expected_info = {info}; EXPECT_EQ(manager_->GetFieldInfo("https://psl.domain.com"), expected_info); }
diff --git a/components/password_manager/core/browser/form_fetcher.h b/components/password_manager/core/browser/form_fetcher.h index 2509855c..aba5c53 100644 --- a/components/password_manager/core/browser/form_fetcher.h +++ b/components/password_manager/core/browser/form_fetcher.h
@@ -110,8 +110,8 @@ // Returns an error if it occurred during login retrieval from the // profile store. - virtual absl::optional<PasswordStoreBackendError> - GetProfileStoreBackendError() const = 0; + virtual std::optional<PasswordStoreBackendError> GetProfileStoreBackendError() + const = 0; }; } // namespace password_manager
diff --git a/components/password_manager/core/browser/form_fetcher_impl.cc b/components/password_manager/core/browser/form_fetcher_impl.cc index 49d76bc..b86e2155 100644 --- a/components/password_manager/core/browser/form_fetcher_impl.cc +++ b/components/password_manager/core/browser/form_fetcher_impl.cc
@@ -251,7 +251,7 @@ return result; } -absl::optional<PasswordStoreBackendError> +std::optional<PasswordStoreBackendError> FormFetcherImpl::GetProfileStoreBackendError() const { return profile_store_backend_error_; }
diff --git a/components/password_manager/core/browser/form_fetcher_impl.h b/components/password_manager/core/browser/form_fetcher_impl.h index b39c2a5..7f339ceb 100644 --- a/components/password_manager/core/browser/form_fetcher_impl.h +++ b/components/password_manager/core/browser/form_fetcher_impl.h
@@ -59,7 +59,7 @@ const std::vector<const PasswordForm*>& GetBestMatches() const override; const PasswordForm* GetPreferredMatch() const override; std::unique_ptr<FormFetcher> Clone() override; - absl::optional<PasswordStoreBackendError> GetProfileStoreBackendError() + std::optional<PasswordStoreBackendError> GetProfileStoreBackendError() const override; protected: @@ -147,7 +147,7 @@ // Holds an error if it occurred during login retrieval from the // PasswordStore. - absl::optional<PasswordStoreBackendError> profile_store_backend_error_; + std::optional<PasswordStoreBackendError> profile_store_backend_error_; base::WeakPtrFactory<FormFetcherImpl> weak_ptr_factory_{this}; };
diff --git a/components/password_manager/core/browser/form_fetcher_impl_unittest.cc b/components/password_manager/core/browser/form_fetcher_impl_unittest.cc index eed4041f..2561b2fb 100644 --- a/components/password_manager/core/browser/form_fetcher_impl_unittest.cc +++ b/components/password_manager/core/browser/form_fetcher_impl_unittest.cc
@@ -1251,7 +1251,7 @@ } TEST_P(FormFetcherImplTest, BackendErrorResetsOnNewFetch) { - ASSERT_EQ(form_fetcher_->GetProfileStoreBackendError(), absl::nullopt); + ASSERT_EQ(form_fetcher_->GetProfileStoreBackendError(), std::nullopt); Fetch(); @@ -1276,7 +1276,7 @@ DeliverPasswordStoreResults(/*profile_store_results=*/std::move(form_results), /*account_store_results=*/{}); - EXPECT_EQ(form_fetcher_->GetProfileStoreBackendError(), absl::nullopt); + EXPECT_EQ(form_fetcher_->GetProfileStoreBackendError(), std::nullopt); } } // namespace password_manager
diff --git a/components/password_manager/core/browser/form_parsing/form_data_parser.cc b/components/password_manager/core/browser/form_parsing/form_data_parser.cc index 0b86c7b..d16b1a3f 100644 --- a/components/password_manager/core/browser/form_parsing/form_data_parser.cc +++ b/components/password_manager/core/browser/form_parsing/form_data_parser.cc
@@ -1000,7 +1000,7 @@ // |form_predictions| has |may_use_prefilled_placeholder| == true for the // username field. bool GetMayUsePrefilledPlaceholder( - const absl::optional<FormPredictions>& form_predictions, + const std::optional<FormPredictions>& form_predictions, const SignificantFields& significant_fields) { if (!form_predictions || !significant_fields.username) return false; @@ -1027,7 +1027,7 @@ const SignificantFields& significant_fields, AlternativeElementVector all_alternative_passwords, AlternativeElementVector all_alternative_usernames, - const absl::optional<FormPredictions>& form_predictions) { + const std::optional<FormPredictions>& form_predictions) { if (!significant_fields.HasPasswords() && !significant_fields.is_single_username && !significant_fields.accepts_webauthn_credentials) {
diff --git a/components/password_manager/core/browser/form_parsing/form_data_parser.h b/components/password_manager/core/browser/form_parsing/form_data_parser.h index 4c652c7..e47e88c 100644 --- a/components/password_manager/core/browser/form_parsing/form_data_parser.h +++ b/components/password_manager/core/browser/form_parsing/form_data_parser.h
@@ -6,12 +6,12 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_PARSING_FORM_DATA_PARSER_H_ #include <memory> +#include <optional> #include <utility> #include <vector> #include "base/memory/raw_ptr.h" #include "components/password_manager/core/browser/form_parsing/password_field_prediction.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace autofill { @@ -139,7 +139,7 @@ void reset_predictions() { predictions_.reset(); } - const absl::optional<FormPredictions>& predictions() { return predictions_; } + const std::optional<FormPredictions>& predictions() { return predictions_; } ReadonlyPasswordFields readonly_status() { return readonly_status_; } @@ -164,7 +164,7 @@ private: // Predictions are an optional source of server-side information about field // types. - absl::optional<FormPredictions> predictions_; + std::optional<FormPredictions> predictions_; // Records whether readonly password fields were seen during the last call to // Parse().
diff --git a/components/password_manager/core/browser/form_parsing/form_data_parser_unittest.cc b/components/password_manager/core/browser/form_parsing/form_data_parser_unittest.cc index 5d09bff..484c1cca 100644 --- a/components/password_manager/core/browser/form_parsing/form_data_parser_unittest.cc +++ b/components/password_manager/core/browser/form_parsing/form_data_parser_unittest.cc
@@ -7,6 +7,7 @@ #include <stddef.h> +#include <optional> #include <set> #include <string> #include <utility> @@ -26,7 +27,6 @@ #include "components/password_manager/core/common/password_manager_features.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" using autofill::FieldPropertiesFlags; @@ -98,15 +98,15 @@ raw_ptr<const AlternativeElementVector> all_alternative_usernames = nullptr; bool server_side_classification_successful = true; bool username_may_use_prefilled_placeholder = false; - absl::optional<FormDataParser::ReadonlyPasswordFields> readonly_status; - absl::optional<FormDataParser::ReadonlyPasswordFields> + std::optional<FormDataParser::ReadonlyPasswordFields> readonly_status; + std::optional<FormDataParser::ReadonlyPasswordFields> readonly_status_for_saving; - absl::optional<FormDataParser::ReadonlyPasswordFields> + std::optional<FormDataParser::ReadonlyPasswordFields> readonly_status_for_filling; // If the result should be marked as only useful for fallbacks. bool fallback_only = false; SubmissionIndicatorEvent submission_event = SubmissionIndicatorEvent::NONE; - absl::optional<bool> is_new_password_reliable; + std::optional<bool> is_new_password_reliable; bool form_has_autofilled_value = false; bool accepts_webauthn_credentials = false; }; @@ -435,7 +435,7 @@ if (test_case.readonly_status) { EXPECT_EQ(*test_case.readonly_status, parser.readonly_status()); } else { - const absl::optional<FormDataParser::ReadonlyPasswordFields>* + const std::optional<FormDataParser::ReadonlyPasswordFields>* expected_readonly_status = mode == FormDataParser::Mode::kSaving ? &test_case.readonly_status_for_saving
diff --git a/components/password_manager/core/browser/hash_password_manager.cc b/components/password_manager/core/browser/hash_password_manager.cc index 42bccf3..12b58b8 100644 --- a/components/password_manager/core/browser/hash_password_manager.cc +++ b/components/password_manager/core/browser/hash_password_manager.cc
@@ -98,21 +98,21 @@ } // Helper function to convert a dictionary value to PasswordWordHashData. -absl::optional<PasswordHashData> ConvertToPasswordHashData( +std::optional<PasswordHashData> ConvertToPasswordHashData( const base::Value& dict) { PasswordHashData result; result.username = GetAndDecryptField(dict, kUsernameFieldKey); if (result.username.empty()) - return absl::nullopt; + return std::nullopt; if (!base::StringToUint64(GetAndDecryptField(dict, kHashFieldKey), &result.hash)) { - return absl::nullopt; + return std::nullopt; } if (!StringToLengthAndSalt(GetAndDecryptField(dict, kLengthAndSaltFieldKey), &result.length, &result.salt)) { - return absl::nullopt; + return std::nullopt; } result.is_gaia_password = GetAndDecryptField(dict, kIsGaiaFieldKey) == "true"; @@ -140,7 +140,7 @@ if (AreUsernamesSame( GetAndDecryptField(password_hash_data, kUsernameFieldKey), IsGaiaPassword(password_hash_data), username, is_gaia_password)) { - absl::optional<PasswordHashData> existing_password_hash = + std::optional<PasswordHashData> existing_password_hash = ConvertToPasswordHashData(password_hash_data); if (existing_password_hash && existing_password_hash->MatchesPassword( username, password, is_gaia_password)) { @@ -227,7 +227,7 @@ prefs_->GetList(prefs::kPasswordHashDataList); for (const base::Value& entry : hash_list) { - absl::optional<PasswordHashData> password_hash_data = + std::optional<PasswordHashData> password_hash_data = ConvertToPasswordHashData(entry); if (password_hash_data) result.push_back(std::move(*password_hash_data)); @@ -235,12 +235,12 @@ return result; } -absl::optional<PasswordHashData> HashPasswordManager::RetrievePasswordHash( +std::optional<PasswordHashData> HashPasswordManager::RetrievePasswordHash( const std::string& username, bool is_gaia_password) { if (!prefs_ || username.empty() || !prefs_->HasPrefPath(prefs::kPasswordHashDataList)) { - return absl::nullopt; + return std::nullopt; } for (const base::Value& entry : @@ -251,7 +251,7 @@ } } - return absl::nullopt; + return std::nullopt; } bool HashPasswordManager::HasPasswordHash(const std::string& username,
diff --git a/components/password_manager/core/browser/hash_password_manager.h b/components/password_manager/core/browser/hash_password_manager.h index a93cf292..89704de 100644 --- a/components/password_manager/core/browser/hash_password_manager.h +++ b/components/password_manager/core/browser/hash_password_manager.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_HASH_PASSWORD_MANAGER_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_HASH_PASSWORD_MANAGER_H_ +#include <optional> #include <string> #include <vector> @@ -12,7 +13,6 @@ #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "components/password_manager/core/browser/password_hash_data.h" -#include "third_party/abseil-cpp/absl/types/optional.h" class PrefService; @@ -50,7 +50,7 @@ // Returns empty if no hash matching |username| and |is_gaia_password| is // available. - absl::optional<PasswordHashData> RetrievePasswordHash( + std::optional<PasswordHashData> RetrievePasswordHash( const std::string& username, bool is_gaia_password);
diff --git a/components/password_manager/core/browser/hash_password_manager_unittest.cc b/components/password_manager/core/browser/hash_password_manager_unittest.cc index 181fbc89..4d358169 100644 --- a/components/password_manager/core/browser/hash_password_manager_unittest.cc +++ b/components/password_manager/core/browser/hash_password_manager_unittest.cc
@@ -52,12 +52,12 @@ EXPECT_TRUE(prefs_.HasPrefPath(prefs::kPasswordHashDataList)); // Saves the same password again won't change password hash, length or salt. - absl::optional<PasswordHashData> current_password_hash_data = + std::optional<PasswordHashData> current_password_hash_data = hash_password_manager.RetrievePasswordHash(username, /*is_gaia_password=*/true); hash_password_manager.SavePasswordHash(username, password, /*is_gaia_password=*/true); - absl::optional<PasswordHashData> existing_password_data = + std::optional<PasswordHashData> existing_password_data = hash_password_manager.RetrievePasswordHash(username, /*is_gaia_password=*/true); EXPECT_EQ(current_password_hash_data->hash, existing_password_data->hash); @@ -99,12 +99,12 @@ // Saves the same password with not canonicalized username should not change // password hash. - absl::optional<PasswordHashData> current_password_hash_data = + std::optional<PasswordHashData> current_password_hash_data = hash_password_manager.RetrievePasswordHash(username, /*is_gaia_password=*/true); hash_password_manager.SavePasswordHash(username, password, /*is_gaia_password=*/true); - absl::optional<PasswordHashData> existing_password_data = + std::optional<PasswordHashData> existing_password_data = hash_password_manager.RetrievePasswordHash(username, /*is_gaia_password=*/true); EXPECT_EQ(current_password_hash_data->hash, existing_password_data->hash); @@ -247,7 +247,7 @@ /*is_gaia_password=*/true); EXPECT_EQ(1u, hash_password_manager.RetrieveAllPasswordHashes().size()); - absl::optional<PasswordHashData> password_hash_data = + std::optional<PasswordHashData> password_hash_data = hash_password_manager.RetrievePasswordHash("username@gmail.com", /*is_gaia_password=*/false); ASSERT_FALSE(password_hash_data); @@ -269,7 +269,7 @@ hash_password_manager.RetrievePasswordHash("USER.NAME@gmail.com", /*is_gaia_password=*/true)); - absl::optional<PasswordHashData> non_existing_data = + std::optional<PasswordHashData> non_existing_data = hash_password_manager.RetrievePasswordHash("non_existing_user", true); ASSERT_FALSE(non_existing_data); }
diff --git a/components/password_manager/core/browser/http_auth_manager_unittest.cc b/components/password_manager/core/browser/http_auth_manager_unittest.cc index a4d72c57..6f8cb88 100644 --- a/components/password_manager/core/browser/http_auth_manager_unittest.cc +++ b/components/password_manager/core/browser/http_auth_manager_unittest.cc
@@ -30,7 +30,6 @@ #include "components/password_manager/core/browser/stub_password_manager_client.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using base::TestMockTimeTaskRunner; using testing::_;
diff --git a/components/password_manager/core/browser/import/csv_password_iterator.h b/components/password_manager/core/browser/import/csv_password_iterator.h index 7d817c76..d07304b 100644 --- a/components/password_manager/core/browser/import/csv_password_iterator.h +++ b/components/password_manager/core/browser/import/csv_password_iterator.h
@@ -8,11 +8,11 @@ #include <stddef.h> #include <iterator> +#include <optional> #include "base/memory/raw_ptr.h" #include "base/strings/string_piece.h" #include "components/password_manager/core/browser/import/csv_password.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -64,7 +64,7 @@ // |csv_row_| contains the CSV row which the iterator points at. base::StringPiece csv_row_; // Contains a CSVPassword created from |map_| and |csv_row_| if possible. - absl::optional<CSVPassword> password_; + std::optional<CSVPassword> password_; }; // ConsumeCSVLine is a shared utility between CSVPasswordIterator (which uses
diff --git a/components/password_manager/core/browser/import/password_importer.cc b/components/password_manager/core/browser/import/password_importer.cc index ae8e87f3..db5cbfa 100644 --- a/components/password_manager/core/browser/import/password_importer.cc +++ b/components/password_manager/core/browser/import/password_importer.cc
@@ -4,6 +4,7 @@ #include "components/password_manager/core/browser/import/password_importer.h" +#include <optional> #include <string> #include <utility> @@ -26,7 +27,6 @@ #include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/services/csv_password/csv_password_parser_service.h" #include "components/sync/base/features.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using password_manager::ImportEntry; namespace password_manager { @@ -189,7 +189,7 @@ return password_manager::CredentialUIEntry(csv_password, store); } -absl::optional<CredentialUIEntry> GetConflictingCredential( +std::optional<CredentialUIEntry> GetConflictingCredential( const std::map<std::u16string, std::vector<CredentialUIEntry>>& credentials_by_username, const CredentialUIEntry& imported_credential) { @@ -210,7 +210,7 @@ } } } - return absl::nullopt; + return std::nullopt; } std::vector<PasswordForm> GetMatchingPasswordForms( @@ -387,7 +387,7 @@ // Check if there are local credentials with the same signon_realm and // username, but different password. Such credentials are considered // conflicts. - absl::optional<CredentialUIEntry> conflicting_credential = + std::optional<CredentialUIEntry> conflicting_credential = GetConflictingCredential(credentials_by_username, imported_credential); if (conflicting_credential.has_value()) { std::vector<PasswordForm> forms = GetMatchingPasswordForms(
diff --git a/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.cc b/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.cc index f35af8b..2145c37 100644 --- a/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.cc +++ b/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.cc
@@ -4,6 +4,7 @@ #include "components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h" +#include <optional> #include <utility> #include "base/check.h" @@ -17,7 +18,6 @@ #include "components/signin/public/identity_manager/access_token_fetcher.h" #include "components/signin/public/identity_manager/access_token_info.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { namespace { @@ -149,7 +149,7 @@ holder->network_request_ = network_request_factory_->CreateNetworkRequest(); holder->network_request_->LookupSingleLeak( url_loader_factory_.get(), access_token_info.token, - /*api_key=*/absl::nullopt, std::move(holder->payload), + /*api_key=*/std::nullopt, std::move(holder->payload), base::BindOnce(&BulkLeakCheckImpl::OnLookupLeakResponse, weak_ptr_factory_.GetWeakPtr(), holder.get())); waiting_response_.push_back(std::move(holder)); @@ -158,7 +158,7 @@ void BulkLeakCheckImpl::OnLookupLeakResponse( CredentialHolder* weak_holder, std::unique_ptr<SingleLookupResponse> response, - absl::optional<LeakDetectionError> error) { + std::optional<LeakDetectionError> error) { std::unique_ptr<CredentialHolder> holder = RemoveFromQueue(weak_holder, &waiting_response_);
diff --git a/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h b/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h index 49815e90..22558de 100644 --- a/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h +++ b/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h
@@ -6,6 +6,7 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_BULK_LEAK_CHECK_IMPL_H_ #include <memory> +#include <optional> #include "base/containers/circular_deque.h" #include "base/memory/raw_ptr.h" @@ -17,7 +18,6 @@ #include "components/password_manager/core/browser/leak_detection/leak_detection_delegate_interface.h" #include "components/password_manager/core/browser/leak_detection/leak_detection_request_factory.h" #include "components/password_manager/core/browser/leak_detection/leak_detection_request_utils.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace network { class SharedURLLoaderFactory; @@ -75,7 +75,7 @@ // Called when the server replied with something. void OnLookupLeakResponse(CredentialHolder* weak_holder, std::unique_ptr<SingleLookupResponse> response, - absl::optional<LeakDetectionError> error); + std::optional<LeakDetectionError> error); // Called when the response was analyzed on the background thread. void OnAnalyzedResponse(CredentialHolder* weak_holder,
diff --git a/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl_unittest.cc b/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl_unittest.cc index c735e69..76bf9b9 100644 --- a/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl_unittest.cc +++ b/components/password_manager/core/browser/leak_detection/bulk_leak_check_impl_unittest.cc
@@ -56,8 +56,8 @@ struct TestLeakDetectionRequest : LeakDetectionRequestInterface { // LeakDetectionRequestInterface: void LookupSingleLeak(network::mojom::URLLoaderFactory* url_loader_factory, - const absl::optional<std::string>& access_token, - const absl::optional<std::string>& api_key, + const std::optional<std::string>& access_token, + const std::optional<std::string>& api_key, LookupSingleLeakPayload payload, LookupSingleLeakCallback callback) override { EXPECT_EQ(payload.initiator, @@ -233,7 +233,7 @@ auto network_request = std::make_unique<MockLeakDetectionRequest>(); EXPECT_CALL(*network_request, LookupSingleLeak( - _, Optional(Eq(kAccessToken)), /*api_key=*/Eq(absl::nullopt), + _, Optional(Eq(kAccessToken)), /*api_key=*/Eq(std::nullopt), AllOf(Field(&LookupSingleLeakPayload::username_hash_prefix, ElementsAre(0xBD, 0x74, 0xA9, 0x00)), Field(&LookupSingleLeakPayload::encrypted_payload, @@ -265,10 +265,10 @@ auto network_request2 = std::make_unique<MockLeakDetectionRequest>(); EXPECT_CALL(*network_request1, LookupSingleLeak(_, Optional(Eq(kAccessToken)), - /*api_key=*/Eq(absl::nullopt), _, _)); + /*api_key=*/Eq(std::nullopt), _, _)); EXPECT_CALL(*network_request2, LookupSingleLeak(_, Optional(Eq(kAccessToken)), - /*api_key=*/Eq(absl::nullopt), _, _)); + /*api_key=*/Eq(std::nullopt), _, _)); EXPECT_CALL(*request_factory(), CreateNetworkRequest) .WillOnce(Return(ByMove(std::move(network_request1)))) .WillOnce(Return(ByMove(std::move(network_request2)))); @@ -299,7 +299,7 @@ EXPECT_CALL(delegate(), OnError(LeakDetectionError::kHashingFailure)); std::move(payload_and_callback.callback) - .Run(std::move(response), absl::nullopt); + .Run(std::move(response), std::nullopt); RunUntilIdle(); EXPECT_EQ(0u, bulk_check().GetPendingChecksCount()); } @@ -332,7 +332,7 @@ CustomDataIs("custom")), IsLeaked(false))); std::move(payload_and_callback.callback) - .Run(std::move(response), absl::nullopt); + .Run(std::move(response), std::nullopt); RunUntilIdle(); EXPECT_EQ(0u, bulk_check().GetPendingChecksCount()); } @@ -364,7 +364,7 @@ CustomDataIs("custom")), IsLeaked(true))); std::move(payload_and_callback.callback) - .Run(std::move(response), absl::nullopt); + .Run(std::move(response), std::nullopt); RunUntilIdle(); EXPECT_EQ(0u, bulk_check().GetPendingChecksCount()); }
diff --git a/components/password_manager/core/browser/leak_detection/encryption_utils.cc b/components/password_manager/core/browser/leak_detection/encryption_utils.cc index 7287774..adfacccb 100644 --- a/components/password_manager/core/browser/leak_detection/encryption_utils.cc +++ b/components/password_manager/core/browser/leak_detection/encryption_utils.cc
@@ -5,6 +5,7 @@ #include "components/password_manager/core/browser/leak_detection/encryption_utils.h" #include <climits> +#include <optional> #include <utility> #include "base/strings/strcat.h" @@ -13,7 +14,6 @@ #include "base/strings/utf_string_conversions.h" #include "crypto/openssl_util.h" #include "crypto/sha2.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/nid.h" #include "third_party/private-join-and-compute/src/crypto/ec_commutative_cipher.h" @@ -84,7 +84,7 @@ return prefix; } -absl::optional<std::string> ScryptHashUsernameAndPassword( +std::optional<std::string> ScryptHashUsernameAndPassword( base::StringPiece canonicalized_username, base::StringPiece password) { // Constant salt added to the password hash on top of canonicalized_username. @@ -120,12 +120,11 @@ reinterpret_cast<const uint8_t*>(salt.data()), salt.size(), kScryptCost, kScryptBlockSize, kScryptParallelization, kScryptMaxMemory, key_data, kHashKeyLength); - return scrypt_ok == 1 ? absl::make_optional(std::move(result)) - : absl::nullopt; + return scrypt_ok == 1 ? std::make_optional(std::move(result)) : std::nullopt; } -absl::optional<std::string> CipherEncrypt(const std::string& plaintext, - std::string* key) { +std::optional<std::string> CipherEncrypt(const std::string& plaintext, + std::string* key) { using ::private_join_and_compute::ECCommutativeCipher; auto cipher = ECCommutativeCipher::CreateWithNewKey( NID_X9_62_prime256v1, ECCommutativeCipher::SHA256); @@ -136,11 +135,11 @@ return std::move(result).value(); } } - return absl::nullopt; + return std::nullopt; } -absl::optional<std::string> CipherEncryptWithKey(const std::string& plaintext, - const std::string& key) { +std::optional<std::string> CipherEncryptWithKey(const std::string& plaintext, + const std::string& key) { using ::private_join_and_compute::ECCommutativeCipher; auto cipher = ECCommutativeCipher::CreateFromKey(NID_X9_62_prime256v1, key, ECCommutativeCipher::SHA256); @@ -149,12 +148,11 @@ if (result.ok()) return std::move(result).value(); } - return absl::nullopt; + return std::nullopt; } -absl::optional<std::string> CipherReEncrypt( - const std::string& already_encrypted, - std::string* key) { +std::optional<std::string> CipherReEncrypt(const std::string& already_encrypted, + std::string* key) { using ::private_join_and_compute::ECCommutativeCipher; auto cipher = ECCommutativeCipher::CreateWithNewKey( NID_X9_62_prime256v1, ECCommutativeCipher::SHA256); @@ -165,11 +163,11 @@ return std::move(result).value(); } } - return absl::nullopt; + return std::nullopt; } -absl::optional<std::string> CipherDecrypt(const std::string& ciphertext, - const std::string& key) { +std::optional<std::string> CipherDecrypt(const std::string& ciphertext, + const std::string& key) { using ::private_join_and_compute::ECCommutativeCipher; auto cipher = ECCommutativeCipher::CreateFromKey(NID_X9_62_prime256v1, key, ECCommutativeCipher::SHA256); @@ -178,16 +176,16 @@ if (result.ok()) return std::move(result).value(); } - return absl::nullopt; + return std::nullopt; } -absl::optional<std::string> CreateNewKey() { +std::optional<std::string> CreateNewKey() { using ::private_join_and_compute::ECCommutativeCipher; auto cipher = ECCommutativeCipher::CreateWithNewKey( NID_X9_62_prime256v1, ECCommutativeCipher::SHA256); if (cipher.ok()) return cipher.value()->GetPrivateKeyBytes(); - return absl::nullopt; + return std::nullopt; } } // namespace password_manager
diff --git a/components/password_manager/core/browser/leak_detection/encryption_utils.h b/components/password_manager/core/browser/leak_detection/encryption_utils.h index 69cb907..eb98b922 100644 --- a/components/password_manager/core/browser/leak_detection/encryption_utils.h +++ b/components/password_manager/core/browser/leak_detection/encryption_utils.h
@@ -5,10 +5,10 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_ENCRYPTION_UTILS_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_ENCRYPTION_UTILS_H_ +#include <optional> #include <string> #include "base/strings/string_piece.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -32,7 +32,7 @@ // Produces the username/password pair hash using scrypt algorithm. // |canonicalized_username| and |password| are UTF-8 strings. // Returns nullopt in case of encryption failure. -absl::optional<std::string> ScryptHashUsernameAndPassword( +std::optional<std::string> ScryptHashUsernameAndPassword( base::StringPiece canonicalized_username, base::StringPiece password); @@ -42,13 +42,13 @@ // Internally the function does some hashing first and then encrypts the result. // In case of an encryption failure this returns nullopt and does not modify // |key|. -absl::optional<std::string> CipherEncrypt(const std::string& plaintext, - std::string* key); +std::optional<std::string> CipherEncrypt(const std::string& plaintext, + std::string* key); // Encrypts |plaintext| with the existing key. // Returns nullopt in case of encryption failure. -absl::optional<std::string> CipherEncryptWithKey(const std::string& plaintext, - const std::string& key); +std::optional<std::string> CipherEncryptWithKey(const std::string& plaintext, + const std::string& key); // |already_encrypted| is an already encrypted string (output of CipherEncrypt). // Encrypts it again with a new key. The key is returned in |key|. @@ -56,19 +56,18 @@ // the input. // In case of an encryption failure this returns nullopt and does not modify // |key|. -absl::optional<std::string> CipherReEncrypt( - const std::string& already_encrypted, - std::string* key); +std::optional<std::string> CipherReEncrypt(const std::string& already_encrypted, + std::string* key); // Decrypts |ciphertext| using |key|. The result isn't the original string but a // hash of it. // Returns nullopt in case of decryption failure. -absl::optional<std::string> CipherDecrypt(const std::string& ciphertext, - const std::string& key); +std::optional<std::string> CipherDecrypt(const std::string& ciphertext, + const std::string& key); // Returns a new key suitable for the encryption functions above, or nullopt if // the operation failed. -absl::optional<std::string> CreateNewKey(); +std::optional<std::string> CreateNewKey(); } // namespace password_manager
diff --git a/components/password_manager/core/browser/leak_detection/fuzzer/cipher_encrypt_fuzzer.cc b/components/password_manager/core/browser/leak_detection/fuzzer/cipher_encrypt_fuzzer.cc index f723350d5..d65154b 100644 --- a/components/password_manager/core/browser/leak_detection/fuzzer/cipher_encrypt_fuzzer.cc +++ b/components/password_manager/core/browser/leak_detection/fuzzer/cipher_encrypt_fuzzer.cc
@@ -5,17 +5,17 @@ #include <stddef.h> #include <stdint.h> +#include <optional> #include <string> #include "components/password_manager/core/browser/leak_detection/encryption_utils.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { std::string payload(reinterpret_cast<const char*>(data), size); std::string key; - absl::optional<std::string> cipher = + std::optional<std::string> cipher = password_manager::CipherEncrypt(payload, &key); return 0; }
diff --git a/components/password_manager/core/browser/leak_detection/fuzzer/cypher_decrypt_fuzzer.cc b/components/password_manager/core/browser/leak_detection/fuzzer/cypher_decrypt_fuzzer.cc index ef811bb..09cfbec 100644 --- a/components/password_manager/core/browser/leak_detection/fuzzer/cypher_decrypt_fuzzer.cc +++ b/components/password_manager/core/browser/leak_detection/fuzzer/cypher_decrypt_fuzzer.cc
@@ -4,7 +4,7 @@ #include "components/password_manager/core/browser/leak_detection/encryption_utils.h" -#include "third_party/abseil-cpp/absl/types/optional.h" +#include <optional> #include "third_party/boringssl/src/include/openssl/nid.h" #include "third_party/private-join-and-compute/src/crypto/ec_commutative_cipher.h" @@ -33,7 +33,7 @@ return 0; std::string payload(reinterpret_cast<const char*>(data), size); - absl::optional<std::string> result = + std::optional<std::string> result = password_manager::CipherDecrypt(payload, key); return 0; }
diff --git a/components/password_manager/core/browser/leak_detection/fuzzer/cypher_encrypt_with_key_fuzzer.cc b/components/password_manager/core/browser/leak_detection/fuzzer/cypher_encrypt_with_key_fuzzer.cc index 0ef1f3b..d9e265e 100644 --- a/components/password_manager/core/browser/leak_detection/fuzzer/cypher_encrypt_with_key_fuzzer.cc +++ b/components/password_manager/core/browser/leak_detection/fuzzer/cypher_encrypt_with_key_fuzzer.cc
@@ -4,7 +4,7 @@ #include "components/password_manager/core/browser/leak_detection/encryption_utils.h" -#include "third_party/abseil-cpp/absl/types/optional.h" +#include <optional> #include "third_party/boringssl/src/include/openssl/nid.h" #include "third_party/private-join-and-compute/src/crypto/ec_commutative_cipher.h" @@ -33,7 +33,7 @@ return 0; std::string payload(reinterpret_cast<const char*>(data), size); - absl::optional<std::string> result = + std::optional<std::string> result = password_manager::CipherEncryptWithKey(payload, key); return 0; }
diff --git a/components/password_manager/core/browser/leak_detection/fuzzer/cypher_reencrypt_fuzzer.cc b/components/password_manager/core/browser/leak_detection/fuzzer/cypher_reencrypt_fuzzer.cc index 3a201329..fa6f183 100644 --- a/components/password_manager/core/browser/leak_detection/fuzzer/cypher_reencrypt_fuzzer.cc +++ b/components/password_manager/core/browser/leak_detection/fuzzer/cypher_reencrypt_fuzzer.cc
@@ -4,14 +4,14 @@ #include "components/password_manager/core/browser/leak_detection/encryption_utils.h" -#include "third_party/abseil-cpp/absl/types/optional.h" +#include <optional> namespace password_manager { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { std::string payload(reinterpret_cast<const char*>(data), size); std::string key; - absl::optional<std::string> result = + std::optional<std::string> result = password_manager::CipherEncrypt(payload, &key); return 0; }
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_check_factory_impl.cc b/components/password_manager/core/browser/leak_detection/leak_detection_check_factory_impl.cc index bb4ba812..20499d6 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_check_factory_impl.cc +++ b/components/password_manager/core/browser/leak_detection/leak_detection_check_factory_impl.cc
@@ -17,13 +17,13 @@ namespace password_manager { namespace { -// Returns |absl::nullopt| for |signed_in_user|, as in this case authentication +// Returns |std::nullopt| for |signed_in_user|, as in this case authentication // happens via access token. Otherwise returns API key for an appropriate // |channel|. -absl::optional<std::string> GetAPIKey(bool signed_in_user, - version_info::Channel channel) { +std::optional<std::string> GetAPIKey(bool signed_in_user, + version_info::Channel channel) { if (signed_in_user) { - return absl::nullopt; + return std::nullopt; } if (channel == version_info::Channel::STABLE) {
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.cc b/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.cc index b677aed..7938010 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.cc +++ b/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.cc
@@ -5,6 +5,7 @@ #include "components/password_manager/core/browser/leak_detection/leak_detection_check_impl.h" #include <memory> +#include <optional> #include <utility> #include "base/functional/callback.h" @@ -24,7 +25,6 @@ #include "components/signin/public/identity_manager/identity_manager.h" #include "google_apis/gaia/google_service_auth_error.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { namespace { @@ -56,7 +56,7 @@ LeakDetectionCheckImpl* leak_check, signin::IdentityManager* identity_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - absl::optional<std::string> api_key); + std::optional<std::string> api_key); ~RequestPayloadHelper() = default; // Neither copyable nor movable. @@ -75,7 +75,7 @@ SingleLeakRequestDataCallback callback); // Notifies that the access token was obtained. - void OnGotAccessToken(absl::optional<std::string> access_token); + void OnGotAccessToken(std::optional<std::string> access_token); // Notifies that the payload was obtained. void OnGotPayload(LookupSingleLeakData data); @@ -103,11 +103,11 @@ // Actual request for the needed token. std::unique_ptr<signin::AccessTokenFetcher> token_fetcher_; // The token to be used for request for signed-in user. It should be - // |absl::nullopt| for signed-out users. - absl::optional<std::string> access_token_; + // |std::nullopt| for signed-out users. + std::optional<std::string> access_token_; // Api key required to authenticate signed-out user. It should be - // |absl::nullopt| for signed-in users. - const absl::optional<std::string> api_key_; + // |std::nullopt| for signed-in users. + const std::optional<std::string> api_key_; // Payload for the actual request. LookupSingleLeakData payload_; }; @@ -116,7 +116,7 @@ LeakDetectionCheckImpl* leak_check, signin::IdentityManager* identity_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - absl::optional<std::string> api_key) + std::optional<std::string> api_key) : leak_check_(leak_check), identity_manager_(identity_manager), url_loader_factory_(std::move(url_loader_factory)), @@ -146,7 +146,7 @@ } void LeakDetectionCheckImpl::RequestPayloadHelper::OnGotAccessToken( - absl::optional<std::string> access_token) { + std::optional<std::string> access_token) { access_token_ = std::move(access_token); steps_ |= kAccessToken; token_fetcher_.reset(); @@ -174,7 +174,7 @@ LeakDetectionDelegateInterface* delegate, signin::IdentityManager* identity_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - absl::optional<std::string> api_key) + std::optional<std::string> api_key) : delegate_(delegate), payload_helper_(new RequestPayloadHelper(this, identity_manager, @@ -215,7 +215,7 @@ weak_ptr_factory_.GetWeakPtr()), "PasswordManager.LeakDetection.ObtainAccessTokenTime")); } else { - payload_helper_->OnGotAccessToken(/*access_token=*/absl::nullopt); + payload_helper_->OnGotAccessToken(/*access_token=*/std::nullopt); } payload_helper_->PreparePayload( initiator, base::UTF16ToUTF8(username_), base::UTF16ToUTF8(password_), @@ -279,8 +279,8 @@ void LeakDetectionCheckImpl::DoLeakRequest( LookupSingleLeakData data, - absl::optional<std::string> access_token, - absl::optional<std::string> api_key, + std::optional<std::string> access_token, + std::optional<std::string> api_key, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { payload_helper_.reset(); encryption_key_ = std::move(data.encryption_key); @@ -295,7 +295,7 @@ void LeakDetectionCheckImpl::OnLookupSingleLeakResponse( std::unique_ptr<SingleLookupResponse> response, - absl::optional<LeakDetectionError> error) { + std::optional<LeakDetectionError> error) { request_.reset(); if (!response) { delegate_->OnError(*error);
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.h b/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.h index 218f5e42..655665d6 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.h +++ b/components/password_manager/core/browser/leak_detection/leak_detection_check_impl.h
@@ -6,6 +6,7 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_CHECK_IMPL_H_ #include <memory> +#include <optional> #include <string> #include "base/memory/raw_ptr.h" @@ -14,7 +15,6 @@ #include "components/password_manager/core/browser/leak_detection/leak_detection_check.h" #include "components/password_manager/core/browser/leak_detection/leak_detection_delegate_interface.h" #include "components/password_manager/core/browser/leak_detection/leak_detection_request_factory.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" class GoogleServiceAuthError; @@ -42,7 +42,7 @@ LeakDetectionDelegateInterface* delegate, signin::IdentityManager* identity_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - absl::optional<std::string> api_key); + std::optional<std::string> api_key); ~LeakDetectionCheckImpl() override; // Returns true if there is a Google account to use for the leak detection @@ -76,8 +76,8 @@ // Does the network request to check the credentials. void DoLeakRequest( LookupSingleLeakData data, - absl::optional<std::string> access_token, - absl::optional<std::string> api_key, + std::optional<std::string> access_token, + std::optional<std::string> api_key, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory); // Called when the single leak lookup request is done. |response| is null in @@ -86,7 +86,7 @@ // null. void OnLookupSingleLeakResponse( std::unique_ptr<SingleLookupResponse> response, - absl::optional<LeakDetectionError> error); + std::optional<LeakDetectionError> error); // Called when the network response is analazyed on the background thread. The // method is called on the main thread.
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_check_impl_unittest.cc b/components/password_manager/core/browser/leak_detection/leak_detection_check_impl_unittest.cc index 94ef641..e187805 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_check_impl_unittest.cc +++ b/components/password_manager/core/browser/leak_detection/leak_detection_check_impl_unittest.cc
@@ -51,8 +51,8 @@ ~TestLeakDetectionRequest() override = default; // LeakDetectionRequestInterface: void LookupSingleLeak(network::mojom::URLLoaderFactory* url_loader_factory, - const absl::optional<std::string>& access_token, - const absl::optional<std::string>& api_key, + const std::optional<std::string>& access_token, + const std::optional<std::string>& api_key, LookupSingleLeakPayload payload, LookupSingleLeakCallback callback) override { encrypted_payload_ = std::move(payload.encrypted_payload); @@ -87,9 +87,9 @@ // Initializes |leak_check_| with the appropriate identity environment based // on the provided |user_signed_in| parameter. void InitializeLeakCheck(bool user_signed_in) { - absl::optional<std::string> api_key = kApiKey; + std::optional<std::string> api_key = kApiKey; if (user_signed_in) { - api_key = absl::nullopt; + api_key = std::nullopt; AccountInfo info = identity_env().MakeAccountAvailable(kTestEmail); identity_env().SetCookieAccounts({{info.email, info.gaia}}); identity_env().SetRefreshTokenForAccount(info.account_id); @@ -190,7 +190,7 @@ EXPECT_CALL( *network_request, LookupSingleLeak( - _, Optional(access_token), /*api_key=*/Eq(absl::nullopt), + _, Optional(access_token), /*api_key=*/Eq(std::nullopt), AllOf(Field(&LookupSingleLeakPayload::username_hash_prefix, ElementsAre(0xBD, 0x74, 0xA9, 0x00)), Field(&LookupSingleLeakPayload::encrypted_payload, Ne(""))), @@ -219,7 +219,7 @@ EXPECT_CALL( *network_request, LookupSingleLeak( - _, Optional(access_token), /*api_key=*/Eq(absl::nullopt), + _, Optional(access_token), /*api_key=*/Eq(std::nullopt), AllOf(Field(&LookupSingleLeakPayload::username_hash_prefix, ElementsAre(0xBD, 0x74, 0xA9, 0x00)), Field(&LookupSingleLeakPayload::encrypted_payload, Ne(""))), @@ -269,7 +269,7 @@ EXPECT_CALL( *network_request, LookupSingleLeak( - _, /*access_token=*/Eq(absl::nullopt), Optional(Eq(kApiKey)), + _, /*access_token=*/Eq(std::nullopt), Optional(Eq(kApiKey)), AllOf(Field(&LookupSingleLeakPayload::username_hash_prefix, ElementsAre(0xBD, 0x74, 0xA9, 0x00)), Field(&LookupSingleLeakPayload::encrypted_payload, Ne(""))), @@ -303,7 +303,7 @@ OnLeakDetectionDone(false, GURL(kExampleCom), Eq(kUsername16), Eq(kPassword16))); std::move(payload_and_callback.callback) - .Run(std::move(response), absl::nullopt); + .Run(std::move(response), std::nullopt); task_env().RunUntilIdle(); histogram_tester().ExpectUniqueSample( @@ -335,7 +335,7 @@ OnLeakDetectionDone(false, GURL(kExampleCom), Eq(kUsername16), Eq(kPassword16))); std::move(payload_and_callback.callback) - .Run(std::move(response), absl::nullopt); + .Run(std::move(response), std::nullopt); task_env().RunUntilIdle(); histogram_tester().ExpectUniqueSample( @@ -373,7 +373,7 @@ OnLeakDetectionDone(true, GURL(kExampleCom), Eq(kUsername16), Eq(kPassword16))); std::move(payload_and_callback.callback) - .Run(std::move(response), absl::nullopt); + .Run(std::move(response), std::nullopt); task_env().RunUntilIdle(); histogram_tester().ExpectUniqueSample(
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_request.cc b/components/password_manager/core/browser/leak_detection/leak_detection_request.cc index 5d61c52..76be907 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_request.cc +++ b/components/password_manager/core/browser/leak_detection/leak_detection_request.cc
@@ -85,8 +85,8 @@ void LeakDetectionRequest::LookupSingleLeak( network::mojom::URLLoaderFactory* url_loader_factory, - const absl::optional<std::string>& access_token, - const absl::optional<std::string>& api_key, + const std::optional<std::string>& access_token, + const std::optional<std::string>& api_key, LookupSingleLeakPayload payload, LookupSingleLeakCallback callback) { net::NetworkTrafficAnnotationTag traffic_annotation = @@ -219,7 +219,7 @@ base::UmaHistogramCounts100000( "PasswordManager.LeakDetection.SingleLeakResponsePrefixes", single_lookup_response->encrypted_leak_match_prefixes.size()); - std::move(callback).Run(std::move(single_lookup_response), absl::nullopt); + std::move(callback).Run(std::move(single_lookup_response), std::nullopt); } } // namespace password_manager
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_request.h b/components/password_manager/core/browser/leak_detection/leak_detection_request.h index 1f02787..bb95ae4 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_request.h +++ b/components/password_manager/core/browser/leak_detection/leak_detection_request.h
@@ -49,8 +49,8 @@ // beforehand. If the request failed, |callback| is invoked with |nullptr|, // otherwise a SingleLookupResponse is returned. void LookupSingleLeak(network::mojom::URLLoaderFactory* url_loader_factory, - const absl::optional<std::string>& access_token, - const absl::optional<std::string>& api_key, + const std::optional<std::string>& access_token, + const std::optional<std::string>& api_key, LookupSingleLeakPayload payload, LookupSingleLeakCallback callback) override;
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_request_factory.h b/components/password_manager/core/browser/leak_detection/leak_detection_request_factory.h index e8385e2..bf93a629 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_request_factory.h +++ b/components/password_manager/core/browser/leak_detection/leak_detection_request_factory.h
@@ -6,10 +6,10 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_REQUEST_FACTORY_H_ #include <memory> +#include <optional> #include <string> #include "base/functional/callback_forward.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace network { namespace mojom { @@ -28,7 +28,7 @@ public: using LookupSingleLeakCallback = base::OnceCallback<void(std::unique_ptr<SingleLookupResponse>, - absl::optional<LeakDetectionError>)>; + std::optional<LeakDetectionError>)>; LeakDetectionRequestInterface() = default; virtual ~LeakDetectionRequestInterface() = default; @@ -50,8 +50,8 @@ // otherwise a SingleLookupResponse is returned. virtual void LookupSingleLeak( network::mojom::URLLoaderFactory* url_loader_factory, - const absl::optional<std::string>& access_token, - const absl::optional<std::string>& api_key, + const std::optional<std::string>& access_token, + const std::optional<std::string>& api_key, LookupSingleLeakPayload payload, LookupSingleLeakCallback callback) = 0; };
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_request_unittest.cc b/components/password_manager/core/browser/leak_detection/leak_detection_request_unittest.cc index 0b1bf79..33b7d4c 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_request_unittest.cc +++ b/components/password_manager/core/browser/leak_detection/leak_detection_request_unittest.cc
@@ -50,7 +50,7 @@ base::MockCallback<LeakDetectionRequest::LookupSingleLeakCallback> callback; request().LookupSingleLeak( test_url_loader_factory(), kAccessToken, - /*api_key=*/absl::nullopt, + /*api_key=*/std::nullopt, {LeakDetectionInitiator::kSignInCheck, kUsernameHash, kEncryptedPayload}, callback.Get()); EXPECT_CALL(callback, @@ -73,7 +73,7 @@ base::MockCallback<LeakDetectionRequest::LookupSingleLeakCallback> callback; request().LookupSingleLeak( test_url_loader_factory(), kAccessToken, - /*api_key=*/absl::nullopt, + /*api_key=*/std::nullopt, {LeakDetectionInitiator::kSignInCheck, kUsernameHash, kEncryptedPayload}, callback.Get()); EXPECT_CALL(callback, Run(IsNull(), Eq(LeakDetectionError::kQuotaLimit))); @@ -96,7 +96,7 @@ base::MockCallback<LeakDetectionRequest::LookupSingleLeakCallback> callback; request().LookupSingleLeak( test_url_loader_factory(), kAccessToken, - /*api_key=*/absl::nullopt, + /*api_key=*/std::nullopt, {LeakDetectionInitiator::kSignInCheck, kUsernameHash, kEncryptedPayload}, callback.Get()); EXPECT_CALL(callback, @@ -121,11 +121,11 @@ base::MockCallback<LeakDetectionRequest::LookupSingleLeakCallback> callback; request().LookupSingleLeak( test_url_loader_factory(), kAccessToken, - /*api_key=*/absl::nullopt, + /*api_key=*/std::nullopt, {LeakDetectionInitiator::kSignInCheck, kUsernameHash, kEncryptedPayload}, callback.Get()); EXPECT_CALL(callback, - Run(testing::Pointee(SingleLookupResponse()), Eq(absl::nullopt))); + Run(testing::Pointee(SingleLookupResponse()), Eq(std::nullopt))); task_env().RunUntilIdle(); histogram_tester().ExpectUniqueSample( @@ -149,11 +149,11 @@ base::MockCallback<LeakDetectionRequest::LookupSingleLeakCallback> callback; request().LookupSingleLeak( - test_url_loader_factory(), /*access_token=*/absl::nullopt, kApiKey, + test_url_loader_factory(), /*access_token=*/std::nullopt, kApiKey, {LeakDetectionInitiator::kSignInCheck, kUsernameHash, kEncryptedPayload}, callback.Get()); EXPECT_CALL(callback, - Run(testing::Pointee(SingleLookupResponse()), Eq(absl::nullopt))); + Run(testing::Pointee(SingleLookupResponse()), Eq(std::nullopt))); task_env().RunUntilIdle(); histogram_tester().ExpectUniqueSample(
diff --git a/components/password_manager/core/browser/leak_detection/leak_detection_request_utils.cc b/components/password_manager/core/browser/leak_detection/leak_detection_request_utils.cc index 8ec02c888..66e998dc 100644 --- a/components/password_manager/core/browser/leak_detection/leak_detection_request_utils.cc +++ b/components/password_manager/core/browser/leak_detection/leak_detection_request_utils.cc
@@ -4,6 +4,7 @@ #include "components/password_manager/core/browser/leak_detection/leak_detection_request_utils.h" +#include <optional> #include <string> #include "base/containers/span.h" @@ -20,7 +21,6 @@ #include "crypto/sha2.h" #include "google_apis/gaia/core_account_id.h" #include "google_apis/gaia/gaia_constants.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { namespace { @@ -96,7 +96,7 @@ AnalyzeResponseResult CheckIfCredentialWasLeaked( std::unique_ptr<SingleLookupResponse> response, const std::string& encryption_key) { - absl::optional<std::string> decrypted_username_password = + std::optional<std::string> decrypted_username_password = CipherDecrypt(response->reencrypted_lookup_hash, encryption_key); if (!decrypted_username_password) { DLOG(ERROR) << "Can't decrypt data="
diff --git a/components/password_manager/core/browser/leak_detection/mock_leak_detection_request_factory.h b/components/password_manager/core/browser/leak_detection/mock_leak_detection_request_factory.h index 210e2b1..b87ca2b 100644 --- a/components/password_manager/core/browser/leak_detection/mock_leak_detection_request_factory.h +++ b/components/password_manager/core/browser/leak_detection/mock_leak_detection_request_factory.h
@@ -20,8 +20,8 @@ MOCK_METHOD(void, LookupSingleLeak, (network::mojom::URLLoaderFactory*, - const absl::optional<std::string>&, - const absl::optional<std::string>&, + const std::optional<std::string>&, + const std::optional<std::string>&, LookupSingleLeakPayload, LookupSingleLeakCallback), (override));
diff --git a/components/password_manager/core/browser/mock_webauthn_credentials_delegate.h b/components/password_manager/core/browser/mock_webauthn_credentials_delegate.h index 7667e59..4e746d0 100644 --- a/components/password_manager/core/browser/mock_webauthn_credentials_delegate.h +++ b/components/password_manager/core/browser/mock_webauthn_credentials_delegate.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_MOCK_WEBAUTHN_CREDENTIALS_DELEGATE_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_MOCK_WEBAUTHN_CREDENTIALS_DELEGATE_H_ +#include <optional> #include <string> #include <vector> @@ -12,7 +13,6 @@ #include "components/password_manager/core/browser/passkey_credential.h" #include "components/password_manager/core/browser/webauthn_credentials_delegate.h" #include "testing/gmock/include/gmock/gmock.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -28,7 +28,7 @@ MOCK_METHOD(void, LaunchWebAuthnFlow, (), (override)); MOCK_METHOD(void, SelectPasskey, (const std::string& backend_id), (override)); - MOCK_METHOD(const absl::optional<std::vector<PasskeyCredential>>&, + MOCK_METHOD(const std::optional<std::vector<PasskeyCredential>>&, GetPasskeys, (), (const override));
diff --git a/components/password_manager/core/browser/passkey_credential.h b/components/password_manager/core/browser/passkey_credential.h index c932342..4203083 100644 --- a/components/password_manager/core/browser/passkey_credential.h +++ b/components/password_manager/core/browser/passkey_credential.h
@@ -6,13 +6,14 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSKEY_CREDENTIAL_H_ #include <stdint.h> + +#include <optional> #include <string> #include <vector> #include "base/containers/span.h" #include "base/types/strong_alias.h" #include "build/build_config.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) #include "components/sync/protocol/webauthn_credential_specifics.pb.h" @@ -105,7 +106,7 @@ // An optional label for the authenticator. If this is not set, a generic // device name will be returned by GetAuthenticatorLabel(). - absl::optional<std::u16string> authenticator_label_; + std::optional<std::u16string> authenticator_label_; }; bool operator==(const PasskeyCredential& lhs, const PasskeyCredential& rhs);
diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc index 978ca8d..12a8822 100644 --- a/components/password_manager/core/browser/password_autofill_manager.cc +++ b/components/password_manager/core/browser/password_autofill_manager.cc
@@ -48,7 +48,6 @@ #include "components/signin/public/base/signin_metrics.h" #include "components/strings/grit/components_strings.h" #include "components/sync/base/features.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h"
diff --git a/components/password_manager/core/browser/password_autofill_manager_unittest.cc b/components/password_manager/core/browser/password_autofill_manager_unittest.cc index fc1ae86c..9ad783c6 100644 --- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc +++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
@@ -5,6 +5,7 @@ #include "components/password_manager/core/browser/password_autofill_manager.h" #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -53,7 +54,6 @@ #include "services/metrics/public/cpp/ukm_builders.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/image/image.h" @@ -2018,7 +2018,7 @@ PasskeyCredential::Username(kNameUtf8)); EXPECT_CALL(client, GetWebAuthnCredentialsDelegateForDriver) .WillRepeatedly(Return(&webauthn_credentials_delegate)); - absl::optional<std::vector<PasskeyCredential>> passkey_list = + std::optional<std::vector<PasskeyCredential>> passkey_list = std::vector<PasskeyCredential>{passkey}; EXPECT_CALL(webauthn_credentials_delegate, GetPasskeys) .WillRepeatedly(ReturnRef(passkey_list)); @@ -2093,7 +2093,7 @@ InitializePasswordAutofillManager(&client, &autofill_client); // Enable WebAuthn autofill. - absl::optional<std::vector<PasskeyCredential>> passkeys(absl::in_place); + std::optional<std::vector<PasskeyCredential>> passkeys(std::in_place); EXPECT_CALL(client, GetWebAuthnCredentialsDelegateForDriver) .WillRepeatedly(Return(&webauthn_credentials_delegate)); EXPECT_CALL(webauthn_credentials_delegate, GetPasskeys) @@ -2131,7 +2131,7 @@ InitializePasswordAutofillManager(&client, &autofill_client); // Enable WebAuthn autofill. - absl::optional<std::vector<PasskeyCredential>> passkeys(absl::in_place); + std::optional<std::vector<PasskeyCredential>> passkeys(std::in_place); EXPECT_CALL(client, GetWebAuthnCredentialsDelegateForDriver) .WillRepeatedly(Return(&webauthn_credentials_delegate)); EXPECT_CALL(webauthn_credentials_delegate, GetPasskeys) @@ -2181,7 +2181,7 @@ PasskeyCredential::CredentialId({1, 2, 3, 4}), PasskeyCredential::UserId({1, 2, 3, 4}), PasskeyCredential::Username("nadeshiko@example.com")); - absl::optional<std::vector<PasskeyCredential>> passkeys = + std::optional<std::vector<PasskeyCredential>> passkeys = std::vector{std::move(passkey)}; EXPECT_CALL(client, GetWebAuthnCredentialsDelegateForDriver) .WillRepeatedly(Return(&webauthn_credentials_delegate)); @@ -2223,7 +2223,7 @@ password_autofill_manager_->DeleteFillData(); // Enable WebAuthn autofill. - absl::optional<std::vector<PasskeyCredential>> passkeys(absl::in_place); + std::optional<std::vector<PasskeyCredential>> passkeys(std::in_place); EXPECT_CALL(client, GetWebAuthnCredentialsDelegateForDriver) .WillRepeatedly(Return(&webauthn_credentials_delegate)); EXPECT_CALL(webauthn_credentials_delegate, GetPasskeys)
diff --git a/components/password_manager/core/browser/password_feature_manager_impl.cc b/components/password_manager/core/browser/password_feature_manager_impl.cc index 2960c144..53f93192a 100644 --- a/components/password_manager/core/browser/password_feature_manager_impl.cc +++ b/components/password_manager/core/browser/password_feature_manager_impl.cc
@@ -19,7 +19,7 @@ PasswordFeatureManagerImpl::PasswordFeatureManagerImpl( PrefService* pref_service, PrefService* local_state, - const syncer::SyncService* sync_service) + syncer::SyncService* sync_service) : pref_service_(pref_service), local_state_(local_state), sync_service_(sync_service) {}
diff --git a/components/password_manager/core/browser/password_feature_manager_impl.h b/components/password_manager/core/browser/password_feature_manager_impl.h index d55cef0..944cfef 100644 --- a/components/password_manager/core/browser/password_feature_manager_impl.h +++ b/components/password_manager/core/browser/password_feature_manager_impl.h
@@ -23,7 +23,7 @@ public: PasswordFeatureManagerImpl(PrefService* pref_service, PrefService* local_state, - const syncer::SyncService* sync_service); + syncer::SyncService* sync_service); PasswordFeatureManagerImpl(const PasswordFeatureManagerImpl&) = delete; PasswordFeatureManagerImpl& operator=(const PasswordFeatureManagerImpl&) = @@ -57,7 +57,7 @@ private: const raw_ptr<PrefService> pref_service_; const raw_ptr<PrefService> local_state_; - const raw_ptr<const syncer::SyncService> sync_service_; + const raw_ptr<syncer::SyncService> sync_service_; }; } // namespace password_manager
diff --git a/components/password_manager/core/browser/password_form.h b/components/password_manager/core/browser/password_form.h index 90cd737..ec9e2885 100644 --- a/components/password_manager/core/browser/password_form.h +++ b/components/password_manager/core/browser/password_form.h
@@ -221,7 +221,7 @@ // forms parsed from the web, or manually added in settings don't have this // field set. Also credentials read from sources other than logins database // (e.g. credential manager on Android) don't have this field set. - absl::optional<FormPrimaryKey> primary_key; + std::optional<FormPrimaryKey> primary_key; Scheme scheme = Scheme::kHtml; @@ -424,7 +424,7 @@ // Only available when PasswordForm was requested though // PasswordStoreInterface::GetLogins(), empty otherwise. - absl::optional<MatchType> match_type; + std::optional<MatchType> match_type; // The type of the event that was taken as an indication that this form is // being or has already been submitted. This field is not persisted and filled @@ -606,7 +606,7 @@ static_cast<int>(rhs)); } -constexpr void operator|=(absl::optional<PasswordForm::MatchType>& lhs, +constexpr void operator|=(std::optional<PasswordForm::MatchType>& lhs, PasswordForm::MatchType rhs) { lhs = lhs.has_value() ? (lhs.value() | rhs) : rhs; }
diff --git a/components/password_manager/core/browser/password_form_filling.cc b/components/password_manager/core/browser/password_form_filling.cc index ca45a25..f31783ce 100644 --- a/components/password_manager/core/browser/password_form_filling.cc +++ b/components/password_manager/core/browser/password_form_filling.cc
@@ -73,7 +73,7 @@ const PasswordForm& form_for_autofill, const std::vector<const PasswordForm*>& best_matches, const std::vector<const PasswordForm*>& federated_matches, - absl::optional<PasswordForm> preferred_match, + std::optional<PasswordForm> preferred_match, bool wait_for_username) { std::unique_ptr<BrowserSavePasswordProgressLogger> logger; if (password_manager_util::IsLoggingActive(client)) { @@ -257,7 +257,7 @@ // done. Autofill( client, driver, observed_form, best_matches, federated_matches, - preferred_match ? absl::make_optional(*preferred_match) : absl::nullopt, + preferred_match ? std::make_optional(*preferred_match) : std::nullopt, wait_for_username); return wait_for_username ? LikelyFormFilling::kFillOnAccountSelect @@ -267,7 +267,7 @@ PasswordFormFillData CreatePasswordFormFillData( const PasswordForm& form_on_page, const std::vector<const PasswordForm*>& matches, - absl::optional<PasswordForm> preferred_match, + std::optional<PasswordForm> preferred_match, const Origin& main_frame_origin, bool wait_for_username) { PasswordFormFillData result;
diff --git a/components/password_manager/core/browser/password_form_filling.h b/components/password_manager/core/browser/password_form_filling.h index 691cd47..cb331aab 100644 --- a/components/password_manager/core/browser/password_form_filling.h +++ b/components/password_manager/core/browser/password_form_filling.h
@@ -7,7 +7,7 @@ #include <vector> -#include "third_party/abseil-cpp/absl/types/optional.h" +#include <optional> namespace autofill { struct PasswordFormFillData; @@ -60,7 +60,7 @@ autofill::PasswordFormFillData CreatePasswordFormFillData( const PasswordForm& form_on_page, const std::vector<const PasswordForm*>& matches, - absl::optional<PasswordForm> preferred_match, + std::optional<PasswordForm> preferred_match, const url::Origin& main_frame_origin, bool wait_for_username);
diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc index b1ea1de..1943ac7d 100644 --- a/components/password_manager/core/browser/password_form_manager.cc +++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -51,7 +51,6 @@ #include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/prefs/pref_service.h" #include "components/signin/public/identity_manager/identity_manager.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if BUILDFLAG(IS_ANDROID) #include "components/webauthn/android/webauthn_cred_man_delegate.h" @@ -112,7 +111,7 @@ } bool ShouldShowErrorMessage( - absl::optional<PasswordStoreBackendError> backend_error, + std::optional<PasswordStoreBackendError> backend_error, PasswordManagerClient* client) { if (!backend_error.has_value()) return false; @@ -715,7 +714,7 @@ autofills_left_ = kMaxTimesAutofill; #if BUILDFLAG(IS_ANDROID) - absl::optional<PasswordStoreBackendError> backend_error = + std::optional<PasswordStoreBackendError> backend_error = form_fetcher_->GetProfileStoreBackendError(); if (ShouldShowErrorMessage(backend_error, client_)) { // If there is no FormData, this is an http authentication form. We don't
diff --git a/components/password_manager/core/browser/password_form_manager_unittest.cc b/components/password_manager/core/browser/password_form_manager_unittest.cc index 48d502e..d363f7b 100644 --- a/components/password_manager/core/browser/password_form_manager_unittest.cc +++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -62,7 +62,6 @@ #include "components/ukm/test_ukm_recorder.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if BUILDFLAG(IS_ANDROID) #include "components/webauthn/android/cred_man_support.h" @@ -220,9 +219,9 @@ } struct ExpectedGenerationUKM { - absl::optional<int64_t> generation_popup_shown; + std::optional<int64_t> generation_popup_shown; int64_t has_generated_password; - absl::optional<int64_t> generated_password_modified; + std::optional<int64_t> generated_password_modified; }; // Check that UKM |metric_name| in |entry| is equal to |expected|. |expected| == @@ -504,7 +503,7 @@ NiceMock<MockWebAuthnCredentialsDelegate> webauthn_credentials_delegate_; std::unique_ptr<FieldInfoManager> field_info_manager_; scoped_refptr<TestMockTimeTaskRunner> task_runner_; - absl::optional<std::vector<PasskeyCredential>> passkeys_; + std::optional<std::vector<PasskeyCredential>> passkeys_; // Define |fetcher_| before |form_manager_|, because the former needs to // outlive the latter. @@ -1763,9 +1762,9 @@ // Check UKM metrics. form_manager_.reset(); ExpectedGenerationUKM expected_metrics = { - absl::make_optional(1u) /* shown automatically */, + std::make_optional(1u) /* shown automatically */, 1 /* password generated */, - absl::make_optional(1u) /* password modified */}; + std::make_optional(1u) /* password modified */}; CheckPasswordGenerationUKM(test_ukm_recorder, expected_metrics); } @@ -1809,9 +1808,9 @@ // Check UKM metrics. form_manager_.reset(); ExpectedGenerationUKM expected_metrics = { - absl::make_optional(1u) /* shown automatically */, + std::make_optional(1u) /* shown automatically */, 1 /* password generated */, - absl::make_optional(0u) /* password modified */}; + std::make_optional(0u) /* password modified */}; CheckPasswordGenerationUKM(test_ukm_recorder, expected_metrics); } @@ -1899,7 +1898,7 @@ // Check UKM metrics. form_manager_.reset(); ExpectedGenerationUKM expected_metrics = { - absl::make_optional(2u) /* shown manually */, + std::make_optional(2u) /* shown manually */, 0 /* password generated */, {} /* generated password is not modified */}; @@ -4078,7 +4077,7 @@ TEST_P(PasswordFormManagerTest, ClientShouldNotShowErrorMessageWhenThereIsNoError) { - fetcher_->SetProfileStoreBackendError(absl::nullopt); + fetcher_->SetProfileStoreBackendError(std::nullopt); EXPECT_CALL(client_, ShowPasswordManagerErrorMessage).Times(0); fetcher_->NotifyFetchCompleted(); @@ -4502,7 +4501,7 @@ // Check UKM metrics. ResetFormManager(); ExpectedGenerationUKM expected_metrics = { - absl::make_optional(2u) /* shown manually */, + std::make_optional(2u) /* shown manually */, 0 /* password generated */, {} /* generated password is not modified */}; CheckPasswordGenerationUKM(test_ukm_recorder, expected_metrics);
diff --git a/components/password_manager/core/browser/password_form_metrics_recorder.cc b/components/password_manager/core/browser/password_form_metrics_recorder.cc index 89005c0..c385112 100644 --- a/components/password_manager/core/browser/password_form_metrics_recorder.cc +++ b/components/password_manager/core/browser/password_form_metrics_recorder.cc
@@ -74,7 +74,7 @@ } bool HasGeneratedPassword( - absl::optional<PasswordFormMetricsRecorder::GeneratedPasswordStatus> + std::optional<PasswordFormMetricsRecorder::GeneratedPasswordStatus> status) { return status.has_value() && (status == PasswordFormMetricsRecorder::GeneratedPasswordStatus::
diff --git a/components/password_manager/core/browser/password_form_metrics_recorder.h b/components/password_manager/core/browser/password_form_metrics_recorder.h index 55c6d76..519a4cc6 100644 --- a/components/password_manager/core/browser/password_form_metrics_recorder.h +++ b/components/password_manager/core/browser/password_form_metrics_recorder.h
@@ -9,6 +9,7 @@ #include <map> #include <memory> +#include <optional> #include <set> #include <vector> @@ -21,7 +22,6 @@ #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "services/metrics/public/cpp/ukm_builders.h" #include "services/metrics/public/cpp/ukm_recorder.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" class PrefService; @@ -475,7 +475,7 @@ // Contains the generated password's status, which resulted from a user // action. - absl::optional<GeneratedPasswordStatus> generated_password_status_; + std::optional<GeneratedPasswordStatus> generated_password_status_; // Tracks which bubble is currently being displayed to the user. CurrentBubbleOfInterest current_bubble_ = CurrentBubbleOfInterest::kNone; @@ -500,7 +500,7 @@ // Presumed form type of the form that the PasswordFormManager is managing. // Set after submission, as the form type can change depending on the // user-entered data. - absl::optional<metrics_util::SubmittedFormType> submitted_form_type_; + std::optional<metrics_util::SubmittedFormType> submitted_form_type_; // The UKM SourceId of the document the form belongs to. ukm::SourceId source_id_; @@ -518,9 +518,9 @@ // 1 = the fallback was shown. // 2 = the password was generated. // 4 = this was an update prompt. - absl::optional<uint32_t> showed_manual_fallback_for_saving_; + std::optional<uint32_t> showed_manual_fallback_for_saving_; - absl::optional<uint32_t> form_changes_bitmask_; + std::optional<uint32_t> form_changes_bitmask_; bool recorded_first_filling_result_ = false; @@ -528,18 +528,18 @@ bool recorded_preferred_matched_password_type = false; - absl::optional<FillingAssistance> filling_assistance_; - absl::optional<FillingSource> filling_source_; - absl::optional<features_util::PasswordAccountStorageUsageLevel> + std::optional<FillingAssistance> filling_assistance_; + std::optional<FillingSource> filling_source_; + std::optional<features_util::PasswordAccountStorageUsageLevel> account_storage_usage_level_; - absl::optional<metrics_util::SubmittedFormFrame> submitted_form_frame_; + std::optional<metrics_util::SubmittedFormFrame> submitted_form_frame_; // Whether a single username candidate was populated in prompt. bool possible_username_used_ = false; bool username_updated_in_bubble_ = false; - absl::optional<JsOnlyInput> js_only_input_; + std::optional<JsOnlyInput> js_only_input_; bool is_mixed_content_form_ = false;
diff --git a/components/password_manager/core/browser/password_form_metrics_recorder_unittest.cc b/components/password_manager/core/browser/password_form_metrics_recorder_unittest.cc index e724763c..9501612 100644 --- a/components/password_manager/core/browser/password_form_metrics_recorder_unittest.cc +++ b/components/password_manager/core/browser/password_form_metrics_recorder_unittest.cc
@@ -214,7 +214,7 @@ static constexpr struct { // Stimuli: - absl::optional<metrics_util::SubmittedFormType> form_type; + std::optional<metrics_util::SubmittedFormType> form_type; bool was_form_submitted; // Expectations: bool should_record_metrics; @@ -222,7 +222,7 @@ {metrics_util::SubmittedFormType::kLogin, true, true}, {metrics_util::SubmittedFormType::kSignup, true, true}, {metrics_util::SubmittedFormType::kLogin, false, false}, - {absl::nullopt, true, false}, + {std::nullopt, true, false}, }; for (const auto& test : kTests) { SCOPED_TRACE(testing::Message() @@ -618,7 +618,7 @@ std::vector<std::string> saved_passwords; std::vector<InteractionsStats> interactions_stats; - absl::optional<PasswordFormMetricsRecorder::FillingAssistance> expectation; + std::optional<PasswordFormMetricsRecorder::FillingAssistance> expectation; }; FormData ConvertToFormData(const std::vector<TestCaseFieldInfo>& fields) { @@ -1115,7 +1115,7 @@ std::vector<std::string> saved_account_usernames; std::vector<std::string> saved_account_passwords; - absl::optional<PasswordFormMetricsRecorder::FillingSource> expectation; + std::optional<PasswordFormMetricsRecorder::FillingSource> expectation; }; void CheckFillingSourceTestCase(const FillingSourceTestCase& test_case) {
diff --git a/components/password_manager/core/browser/password_generation_frame_helper.cc b/components/password_manager/core/browser/password_generation_frame_helper.cc index 5947b19..aa787a62 100644 --- a/components/password_manager/core/browser/password_generation_frame_helper.cc +++ b/components/password_manager/core/browser/password_generation_frame_helper.cc
@@ -22,7 +22,6 @@ #include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_requirements_service.h" #include "components/password_manager/core/common/password_manager_features.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" using autofill::AutofillType;
diff --git a/components/password_manager/core/browser/password_generation_manager.h b/components/password_manager/core/browser/password_generation_manager.h index 1fd2090..c3a1dc8 100644 --- a/components/password_manager/core/browser/password_generation_manager.h +++ b/components/password_manager/core/browser/password_generation_manager.h
@@ -7,11 +7,11 @@ #include <map> #include <memory> +#include <optional> #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "components/password_manager/core/browser/password_form.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -91,7 +91,7 @@ // The client for the password form. const raw_ptr<PasswordManagerClient> client_; // Stores the pre-saved credential. - absl::optional<PasswordForm> presaved_; + std::optional<PasswordForm> presaved_; // Stores the initially generated password, i.e. before any user edits. std::u16string initial_generated_password_; // Used to produce callbacks.
diff --git a/components/password_manager/core/browser/password_manager.cc b/components/password_manager/core/browser/password_manager.cc index 978079e98..8aef0328 100644 --- a/components/password_manager/core/browser/password_manager.cc +++ b/components/password_manager/core/browser/password_manager.cc
@@ -1332,11 +1332,11 @@ return nullptr; } -absl::optional<PasswordForm> PasswordManager::GetSubmittedCredentials() { +std::optional<PasswordForm> PasswordManager::GetSubmittedCredentials() { PasswordFormManager* submitted_manager = GetSubmittedManager(); if (submitted_manager) return submitted_manager->GetPendingCredentials(); - return absl::nullopt; + return std::nullopt; } void PasswordManager::ResetSubmittedManager() { @@ -1397,7 +1397,7 @@ return nullptr; } -absl::optional<FormPredictions> PasswordManager::FindPredictionsForField( +std::optional<FormPredictions> PasswordManager::FindPredictionsForField( FieldRendererId field_id, int driver_id) { for (const auto& form : predictions_) { @@ -1410,7 +1410,7 @@ } } } - return absl::nullopt; + return std::nullopt; } void PasswordManager::TryToFindPredictionsToPossibleUsernames() {
diff --git a/components/password_manager/core/browser/password_manager.h b/components/password_manager/core/browser/password_manager.h index 838c41d4..ffb93a0 100644 --- a/components/password_manager/core/browser/password_manager.h +++ b/components/password_manager/core/browser/password_manager.h
@@ -233,7 +233,7 @@ bool IsFormManagerPendingPasswordUpdate() const; // Returns the submitted PasswordForm if there exists one. - absl::optional<PasswordForm> GetSubmittedCredentials(); + std::optional<PasswordForm> GetSubmittedCredentials(); private: FRIEND_TEST_ALL_PREFIXES( @@ -325,7 +325,7 @@ // Finds FormPredictions for a form containing field identified by |field_id| // and |driver_id|. - absl::optional<FormPredictions> FindPredictionsForField( + std::optional<FormPredictions> FindPredictionsForField( autofill::FieldRendererId field_id, int driver_id);
diff --git a/components/password_manager/core/browser/password_manager_metrics_util.cc b/components/password_manager/core/browser/password_manager_metrics_util.cc index 13145959..644fa82 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.cc +++ b/components/password_manager/core/browser/password_manager_metrics_util.cc
@@ -110,7 +110,7 @@ void LogSaveUIDismissalReason( UIDismissalReason reason, - absl::optional< + std::optional< password_manager::features_util::PasswordAccountStorageUserState> user_state) { base::UmaHistogramEnumeration("PasswordManager.SaveUIDismissalReason", reason,
diff --git a/components/password_manager/core/browser/password_manager_metrics_util.h b/components/password_manager/core/browser/password_manager_metrics_util.h index d093f676..43f67bef 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.h +++ b/components/password_manager/core/browser/password_manager_metrics_util.h
@@ -724,7 +724,7 @@ // user-state-specific histogram. void LogSaveUIDismissalReason( UIDismissalReason reason, - absl::optional<features_util::PasswordAccountStorageUserState> user_state); + std::optional<features_util::PasswordAccountStorageUserState> user_state); // Log the |reason| a user dismissed the update password bubble. void LogUpdateUIDismissalReason(UIDismissalReason reason);
diff --git a/components/password_manager/core/browser/password_manager_test_utils.cc b/components/password_manager/core/browser/password_manager_test_utils.cc index 98f17001..30756f70d 100644 --- a/components/password_manager/core/browser/password_manager_test_utils.cc +++ b/components/password_manager/core/browser/password_manager_test_utils.cc
@@ -132,19 +132,21 @@ default; PasswordHashDataMatcher::PasswordHashDataMatcher( - absl::optional<PasswordHashData> expected) + std::optional<PasswordHashData> expected) : expected_(expected) {} PasswordHashDataMatcher::~PasswordHashDataMatcher() = default; bool PasswordHashDataMatcher::MatchAndExplain( - absl::optional<PasswordHashData> hash_data, + std::optional<PasswordHashData> hash_data, ::testing::MatchResultListener* listener) const { - if (expected_ == absl::nullopt) - return hash_data == absl::nullopt; + if (expected_ == std::nullopt) { + return hash_data == std::nullopt; + } - if (hash_data == absl::nullopt) + if (hash_data == std::nullopt) { return false; + } return expected_->username == hash_data->username && expected_->length == hash_data->length && @@ -159,8 +161,8 @@ *os << "doesn't match password hash data for " << expected_->username; } -::testing::Matcher<absl::optional<PasswordHashData>> Matches( - absl::optional<PasswordHashData> expected) { +::testing::Matcher<std::optional<PasswordHashData>> Matches( + std::optional<PasswordHashData> expected) { return ::testing::MakeMatcher(new PasswordHashDataMatcher(expected)); }
diff --git a/components/password_manager/core/browser/password_manager_test_utils.h b/components/password_manager/core/browser/password_manager_test_utils.h index cb72d57..08bc4150 100644 --- a/components/password_manager/core/browser/password_manager_test_utils.h +++ b/components/password_manager/core/browser/password_manager_test_utils.h
@@ -151,7 +151,7 @@ OnReuseCheckDone, (bool, size_t, - absl::optional<PasswordHashData>, + std::optional<PasswordHashData>, const std::vector<MatchingReusedCredential>&, int, const std::string&, @@ -161,9 +161,9 @@ // Matcher class used to compare PasswordHashData in tests. class PasswordHashDataMatcher - : public ::testing::MatcherInterface<absl::optional<PasswordHashData>> { + : public ::testing::MatcherInterface<std::optional<PasswordHashData>> { public: - explicit PasswordHashDataMatcher(absl::optional<PasswordHashData> expected); + explicit PasswordHashDataMatcher(std::optional<PasswordHashData> expected); PasswordHashDataMatcher(const PasswordHashDataMatcher&) = delete; PasswordHashDataMatcher& operator=(const PasswordHashDataMatcher&) = delete; @@ -171,17 +171,17 @@ ~PasswordHashDataMatcher() override; // ::testing::MatcherInterface overrides - bool MatchAndExplain(absl::optional<PasswordHashData> hash_data, + bool MatchAndExplain(std::optional<PasswordHashData> hash_data, ::testing::MatchResultListener* listener) const override; void DescribeTo(::std::ostream* os) const override; void DescribeNegationTo(::std::ostream* os) const override; private: - const absl::optional<PasswordHashData> expected_; + const std::optional<PasswordHashData> expected_; }; -::testing::Matcher<absl::optional<PasswordHashData>> Matches( - absl::optional<PasswordHashData> expected); +::testing::Matcher<std::optional<PasswordHashData>> Matches( + std::optional<PasswordHashData> expected); } // namespace password_manager
diff --git a/components/password_manager/core/browser/password_manager_unittest.cc b/components/password_manager/core/browser/password_manager_unittest.cc index dba4d0d..bdff48ca 100644 --- a/components/password_manager/core/browser/password_manager_unittest.cc +++ b/components/password_manager/core/browser/password_manager_unittest.cc
@@ -6,6 +6,7 @@ #include <limits> #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -67,7 +68,6 @@ #include "services/network/test/test_network_context.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if BUILDFLAG(IS_ANDROID) #include "components/webauthn/android/cred_man_support.h" @@ -267,7 +267,7 @@ mutable FakeNetworkContext network_context_; testing::NiceMock<MockStoreResultFilter> filter_; MockWebAuthnCredentialsDelegate webauthn_credentials_delegate_; - absl::optional<std::vector<PasskeyCredential>> passkeys_; + std::optional<std::vector<PasskeyCredential>> passkeys_; }; class MockPasswordManagerDriver : public StubPasswordManagerDriver { @@ -3273,8 +3273,8 @@ // A convenience helper for type conversions. template <typename T> -absl::optional<int64_t> MetricValue(T value) { - return absl::optional<int64_t>(static_cast<int64_t>(value)); +std::optional<int64_t> MetricValue(T value) { + return std::optional<int64_t>(static_cast<int64_t>(value)); } struct MissingFormManagerTestCase { @@ -3289,8 +3289,8 @@ // A list of forms to be processed for saving, one at a time. std::vector<FormData> processed_form_data; // The expected value of the PageWithPassword::kFormManagerAvailableName - // metric, or absl::nullopt if no value should be logged. - absl::optional<int64_t> expected_metric_value; + // metric, or std::nullopt if no value should be logged. + std::optional<int64_t> expected_metric_value; }; } // namespace @@ -3359,7 +3359,7 @@ .save_signal = MissingFormManagerTestCase::Signal::None, .parsed_forms_data = {}, .processed_form_data = {}, - .expected_metric_value = absl::nullopt, + .expected_metric_value = std::nullopt, }, { .description = "Not enabled, no report.", @@ -3367,7 +3367,7 @@ .save_signal = MissingFormManagerTestCase::Signal::Automatic, .parsed_forms_data = {form_data}, .processed_form_data = {form_data}, - .expected_metric_value = absl::nullopt, + .expected_metric_value = std::nullopt, }, }; @@ -5366,8 +5366,8 @@ : public PasswordManagerTest, public testing::WithParamInterface<std::tuple< /*saved_form.username=*/std::u16string, - /*saved_form.password=*/absl::optional<std::u16string>, - /*another_saved_form.password_value=*/absl::optional<std::u16string>, + /*saved_form.password=*/std::optional<std::u16string>, + /*another_saved_form.password_value=*/std::optional<std::u16string>, /*one_time_code_form.username_value=*/std::u16string, PredictionSource>> { protected: @@ -5388,8 +5388,8 @@ EXPECT_CALL(client_, IsSavingAndFillingEnabled(_)) .WillRepeatedly(Return(true)); - absl::optional<PasswordForm> saved_form; - absl::optional<PasswordForm> another_saved_form; + std::optional<PasswordForm> saved_form; + std::optional<PasswordForm> another_saved_form; // No saved password means no saved credential. if (saved_form_password.has_value()) { saved_form = PasswordForm(); @@ -5410,7 +5410,7 @@ another_saved_form_password.value(); store_->AddLogin(another_saved_form.value()); } else { - another_saved_form = absl::nullopt; + another_saved_form = std::nullopt; } } @@ -5541,8 +5541,8 @@ All, PasswordManagerWithOtpVariationsTest, testing::Combine(testing::Values(u"", u"username"), - testing::Values(u"password", absl::nullopt), - testing::Values(u"another_password", absl::nullopt), + testing::Values(u"password", std::nullopt), + testing::Values(u"another_password", std::nullopt), testing::Values(u"", u"username", u"+1 650 000 000"), testing::Values(PredictionSource::ID_ATTRIBUTE, PredictionSource::NAME_ATTRIBUTE,
diff --git a/components/password_manager/core/browser/password_reuse_detector.cc b/components/password_manager/core/browser/password_reuse_detector.cc index 286b3d20a..0ff65a7 100644 --- a/components/password_manager/core/browser/password_reuse_detector.cc +++ b/components/password_manager/core/browser/password_reuse_detector.cc
@@ -5,6 +5,7 @@ #include "components/password_manager/core/browser/password_reuse_detector.h" #include <algorithm> +#include <optional> #include <utility> #include "base/containers/contains.h" @@ -43,10 +44,10 @@ // Helper function to returns matching PasswordHashData from a list that has // the longest password length. -absl::optional<PasswordHashData> FindPasswordReuse( +std::optional<PasswordHashData> FindPasswordReuse( const std::u16string& input, const std::vector<PasswordHashData>& password_hash_list) { - absl::optional<PasswordHashData> longest_match = absl::nullopt; + std::optional<PasswordHashData> longest_match = std::nullopt; size_t longest_match_size = 0; for (const PasswordHashData& hash_data : password_hash_list) { if (input.size() < hash_data.length) @@ -143,18 +144,18 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(consumer); if (input.size() < GetMinPasswordLengthToCheck()) { - consumer->OnReuseCheckDone(false, 0, absl::nullopt, {}, + consumer->OnReuseCheckDone(false, 0, std::nullopt, {}, SavedPasswordsCount(), std::string(), 0); return; } - absl::optional<PasswordHashData> reused_gaia_password_hash = + std::optional<PasswordHashData> reused_gaia_password_hash = CheckGaiaPasswordReuse(input, domain); size_t gaia_reused_password_length = reused_gaia_password_hash.has_value() ? reused_gaia_password_hash->length : 0; - absl::optional<PasswordHashData> reused_enterprise_password_hash = + std::optional<PasswordHashData> reused_enterprise_password_hash = CheckNonGaiaEnterprisePasswordReuse(input, domain); size_t enterprise_reused_password_length = reused_enterprise_password_hash.has_value() @@ -171,7 +172,7 @@ enterprise_reused_password_length}); if (max_reused_password_length == 0) { - consumer->OnReuseCheckDone(false, 0, absl::nullopt, {}, + consumer->OnReuseCheckDone(false, 0, std::nullopt, {}, SavedPasswordsCount(), std::string(), 0); return; } @@ -179,8 +180,7 @@ uint64_t reused_password_hash = CalculatePasswordHash(saved_reused_password, std::string()); - absl::optional<PasswordHashData> reused_protected_password_hash = - absl::nullopt; + std::optional<PasswordHashData> reused_protected_password_hash = std::nullopt; if (gaia_reused_password_length > enterprise_reused_password_length) { reused_password_hash = reused_gaia_password_hash->hash; reused_protected_password_hash = std::move(reused_gaia_password_hash); @@ -195,30 +195,31 @@ domain, reused_password_hash); } -absl::optional<PasswordHashData> PasswordReuseDetector::CheckGaiaPasswordReuse( +std::optional<PasswordHashData> PasswordReuseDetector::CheckGaiaPasswordReuse( const std::u16string& input, const std::string& domain) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!gaia_password_hash_data_list_.has_value() || gaia_password_hash_data_list_->empty()) { - return absl::nullopt; + return std::nullopt; } // Skips password reuse check if |domain| matches Gaia origin. - if (gaia::HasGaiaSchemeHostPort(GURL(domain))) - return absl::nullopt; + if (gaia::HasGaiaSchemeHostPort(GURL(domain))) { + return std::nullopt; + } return FindPasswordReuse(input, gaia_password_hash_data_list_.value()); } -absl::optional<PasswordHashData> +std::optional<PasswordHashData> PasswordReuseDetector::CheckNonGaiaEnterprisePasswordReuse( const std::u16string& input, const std::string& domain) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!enterprise_password_hash_data_list_.has_value() || enterprise_password_hash_data_list_->empty()) { - return absl::nullopt; + return std::nullopt; } // Skips password reuse check if |domain| matches enterprise login URL or @@ -227,7 +228,7 @@ if (enterprise_password_urls_.has_value() && safe_browsing::MatchesURLList(page_url, enterprise_password_urls_.value())) { - return absl::nullopt; + return std::nullopt; } return FindPasswordReuse(input, enterprise_password_hash_data_list_.value()); @@ -285,20 +286,20 @@ } void PasswordReuseDetector::UseGaiaPasswordHash( - absl::optional<std::vector<PasswordHashData>> password_hash_data_list) { + std::optional<std::vector<PasswordHashData>> password_hash_data_list) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); gaia_password_hash_data_list_ = std::move(password_hash_data_list); } void PasswordReuseDetector::UseNonGaiaEnterprisePasswordHash( - absl::optional<std::vector<PasswordHashData>> password_hash_data_list) { + std::optional<std::vector<PasswordHashData>> password_hash_data_list) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); enterprise_password_hash_data_list_ = std::move(password_hash_data_list); } void PasswordReuseDetector::UseEnterprisePasswordURLs( - absl::optional<std::vector<GURL>> enterprise_login_urls, - absl::optional<GURL> enterprise_change_password_url) { + std::optional<std::vector<GURL>> enterprise_login_urls, + std::optional<GURL> enterprise_change_password_url) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); enterprise_password_urls_ = std::move(enterprise_login_urls); if (!enterprise_change_password_url.has_value() || @@ -306,8 +307,9 @@ return; } - if (!enterprise_password_urls_) - enterprise_password_urls_ = absl::make_optional<std::vector<GURL>>(); + if (!enterprise_password_urls_) { + enterprise_password_urls_ = std::make_optional<std::vector<GURL>>(); + } enterprise_password_urls_->push_back(enterprise_change_password_url.value()); }
diff --git a/components/password_manager/core/browser/password_reuse_detector.h b/components/password_manager/core/browser/password_reuse_detector.h index 520780c0..32f9ef18 100644 --- a/components/password_manager/core/browser/password_reuse_detector.h +++ b/components/password_manager/core/browser/password_reuse_detector.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <map> #include <memory> +#include <optional> #include <set> #include <string> #include <vector> @@ -15,7 +16,6 @@ #include "components/password_manager/core/browser/hash_password_manager.h" #include "components/password_manager/core/browser/password_form.h" #include "components/password_manager/core/browser/password_store/password_store_change.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -83,17 +83,17 @@ // Stores a vector of PasswordHashData for Gaia password reuse checking. void UseGaiaPasswordHash( - absl::optional<std::vector<PasswordHashData>> password_hash_data_list); + std::optional<std::vector<PasswordHashData>> password_hash_data_list); // Stores a vector of PasswordHashData for enterprise password reuse checking. void UseNonGaiaEnterprisePasswordHash( - absl::optional<std::vector<PasswordHashData>> password_hash_data_list); + std::optional<std::vector<PasswordHashData>> password_hash_data_list); // Stores enterprise login URLs and change password URL. // These URLs should be skipped in enterprise password reuse checking. void UseEnterprisePasswordURLs( - absl::optional<std::vector<GURL>> enterprise_login_urls, - absl::optional<GURL> enterprise_change_password_url); + std::optional<std::vector<GURL>> enterprise_login_urls, + std::optional<GURL> enterprise_change_password_url); void ClearGaiaPasswordHash(const std::string& username); @@ -120,14 +120,14 @@ void RemovePassword(const PasswordForm& form); // If Gaia password reuse is found, return the PasswordHashData of the reused - // password. If no reuse is found, return |absl::nullopt|. - absl::optional<PasswordHashData> CheckGaiaPasswordReuse( + // password. If no reuse is found, return |std::nullopt|. + std::optional<PasswordHashData> CheckGaiaPasswordReuse( const std::u16string& input, const std::string& domain); // If Non-Gaia enterprise password reuse is found, return the PasswordHashData - // of the the reused password. If no reuse is found, return |absl::nullopt|. - absl::optional<PasswordHashData> CheckNonGaiaEnterprisePasswordReuse( + // of the the reused password. If no reuse is found, return |std::nullopt|. + std::optional<PasswordHashData> CheckNonGaiaEnterprisePasswordReuse( const std::u16string& input, const std::string& domain); @@ -176,13 +176,13 @@ PasswordsReusedCredentialsMap passwords_with_matching_reused_credentials_ GUARDED_BY_CONTEXT(sequence_checker_); - absl::optional<std::vector<PasswordHashData>> gaia_password_hash_data_list_ + std::optional<std::vector<PasswordHashData>> gaia_password_hash_data_list_ GUARDED_BY_CONTEXT(sequence_checker_); - absl::optional<std::vector<PasswordHashData>> + std::optional<std::vector<PasswordHashData>> enterprise_password_hash_data_list_ GUARDED_BY_CONTEXT(sequence_checker_); - absl::optional<std::vector<GURL>> enterprise_password_urls_ + std::optional<std::vector<GURL>> enterprise_password_urls_ GUARDED_BY_CONTEXT(sequence_checker_); };
diff --git a/components/password_manager/core/browser/password_reuse_detector_consumer.h b/components/password_manager/core/browser/password_reuse_detector_consumer.h index 12ba2d6..bd290666 100644 --- a/components/password_manager/core/browser/password_reuse_detector_consumer.h +++ b/components/password_manager/core/browser/password_reuse_detector_consumer.h
@@ -5,11 +5,11 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_REUSE_DETECTOR_CONSUMER_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_REUSE_DETECTOR_CONSUMER_H_ +#include <optional> #include <vector> #include "base/memory/weak_ptr.h" #include "components/password_manager/core/browser/hash_password_manager.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -38,7 +38,7 @@ virtual void OnReuseCheckDone( bool is_reuse_found, size_t password_length, - absl::optional<PasswordHashData> reused_protected_password_hash, + std::optional<PasswordHashData> reused_protected_password_hash, const std::vector<MatchingReusedCredential>& matching_reused_credentials, int saved_passwords, const std::string& domain,
diff --git a/components/password_manager/core/browser/password_reuse_detector_unittest.cc b/components/password_manager/core/browser/password_reuse_detector_unittest.cc index 9c63361..e5d1ecb 100644 --- a/components/password_manager/core/browser/password_reuse_detector_unittest.cc +++ b/components/password_manager/core/browser/password_reuse_detector_unittest.cc
@@ -5,6 +5,7 @@ #include "components/password_manager/core/browser/password_reuse_detector.h" #include <memory> +#include <optional> #include <string> #include <vector> @@ -30,8 +31,8 @@ using StringVector = std::vector<std::string>; // Constants to make the tests more readable. -const absl::optional<PasswordHashData> NO_GAIA_OR_ENTERPRISE_REUSE = - absl::nullopt; +const std::optional<PasswordHashData> NO_GAIA_OR_ENTERPRISE_REUSE = + std::nullopt; struct TestData { // Comma separated list of domains. @@ -116,8 +117,8 @@ void ConfigureEnterprisePasswordProtection( PasswordReuseDetector* reuse_detector) { - absl::optional<std::vector<GURL>> login_urls = - absl::make_optional<std::vector<GURL>>(); + std::optional<std::vector<GURL>> login_urls = + std::make_optional<std::vector<GURL>>(); login_urls->push_back(GURL("https://login.example.com")); reuse_detector->UseEnterprisePasswordURLs( login_urls, GURL("https://changepassword.example.com/")); @@ -439,7 +440,7 @@ std::vector<PasswordHashData> gaia_password_hashes = PrepareGaiaPasswordData({"gaia_pw1", "gaia_pw2"}); - absl::optional<PasswordHashData> expected_reused_password_hash( + std::optional<PasswordHashData> expected_reused_password_hash( gaia_password_hashes[0]); reuse_detector.UseGaiaPasswordHash(gaia_password_hashes); @@ -460,7 +461,7 @@ std::vector<PasswordHashData> enterprise_password_hashes = PrepareEnterprisePasswordData({"enterprise_pw1", "enterprise_pw2"}); - absl::optional<PasswordHashData> expected_reused_password_hash( + std::optional<PasswordHashData> expected_reused_password_hash( enterprise_password_hashes[1]); reuse_detector.UseNonGaiaEnterprisePasswordHash(enterprise_password_hashes); @@ -488,7 +489,7 @@ std::vector<PasswordHashData> enterprise_password_hashes = PrepareEnterprisePasswordData({"enterprise_pw1", "enterprise_pw2"}); - absl::optional<PasswordHashData> expected_reused_password_hash( + std::optional<PasswordHashData> expected_reused_password_hash( enterprise_password_hashes[1]); reuse_detector.UseNonGaiaEnterprisePasswordHash(enterprise_password_hashes); @@ -512,7 +513,7 @@ std::vector<PasswordHashData> gaia_password_hashes = PrepareGaiaPasswordData({gaia_password}); ASSERT_EQ(1u, gaia_password_hashes.size()); - absl::optional<PasswordHashData> expected_reused_password_hash( + std::optional<PasswordHashData> expected_reused_password_hash( gaia_password_hashes[0]); reuse_detector.UseGaiaPasswordHash(gaia_password_hashes); @@ -605,7 +606,7 @@ std::vector<PasswordHashData> enterprise_password_hashes = PrepareEnterprisePasswordData({enterprise_password}); ASSERT_EQ(1u, enterprise_password_hashes.size()); - absl::optional<PasswordHashData> expected_reused_password_hash( + std::optional<PasswordHashData> expected_reused_password_hash( enterprise_password_hashes[0]); reuse_detector.UseNonGaiaEnterprisePasswordHash(enterprise_password_hashes); @@ -673,7 +674,7 @@ std::vector<PasswordHashData> enterprise_password_hashes = PrepareEnterprisePasswordData({enterprise_password}); ASSERT_EQ(1u, enterprise_password_hashes.size()); - absl::optional<PasswordHashData> expected_reused_password_hash( + std::optional<PasswordHashData> expected_reused_password_hash( enterprise_password_hashes[0]); reuse_detector.UseNonGaiaEnterprisePasswordHash(enterprise_password_hashes);
diff --git a/components/password_manager/core/browser/password_reuse_manager_impl.cc b/components/password_manager/core/browser/password_reuse_manager_impl.cc index 26b4fe04..c29e546 100644 --- a/components/password_manager/core/browser/password_reuse_manager_impl.cc +++ b/components/password_manager/core/browser/password_reuse_manager_impl.cc
@@ -5,6 +5,7 @@ #include "components/password_manager/core/browser/password_reuse_manager_impl.h" #include <memory> +#include <optional> #include <string> #include <vector> @@ -17,7 +18,6 @@ #include "components/password_manager/core/common/password_manager_features.h" #include "components/prefs/pref_service.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using base::RecordAction; using base::UserMetricsAction; @@ -52,7 +52,7 @@ void OnReuseCheckDone( bool is_reuse_found, size_t password_length, - absl::optional<PasswordHashData> reused_protected_password_hash, + std::optional<PasswordHashData> reused_protected_password_hash, const std::vector<MatchingReusedCredential>& matching_reused_credentials, int saved_passwords, const std::string& domain, @@ -72,7 +72,7 @@ void CheckReuseRequest::OnReuseCheckDone( bool is_reuse_found, size_t password_length, - absl::optional<PasswordHashData> reused_protected_password_hash, + std::optional<PasswordHashData> reused_protected_password_hash, const std::vector<MatchingReusedCredential>& matching_reused_credentials, int saved_passwords, const std::string& domain, @@ -174,8 +174,7 @@ PasswordReuseDetectorConsumer* consumer) { DCHECK(main_task_runner_->RunsTasksInCurrentSequence()); if (!reuse_detector_) { - consumer->OnReuseCheckDone(false, 0, absl::nullopt, {}, 0, std::string(), - 0); + consumer->OnReuseCheckDone(false, 0, std::nullopt, {}, 0, std::string(), 0); return; } ScheduleTask(base::BindOnce( @@ -229,7 +228,7 @@ is_sync_password_for_metrics); } // This method is not being called on startup so it shouldn't log metrics. - SchedulePasswordHashUpdate(/*sign_in_state_for_metrics=*/absl::nullopt); + SchedulePasswordHashUpdate(/*sign_in_state_for_metrics=*/std::nullopt); } } @@ -240,7 +239,7 @@ if (hash_password_manager_.SavePasswordHash(sync_password_data)) { metrics_util::LogGaiaPasswordHashChange(event, /*is_sync_password=*/true); - SchedulePasswordHashUpdate(/*sign_in_state_for_metrics=*/absl::nullopt); + SchedulePasswordHashUpdate(/*sign_in_state_for_metrics=*/std::nullopt); } } @@ -303,7 +302,7 @@ } void PasswordReuseManagerImpl::SchedulePasswordHashUpdate( - absl::optional<metrics_util::SignInState> sign_in_state_for_metrics) { + std::optional<metrics_util::SignInState> sign_in_state_for_metrics) { DCHECK(main_task_runner_->RunsTasksInCurrentSequence()); if (!reuse_detector_) {
diff --git a/components/password_manager/core/browser/password_reuse_manager_impl.h b/components/password_manager/core/browser/password_reuse_manager_impl.h index 9821f82..42ebaf2 100644 --- a/components/password_manager/core/browser/password_reuse_manager_impl.h +++ b/components/password_manager/core/browser/password_reuse_manager_impl.h
@@ -6,6 +6,7 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_REUSE_MANAGER_IMPL_H_ #include <memory> +#include <optional> #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" @@ -14,7 +15,6 @@ #include "components/password_manager/core/browser/password_reuse_manager.h" #include "components/password_manager/core/browser/password_store/password_store_consumer.h" #include "components/password_manager/core/browser/password_store/password_store_interface.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -69,7 +69,7 @@ // Schedules the update of password hashes used by reuse detector. // |sign_in_state_for_metrics|, if not nullopt, is used for metrics only. void SchedulePasswordHashUpdate( - absl::optional<metrics_util::SignInState> sign_in_state_for_metrics); + std::optional<metrics_util::SignInState> sign_in_state_for_metrics); // Executed deferred on Android in order avoid high startup latencies. void RequestLoginsFromStores();
diff --git a/components/password_manager/core/browser/password_reuse_manager_impl_unittest.cc b/components/password_manager/core/browser/password_reuse_manager_impl_unittest.cc index 24ac1d2..5ced30e 100644 --- a/components/password_manager/core/browser/password_reuse_manager_impl_unittest.cc +++ b/components/password_manager/core/browser/password_reuse_manager_impl_unittest.cc
@@ -49,7 +49,7 @@ return form; } -absl::optional<PasswordHashData> GetPasswordFromPref( +std::optional<PasswordHashData> GetPasswordFromPref( const std::string& username, bool is_gaia_password, TestingPrefServiceSimple& prefs) { @@ -149,7 +149,7 @@ PasswordForm::Store::kProfileStore}}; EXPECT_CALL(mock_consumer, OnReuseCheckDone(true, test_data.reused_password_len, - Matches(absl::nullopt), + Matches(std::nullopt), ElementsAreArray(credentials), 2, _, _)); } else { EXPECT_CALL(mock_consumer, OnReuseCheckDone(false, _, _, _, _, _, _)); @@ -174,7 +174,7 @@ RunUntilIdle(); EXPECT_TRUE(prefs().HasPrefPath(prefs::kPasswordHashDataList)); - absl::optional<PasswordHashData> sync_password_hash = + std::optional<PasswordHashData> sync_password_hash = GetPasswordFromPref("sync_username", /*is_gaia_password=*/true, prefs()); EXPECT_TRUE(sync_password_hash.has_value()); @@ -197,7 +197,7 @@ "other_gaia_username", gaia_password, /*is_primary_account=*/false, GaiaPasswordHashChange::NOT_SYNC_PASSWORD_CHANGE); - absl::optional<PasswordHashData> gaia_password_hash = GetPasswordFromPref( + std::optional<PasswordHashData> gaia_password_hash = GetPasswordFromPref( "other_gaia_username", /*is_gaia_password=*/true, prefs()); ASSERT_TRUE(gaia_password_hash.has_value()); @@ -220,7 +220,7 @@ "sync_username", gaia_password, /*is_primary_account=*/true, metrics_util::GaiaPasswordHashChange::SAVED_ON_CHROME_SIGNIN); - absl::optional<PasswordHashData> gaia_password_hash = + std::optional<PasswordHashData> gaia_password_hash = GetPasswordFromPref("sync_username", /*is_gaia_password=*/true, prefs()); ASSERT_TRUE(gaia_password_hash.has_value()); @@ -244,7 +244,7 @@ "other_gaia_username", gaia_password, /*is_primary_account=*/false, GaiaPasswordHashChange::NOT_SYNC_PASSWORD_CHANGE); - absl::optional<PasswordHashData> gaia_password_hash = GetPasswordFromPref( + std::optional<PasswordHashData> gaia_password_hash = GetPasswordFromPref( "other_gaia_username", /*is_gaia_password=*/true, prefs()); ASSERT_TRUE(gaia_password_hash.has_value()); @@ -266,7 +266,7 @@ const std::u16string enterprise_password = u"23password"; reuse_manager()->SaveEnterprisePasswordHash("enterprise_username", enterprise_password); - absl::optional<PasswordHashData> enterprise_password_hash = + std::optional<PasswordHashData> enterprise_password_hash = GetPasswordFromPref("enterprise_username", /*is_gaia_password=*/false, prefs()); ASSERT_TRUE(enterprise_password_hash.has_value()); @@ -287,7 +287,7 @@ const std::u16string enterprise_password = u"23password"; reuse_manager()->SaveEnterprisePasswordHash("enterprise_username", enterprise_password); - absl::optional<PasswordHashData> enterprise_password_hash = + std::optional<PasswordHashData> enterprise_password_hash = GetPasswordFromPref("enterprise_username", /*is_gaia_password=*/false, prefs()); ASSERT_TRUE(enterprise_password_hash.has_value()); @@ -311,7 +311,7 @@ "non_sync_gaia_password@gsuite.com", non_sync_gaia_password, /*is_primary_account=*/false, GaiaPasswordHashChange::NOT_SYNC_PASSWORD_CHANGE); - absl::optional<PasswordHashData> non_sync_gaia_password_hash = + std::optional<PasswordHashData> non_sync_gaia_password_hash = GetPasswordFromPref("non_sync_gaia_password@gsuite.com", /*is_gaia_password=*/true, prefs()); ASSERT_TRUE(non_sync_gaia_password_hash.has_value()); @@ -323,7 +323,7 @@ GaiaPasswordHashChange::NOT_SYNC_PASSWORD_CHANGE); RunUntilIdle(); EXPECT_TRUE(prefs().HasPrefPath(prefs::kPasswordHashDataList)); - absl::optional<PasswordHashData> gmail_password_hash = GetPasswordFromPref( + std::optional<PasswordHashData> gmail_password_hash = GetPasswordFromPref( "username@gmail.com", /*is_gaia_password=*/true, prefs()); ASSERT_TRUE(gmail_password_hash.has_value()); @@ -411,7 +411,7 @@ mock_consumer, OnReuseCheckDone( /* is_reuse_found=*/true, /*password_length=*/8, - Matches(absl::nullopt), + Matches(std::nullopt), UnorderedElementsAreArray(std::vector<MatchingReusedCredential>{ {"https://www.google.com", u"username1", PasswordForm::Store::kProfileStore},
diff --git a/components/password_manager/core/browser/password_save_manager_impl.cc b/components/password_manager/core/browser/password_save_manager_impl.cc index a5fca9353..6dbcb6d0 100644 --- a/components/password_manager/core/browser/password_save_manager_impl.cc +++ b/components/password_manager/core/browser/password_save_manager_impl.cc
@@ -150,7 +150,8 @@ PendingCredentialsState ComputePendingCredentialsState( const PasswordForm& parsed_submitted_form, - const PasswordForm* similar_saved_form) { + const PasswordForm* similar_saved_form, + PasswordGenerationManager* generation_manager) { AlternativeElement password_to_save(PasswordToSave(parsed_submitted_form)); // Check if there are previously saved credentials (that were available to // autofilling) matching the actually submitted credentials. @@ -158,6 +159,18 @@ return PendingCredentialsState::NEW_LOGIN; } + if (generation_manager && generation_manager->HasGeneratedPassword() && + generation_manager->generated_password() == password_to_save.value && + parsed_submitted_form.username_value == u"" && + similar_saved_form->username_value == u"") { + // This is the special corner case when a generated password is being saved + // with an empty username, while another generated password with an empty + // username is already being stored. In this case, just silently update the + // password (the allowance to update is asked before filling the form in + // this case). + return PendingCredentialsState::EQUAL_TO_SAVED_MATCH; + } + // A similar credential exists in the store already. if (similar_saved_form->password_value != password_to_save.value) { return PendingCredentialsState::UPDATE; @@ -177,7 +190,8 @@ PendingCredentialsStates ComputePendingCredentialsStates( const PasswordForm& parsed_submitted_form, const std::vector<const PasswordForm*>& matches, - bool username_updated_in_bubble) { + bool username_updated_in_bubble, + PasswordGenerationManager* generation_manager) { PendingCredentialsStates result; // Try to find a similar existing saved form from each of the stores. @@ -193,9 +207,11 @@ // Compute the PendingCredentialsState (i.e. what to do - save, update, silent // update) separately for the two stores. result.profile_store_state = ComputePendingCredentialsState( - parsed_submitted_form, result.similar_saved_form_from_profile_store); + parsed_submitted_form, result.similar_saved_form_from_profile_store, + generation_manager); result.account_store_state = ComputePendingCredentialsState( - parsed_submitted_form, result.similar_saved_form_from_account_store); + parsed_submitted_form, result.similar_saved_form_from_account_store, + generation_manager); return result; } @@ -536,7 +552,7 @@ // login. This entails that the credentials must exist in the profile store. PendingCredentialsStates states = ComputePendingCredentialsStates( pending_credentials_, form_fetcher_->GetAllRelevantMatches(), - username_updated_in_bubble_); + username_updated_in_bubble_, generation_manager_.get()); DCHECK(states.similar_saved_form_from_profile_store); DCHECK_EQ(PendingCredentialsState::EQUAL_TO_SAVED_MATCH, states.profile_store_state); @@ -674,7 +690,7 @@ const PasswordForm& parsed_submitted_form) const { PendingCredentialsStates states = ComputePendingCredentialsStates( parsed_submitted_form, form_fetcher_->GetBestMatches(), - username_updated_in_bubble_); + username_updated_in_bubble_, generation_manager_.get()); // Resolve the two states to a single canonical one. This will be used to // decide what UI bubble (if any) to show to the user. @@ -713,7 +729,8 @@ const PasswordForm& parsed_submitted_form) { auto matches = form_fetcher_->GetAllRelevantMatches(); PendingCredentialsStates states = ComputePendingCredentialsStates( - parsed_submitted_form, matches, username_updated_in_bubble_); + parsed_submitted_form, matches, username_updated_in_bubble_, + generation_manager_.get()); auto account_matches = AccountStoreMatches(matches); auto profile_matches = ProfileStoreMatches(matches);
diff --git a/components/password_manager/core/browser/password_save_manager_impl_unittest.cc b/components/password_manager/core/browser/password_save_manager_impl_unittest.cc index 4123344..2459a6c 100644 --- a/components/password_manager/core/browser/password_save_manager_impl_unittest.cc +++ b/components/password_manager/core/browser/password_save_manager_impl_unittest.cc
@@ -81,9 +81,9 @@ } struct ExpectedGenerationUKM { - absl::optional<int64_t> generation_popup_shown; + std::optional<int64_t> generation_popup_shown; int64_t has_generated_password; - absl::optional<int64_t> generated_password_modified; + std::optional<int64_t> generated_password_modified; }; // Check that UKM |metric_name| in |entry| is equal to |expected|. |expected| == @@ -1377,6 +1377,25 @@ password_save_manager_impl()->Save(&observed_form_, saved_shared_credentials); } +TEST_P(PasswordSaveManagerImplTest, + PresavedGeneratedPasswordWithEmptyUsernameUpdate) { + fetcher()->NotifyFetchCompleted(); + + PasswordForm form_with_generated_password = parsed_submitted_form_; + form_with_generated_password.username_value = u""; + + password_save_manager_impl()->PresaveGeneratedPassword( + form_with_generated_password); + password_save_manager_impl()->CreatePendingCredentials( + form_with_generated_password, &observed_form_, submitted_form_, + /*is_http_auth=*/false, + /*is_credential_api_save=*/false); + + // Do not consider as update if there is a pre-saved generated password with + // the same value. + ASSERT_FALSE(password_save_manager_impl()->IsPasswordUpdate()); +} + INSTANTIATE_TEST_SUITE_P(, PasswordSaveManagerImplTest, testing::Values(false, true));
diff --git a/components/password_manager/core/browser/password_session_durations_metrics_recorder.cc b/components/password_manager/core/browser/password_session_durations_metrics_recorder.cc index aceca5b6..e2016871 100644 --- a/components/password_manager/core/browser/password_session_durations_metrics_recorder.cc +++ b/components/password_manager/core/browser/password_session_durations_metrics_recorder.cc
@@ -29,12 +29,6 @@ syncer::SyncService* sync_service) : pref_service_(pref_service), sync_service_(sync_service), - settings_watcher_( - pref_service_, - sync_service_, - base::BindRepeating( - &PasswordSessionDurationsMetricsRecorder::CheckForUserStateChange, - base::Unretained(this))), user_state_(features_util::ComputePasswordAccountStorageUserState( pref_service_, sync_service_)) {
diff --git a/components/password_manager/core/browser/password_session_durations_metrics_recorder.h b/components/password_manager/core/browser/password_session_durations_metrics_recorder.h index 919fb06..10c1e34 100644 --- a/components/password_manager/core/browser/password_session_durations_metrics_recorder.h +++ b/components/password_manager/core/browser/password_session_durations_metrics_recorder.h
@@ -11,7 +11,6 @@ #include "base/scoped_observation.h" #include "base/timer/elapsed_timer.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h" -#include "components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h" #include "components/sync/service/sync_service.h" #include "components/sync/service/sync_service_observer.h" @@ -51,8 +50,6 @@ const raw_ptr<PrefService> pref_service_; const raw_ptr<syncer::SyncService> sync_service_; - PasswordAccountStorageSettingsWatcher settings_watcher_; - base::ScopedObservation<syncer::SyncService, syncer::SyncServiceObserver> sync_observation_{this};
diff --git a/components/password_manager/core/browser/password_store/android_backend_error.h b/components/password_manager/core/browser/password_store/android_backend_error.h index f575e5a0..87125c06 100644 --- a/components/password_manager/core/browser/password_store/android_backend_error.h +++ b/components/password_manager/core/browser/password_store/android_backend_error.h
@@ -5,7 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_ANDROID_BACKEND_ERROR_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_ANDROID_BACKEND_ERROR_H_ -#include "third_party/abseil-cpp/absl/types/optional.h" +#include <optional> namespace password_manager { @@ -54,11 +54,11 @@ // Numeric error code returned by the GMS Core API, only available if 'type' // is kExternalError. - absl::optional<int> api_error_code; + std::optional<int> api_error_code; // Numeric connection result status code returned by the GMS Core API, only // available if ConnectionResult was set on the returned exception. - absl::optional<int> connection_result_code; + std::optional<int> connection_result_code; }; } // namespace password_manager
diff --git a/components/password_manager/core/browser/password_store/fake_password_store_backend.cc b/components/password_manager/core/browser/password_store/fake_password_store_backend.cc index ed42382..f324bf90 100644 --- a/components/password_manager/core/browser/password_store/fake_password_store_backend.cc +++ b/components/password_manager/core/browser/password_store/fake_password_store_backend.cc
@@ -109,7 +109,7 @@ } void FakePasswordStoreBackend::GetAllLoginsForAccountAsync( - absl::optional<std::string> account, + std::optional<std::string> account, LoginsOrErrorReply callback) { GetAllLoginsAsync(std::move(callback)); }
diff --git a/components/password_manager/core/browser/password_store/fake_password_store_backend.h b/components/password_manager/core/browser/password_store/fake_password_store_backend.h index b7ec92b7..7b3eea7 100644 --- a/components/password_manager/core/browser/password_store/fake_password_store_backend.h +++ b/components/password_manager/core/browser/password_store/fake_password_store_backend.h
@@ -65,7 +65,7 @@ void GetAllLoginsWithAffiliationAndBrandingAsync( LoginsOrErrorReply callback) override; void GetAutofillableLoginsAsync(LoginsOrErrorReply callback) override; - void GetAllLoginsForAccountAsync(absl::optional<std::string> account, + void GetAllLoginsForAccountAsync(std::optional<std::string> account, LoginsOrErrorReply callback) override; void FillMatchingLoginsAsync( LoginsOrErrorReply callback,
diff --git a/components/password_manager/core/browser/password_store/login_database.cc b/components/password_manager/core/browser/password_store/login_database.cc index dd37e8e..29f1f72 100644 --- a/components/password_manager/core/browser/password_store/login_database.cc +++ b/components/password_manager/core/browser/password_store/login_database.cc
@@ -50,7 +50,6 @@ #include "sql/database.h" #include "sql/statement.h" #include "sql/transaction.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/re2/src/re2/re2.h" #include "url/origin.h" #include "url/url_constants.h"
diff --git a/components/password_manager/core/browser/password_store/login_database_unittest.cc b/components/password_manager/core/browser/password_store/login_database_unittest.cc index 286b3f49c..3aaef3dd 100644 --- a/components/password_manager/core/browser/password_store/login_database_unittest.cc +++ b/components/password_manager/core/browser/password_store/login_database_unittest.cc
@@ -45,7 +45,6 @@ #include "sql/test/test_helpers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" #if BUILDFLAG(IS_IOS)
diff --git a/components/password_manager/core/browser/password_store/mock_password_store_backend.h b/components/password_manager/core/browser/password_store/mock_password_store_backend.h index 4f02eaa..e8f3a5d 100644 --- a/components/password_manager/core/browser/password_store/mock_password_store_backend.h +++ b/components/password_manager/core/browser/password_store/mock_password_store_backend.h
@@ -44,8 +44,7 @@ (override)); MOCK_METHOD(void, GetAllLoginsForAccountAsync, - (absl::optional<std::string> account, - LoginsOrErrorReply callback), + (std::optional<std::string> account, LoginsOrErrorReply callback), (override)); MOCK_METHOD(void, FillMatchingLoginsAsync,
diff --git a/components/password_manager/core/browser/password_store/password_notes_table.cc b/components/password_manager/core/browser/password_store/password_notes_table.cc index 433465b..ee29bed9 100644 --- a/components/password_manager/core/browser/password_store/password_notes_table.cc +++ b/components/password_manager/core/browser/password_store/password_notes_table.cc
@@ -12,14 +12,13 @@ #include "base/strings/strcat.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" -#include "components/password_manager/core/browser/password_store/login_database.h" #include "components/password_manager/core/browser/password_form.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h" +#include "components/password_manager/core/browser/password_store/login_database.h" #include "components/password_manager/core/browser/sql_table_builder.h" #include "components/password_manager/core/browser/sync/password_store_sync.h" #include "sql/database.h" #include "sql/statement.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if BUILDFLAG(IS_IOS) #import <Security/Security.h>
diff --git a/components/password_manager/core/browser/password_store/password_notes_table.h b/components/password_manager/core/browser/password_store/password_notes_table.h index d47ae9b..4b516c2 100644 --- a/components/password_manager/core/browser/password_store/password_notes_table.h +++ b/components/password_manager/core/browser/password_store/password_notes_table.h
@@ -10,7 +10,6 @@ #include "base/memory/raw_ptr.h" #include "base/time/time.h" #include "components/password_manager/core/browser/password_form.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace sql { class Database;
diff --git a/components/password_manager/core/browser/password_store/password_notes_table_unittest.cc b/components/password_manager/core/browser/password_store/password_notes_table_unittest.cc index 7eb70c2..3062566e 100644 --- a/components/password_manager/core/browser/password_store/password_notes_table_unittest.cc +++ b/components/password_manager/core/browser/password_store/password_notes_table_unittest.cc
@@ -10,12 +10,11 @@ #include "base/files/scoped_temp_dir.h" #include "base/time/time.h" #include "components/os_crypt/sync/os_crypt_mocker.h" -#include "components/password_manager/core/browser/password_store/login_database.h" #include "components/password_manager/core/browser/password_form.h" +#include "components/password_manager/core/browser/password_store/login_database.h" #include "sql/database.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { namespace {
diff --git a/components/password_manager/core/browser/password_store/password_store.cc b/components/password_manager/core/browser/password_store/password_store.cc index 0057951..2975184 100644 --- a/components/password_manager/core/browser/password_store/password_store.cc +++ b/components/password_manager/core/browser/password_store/password_store.cc
@@ -395,7 +395,7 @@ void PasswordStore::NotifyLoginsChangedOnMainSequence( LoginsChangedTrigger logins_changed_trigger, - absl::optional<PasswordStoreChangeList> changes) { + std::optional<PasswordStoreChangeList> changes) { DCHECK(main_task_runner_->RunsTasksInCurrentSequence()); // Don't propagate reference to this store after its shutdown. No caller
diff --git a/components/password_manager/core/browser/password_store/password_store.h b/components/password_manager/core/browser/password_store/password_store.h index 1a16990..5c5c638 100644 --- a/components/password_manager/core/browser/password_store/password_store.h +++ b/components/password_manager/core/browser/password_store/password_store.h
@@ -169,7 +169,7 @@ // requested and forwarded to `NotifyLoginsRetainedOnMainSequence`. void NotifyLoginsChangedOnMainSequence( LoginsChangedTrigger change_event, - absl::optional<PasswordStoreChangeList> changes); + std::optional<PasswordStoreChangeList> changes); // Notifies observers with all logins remaining after a modifying operation. void NotifyLoginsRetainedOnMainSequence(LoginsResultOrError result);
diff --git a/components/password_manager/core/browser/password_store/password_store_backend.h b/components/password_manager/core/browser/password_store/password_store_backend.h index 2c02032..716320ab 100644 --- a/components/password_manager/core/browser/password_store/password_store_backend.h +++ b/components/password_manager/core/browser/password_store/password_store_backend.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_PASSWORD_STORE_BACKEND_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_PASSWORD_STORE_BACKEND_H_ +#include <optional> #include <vector> #include "base/functional/callback_forward.h" @@ -12,7 +13,6 @@ #include "components/password_manager/core/browser/password_form_digest.h" #include "components/password_manager/core/browser/password_store/password_store_change.h" #include "components/password_manager/core/browser/password_store/password_store_consumer.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace syncer { class ProxyModelTypeControllerDelegate; @@ -40,7 +40,7 @@ : public base::SupportsWeakPtr<PasswordStoreBackend> { public: using RemoteChangesReceived = - base::RepeatingCallback<void(absl::optional<PasswordStoreChangeList>)>; + base::RepeatingCallback<void(std::optional<PasswordStoreChangeList>)>; PasswordStoreBackend() = default; PasswordStoreBackend(const PasswordStoreBackend&) = delete; @@ -80,7 +80,7 @@ // called with an error result. Callback is called on the main sequence. // TODO(crbug.com/1315594): Clean up/refactor to avoid having methods // introduced for a specific backend in this interface. - virtual void GetAllLoginsForAccountAsync(absl::optional<std::string> account, + virtual void GetAllLoginsForAccountAsync(std::optional<std::string> account, LoginsOrErrorReply callback) = 0; // Returns all PasswordForms with the same signon_realm as a form in |forms|.
diff --git a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc index 405ac864..5f2759a 100644 --- a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc +++ b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.cc
@@ -54,7 +54,7 @@ void PasswordStoreBackendMetricsRecorder::RecordMetrics( SuccessStatus success_status, - absl::optional<ErrorFromPasswordStoreOrAndroidBackend> error) const { + std::optional<ErrorFromPasswordStoreOrAndroidBackend> error) const { RecordSuccess(success_status); if (HasRunToCompletion(success_status)) { RecordLatency();
diff --git a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h index 1880b9e..8777294 100644 --- a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h +++ b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_PASSWORD_STORE_BACKEND_METRICS_RECORDER_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_PASSWORD_STORE_BACKEND_METRICS_RECORDER_H_ +#include <optional> #include <string> #include "base/strings/string_piece.h" @@ -12,7 +13,6 @@ #include "base/types/strong_alias.h" #include "components/password_manager/core/browser/password_store/android_backend_error.h" #include "components/password_manager/core/browser/password_store/password_store_backend_error.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/abseil-cpp/absl/types/variant.h" namespace password_manager { @@ -46,7 +46,7 @@ // Records metrics from `RecordErrorCode` if `error` is specified. void RecordMetrics( SuccessStatus success_status, - absl::optional<ErrorFromPasswordStoreOrAndroidBackend> error) const; + std::optional<ErrorFromPasswordStoreOrAndroidBackend> error) const; // Returns the delta between creating this recorder and calling this method. base::TimeDelta GetElapsedTimeSinceCreation() const;
diff --git a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc index 0bef11f..ef420d5 100644 --- a/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc +++ b/components/password_manager/core/browser/password_store/password_store_backend_metrics_recorder_unittest.cc
@@ -80,7 +80,7 @@ AdvanceClock(kLatencyDelta); metrics_recorder.RecordMetrics(SuccessStatus::kSuccess, - /*error=*/absl::nullopt); + /*error=*/std::nullopt); // Checking records in the backend-specific histogram histogram_tester.ExpectTotalCount(kDurationMetric, 1); @@ -215,7 +215,7 @@ AdvanceClock(kLatencyDelta); metrics_recorder.RecordMetrics(SuccessStatus::kCancelled, - /*error=*/absl::nullopt); + /*error=*/std::nullopt); // Checking records in the backend-specific histogram. histogram_tester.ExpectTotalCount(kDurationMetric, 0);
diff --git a/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc b/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc index 1578678c..61175168 100644 --- a/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc +++ b/components/password_manager/core/browser/password_store/password_store_built_in_backend.cc
@@ -39,7 +39,7 @@ reporter.RecordMetrics(SuccessStatus::kError, absl::get<PasswordStoreBackendError>(result)); } else { - reporter.RecordMetrics(SuccessStatus::kSuccess, absl::nullopt); + reporter.RecordMetrics(SuccessStatus::kSuccess, std::nullopt); } return result; }, @@ -134,7 +134,7 @@ } void PasswordStoreBuiltInBackend::GetAllLoginsForAccountAsync( - absl::optional<std::string> account, + std::optional<std::string> account, LoginsOrErrorReply callback) { NOTREACHED(); }
diff --git a/components/password_manager/core/browser/password_store/password_store_built_in_backend.h b/components/password_manager/core/browser/password_store/password_store_built_in_backend.h index d8b0e7d..192fb3d 100644 --- a/components/password_manager/core/browser/password_store/password_store_built_in_backend.h +++ b/components/password_manager/core/browser/password_store/password_store_built_in_backend.h
@@ -55,7 +55,7 @@ void GetAllLoginsWithAffiliationAndBrandingAsync( LoginsOrErrorReply callback) override; void GetAutofillableLoginsAsync(LoginsOrErrorReply callback) override; - void GetAllLoginsForAccountAsync(absl::optional<std::string> account, + void GetAllLoginsForAccountAsync(std::optional<std::string> account, LoginsOrErrorReply callback) override; void FillMatchingLoginsAsync( LoginsOrErrorReply callback,
diff --git a/components/password_manager/core/browser/password_store/password_store_change.h b/components/password_manager/core/browser/password_store/password_store_change.h index 561f567..cc339a6 100644 --- a/components/password_manager/core/browser/password_store/password_store_change.h +++ b/components/password_manager/core/browser/password_store/password_store_change.h
@@ -5,12 +5,12 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_PASSWORD_STORE_CHANGE_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_PASSWORD_STORE_CHANGE_H_ +#include <optional> #include <ostream> #include <vector> #include "components/password_manager/core/browser/password_form.h" #include "components/password_manager/core/browser/password_store/password_store_backend_error.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -53,7 +53,7 @@ }; using PasswordStoreChangeList = std::vector<PasswordStoreChange>; -using PasswordChanges = absl::optional<PasswordStoreChangeList>; +using PasswordChanges = std::optional<PasswordStoreChangeList>; using PasswordChangesOrError = absl::variant<PasswordChanges, PasswordStoreBackendError>;
diff --git a/components/password_manager/core/browser/password_store/password_store_unittest.cc b/components/password_manager/core/browser/password_store/password_store_unittest.cc index 2f67adf5..2e31d35 100644 --- a/components/password_manager/core/browser/password_store/password_store_unittest.cc +++ b/components/password_manager/core/browser/password_store/password_store_unittest.cc
@@ -221,10 +221,9 @@ TestingPrefServiceSimple pref_service_; }; -absl::optional<PasswordHashData> GetPasswordFromPref( - const std::string& username, - bool is_gaia_password, - PrefService* prefs) { +std::optional<PasswordHashData> GetPasswordFromPref(const std::string& username, + bool is_gaia_password, + PrefService* prefs) { HashPasswordManager hash_password_manager; hash_password_manager.set_prefs(prefs); @@ -1382,7 +1381,7 @@ EXPECT_CALL(*mock_backend, UpdateLoginAsync(Eq(kTestForm), _)) .WillOnce( WithArg<1>(Invoke([](PasswordChangesOrErrorReply reply) -> void { - std::move(reply).Run(absl::nullopt); + std::move(reply).Run(std::nullopt); }))); EXPECT_CALL(*mock_backend, GetAllLoginsAsync(_)) .WillOnce(WithArg<0>(
diff --git a/components/password_manager/core/browser/password_store/password_store_util.cc b/components/password_manager/core/browser/password_store/password_store_util.cc index 99d61be..3c73bb8 100644 --- a/components/password_manager/core/browser/password_store/password_store_util.cc +++ b/components/password_manager/core/browser/password_store/password_store_util.cc
@@ -13,11 +13,11 @@ PasswordStoreChangeList joined_changes; for (const auto& changes_or_error : changes_to_join) { if (absl::holds_alternative<PasswordStoreBackendError>(changes_or_error)) - return absl::nullopt; + return std::nullopt; const PasswordChanges& changes = absl::get<PasswordChanges>(changes_or_error); if (!changes.has_value()) - return absl::nullopt; + return std::nullopt; base::ranges::copy(*changes, std::back_inserter(joined_changes)); } return joined_changes; @@ -33,7 +33,7 @@ PasswordChanges GetPasswordChangesOrNulloptOnFailure( PasswordChangesOrError result) { if (absl::holds_alternative<PasswordStoreBackendError>(result)) { - return absl::nullopt; + return std::nullopt; } return std::move(absl::get<PasswordChanges>(result)); }
diff --git a/components/password_manager/core/browser/password_store/password_store_util.h b/components/password_manager/core/browser/password_store/password_store_util.h index 6237d7d..50ea5b4 100644 --- a/components/password_manager/core/browser/password_store/password_store_util.h +++ b/components/password_manager/core/browser/password_store/password_store_util.h
@@ -9,7 +9,6 @@ #include "components/password_manager/core/browser/password_store/password_store_change.h" #include "components/password_manager/core/browser/password_store/password_store_consumer.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -23,8 +22,8 @@ // holds an error. LoginsResult GetLoginsOrEmptyListOnFailure(LoginsResultOrError result); -// Returns password changes if |result| holds them, or absl::nullopt if |result| -// holds an absl::nullopt or error. +// Returns password changes if |result| holds them, or std::nullopt if |result| +// holds an std::nullopt or error. PasswordChanges GetPasswordChangesOrNulloptOnFailure( PasswordChangesOrError result);
diff --git a/components/password_manager/core/browser/password_sync_util.cc b/components/password_manager/core/browser/password_sync_util.cc index c2e2c69..62dc3ee 100644 --- a/components/password_manager/core/browser/password_sync_util.cc +++ b/components/password_manager/core/browser/password_sync_util.cc
@@ -94,17 +94,17 @@ sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS); } -absl::optional<std::string> GetAccountForSaving( +std::optional<std::string> GetAccountForSaving( const PrefService* pref_service, const syncer::SyncService* sync_service) { if (!sync_service) { - return absl::nullopt; + return std::nullopt; } if (IsSyncFeatureEnabledIncludingPasswords(sync_service) || features_util::IsOptedInForAccountStorage(pref_service, sync_service)) { return sync_service->GetAccountInfo().email; } - return absl::nullopt; + return std::nullopt; } password_manager::SyncState GetPasswordSyncState(
diff --git a/components/password_manager/core/browser/password_sync_util.h b/components/password_manager/core/browser/password_sync_util.h index 0add939f..f5371af5 100644 --- a/components/password_manager/core/browser/password_sync_util.h +++ b/components/password_manager/core/browser/password_sync_util.h
@@ -72,7 +72,7 @@ // Returns the account where passwords are being saved, or nullopt if passwords // are being saved only locally. In practice, this returns a non-empty // value if the user is syncing or signed in and opted in to account storage. -absl::optional<std::string> GetAccountForSaving( +std::optional<std::string> GetAccountForSaving( const PrefService* pref_service, const syncer::SyncService* sync_service);
diff --git a/components/password_manager/core/browser/password_ui_utils.cc b/components/password_manager/core/browser/password_ui_utils.cc index 5af48ab..ea6d558 100644 --- a/components/password_manager/core/browser/password_ui_utils.cc +++ b/components/password_manager/core/browser/password_ui_utils.cc
@@ -20,7 +20,6 @@ #include "components/password_manager/core/browser/ui/credential_ui_entry.h" #include "components/strings/grit/components_strings.h" #include "components/url_formatter/elide_url.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/l10n/l10n_util.h" namespace password_manager {
diff --git a/components/password_manager/core/browser/possible_username_data.h b/components/password_manager/core/browser/possible_username_data.h index 596f90969..7ea86e1 100644 --- a/components/password_manager/core/browser/possible_username_data.h +++ b/components/password_manager/core/browser/possible_username_data.h
@@ -5,13 +5,13 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_POSSIBLE_USERNAME_DATA_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_POSSIBLE_USERNAME_DATA_H_ +#include <optional> #include <string> #include "base/time/time.h" #include "components/autofill/core/common/unique_ids.h" #include "components/password_manager/core/browser/form_parsing/password_field_prediction.h" #include "components/password_manager/core/browser/votes_uploader.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -87,7 +87,7 @@ bool is_likely_otp; // Predictions for the form which contains a field with |renderer_id|. - absl::optional<FormPredictions> form_predictions; + std::optional<FormPredictions> form_predictions; // Returns whether |possible_username| was last edited too far in the past and // should not be considered as a possible single username.
diff --git a/components/password_manager/core/browser/sharing/BUILD.gn b/components/password_manager/core/browser/sharing/BUILD.gn index d7422d60..4fd311b3 100644 --- a/components/password_manager/core/browser/sharing/BUILD.gn +++ b/components/password_manager/core/browser/sharing/BUILD.gn
@@ -36,7 +36,6 @@ "//components/password_manager/core/browser/features:password_features", "//components/password_manager/core/browser/features:utils", "//components/password_manager/core/browser/password_store:password_store_interface", - "//components/password_manager/core/browser/sync", "//components/password_manager/core/common", "//components/prefs", "//components/signin/public/identity_manager",
diff --git a/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.cc b/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.cc index 7941245..b619574 100644 --- a/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.cc +++ b/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.cc
@@ -56,7 +56,7 @@ return std::make_unique<syncer::InMemoryMetadataChangeList>(); } -absl::optional<syncer::ModelError> +std::optional<syncer::ModelError> IncomingPasswordSharingInvitationSyncBridge::MergeFullSyncData( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) { @@ -67,7 +67,7 @@ std::move(entity_data)); } -absl::optional<syncer::ModelError> +std::optional<syncer::ModelError> IncomingPasswordSharingInvitationSyncBridge::ApplyIncrementalSyncChanges( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_changes) { @@ -95,7 +95,7 @@ batch->TakeMetadataChangesFrom(std::move(metadata_change_list)); CommitSyncMetadata(std::move(batch)); - return absl::nullopt; + return std::nullopt; } void IncomingPasswordSharingInvitationSyncBridge::GetData( @@ -149,7 +149,7 @@ } void IncomingPasswordSharingInvitationSyncBridge::OnModelTypeStoreCreated( - const absl::optional<syncer::ModelError>& error, + const std::optional<syncer::ModelError>& error, std::unique_ptr<syncer::ModelTypeStore> store) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (error) { @@ -165,7 +165,7 @@ } void IncomingPasswordSharingInvitationSyncBridge::OnReadAllMetadata( - const absl::optional<syncer::ModelError>& error, + const std::optional<syncer::ModelError>& error, std::unique_ptr<syncer::MetadataBatch> metadata_batch) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (error) { @@ -176,7 +176,7 @@ } void IncomingPasswordSharingInvitationSyncBridge::OnCommitSyncMetadata( - const absl::optional<syncer::ModelError>& error) { + const std::optional<syncer::ModelError>& error) { if (error) { change_processor()->ReportError(*error); }
diff --git a/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.h b/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.h index eac8a3c4..3bb62fa 100644 --- a/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.h +++ b/components/password_manager/core/browser/sharing/incoming_password_sharing_invitation_sync_bridge.h
@@ -6,13 +6,14 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SHARING_INCOMING_PASSWORD_SHARING_INVITATION_SYNC_BRIDGE_H_ #include <memory> +#include <optional> + #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "components/sync/model/model_error.h" #include "components/sync/model/model_type_store.h" #include "components/sync/model/model_type_sync_bridge.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace syncer { class MetadataBatch; @@ -49,10 +50,10 @@ const syncer::DataTypeActivationRequest& request) override; std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() override; - absl::optional<syncer::ModelError> MergeFullSyncData( + std::optional<syncer::ModelError> MergeFullSyncData( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) override; - absl::optional<syncer::ModelError> ApplyIncrementalSyncChanges( + std::optional<syncer::ModelError> ApplyIncrementalSyncChanges( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_changes) override; void GetData(StorageKeyList storage_keys, DataCallback callback) override; @@ -66,11 +67,11 @@ private: // Methods used as callbacks given to DataTypeStore. - void OnModelTypeStoreCreated(const absl::optional<syncer::ModelError>& error, + void OnModelTypeStoreCreated(const std::optional<syncer::ModelError>& error, std::unique_ptr<syncer::ModelTypeStore> store); - void OnReadAllMetadata(const absl::optional<syncer::ModelError>& error, + void OnReadAllMetadata(const std::optional<syncer::ModelError>& error, std::unique_ptr<syncer::MetadataBatch> metadata_batch); - void OnCommitSyncMetadata(const absl::optional<syncer::ModelError>& error); + void OnCommitSyncMetadata(const std::optional<syncer::ModelError>& error); // Persists the changes to sync metadata store. void CommitSyncMetadata(
diff --git a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.cc b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.cc index a1a6578..9bb1800e 100644 --- a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.cc +++ b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.cc
@@ -5,8 +5,6 @@ #include "components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.h" #include "base/functional/bind.h" -#include "build/build_config.h" -#include "components/password_manager/core/browser/features/password_manager_features_util.h" #include "components/password_manager/core/browser/sharing/password_sender_service.h" #include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/prefs/pref_service.h" @@ -39,16 +37,7 @@ CreateDelegateFromPasswordSenderService(password_sender_service), /*delegate_for_transport_mode=*/ CreateDelegateFromPasswordSenderService(password_sender_service)), - sync_service_(sync_service), - pref_service_(pref_service), - account_storage_settings_watcher_( - pref_service, - sync_service, - // base::Unretained() is safe because `this` outlives the watcher. - base::BindRepeating( - &OutgoingPasswordSharingInvitationModelTypeController:: - OnAccountStorageSettingsChanged, - base::Unretained(this))) { + sync_service_(sync_service) { password_sharing_enabled_policy_.Init( password_manager::prefs::kPasswordSharingEnabled, pref_service, base::BindRepeating( @@ -69,19 +58,6 @@ return syncer::DataTypeController::PreconditionState::kMustStopAndClearData; } -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - if (!sync_service_->IsSyncFeatureEnabled() && - !sync_service_->IsLocalSyncEnabled() && - !features_util::IsOptedInForAccountStorage(pref_service_, - sync_service_)) { - // The user is in transport mode and password sync is disabled because they - // are not opted in to account storage. Sharing should be disabled too. - // TODO(crbug.com/1484531): IsOptedInForAccountStorage() with "selected - // types" and delete this check. - return PreconditionState::kMustStopAndClearData; - } -#endif - return syncer::DataTypeController::PreconditionState::kPreconditionsMet; } @@ -91,10 +67,4 @@ sync_service_->DataTypePreconditionChanged(type()); } -void OutgoingPasswordSharingInvitationModelTypeController:: - OnAccountStorageSettingsChanged() { - DCHECK(CalledOnValidThread()); - sync_service_->DataTypePreconditionChanged(type()); -} - } // namespace password_manager
diff --git a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.h b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.h index 389660f..192342c 100644 --- a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.h +++ b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_model_type_controller.h
@@ -5,7 +5,6 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SHARING_OUTGOING_PASSWORD_SHARING_INVITATION_MODEL_TYPE_CONTROLLER_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SHARING_OUTGOING_PASSWORD_SHARING_INVITATION_MODEL_TYPE_CONTROLLER_H_ -#include "components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h" #include "components/prefs/pref_member.h" #include "components/sync/service/model_type_controller.h" #include "components/sync/service/sync_service.h" @@ -34,11 +33,8 @@ private: void OnPasswordSharingEnabledPolicyChanged(); - void OnAccountStorageSettingsChanged(); const raw_ptr<syncer::SyncService> sync_service_; - const raw_ptr<PrefService> pref_service_; - PasswordAccountStorageSettingsWatcher account_storage_settings_watcher_; BooleanPrefMember password_sharing_enabled_policy_; };
diff --git a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.cc b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.cc index 46301ba..65f7534c8 100644 --- a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.cc +++ b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.cc
@@ -151,16 +151,16 @@ metadata_change_list.get()); } -absl::optional<syncer::ModelError> +std::optional<syncer::ModelError> OutgoingPasswordSharingInvitationSyncBridge::MergeFullSyncData( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); CHECK(entity_data.empty()); - return absl::nullopt; + return std::nullopt; } -absl::optional<syncer::ModelError> +std::optional<syncer::ModelError> OutgoingPasswordSharingInvitationSyncBridge::ApplyIncrementalSyncChanges( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_changes) { @@ -173,7 +173,7 @@ outgoing_invitations_in_flight_.erase( GetClientTagHashFromStorageKey(change->storage_key())); } - return absl::nullopt; + return std::nullopt; } void OutgoingPasswordSharingInvitationSyncBridge::GetData(
diff --git a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.h b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.h index f1d1451..714823f1 100644 --- a/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.h +++ b/components/password_manager/core/browser/sharing/outgoing_password_sharing_invitation_sync_bridge.h
@@ -49,10 +49,10 @@ // ModelTypeSyncBridge implementation. std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() override; - absl::optional<syncer::ModelError> MergeFullSyncData( + std::optional<syncer::ModelError> MergeFullSyncData( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) override; - absl::optional<syncer::ModelError> ApplyIncrementalSyncChanges( + std::optional<syncer::ModelError> ApplyIncrementalSyncChanges( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_changes) override; void GetData(StorageKeyList storage_keys, DataCallback callback) override;
diff --git a/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.cc b/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.cc index 432d2be0..27255632 100644 --- a/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.cc +++ b/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.cc
@@ -72,7 +72,7 @@ StartFetchingAccessToken(); } -absl::optional<sync_pb::PasswordSharingRecipientsResponse> +std::optional<sync_pb::PasswordSharingRecipientsResponse> PasswordSharingRecipientsDownloader::TakeResponse() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); return std::move(response_);
diff --git a/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.h b/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.h index 01f25b28d..6d26887 100644 --- a/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.h +++ b/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader.h
@@ -6,6 +6,7 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SHARING_PASSWORD_SHARING_RECIPIENTS_DOWNLOADER_H_ #include <memory> +#include <optional> #include <string> #include "base/functional/callback_forward.h" @@ -15,7 +16,6 @@ #include "components/sync/protocol/password_sharing_recipients.pb.h" #include "components/version_info/channel.h" #include "google_apis/gaia/google_service_auth_error.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace network { @@ -51,7 +51,7 @@ // Returns response if request successfully complete, nullopt otherwise. Must // be called at most once. - absl::optional<sync_pb::PasswordSharingRecipientsResponse> TakeResponse(); + std::optional<sync_pb::PasswordSharingRecipientsResponse> TakeResponse(); // Returns request failure. Must be called once the request is complete. int GetNetError() const; @@ -86,7 +86,7 @@ ongoing_access_token_fetch_; // Contains a parsed response if the request succeeded. - absl::optional<sync_pb::PasswordSharingRecipientsResponse> response_; + std::optional<sync_pb::PasswordSharingRecipientsResponse> response_; // Contains request failure if the request is complete and there was an HTTP // error code or request timed out.
diff --git a/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader_unittest.cc b/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader_unittest.cc index beb60da..fc87250b 100644 --- a/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader_unittest.cc +++ b/components/password_manager/core/browser/sharing/password_sharing_recipients_downloader_unittest.cc
@@ -71,7 +71,7 @@ downloader->Start(run_loop.QuitClosure()); run_loop.Run(); - absl::optional<PasswordSharingRecipientsResponse> response = + std::optional<PasswordSharingRecipientsResponse> response = downloader->TakeResponse(); ASSERT_TRUE(response); EXPECT_EQ(response->result(), PasswordSharingRecipientsResponse::SUCCESS);
diff --git a/components/password_manager/core/browser/sharing/recipients_fetcher_impl.cc b/components/password_manager/core/browser/sharing/recipients_fetcher_impl.cc index 1f844ad..a2ccfb5 100644 --- a/components/password_manager/core/browser/sharing/recipients_fetcher_impl.cc +++ b/components/password_manager/core/browser/sharing/recipients_fetcher_impl.cc
@@ -78,7 +78,7 @@ return; } - absl::optional<sync_pb::PasswordSharingRecipientsResponse> server_response = + std::optional<sync_pb::PasswordSharingRecipientsResponse> server_response = pending_request_->TakeResponse(); // Destroy the request object after the response was fetched otherwise no // further call can be made.
diff --git a/components/password_manager/core/browser/store_metrics_reporter.cc b/components/password_manager/core/browser/store_metrics_reporter.cc index 73c0bde..750f69e 100644 --- a/components/password_manager/core/browser/store_metrics_reporter.cc +++ b/components/password_manager/core/browser/store_metrics_reporter.cc
@@ -569,9 +569,9 @@ const std::string& sync_username, bool is_opted_in_account_storage, bool is_safe_browsing_enabled, - absl::optional<std::vector<std::unique_ptr<PasswordForm>>> + std::optional<std::vector<std::unique_ptr<PasswordForm>>> profile_store_results, - absl::optional<std::vector<std::unique_ptr<PasswordForm>>> + std::optional<std::vector<std::unique_ptr<PasswordForm>>> account_store_results) { // Maps from (signon_realm, username) to password. std::unique_ptr< @@ -754,8 +754,8 @@ base::BindOnce(&ReportAllMetrics, custom_passphrase_enabled_, sync_username_, is_opted_in_account_storage_, is_safe_browsing_enabled_, - std::exchange(profile_store_results_, absl::nullopt), - std::exchange(account_store_results_, absl::nullopt)), + std::exchange(profile_store_results_, std::nullopt), + std::exchange(account_store_results_, std::nullopt)), base::BindOnce(&OnMetricsReportingCompleted, weak_ptr_factory_.GetWeakPtr(), std::move(done_callback_)));
diff --git a/components/password_manager/core/browser/store_metrics_reporter.h b/components/password_manager/core/browser/store_metrics_reporter.h index 0c3a006..3c31e48 100644 --- a/components/password_manager/core/browser/store_metrics_reporter.h +++ b/components/password_manager/core/browser/store_metrics_reporter.h
@@ -72,9 +72,9 @@ // Temporarily holds the credentials stored in the profile and account stores // till the actual metric computation starts. They don't have a value until // the credentials are loaded from the storage. - absl::optional<std::vector<std::unique_ptr<PasswordForm>>> + std::optional<std::vector<std::unique_ptr<PasswordForm>>> profile_store_results_; - absl::optional<std::vector<std::unique_ptr<PasswordForm>>> + std::optional<std::vector<std::unique_ptr<PasswordForm>>> account_store_results_; base::OnceClosure done_callback_;
diff --git a/components/password_manager/core/browser/store_metrics_reporter_unittest.cc b/components/password_manager/core/browser/store_metrics_reporter_unittest.cc index 5db52d9..ac769470 100644 --- a/components/password_manager/core/browser/store_metrics_reporter_unittest.cc +++ b/components/password_manager/core/browser/store_metrics_reporter_unittest.cc
@@ -1175,15 +1175,15 @@ for (bool opted_in : {false, true}) { if (opted_in) { #if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - features_util::OptInToAccountStorage(&prefs_, sync_service()); + features_util::OptInToAccountStorage(&prefs_, test_sync_service()); #else test_sync_service()->GetUserSettings()->SetSelectedTypes( /*sync_everything=*/true, syncer::UserSelectableTypeSet::All()); #endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) } else { #if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - features_util::OptOutOfAccountStorageAndClearSettings(&prefs_, - sync_service()); + features_util::OptOutOfAccountStorageAndClearSettings( + &prefs_, test_sync_service()); #else test_sync_service()->GetUserSettings()->SetSelectedTypes( /*sync_everything=*/false, syncer::UserSelectableTypeSet());
diff --git a/components/password_manager/core/browser/stub_password_manager_client.h b/components/password_manager/core/browser/stub_password_manager_client.h index 6ba1a63..3ccce8e 100644 --- a/components/password_manager/core/browser/stub_password_manager_client.h +++ b/components/password_manager/core/browser/stub_password_manager_client.h
@@ -5,13 +5,14 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STUB_PASSWORD_MANAGER_CLIENT_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_STUB_PASSWORD_MANAGER_CLIENT_H_ +#include <optional> + #include "components/autofill/core/browser/logging/stub_log_manager.h" #include "components/password_manager/core/browser/mock_password_feature_manager.h" #include "components/password_manager/core/browser/password_manager_client.h" #include "components/password_manager/core/browser/password_manager_metrics_recorder.h" #include "components/password_manager/core/browser/stub_credentials_filter.h" #include "components/sync/service/sync_service.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -92,7 +93,7 @@ testing::NiceMock<MockPasswordFeatureManager> password_feature_manager_; autofill::StubLogManager log_manager_; ukm::SourceId ukm_source_id_; - absl::optional<PasswordManagerMetricsRecorder> metrics_recorder_; + std::optional<PasswordManagerMetricsRecorder> metrics_recorder_; }; } // namespace password_manager
diff --git a/components/password_manager/core/browser/sync/BUILD.gn b/components/password_manager/core/browser/sync/BUILD.gn index 4d32c7f..17ea9d787 100644 --- a/components/password_manager/core/browser/sync/BUILD.gn +++ b/components/password_manager/core/browser/sync/BUILD.gn
@@ -9,8 +9,6 @@ sources = [ "credential_model_type_controller.cc", "credential_model_type_controller.h", - "password_account_storage_settings_watcher.cc", - "password_account_storage_settings_watcher.h", "password_proto_utils.cc", "password_proto_utils.h", "password_store_sync.cc", @@ -30,7 +28,6 @@ "//components/sync/model", "//components/sync/protocol:util", "//components/sync/service", - "//third_party/abseil-cpp:absl", "//url", ] } @@ -38,7 +35,6 @@ source_set("unit_tests") { testonly = true sources = [ - "password_account_storage_settings_watcher_unittest.cc", "password_proto_utils_unittest.cc", "password_sync_bridge_unittest.cc", ]
diff --git a/components/password_manager/core/browser/sync/credential_model_type_controller.cc b/components/password_manager/core/browser/sync/credential_model_type_controller.cc index 355a020..17b1989e0 100644 --- a/components/password_manager/core/browser/sync/credential_model_type_controller.cc +++ b/components/password_manager/core/browser/sync/credential_model_type_controller.cc
@@ -37,13 +37,7 @@ std::move(delegate_for_transport_mode)), pref_service_(pref_service), identity_manager_(identity_manager), - sync_service_(sync_service), - account_storage_settings_watcher_( - pref_service_, - sync_service_, - base::BindRepeating( - &CredentialModelTypeController::OnOptInStateMaybeChanged, - base::Unretained(this))) { + sync_service_(sync_service) { CHECK(model_type == syncer::PASSWORDS || model_type == syncer::WEBAUTHN_CREDENTIAL); identity_manager_observation_.Observe(identity_manager_); @@ -66,30 +60,6 @@ ModelTypeController::Stop(fate, std::move(callback)); } -syncer::DataTypeController::PreconditionState -CredentialModelTypeController::GetPreconditionState() const { -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - // If Sync-the-feature is enabled, then the user has opted in to that, and no - // additional opt-in is required here. - // TODO(crbug.com/1466447): IsSyncFeatureEnabled() is deprecated and should be - // removed. See ConsentLevel::kSync documentation for details. - if (sync_service_->IsSyncFeatureEnabled() || - sync_service_->IsLocalSyncEnabled()) { - return PreconditionState::kPreconditionsMet; - } - // If Sync-the-feature is *not* enabled, then credential sync should only be - // turned on if the user has opted in to the account-scoped storage. - return features_util::IsOptedInForAccountStorage(pref_service_, sync_service_) - ? PreconditionState::kPreconditionsMet - : PreconditionState::kMustStopAndClearData; -#else - // On Android and iOS, there is no explicit opt-in - instead the user's choice - // is handled via Sync's selected types (see `UserSelectableType`). So nothing - // to check here. - return PreconditionState::kPreconditionsMet; -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) -} - bool CredentialModelTypeController::ShouldRunInTransportOnlyMode() const { #if !BUILDFLAG(IS_IOS) // Outside iOS, passphrase errors aren't reported in the UI, so it doesn't @@ -137,11 +107,4 @@ #endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) } -void CredentialModelTypeController::OnOptInStateMaybeChanged() { - // Note: This method gets called in many other situations as well, not just - // when the opt-in state changes, but DataTypePreconditionChanged() is cheap - // if nothing actually changed, so some spurious calls don't hurt. - sync_service_->DataTypePreconditionChanged(type()); -} - } // namespace password_manager
diff --git a/components/password_manager/core/browser/sync/credential_model_type_controller.h b/components/password_manager/core/browser/sync/credential_model_type_controller.h index 624f20f5..2cb0f20e 100644 --- a/components/password_manager/core/browser/sync/credential_model_type_controller.h +++ b/components/password_manager/core/browser/sync/credential_model_type_controller.h
@@ -10,7 +10,6 @@ #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observation.h" -#include "components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "components/sync/base/model_type.h" #include "components/sync/service/model_type_controller.h" @@ -50,7 +49,6 @@ void LoadModels(const syncer::ConfigureContext& configure_context, const ModelLoadCallback& model_load_callback) override; void Stop(syncer::SyncStopMetadataFate fate, StopCallback callback) override; - PreconditionState GetPreconditionState() const override; bool ShouldRunInTransportOnlyMode() const override; // SyncServiceObserver overrides. @@ -63,14 +61,10 @@ void OnAccountsCookieDeletedByUserAction() override; private: - void OnOptInStateMaybeChanged(); - const raw_ptr<PrefService> pref_service_; const raw_ptr<signin::IdentityManager> identity_manager_; const raw_ptr<syncer::SyncService> sync_service_; - PasswordAccountStorageSettingsWatcher account_storage_settings_watcher_; - base::ScopedObservation<signin::IdentityManager, signin::IdentityManager::Observer> identity_manager_observation_{this};
diff --git a/components/password_manager/core/browser/sync/password_account_storage_settings_watcher.cc b/components/password_manager/core/browser/sync/password_account_storage_settings_watcher.cc deleted file mode 100644 index 48cc7085..0000000 --- a/components/password_manager/core/browser/sync/password_account_storage_settings_watcher.cc +++ /dev/null
@@ -1,48 +0,0 @@ -// Copyright 2020 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h" - -#include <utility> - -#include "base/functional/callback.h" -#include "build/build_config.h" -#include "components/password_manager/core/common/password_manager_pref_names.h" -#include "components/sync/service/sync_service.h" - -namespace password_manager { - -PasswordAccountStorageSettingsWatcher::PasswordAccountStorageSettingsWatcher( - PrefService* pref_service, - syncer::SyncService* sync_service, - base::RepeatingClosure change_callback) - : sync_service_(sync_service), - change_callback_(std::move(change_callback)) { - DCHECK(pref_service); - // The opt-in state is per-account, so it can change whenever the state of the - // account used by Sync changes. - if (sync_service_) - sync_service_->AddObserver(this); -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - // The opt-in state is stored in a pref, so changes to the pref might indicate - // a change to the opt-in state. - pref_change_registrar_.Init(pref_service); - pref_change_registrar_.Add( - password_manager::prefs::kAccountStoragePerAccountSettings, - change_callback_); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) -} - -PasswordAccountStorageSettingsWatcher:: - ~PasswordAccountStorageSettingsWatcher() { - if (sync_service_) - sync_service_->RemoveObserver(this); -} - -void PasswordAccountStorageSettingsWatcher::OnStateChanged( - syncer::SyncService* sync_service) { - change_callback_.Run(); -} - -} // namespace password_manager
diff --git a/components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h b/components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h deleted file mode 100644 index 98d4e1d..0000000 --- a/components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright 2020 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SYNC_PASSWORD_ACCOUNT_STORAGE_SETTINGS_WATCHER_H_ -#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SYNC_PASSWORD_ACCOUNT_STORAGE_SETTINGS_WATCHER_H_ - -#include "base/functional/callback_forward.h" -#include "base/memory/raw_ptr.h" -#include "build/build_config.h" -#include "components/prefs/pref_change_registrar.h" -#include "components/sync/service/sync_service_observer.h" - -class PrefService; - -namespace syncer { -class SyncService; -} // namespace syncer - -namespace password_manager { - -// Helper class to watch for changes to the password account storage preferences -// such as opt-in state and default storage location. -class PasswordAccountStorageSettingsWatcher - : public syncer::SyncServiceObserver { - public: - // |pref_service| must not be null and must outlive this object. - // |sync_service| may be null (in incognito profiles or due to a commandline - // flag), but if non-null must outlive this object. - // |change_callback| will be invoked whenever any password account storage - // setting is changed (e.g. the opt-in state or the default storage location). - PasswordAccountStorageSettingsWatcher(PrefService* pref_service, - syncer::SyncService* sync_service, - base::RepeatingClosure change_callback); - ~PasswordAccountStorageSettingsWatcher() override; - - // syncer::SyncServiceObserver: - void OnStateChanged(syncer::SyncService* sync_service) override; - - private: - const raw_ptr<syncer::SyncService> sync_service_; - base::RepeatingClosure change_callback_; - -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - PrefChangeRegistrar pref_change_registrar_; -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) -}; - -} // namespace password_manager - -#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SYNC_PASSWORD_ACCOUNT_STORAGE_SETTINGS_WATCHER_H_
diff --git a/components/password_manager/core/browser/sync/password_account_storage_settings_watcher_unittest.cc b/components/password_manager/core/browser/sync/password_account_storage_settings_watcher_unittest.cc deleted file mode 100644 index c439935..0000000 --- a/components/password_manager/core/browser/sync/password_account_storage_settings_watcher_unittest.cc +++ /dev/null
@@ -1,100 +0,0 @@ -// Copyright 2020 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/password_manager/core/browser/sync/password_account_storage_settings_watcher.h" - -#include "base/test/mock_callback.h" -#include "base/test/scoped_feature_list.h" -#include "build/build_config.h" -#include "components/password_manager/core/browser/features/password_features.h" -#include "components/password_manager/core/browser/password_feature_manager_impl.h" -#include "components/password_manager/core/common/password_manager_pref_names.h" -#include "components/prefs/pref_registry_simple.h" -#include "components/prefs/testing_pref_service.h" -#include "components/sync/test/test_sync_service.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace password_manager { - -TEST(PasswordAccountStorageSettingsWatcherTest, NotifiesOnChanges) { - base::test::ScopedFeatureList feature; - feature.InitAndEnableFeature(features::kEnablePasswordsAccountStorage); - - TestingPrefServiceSimple pref_service; - syncer::TestSyncService sync_service; - - PasswordFeatureManagerImpl feature_manager( - &pref_service, /*local_state=*/nullptr, &sync_service); - -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - pref_service.registry()->RegisterDictionaryPref( - prefs::kAccountStoragePerAccountSettings); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - - base::MockRepeatingClosure change_callback; - PasswordAccountStorageSettingsWatcher watcher(&pref_service, &sync_service, - change_callback.Get()); - - // Initial state: Not opted in, and saving to the profile store (because not - // signed in). - ASSERT_FALSE(feature_manager.IsOptedInForAccountStorage()); - ASSERT_EQ(feature_manager.GetDefaultPasswordStore(), - PasswordForm::Store::kProfileStore); - - // Sign in (but don't enable Sync-the-feature). Note that the TestSyncService - // doesn't automatically notify observers of the change. - CoreAccountInfo account; - account.gaia = "gaia_id"; - account.email = "email@test.com"; - account.account_id = CoreAccountId::FromGaiaId(account.gaia); - sync_service.SetAccountInfo(account); - sync_service.SetHasSyncConsent(false); - ASSERT_FALSE(sync_service.IsSyncFeatureEnabled()); - - // Once the SyncService notifies its observers, the watcher should run the - // callback. - EXPECT_CALL(change_callback, Run()).WillOnce([&]() { -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - // On desktop: Still not opted in, and saving to the profile store. - EXPECT_FALSE(feature_manager.IsOptedInForAccountStorage()); - EXPECT_EQ(feature_manager.GetDefaultPasswordStore(), - PasswordForm::Store::kProfileStore); -#else - // On mobile: Opted in by default and thus saving to the account store. - EXPECT_TRUE(feature_manager.IsOptedInForAccountStorage()); - EXPECT_EQ(feature_manager.GetDefaultPasswordStore(), - PasswordForm::Store::kAccountStore); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - EXPECT_FALSE(feature_manager.IsDefaultPasswordStoreSet()); - }); - sync_service.FireStateChanged(); - -#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) - // Opt in. The watcher should run the callback. - EXPECT_CALL(change_callback, Run()).WillOnce([&]() { - EXPECT_TRUE(feature_manager.IsOptedInForAccountStorage()); - EXPECT_FALSE(feature_manager.IsDefaultPasswordStoreSet()); - }); - feature_manager.OptInToAccountStorage(); - - // Switch to saving to the profile store. The watcher should run the callback. - EXPECT_CALL(change_callback, Run()).WillOnce([&]() { - EXPECT_TRUE(feature_manager.IsOptedInForAccountStorage()); - EXPECT_EQ(feature_manager.GetDefaultPasswordStore(), - PasswordForm::Store::kProfileStore); - }); - feature_manager.SetDefaultPasswordStore(PasswordForm::Store::kProfileStore); - - // Switch to saving to the account store. The watcher should run the callback. - EXPECT_CALL(change_callback, Run()).WillOnce([&]() { - EXPECT_TRUE(feature_manager.IsOptedInForAccountStorage()); - EXPECT_EQ(feature_manager.GetDefaultPasswordStore(), - PasswordForm::Store::kAccountStore); - }); - feature_manager.SetDefaultPasswordStore(PasswordForm::Store::kAccountStore); -#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) -} - -} // namespace password_manager
diff --git a/components/password_manager/core/browser/sync/password_sync_bridge.cc b/components/password_manager/core/browser/sync/password_sync_bridge.cc index 19ad1f2c..69d2709 100644 --- a/components/password_manager/core/browser/sync/password_sync_bridge.cc +++ b/components/password_manager/core/browser/sync/password_sync_bridge.cc
@@ -4,6 +4,7 @@ #include "components/password_manager/core/browser/sync/password_sync_bridge.h" +#include <optional> #include <unordered_set> #include <utility> #include <vector> @@ -35,7 +36,6 @@ #include "components/sync/model/mutable_data_batch.h" #include "components/sync/model/sync_metadata_store_change_list.h" #include "components/sync/protocol/model_type_state_helper.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace password_manager { @@ -473,7 +473,7 @@ } } - if (absl::optional<syncer::ModelError> error = + if (std::optional<syncer::ModelError> error = metadata_change_list.TakeError()) { change_processor()->ReportError(*error); } @@ -484,7 +484,7 @@ return std::make_unique<syncer::InMemoryMetadataChangeList>(); } -absl::optional<syncer::ModelError> PasswordSyncBridge::MergeFullSyncData( +std::optional<syncer::ModelError> PasswordSyncBridge::MergeFullSyncData( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) { // This method merges the local and remote passwords based on their client @@ -520,7 +520,7 @@ "Failed to load entries from password store. " "Encryption service failure."); } - absl::optional<syncer::ModelError> cleanup_result_error = + std::optional<syncer::ModelError> cleanup_result_error = CleanupPasswordStore(); if (cleanup_result_error) { return cleanup_result_error; @@ -714,7 +714,7 @@ // CreateMetadataChangeList() so downcasting is safe. static_cast<syncer::InMemoryMetadataChangeList*>(metadata_change_list.get()) ->TransferChangesTo(&sync_metadata_store_change_list); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = sync_metadata_store_change_list.TakeError(); if (error) { metrics_util::LogPasswordSyncState( @@ -756,10 +756,10 @@ } sync_enabled_or_disabled_cb_.Run(); - return absl::nullopt; + return std::nullopt; } -absl::optional<syncer::ModelError> +std::optional<syncer::ModelError> PasswordSyncBridge::ApplyIncrementalSyncChanges( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_changes) { @@ -901,7 +901,7 @@ // CreateMetadataChangeList() so downcasting is safe. static_cast<syncer::InMemoryMetadataChangeList*>(metadata_change_list.get()) ->TransferChangesTo(&sync_metadata_store_change_list); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = sync_metadata_store_change_list.TakeError(); if (error) { metrics_util::LogApplySyncChangesState( @@ -919,7 +919,7 @@ } metrics_util::LogApplySyncChangesState( metrics_util::ApplySyncChangesState::kApplyOK); - return absl::nullopt; + return std::nullopt; } void PasswordSyncBridge::GetData(StorageKeyList storage_keys, @@ -1155,7 +1155,7 @@ return ComputeClientTag(password_data); } -absl::optional<syncer::ModelError> PasswordSyncBridge::CleanupPasswordStore() { +std::optional<syncer::ModelError> PasswordSyncBridge::CleanupPasswordStore() { DatabaseCleanupResult cleanup_result = password_store_sync_->DeleteUndecryptableCredentials(); switch (cleanup_result) { @@ -1172,7 +1172,7 @@ metrics_util::PasswordSyncState::kNotSyncingFailedCleanup); return syncer::ModelError(FROM_HERE, "Failed to cleanup database."); } - return absl::nullopt; + return std::nullopt; } } // namespace password_manager
diff --git a/components/password_manager/core/browser/sync/password_sync_bridge.h b/components/password_manager/core/browser/sync/password_sync_bridge.h index 3f843e30..e78f66a 100644 --- a/components/password_manager/core/browser/sync/password_sync_bridge.h +++ b/components/password_manager/core/browser/sync/password_sync_bridge.h
@@ -54,10 +54,10 @@ // ModelTypeSyncBridge implementation. std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() override; - absl::optional<syncer::ModelError> MergeFullSyncData( + std::optional<syncer::ModelError> MergeFullSyncData( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) override; - absl::optional<syncer::ModelError> ApplyIncrementalSyncChanges( + std::optional<syncer::ModelError> ApplyIncrementalSyncChanges( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_changes) override; void GetData(StorageKeyList storage_keys, DataCallback callback) override; @@ -79,7 +79,7 @@ // (https://crbug.com/730625). This method deletes those logins from the // store. So during merge, the data in sync will be added to the password // store. This should be called during MergeFullSyncData(). - absl::optional<syncer::ModelError> CleanupPasswordStore(); + std::optional<syncer::ModelError> CleanupPasswordStore(); // Retrieves the storage keys of all unsynced passwords in the store. std::set<FormPrimaryKey> GetUnsyncedPasswordsStorageKeys();
diff --git a/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc b/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc index e518aae..5f232276 100644 --- a/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc +++ b/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc
@@ -460,7 +460,7 @@ return data; } - absl::optional<sync_pb::PasswordSpecifics> GetDataFromBridge( + std::optional<sync_pb::PasswordSpecifics> GetDataFromBridge( const std::string& storage_key) { std::unique_ptr<syncer::DataBatch> batch; bridge_->GetData({storage_key}, @@ -470,7 +470,7 @@ })); EXPECT_THAT(batch, NotNull()); if (!batch || !batch->HasNext()) { - return absl::nullopt; + return std::nullopt; } auto [other_storage_key, entity_data] = batch->Next(); EXPECT_THAT(other_storage_key, Eq(storage_key)); @@ -562,7 +562,7 @@ } TEST_F(PasswordSyncBridgeTest, ShouldApplyEmptySyncChangesWithoutError) { - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), syncer::EntityChangeList()); EXPECT_FALSE(error); @@ -582,7 +582,7 @@ EXPECT_CALL(*mock_sync_metadata_store_sync(), UpdateEntityMetadata(syncer::PASSWORDS, kStorageKey, _)); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges(std::move(metadata_change_list), syncer::EntityChangeList()); EXPECT_FALSE(error); @@ -613,7 +613,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateAdd( /*storage_key=*/"", SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); @@ -634,7 +634,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateAdd( /*storage_key=*/"", SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); @@ -669,7 +669,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateUpdate( kStorageKey, SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); @@ -696,7 +696,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateDelete(kStorageKey)); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); @@ -713,7 +713,7 @@ fake_db()->AddLoginWithPrimaryKey(form1); fake_db()->AddLoginWithPrimaryKey(form2); - absl::optional<sync_pb::PasswordSpecifics> optional_specifics = + std::optional<sync_pb::PasswordSpecifics> optional_specifics = GetDataFromBridge(/*storage_key=*/kPrimaryKeyStr1); ASSERT_TRUE(optional_specifics.has_value()); EXPECT_EQ( @@ -729,7 +729,7 @@ TEST_F(PasswordSyncBridgeTest, ShouldNotGetDataForNonExistingStorageKey) { const std::string kPrimaryKeyStr = "1"; - absl::optional<sync_pb::PasswordSpecifics> optional_specifics = + std::optional<sync_pb::PasswordSpecifics> optional_specifics = GetDataFromBridge(/*storage_key=*/kPrimaryKeyStr); EXPECT_FALSE(optional_specifics.has_value()); } @@ -818,7 +818,7 @@ entity_change_list.push_back(syncer::EntityChange::CreateAdd( /*storage_key=*/"", SpecificsToEntity(specifics3))); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); } @@ -872,7 +872,7 @@ /*storage_key=*/"", SpecificsToEntity(specifics1))); entity_change_list.push_back(syncer::EntityChange::CreateAdd( /*storage_key=*/"", SpecificsToEntity(specifics2))); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); } @@ -903,7 +903,7 @@ // Simulate a failed ReadAllCredentials() by returning a kDbError. ON_CALL(*mock_password_store_sync(), ReadAllCredentials) .WillByDefault(testing::Return(FormRetrievalResult::kDbError)); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData(bridge()->CreateMetadataChangeList(), {}); EXPECT_TRUE(error); } @@ -1201,7 +1201,7 @@ SpecificsToEntity(CreateSpecificsWithSignonRealm(kSignonRealm1)))); EXPECT_CALL(*mock_password_store_sync(), RollbackTransaction()); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_TRUE(error); } @@ -1224,7 +1224,7 @@ metadata_changes->UpdateModelTypeState(model_type_state); EXPECT_CALL(*mock_password_store_sync(), RollbackTransaction()); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData(std::move(metadata_changes), {}); EXPECT_TRUE(error); } @@ -1243,7 +1243,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateAdd( /*storage_key=*/"", SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); } @@ -1320,7 +1320,7 @@ EXPECT_CALL(*mock_password_store_sync(), ReadAllCredentials) .WillOnce(Return(FormRetrievalResult::kSuccess)); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData(bridge()->CreateMetadataChangeList(), {}); EXPECT_FALSE(error); } @@ -1364,7 +1364,7 @@ /*storage_key=*/"", SpecificsToEntity(CreateSpecificsWithSignonRealm(kSignonRealm1)))); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(initial_entity_data)); ASSERT_FALSE(error); } @@ -1381,7 +1381,7 @@ /*storage_key=*/"", SpecificsToEntity(CreateSpecificsWithSignonRealm(kSignonRealm1)))); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), std::move(entity_changes)); ASSERT_FALSE(error); @@ -1531,7 +1531,7 @@ /*storage_key=*/"", SpecificsToEntity(blocklisted_specifics))); base::HistogramTester histogram_tester; - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); ASSERT_FALSE(error); histogram_tester.ExpectUniqueSample( @@ -1547,7 +1547,7 @@ fake_db()->AddLoginWithPrimaryKey(MakePasswordForm(kSignonRealm2, 101)); base::HistogramTester histogram_tester; - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), syncer::EntityChangeList()); ASSERT_FALSE(error); histogram_tester.ExpectUniqueSample( @@ -1575,7 +1575,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateAdd( /*storage_key=*/"", SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); @@ -1607,9 +1607,9 @@ entity_change_list.push_back(syncer::EntityChange::CreateAdd( /*storage_key=*/"", SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); - EXPECT_EQ(error, absl::nullopt); + EXPECT_EQ(error, std::nullopt); } TEST_F(PasswordSyncBridgeTest, ShouldPutSecurityIssuesOnLoginChange) { @@ -1649,7 +1649,7 @@ mock_processor(), Put(kPrimaryKeyStr1, EntityDataHasSecurityIssueTypes(kIssuesTypes), _)); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData(bridge()->CreateMetadataChangeList(), {}); EXPECT_FALSE(error); } @@ -1664,7 +1664,7 @@ fake_db()->AddLoginWithPrimaryKey(kForm); - absl::optional<sync_pb::PasswordSpecifics> optional_specifics = + std::optional<sync_pb::PasswordSpecifics> optional_specifics = GetDataFromBridge(/*storage_key=*/kPrimaryKeyStr1); ASSERT_TRUE(optional_specifics.has_value()); ASSERT_TRUE(PasswordIssuesHasExpectedInsecureTypes( @@ -1696,7 +1696,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateUpdate( kStorageKey, SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = + std::optional<syncer::ModelError> error = bridge()->ApplyIncrementalSyncChanges( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); @@ -1729,7 +1729,7 @@ mock_processor(), Put(kStorageKey, EntityDataHasSecurityIssueTypes(kLocalIssuesTypes), _)); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); } @@ -1761,7 +1761,7 @@ syncer::EntityChangeList entity_change_list; entity_change_list.push_back(syncer::EntityChange::CreateAdd( kStorageKey, SpecificsToEntity(specifics))); - absl::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( + std::optional<syncer::ModelError> error = bridge()->MergeFullSyncData( bridge()->CreateMetadataChangeList(), std::move(entity_change_list)); EXPECT_FALSE(error); }
diff --git a/components/password_manager/core/browser/sync_credentials_filter_unittest.cc b/components/password_manager/core/browser/sync_credentials_filter_unittest.cc index 3e2a82bf..2c7d2f5 100644 --- a/components/password_manager/core/browser/sync_credentials_filter_unittest.cc +++ b/components/password_manager/core/browser/sync_credentials_filter_unittest.cc
@@ -117,7 +117,7 @@ scoped_refptr<testing::NiceMock<MockPasswordStoreInterface>> password_store_ = new testing::NiceMock<MockPasswordStoreInterface>; MockWebAuthnCredentialsDelegate webauthn_credentials_delegate_; - absl::optional<std::vector<PasskeyCredential>> passkeys_; + std::optional<std::vector<PasskeyCredential>> passkeys_; bool is_incognito_ = false; raw_ptr<signin::IdentityManager> identity_manager_; std::unique_ptr<TestingPrefServiceSimple> prefs_;
diff --git a/components/password_manager/core/browser/ui/BUILD.gn b/components/password_manager/core/browser/ui/BUILD.gn index 3ddcfec..b0586711 100644 --- a/components/password_manager/core/browser/ui/BUILD.gn +++ b/components/password_manager/core/browser/ui/BUILD.gn
@@ -18,7 +18,6 @@ "//components/password_manager/core/browser/import:csv", "//components/password_manager/core/browser/well_known_change_password", "//components/url_formatter", - "//third_party/abseil-cpp:absl", ] }
diff --git a/components/password_manager/core/browser/ui/credential_ui_entry.cc b/components/password_manager/core/browser/ui/credential_ui_entry.cc index 03d3e5d1..4cdf122 100644 --- a/components/password_manager/core/browser/ui/credential_ui_entry.cc +++ b/components/password_manager/core/browser/ui/credential_ui_entry.cc
@@ -215,7 +215,7 @@ return facets[0].url; } -absl::optional<GURL> CredentialUIEntry::GetChangePasswordURL() const { +std::optional<GURL> CredentialUIEntry::GetChangePasswordURL() const { GURL change_password_origin; auto facetUri = password_manager::FacetURI::FromPotentiallyInvalidSpec( GetFirstSignonRealm()); @@ -231,7 +231,7 @@ return password_manager::CreateChangePasswordUrl(GetURL()); } - return absl::nullopt; + return std::nullopt; } std::vector<CredentialUIEntry::DomainInfo>
diff --git a/components/password_manager/core/browser/ui/credential_ui_entry.h b/components/password_manager/core/browser/ui/credential_ui_entry.h index 9d6a76a2..3960895 100644 --- a/components/password_manager/core/browser/ui/credential_ui_entry.h +++ b/components/password_manager/core/browser/ui/credential_ui_entry.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_UI_CREDENTIAL_UI_ENTRY_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_UI_CREDENTIAL_UI_ENTRY_H_ +#include <optional> #include <string> #include <vector> @@ -13,7 +14,6 @@ #include "components/password_manager/core/browser/import/csv_password.h" #include "components/password_manager/core/browser/passkey_credential.h" #include "components/password_manager/core/browser/password_form.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -162,7 +162,7 @@ // Returns the URL which allows to change the password of compromised // credentials. Can be null for Android credentials. - absl::optional<GURL> GetChangePasswordURL() const; + std::optional<GURL> GetChangePasswordURL() const; // Returns a vector of pairs, where the first element is formatted string // representing website or an Android application and a second parameter is a
diff --git a/components/password_manager/core/browser/ui/passwords_grouper.cc b/components/password_manager/core/browser/ui/passwords_grouper.cc index 03ee058..6af710b 100644 --- a/components/password_manager/core/browser/ui/passwords_grouper.cc +++ b/components/password_manager/core/browser/ui/passwords_grouper.cc
@@ -285,13 +285,13 @@ return forms_iterator->second; } -absl::optional<PasskeyCredential> PasswordsGrouper::GetPasskeyFor( +std::optional<PasskeyCredential> PasswordsGrouper::GetPasskeyFor( const CredentialUIEntry& credential) { // Find the group id based on the sign on realm. auto group_id_iterator = map_signon_realm_to_group_id_.find( SignonRealm(credential.GetFirstSignonRealm())); if (group_id_iterator == map_signon_realm_to_group_id_.end()) { - return absl::nullopt; + return std::nullopt; } // Find the passkey in the group. const std::vector<PasskeyCredential>& passkeys = @@ -300,7 +300,7 @@ base::ranges::find(passkeys, credential.passkey_credential_id, &PasskeyCredential::credential_id); if (passkey_it == passkeys.end()) { - return absl::nullopt; + return std::nullopt; } return *passkey_it; }
diff --git a/components/password_manager/core/browser/ui/passwords_grouper.h b/components/password_manager/core/browser/ui/passwords_grouper.h index 47b3370..bc62014 100644 --- a/components/password_manager/core/browser/ui/passwords_grouper.h +++ b/components/password_manager/core/browser/ui/passwords_grouper.h
@@ -57,8 +57,8 @@ const CredentialUIEntry& credential) const; // Returns the passkey corresponding to the given |credential| entry. If there - // is no corresponding entry, returns absl::nullopt. - absl::optional<PasskeyCredential> GetPasskeyFor( + // is no corresponding entry, returns std::nullopt. + std::optional<PasskeyCredential> GetPasskeyFor( const CredentialUIEntry& credential); void ClearCache();
diff --git a/components/password_manager/core/browser/ui/post_save_compromised_helper.h b/components/password_manager/core/browser/ui/post_save_compromised_helper.h index 7e82354..4782ead 100644 --- a/components/password_manager/core/browser/ui/post_save_compromised_helper.h +++ b/components/password_manager/core/browser/ui/post_save_compromised_helper.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_UI_POST_SAVE_COMPROMISED_HELPER_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_UI_POST_SAVE_COMPROMISED_HELPER_H_ +#include <optional> #include <string> #include "base/containers/span.h" @@ -12,7 +13,6 @@ #include "base/memory/weak_ptr.h" #include "components/password_manager/core/browser/password_form.h" #include "components/password_manager/core/browser/password_store/password_store_consumer.h" -#include "third_party/abseil-cpp/absl/types/optional.h" class PrefService; @@ -67,7 +67,7 @@ void AnalyzeLeakedCredentialsInternal(); // Contains the entry for the currently leaked credentials if it was leaked. - absl::optional<PasswordForm> current_leak_; + std::optional<PasswordForm> current_leak_; // Callback to notify the caller about the bubble type. BubbleCallback callback_; // BubbleType after the callback was executed.
diff --git a/components/password_manager/core/browser/ui/saved_passwords_presenter.cc b/components/password_manager/core/browser/ui/saved_passwords_presenter.cc index afb0705..188c97f 100644 --- a/components/password_manager/core/browser/ui/saved_passwords_presenter.cc +++ b/components/password_manager/core/browser/ui/saved_passwords_presenter.cc
@@ -573,7 +573,7 @@ const CredentialUIEntry& updated_credential) { CHECK(!updated_credential.passkey_credential_id.empty()); CHECK(passkey_store_); - absl::optional<PasskeyCredential> original_credential = + std::optional<PasskeyCredential> original_credential = passwords_grouper_->GetPasskeyFor(updated_credential); if (!original_credential) { return EditResult::kNotFound;
diff --git a/components/password_manager/core/browser/vote_uploads_test_matchers.h b/components/password_manager/core/browser/vote_uploads_test_matchers.h index 89d87d79c..babd876 100644 --- a/components/password_manager/core/browser/vote_uploads_test_matchers.h +++ b/components/password_manager/core/browser/vote_uploads_test_matchers.h
@@ -161,7 +161,7 @@ } MATCHER_P(HasPasswordAttributesVote, is_vote_expected, "") { - absl::optional<std::pair<autofill::PasswordAttribute, bool>> vote = + std::optional<std::pair<autofill::PasswordAttribute, bool>> vote = arg.get_password_attributes_vote(); EXPECT_EQ(is_vote_expected, vote.has_value()); return true;
diff --git a/components/password_manager/core/browser/votes_uploader.cc b/components/password_manager/core/browser/votes_uploader.cc index 2eaa6595..d4d3022 100644 --- a/components/password_manager/core/browser/votes_uploader.cc +++ b/components/password_manager/core/browser/votes_uploader.cc
@@ -32,7 +32,6 @@ #include "components/password_manager/core/browser/password_manager_client.h" #include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/common/password_manager_constants.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using autofill::AutofillDownloadManager; using autofill::AutofillField;
diff --git a/components/password_manager/core/browser/votes_uploader.h b/components/password_manager/core/browser/votes_uploader.h index c478180..edb4b1c 100644 --- a/components/password_manager/core/browser/votes_uploader.h +++ b/components/password_manager/core/browser/votes_uploader.h
@@ -6,6 +6,7 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_VOTES_UPLOADER_H_ #include <map> +#include <optional> #include <string> #include <vector> @@ -18,7 +19,6 @@ #include "components/autofill/core/common/unique_ids.h" #include "components/password_manager/core/browser/form_parsing/password_field_prediction.h" #include "components/password_manager/core/browser/password_form.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace autofill { class AutofillField; @@ -376,7 +376,7 @@ // The matched credential is copied to |username_correction_vote_|, but // |username_correction_vote_.username_element| is set to the name of the // field where the matched username was found. - absl::optional<PasswordForm> username_correction_vote_; + std::optional<PasswordForm> username_correction_vote_; // Whether the password values have been shown to the user on the save prompt. bool has_passwords_revealed_vote_ = false;
diff --git a/components/password_manager/core/browser/votes_uploader_unittest.cc b/components/password_manager/core/browser/votes_uploader_unittest.cc index d31e725..409a9ce 100644 --- a/components/password_manager/core/browser/votes_uploader_unittest.cc +++ b/components/password_manager/core/browser/votes_uploader_unittest.cc
@@ -4,6 +4,7 @@ #include "components/password_manager/core/browser/votes_uploader.h" +#include <optional> #include <string> #include <utility> @@ -30,7 +31,6 @@ #include "components/prefs/testing_pref_service.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using autofill::AutofillDownloadManager; using autofill::CONFIRMATION_PASSWORD; @@ -529,7 +529,7 @@ for (int i = 0; i < kNumberOfRuns; ++i) { votes_uploader.GeneratePasswordAttributesVote(password_value, &form_structure); - absl::optional<std::pair<PasswordAttribute, bool>> vote = + std::optional<std::pair<PasswordAttribute, bool>> vote = form_structure.get_password_attributes_vote(); int attribute_index = static_cast<int>(vote->first); if (vote->second) @@ -586,7 +586,7 @@ votes_uploader.GeneratePasswordAttributesVote(password_value, &form_structure); - absl::optional<std::pair<PasswordAttribute, bool>> vote = + std::optional<std::pair<PasswordAttribute, bool>> vote = form_structure.get_password_attributes_vote(); // Continue if the vote is not about special symbols or implies that no @@ -616,7 +616,7 @@ FormStructure form_structure(form); VotesUploader votes_uploader(&client_, true); votes_uploader.GeneratePasswordAttributesVote(u"1", &form_structure); - absl::optional<std::pair<PasswordAttribute, bool>> vote = + std::optional<std::pair<PasswordAttribute, bool>> vote = form_structure.get_password_attributes_vote(); EXPECT_TRUE(vote.has_value()); size_t reported_length = form_structure.get_password_length_vote(); @@ -631,7 +631,7 @@ u"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr" u"stuvwxyz!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", &form_structure); - absl::optional<std::pair<PasswordAttribute, bool>> vote = + std::optional<std::pair<PasswordAttribute, bool>> vote = form_structure.get_password_attributes_vote(); EXPECT_TRUE(vote.has_value()); } @@ -647,7 +647,7 @@ FormStructure form_structure(form); VotesUploader votes_uploader(&client_, true); votes_uploader.GeneratePasswordAttributesVote(password, &form_structure); - absl::optional<std::pair<PasswordAttribute, bool>> vote = + std::optional<std::pair<PasswordAttribute, bool>> vote = form_structure.get_password_attributes_vote(); EXPECT_FALSE(vote.has_value()) << password;
diff --git a/components/password_manager/core/browser/webauthn_credentials_delegate.h b/components/password_manager/core/browser/webauthn_credentials_delegate.h index 6b1156f..e727507 100644 --- a/components/password_manager/core/browser/webauthn_credentials_delegate.h +++ b/components/password_manager/core/browser/webauthn_credentials_delegate.h
@@ -5,6 +5,7 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_WEBAUTHN_CREDENTIALS_DELEGATE_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_WEBAUTHN_CREDENTIALS_DELEGATE_H_ +#include <optional> #include <string> #include <vector> @@ -12,7 +13,6 @@ #include "base/memory/weak_ptr.h" #include "build/build_config.h" #include "components/password_manager/core/browser/passkey_credential.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace password_manager { @@ -33,9 +33,9 @@ virtual void SelectPasskey(const std::string& backend_id) = 0; // Returns the list of eligible passkeys to fulfill an ongoing WebAuthn - // request if one has been received and is active. Returns absl::nullopt + // request if one has been received and is active. Returns std::nullopt // otherwise. - virtual const absl::optional<std::vector<PasskeyCredential>>& GetPasskeys() + virtual const std::optional<std::vector<PasskeyCredential>>& GetPasskeys() const = 0; // Returns whether a "Use a passkey from a different device" option should
diff --git a/components/password_manager/core/browser/well_known_change_password/BUILD.gn b/components/password_manager/core/browser/well_known_change_password/BUILD.gn index f40fbda..f451a2cc 100644 --- a/components/password_manager/core/browser/well_known_change_password/BUILD.gn +++ b/components/password_manager/core/browser/well_known_change_password/BUILD.gn
@@ -15,7 +15,6 @@ deps = [ "//components/password_manager/core/browser/affiliation", "//services/network/public/cpp", - "//third_party/abseil-cpp:absl", "//url", ] configs += [ "//build/config/compiler:wexit_time_destructors" ]
diff --git a/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.cc b/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.cc index 6b367e1d..34aebd8 100644 --- a/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.cc +++ b/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.cc
@@ -4,6 +4,7 @@ #include "components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.h" +#include <optional> #include <utility> #include "base/time/time.h" @@ -15,7 +16,6 @@ #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/simple_url_loader.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" using password_manager::WellKnownChangePasswordState; @@ -29,8 +29,8 @@ std::unique_ptr<network::SimpleURLLoader> CreateResourceRequestToWellKnownNonExistingResourceFor( const GURL& url, - absl::optional<url::Origin> request_initiator, - absl::optional<network::ResourceRequest::TrustedParams> trusted_params) { + std::optional<url::Origin> request_initiator, + std::optional<network::ResourceRequest::TrustedParams> trusted_params) { auto resource_request = std::make_unique<network::ResourceRequest>(); resource_request->url = CreateWellKnownNonExistingResourceURL(url); resource_request->credentials_mode = network::mojom::CredentialsMode::kOmit; @@ -90,8 +90,8 @@ void WellKnownChangePasswordState::FetchNonExistingResource( network::SharedURLLoaderFactory* url_loader_factory, const GURL& url, - absl::optional<url::Origin> request_initiator, - absl::optional<network::ResourceRequest::TrustedParams> trusted_params) { + std::optional<url::Origin> request_initiator, + std::optional<network::ResourceRequest::TrustedParams> trusted_params) { url_loader_ = CreateResourceRequestToWellKnownNonExistingResourceFor( url, std::move(request_initiator), std::move(trusted_params)); // Binding the callback to |this| is safe, because the State exists until
diff --git a/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.h b/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.h index 911dcc75..53af8a4 100644 --- a/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.h +++ b/components/password_manager/core/browser/well_known_change_password/well_known_change_password_state.h
@@ -6,6 +6,7 @@ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_WELL_KNOWN_CHANGE_PASSWORD_WELL_KNOWN_CHANGE_PASSWORD_STATE_H_ #include <memory> +#include <optional> #include "base/memory/raw_ptr.h" #include "base/memory/scoped_refptr.h" @@ -13,7 +14,6 @@ #include "base/timer/timer.h" #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/simple_url_loader.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -49,9 +49,9 @@ void FetchNonExistingResource( network::SharedURLLoaderFactory* url_loader_factory, const GURL& origin, - absl::optional<url::Origin> request_initiator = absl::nullopt, - absl::optional<network::ResourceRequest::TrustedParams> trusted_params = - absl::nullopt); + std::optional<url::Origin> request_initiator = std::nullopt, + std::optional<network::ResourceRequest::TrustedParams> trusted_params = + std::nullopt); // Prefetch change password URLs from |affiliation_service|. void PrefetchChangePasswordURLs(AffiliationService* affiliation_service, const std::vector<GURL>& urls);
diff --git a/components/password_manager/core/common/credential_manager_types.cc b/components/password_manager/core/common/credential_manager_types.cc index 832a35f..be01b83 100644 --- a/components/password_manager/core/common/credential_manager_types.cc +++ b/components/password_manager/core/common/credential_manager_types.cc
@@ -30,10 +30,10 @@ CredentialInfo::CredentialInfo() = default; CredentialInfo::CredentialInfo(CredentialType type, - absl::optional<std::u16string> id, - absl::optional<std::u16string> name, + std::optional<std::u16string> id, + std::optional<std::u16string> name, GURL icon, - absl::optional<std::u16string> password, + std::optional<std::u16string> password, url::Origin federation) : type(type), id(std::move(id)),
diff --git a/components/password_manager/core/common/credential_manager_types.h b/components/password_manager/core/common/credential_manager_types.h index c51300d..c3376d4 100644 --- a/components/password_manager/core/common/credential_manager_types.h +++ b/components/password_manager/core/common/credential_manager_types.h
@@ -8,11 +8,11 @@ #include <stddef.h> #include <memory> +#include <optional> #include <ostream> #include <string> #include "base/compiler_specific.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -53,10 +53,10 @@ struct CredentialInfo { CredentialInfo(); CredentialInfo(CredentialType type, - absl::optional<std::u16string> id, - absl::optional<std::u16string> name, + std::optional<std::u16string> id, + std::optional<std::u16string> name, GURL icon, - absl::optional<std::u16string> password, + std::optional<std::u16string> password, url::Origin federation); CredentialInfo(const CredentialInfo& other); @@ -68,18 +68,18 @@ // An identifier (username, email address, etc). Corresponds to // WebCredential's id property. - absl::optional<std::u16string> id; + std::optional<std::u16string> id; // An user-friendly name ("Jane Doe"). Corresponds to WebCredential's name // property. - absl::optional<std::u16string> name; + std::optional<std::u16string> name; // The address of this credential's icon (e.g. the user's avatar). // Corresponds to WebCredential's icon property. GURL icon; // Corresponds to WebPasswordCredential's password property. - absl::optional<std::u16string> password; + std::optional<std::u16string> password; // Corresponds to WebFederatedCredential's provider property. url::Origin federation;
diff --git a/components/password_manager/ios/password_form_helper.mm b/components/password_manager/ios/password_form_helper.mm index fc2943407..0cf7ee0 100644 --- a/components/password_manager/ios/password_form_helper.mm +++ b/components/password_manager/ios/password_form_helper.mm
@@ -348,7 +348,7 @@ return HandleSubmittedFormStatus::kRejectedNoDelegate; } - absl::optional<GURL> pageURL = _webState->GetLastCommittedURLIfTrusted(); + std::optional<GURL> pageURL = _webState->GetLastCommittedURLIfTrusted(); if (!pageURL) { return HandleSubmittedFormStatus::kRejectedNoTrustedUrl; }
diff --git a/components/password_manager/ios/password_form_helper_unittest.mm b/components/password_manager/ios/password_form_helper_unittest.mm index 76c6b40..acf157a 100644 --- a/components/password_manager/ios/password_form_helper_unittest.mm +++ b/components/password_manager/ios/password_form_helper_unittest.mm
@@ -61,8 +61,8 @@ ~FakeWebStateWithoutTrustedCommittedUrl() override {} // WebState implementation. - absl::optional<GURL> GetLastCommittedURLIfTrusted() const override { - return absl::nullopt; + std::optional<GURL> GetLastCommittedURLIfTrusted() const override { + return std::nullopt; } };
diff --git a/components/password_manager/ios/password_manager_java_script_feature.h b/components/password_manager/ios/password_manager_java_script_feature.h index 54278b2b2..b3d2e579 100644 --- a/components/password_manager/ios/password_manager_java_script_feature.h +++ b/components/password_manager/ios/password_manager_java_script_feature.h
@@ -82,7 +82,7 @@ const PasswordManagerJavaScriptFeature&) = delete; // web::JavaScriptFeature - absl::optional<std::string> GetScriptMessageHandlerName() const override; + std::optional<std::string> GetScriptMessageHandlerName() const override; void ScriptMessageReceived(web::WebState* web_state, const web::ScriptMessage& message) override;
diff --git a/components/password_manager/ios/password_manager_java_script_feature.mm b/components/password_manager/ios/password_manager_java_script_feature.mm index 904cda0e..1479bf2 100644 --- a/components/password_manager/ios/password_manager_java_script_feature.mm +++ b/components/password_manager/ios/password_manager_java_script_feature.mm
@@ -143,7 +143,7 @@ base::Seconds(kJavaScriptExecutionTimeoutInSeconds)); } -absl::optional<std::string> +std::optional<std::string> PasswordManagerJavaScriptFeature::GetScriptMessageHandlerName() const { return FormSubmittedHandlerName; }
diff --git a/components/password_manager/ios/shared_password_controller.mm b/components/password_manager/ios/shared_password_controller.mm index 97782f1..da370917 100644 --- a/components/password_manager/ios/shared_password_controller.mm +++ b/components/password_manager/ios/shared_password_controller.mm
@@ -266,7 +266,7 @@ // Retrieve the identity of the page. In case the page might be malicous, // returns early. - absl::optional<GURL> pageURL = webState->GetLastCommittedURLIfTrusted(); + std::optional<GURL> pageURL = webState->GetLastCommittedURLIfTrusted(); if (!pageURL) { return; } @@ -538,7 +538,7 @@ metadata:rawSuggestion.metadata]; [suggestions addObject:suggestion]; } - absl::optional<PasswordDropdownState> suggestionState; + std::optional<PasswordDropdownState> suggestionState; if (suggestions.count) { suggestionState = PasswordDropdownState::kStandard; } @@ -1004,7 +1004,7 @@ inFrame:(web::WebFrame*)frame { DCHECK_EQ(_webState, webState); - absl::optional<GURL> pageURL = webState->GetLastCommittedURLIfTrusted(); + std::optional<GURL> pageURL = webState->GetLastCommittedURLIfTrusted(); if (!pageURL || !frame || params.input_missing) { _lastFocusedFormIdentifier = FormRendererId(); _lastFocusedFieldIdentifier = FieldRendererId();
diff --git a/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.cc b/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.cc index 9d816e8..f4c09a0 100644 --- a/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.cc +++ b/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.cc
@@ -68,7 +68,7 @@ *out = password_manager::CSVPassword(url, username, password, note, status); return true; } - absl::optional<std::string> invalid_url; + std::optional<std::string> invalid_url; if (!data.ReadInvalidUrl(&invalid_url)) return false; DCHECK(invalid_url.has_value());
diff --git a/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.h b/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.h index a8170ba6..01d873ca 100644 --- a/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.h +++ b/components/password_manager/services/csv_password/public/mojom/csv_password_parser_traits.h
@@ -5,12 +5,13 @@ #ifndef COMPONENTS_PASSWORD_MANAGER_SERVICES_CSV_PASSWORD_PUBLIC_MOJOM_CSV_PASSWORD_PARSER_TRAITS_H_ #define COMPONENTS_PASSWORD_MANAGER_SERVICES_CSV_PASSWORD_PUBLIC_MOJOM_CSV_PASSWORD_PARSER_TRAITS_H_ +#include <optional> + #include "base/types/expected.h" #include "base/types/expected_macros.h" #include "components/password_manager/core/browser/import/csv_password.h" #include "components/password_manager/services/csv_password/public/mojom/csv_password_parser.mojom.h" #include "mojo/public/cpp/bindings/struct_traits.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace mojo { @@ -33,10 +34,10 @@ static const GURL url(const password_manager::CSVPassword& r) { return r.GetURL().value_or(GURL()); } - static absl::optional<std::string> invalid_url( + static std::optional<std::string> invalid_url( const password_manager::CSVPassword& r) { RETURN_IF_ERROR(r.GetURL()); - return absl::nullopt; + return std::nullopt; } static const std::string& username(const password_manager::CSVPassword& r) { return r.GetUsername();
diff --git a/components/reading_list/core/dual_reading_list_model_unittest.cc b/components/reading_list/core/dual_reading_list_model_unittest.cc index 2035cc2..b9f3a20 100644 --- a/components/reading_list/core/dual_reading_list_model_unittest.cc +++ b/components/reading_list/core/dual_reading_list_model_unittest.cc
@@ -306,7 +306,7 @@ ResetStorage(); static_cast<syncer::ClientTagBasedModelTypeProcessor*>( account_model_ptr_->GetSyncBridgeForTest()->change_processor()) - ->ClearMetadataWhileStopped(); + ->ClearMetadataIfStopped(); EXPECT_CALL(observer_, ReadingListModelBeganBatchUpdates).Times(0); EXPECT_CALL(observer_, ReadingListModelCompletedBatchUpdates).Times(0);
diff --git a/components/signin/internal/identity_manager/primary_account_manager.cc b/components/signin/internal/identity_manager/primary_account_manager.cc index 47a9ba9..ab28e707 100644 --- a/components/signin/internal/identity_manager/primary_account_manager.cc +++ b/components/signin/internal/identity_manager/primary_account_manager.cc
@@ -187,6 +187,10 @@ std::string()); registry->RegisterStringPref(prefs::kGoogleServicesAccountId, std::string()); registry->RegisterBooleanPref(prefs::kGoogleServicesConsentedToSync, false); + registry->RegisterStringPref( + prefs::kGoogleServicesSyncingGaiaIdMigratedToSignedIn, std::string()); + registry->RegisterStringPref( + prefs::kGoogleServicesSyncingUsernameMigratedToSignedIn, std::string()); registry->RegisterBooleanPref(prefs::kAutologinEnabled, true); registry->RegisterListPref(prefs::kReverseAutologinRejectedEmailList); registry->RegisterBooleanPref(prefs::kSigninAllowed, true);
diff --git a/components/signin/public/base/signin_pref_names.cc b/components/signin/public/base/signin_pref_names.cc index 17897fb..620ab92 100644 --- a/components/signin/public/base/signin_pref_names.cc +++ b/components/signin/public/base/signin_pref_names.cc
@@ -75,6 +75,18 @@ const char kGoogleServicesSigninScopedDeviceId[] = "google.services.signin_scoped_device_id"; +// A string indicating the Gaia ID (as in `kGoogleServicesAccountId`) of a +// user who was previously syncing (had `kGoogleServicesConsentedToSync` set to +// true), and was migrated to the signed-in non-syncing state. See feature +// `kMigrateSyncingUserToSignedIn`. +const char kGoogleServicesSyncingGaiaIdMigratedToSignedIn[] = + "google.services.syncing_gaia_id_migrated_to_signed_in"; + +// Like `kGoogleServicesSyncingAccountIdMigratedToSignedIn` but for the username +// instead of the account ID. +const char kGoogleServicesSyncingUsernameMigratedToSignedIn[] = + "google.services.syncing_username_migrated_to_signed_in"; + // Local state pref containing a string regex that restricts which accounts // can be used to log in to chrome (e.g. "*@google.com"). If missing or blank, // all accounts are allowed (no restrictions).
diff --git a/components/signin/public/base/signin_pref_names.h b/components/signin/public/base/signin_pref_names.h index 89f85ff..a5f907c 100644 --- a/components/signin/public/base/signin_pref_names.h +++ b/components/signin/public/base/signin_pref_names.h
@@ -26,6 +26,8 @@ extern const char kGoogleServicesLastSyncingGaiaId[]; extern const char kGoogleServicesLastSyncingUsername[]; extern const char kGoogleServicesSigninScopedDeviceId[]; +extern const char kGoogleServicesSyncingGaiaIdMigratedToSignedIn[]; +extern const char kGoogleServicesSyncingUsernameMigratedToSignedIn[]; extern const char kGoogleServicesUsernamePattern[]; extern const char kRestrictAccountsToPatterns[]; extern const char kReverseAutologinRejectedEmailList[];
diff --git a/components/sync/model/client_tag_based_model_type_processor.cc b/components/sync/model/client_tag_based_model_type_processor.cc index 7e7d977..2037c80 100644 --- a/components/sync/model/client_tag_based_model_type_processor.cc +++ b/components/sync/model/client_tag_based_model_type_processor.cc
@@ -1287,7 +1287,7 @@ metadata.GetModelTypeState(); const EntityMetadataMap& metadata_map = metadata.GetAllMetadata(); - // Check if ClearMetadataWhileStopped() was called before ModelReadyToSync(). + // Check if ClearMetadataIfStopped() was called before ModelReadyToSync(). // If so, clear the metadata from storage (using the bridge's // ApplyDisableSyncChanges()). if (pending_clear_metadata_) { @@ -1419,7 +1419,7 @@ return weak_ptr_factory_for_controller_.GetWeakPtr(); } -void ClientTagBasedModelTypeProcessor::ClearMetadataWhileStopped() { +void ClientTagBasedModelTypeProcessor::ClearMetadataIfStopped() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); // If a model error has been encountered, the local model is assumed to be
diff --git a/components/sync/model/client_tag_based_model_type_processor.h b/components/sync/model/client_tag_based_model_type_processor.h index fcd179e..38cb6449 100644 --- a/components/sync/model/client_tag_based_model_type_processor.h +++ b/components/sync/model/client_tag_based_model_type_processor.h
@@ -121,7 +121,7 @@ base::OnceCallback<void(const TypeEntitiesCount&)> callback) const override; void RecordMemoryUsageAndCountsHistograms() override; - void ClearMetadataWhileStopped() override; + void ClearMetadataIfStopped() override; // Returns the estimate of dynamically allocated memory in bytes. size_t EstimateMemoryUsage() const; @@ -279,7 +279,7 @@ bool model_ready_to_sync_ = false; // Marks whether metadata should be cleared upon ModelReadyToSync(). True if - // ClearMetadataWhileStopped() is called before ModelReadyToSync(). + // ClearMetadataIfStopped() is called before ModelReadyToSync(). bool pending_clear_metadata_ = false; ////////////////
diff --git a/components/sync/model/client_tag_based_model_type_processor_unittest.cc b/components/sync/model/client_tag_based_model_type_processor_unittest.cc index 62f5b37a..a4448488 100644 --- a/components/sync/model/client_tag_based_model_type_processor_unittest.cc +++ b/components/sync/model/client_tag_based_model_type_processor_unittest.cc
@@ -3146,7 +3146,7 @@ EXPECT_FALSE(bridge()->sync_started()); } -TEST_F(ClientTagBasedModelTypeProcessorTest, ShouldClearMetadataWhileStopped) { +TEST_F(ClientTagBasedModelTypeProcessorTest, ShouldClearMetadataIfStopped) { // Bring the processor to a stopped state. InitializeToReadyState(); WritePrefItem(bridge(), kKey1, kValue1); @@ -3159,7 +3159,7 @@ base::HistogramTester histogram_tester; // Should clear the metadata even if already stopped. - type_processor()->ClearMetadataWhileStopped(); + type_processor()->ClearMetadataIfStopped(); EXPECT_FALSE(type_processor()->IsTrackingMetadata()); EXPECT_EQ(0U, db()->model_type_state().ByteSizeLong()); EXPECT_EQ(0U, db()->metadata_count()); @@ -3173,11 +3173,11 @@ } TEST_F(ClientTagBasedModelTypeProcessorTest, - ShouldClearMetadataWhileStoppedUponModelReadyToSync) { + ShouldClearMetadataIfStoppedUponModelReadyToSync) { base::HistogramTester histogram_tester; // Called before ModelReadyToSync(). - type_processor()->ClearMetadataWhileStopped(); + type_processor()->ClearMetadataIfStopped(); // Nothing recorded to the histograms yet. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); @@ -3218,7 +3218,7 @@ base::HistogramTester histogram_tester; // Called before ModelReadyToSync(). - type_processor()->ClearMetadataWhileStopped(); + type_processor()->ClearMetadataIfStopped(); // Nothing recorded to the histograms yet. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); @@ -3260,7 +3260,7 @@ base::HistogramTester histogram_tester; // Should NOT clear the metadata since the processor is not stopped. - type_processor()->ClearMetadataWhileStopped(); + type_processor()->ClearMetadataIfStopped(); EXPECT_TRUE(type_processor()->IsTrackingMetadata()); EXPECT_NE(0U, db()->model_type_state().ByteSizeLong()); EXPECT_NE(0U, db()->metadata_count()); @@ -3269,7 +3269,7 @@ } TEST_F(ClientTagBasedModelTypeProcessorTest, - ShouldNotClearMetadataWhileStoppedIfNotTracking) { + ShouldNotClearMetadataIfStoppedIfNotTracking) { // Bring the processor to a stopped state. InitializeToReadyState(); type_processor()->OnSyncStopping(CLEAR_METADATA); @@ -3280,7 +3280,7 @@ base::HistogramTester histogram_tester; // Should do nothing since there's nothing to clear. - type_processor()->ClearMetadataWhileStopped(); + type_processor()->ClearMetadataIfStopped(); // Expect no entry to the histogram. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); histogram_tester.ExpectTotalCount( @@ -3288,16 +3288,16 @@ } TEST_F(ClientTagBasedModelTypeProcessorTest, - ShouldNotClearMetadataWhileStoppedWithoutMetadataInitially) { + ShouldNotClearMetadataIfStoppedWithoutMetadataInitially) { InitializeToMetadataLoaded( sync_pb::ModelTypeState::INITIAL_SYNC_STATE_UNSPECIFIED); ASSERT_FALSE(type_processor()->IsTrackingMetadata()); base::HistogramTester histogram_tester; - // Call ClearMetadataWhileStopped() without a prior call to OnSyncStopping(). + // Call ClearMetadataIfStopped() without a prior call to OnSyncStopping(). // Since there's no metadata, this should do nothing. - type_processor()->ClearMetadataWhileStopped(); + type_processor()->ClearMetadataIfStopped(); // Expect no entry to the histogram. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); histogram_tester.ExpectTotalCount( @@ -3305,11 +3305,11 @@ } TEST_F(ClientTagBasedModelTypeProcessorTest, - ShouldNotClearMetadataWhileStoppedUponModelReadyToSyncWithoutMetadata) { + ShouldNotClearMetadataIfStoppedUponModelReadyToSyncWithoutMetadata) { base::HistogramTester histogram_tester; // Called before ModelReadyToSync(). - type_processor()->ClearMetadataWhileStopped(); + type_processor()->ClearMetadataIfStopped(); InitializeToMetadataLoaded( sync_pb::ModelTypeState::INITIAL_SYNC_STATE_UNSPECIFIED);
diff --git a/components/sync/model/forwarding_model_type_controller_delegate.cc b/components/sync/model/forwarding_model_type_controller_delegate.cc index d1a07ca..8c1195c4 100644 --- a/components/sync/model/forwarding_model_type_controller_delegate.cc +++ b/components/sync/model/forwarding_model_type_controller_delegate.cc
@@ -44,11 +44,11 @@ other_->RecordMemoryUsageAndCountsHistograms(); } -void ForwardingModelTypeControllerDelegate::ClearMetadataWhileStopped() { +void ForwardingModelTypeControllerDelegate::ClearMetadataIfStopped() { // `other_` can be null during testing. // TODO(crbug.com/1418351): Remove test-only code-path. if (other_) { - other_->ClearMetadataWhileStopped(); + other_->ClearMetadataIfStopped(); } }
diff --git a/components/sync/model/forwarding_model_type_controller_delegate.h b/components/sync/model/forwarding_model_type_controller_delegate.h index d88d6ebb..b583a3f0 100644 --- a/components/sync/model/forwarding_model_type_controller_delegate.h +++ b/components/sync/model/forwarding_model_type_controller_delegate.h
@@ -38,7 +38,7 @@ base::OnceCallback<void(const TypeEntitiesCount&)> callback) const override; void RecordMemoryUsageAndCountsHistograms() override; - void ClearMetadataWhileStopped() override; + void ClearMetadataIfStopped() override; private: const raw_ptr<ModelTypeControllerDelegate, AcrossTasksDanglingUntriaged>
diff --git a/components/sync/model/model_type_controller_delegate.h b/components/sync/model/model_type_controller_delegate.h index e6b52dc3..70a676a 100644 --- a/components/sync/model/model_type_controller_delegate.h +++ b/components/sync/model/model_type_controller_delegate.h
@@ -56,8 +56,7 @@ virtual void RecordMemoryUsageAndCountsHistograms() = 0; // Clear metadata if the model is stopped. - // TODO(crbug.com/1502832): Rename to ClearMetadataIfStopped. - virtual void ClearMetadataWhileStopped() = 0; + virtual void ClearMetadataIfStopped() = 0; }; } // namespace syncer
diff --git a/components/sync/model/proxy_model_type_controller_delegate.cc b/components/sync/model/proxy_model_type_controller_delegate.cc index a2355a5..7361e257 100644 --- a/components/sync/model/proxy_model_type_controller_delegate.cc +++ b/components/sync/model/proxy_model_type_controller_delegate.cc
@@ -54,10 +54,10 @@ delegate->RecordMemoryUsageAndCountsHistograms(); } -void ClearMetadataWhileStoppedHelperOnModelThread( +void ClearMetadataIfStoppedHelperOnModelThread( base::WeakPtr<ModelTypeControllerDelegate> delegate) { DCHECK(delegate); - delegate->ClearMetadataWhileStopped(); + delegate->ClearMetadataIfStopped(); } // Rurns some task on the destination task runner (backend sequence), first @@ -120,9 +120,9 @@ base::BindOnce(&RecordMemoryUsageAndCountsHistogramsHelperOnModelThread)); } -void ProxyModelTypeControllerDelegate::ClearMetadataWhileStopped() { +void ProxyModelTypeControllerDelegate::ClearMetadataIfStopped() { PostTask(FROM_HERE, - base::BindOnce(&ClearMetadataWhileStoppedHelperOnModelThread)); + base::BindOnce(&ClearMetadataIfStoppedHelperOnModelThread)); } void ProxyModelTypeControllerDelegate::PostTask(
diff --git a/components/sync/model/proxy_model_type_controller_delegate.h b/components/sync/model/proxy_model_type_controller_delegate.h index ef92ad2d..b469858 100644 --- a/components/sync/model/proxy_model_type_controller_delegate.h +++ b/components/sync/model/proxy_model_type_controller_delegate.h
@@ -42,7 +42,7 @@ base::OnceCallback<void(const TypeEntitiesCount&)> callback) const override; void RecordMemoryUsageAndCountsHistograms() override; - void ClearMetadataWhileStopped() override; + void ClearMetadataIfStopped() override; private: // Post the given task (that requires the destination delegate to run) to
diff --git a/components/sync/nigori/nigori_model_type_processor.cc b/components/sync/nigori/nigori_model_type_processor.cc index 3fb1a3f..2b7fd4b 100644 --- a/components/sync/nigori/nigori_model_type_processor.cc +++ b/components/sync/nigori/nigori_model_type_processor.cc
@@ -490,7 +490,7 @@ sync_pb::EntitySpecifics::kNigoriFieldNumber); } -void NigoriModelTypeProcessor::ClearMetadataWhileStopped() { +void NigoriModelTypeProcessor::ClearMetadataIfStopped() { // Nigori has a separate load callback and way to clear data. In particular, // Nigori is never considered to be stopped. }
diff --git a/components/sync/nigori/nigori_model_type_processor.h b/components/sync/nigori/nigori_model_type_processor.h index 20a0cc1..2c85895 100644 --- a/components/sync/nigori/nigori_model_type_processor.h +++ b/components/sync/nigori/nigori_model_type_processor.h
@@ -58,7 +58,7 @@ base::OnceCallback<void(const TypeEntitiesCount&)> callback) const override; void RecordMemoryUsageAndCountsHistograms() override; - void ClearMetadataWhileStopped() override; + void ClearMetadataIfStopped() override; // NigoriLocalChangeProcessor implementation. void ModelReadyToSync(NigoriSyncBridge* bridge,
diff --git a/components/sync/service/model_type_controller.cc b/components/sync/service/model_type_controller.cc index 1baf70a8..7c0f3b2 100644 --- a/components/sync/service/model_type_controller.cc +++ b/components/sync/service/model_type_controller.cc
@@ -179,7 +179,7 @@ // this is a no-op for the delegate that was just started. Note^2 that that // also covers the case of data types using the same underlying delegate for // both modes. - ClearMetadataWhileStopped(); + ClearMetadataIfStopped(); } std::unique_ptr<DataTypeActivationResponse> ModelTypeController::Connect() { @@ -204,7 +204,7 @@ std::move(callback).Run(); // Clear metadata if needed. if (fate == CLEAR_METADATA) { - ClearMetadataWhileStopped(); + ClearMetadataIfStopped(); } return; @@ -393,12 +393,12 @@ } } -void ModelTypeController::ClearMetadataWhileStopped() { +void ModelTypeController::ClearMetadataIfStopped() { for (auto& [sync_mode, delegate] : delegate_map_) { // `delegate` can be null during testing. // TODO(crbug.com/1418351): Remove test-only code-path. if (delegate) { - delegate->ClearMetadataWhileStopped(); + delegate->ClearMetadataIfStopped(); } } }
diff --git a/components/sync/service/model_type_controller.h b/components/sync/service/model_type_controller.h index ea236bf..9e6edcd1 100644 --- a/components/sync/service/model_type_controller.h +++ b/components/sync/service/model_type_controller.h
@@ -73,7 +73,7 @@ void OnDelegateStarted( std::unique_ptr<DataTypeActivationResponse> activation_response); void TriggerCompletionCallbacks(const SyncError& error); - void ClearMetadataWhileStopped(); + void ClearMetadataIfStopped(); base::flat_map<SyncMode, std::unique_ptr<ModelTypeControllerDelegate>> delegate_map_;
diff --git a/components/sync/service/model_type_controller_unittest.cc b/components/sync/service/model_type_controller_unittest.cc index d3fdf00..c441542 100644 --- a/components/sync/service/model_type_controller_unittest.cc +++ b/components/sync/service/model_type_controller_unittest.cc
@@ -64,7 +64,7 @@ (base::OnceCallback<void(const TypeEntitiesCount&)> callback), (const override)); MOCK_METHOD(void, RecordMemoryUsageAndCountsHistograms, (), (override)); - MOCK_METHOD(void, ClearMetadataWhileStopped, (), (override)); + MOCK_METHOD(void, ClearMetadataIfStopped, (), (override)); }; // Class used to expose ReportModelError() publicly. @@ -295,9 +295,9 @@ // Test emulates disabling sync when datatype is not loaded yet. TEST_F(ModelTypeControllerTest, StopBeforeLoadModels) { // OnSyncStopping() should not be called, since the delegate was never - // started. Instead, ClearMetadataWhileStopped() should get called. + // started. Instead, ClearMetadataIfStopped() should get called. EXPECT_CALL(*delegate(), OnSyncStopping(_)).Times(0); - EXPECT_CALL(*delegate(), ClearMetadataWhileStopped()); + EXPECT_CALL(*delegate(), ClearMetadataIfStopped()); ASSERT_EQ(DataTypeController::NOT_RUNNING, controller()->state()); @@ -641,12 +641,12 @@ { InSequence s; EXPECT_CALL(*delegate(), OnSyncStopping(KEEP_METADATA)); - EXPECT_CALL(*delegate(), ClearMetadataWhileStopped); + EXPECT_CALL(*delegate(), ClearMetadataIfStopped); } controller()->Stop(SyncStopMetadataFate::KEEP_METADATA, base::DoNothing()); ASSERT_EQ(DataTypeController::NOT_RUNNING, controller()->state()); - // ClearMetadataWhileStopped() should be called on Stop() even if state is + // ClearMetadataIfStopped() should be called on Stop() even if state is // NOT_RUNNING. controller()->Stop(SyncStopMetadataFate::CLEAR_METADATA, base::DoNothing()); ASSERT_EQ(DataTypeController::NOT_RUNNING, controller()->state()); @@ -668,10 +668,10 @@ activation_request.error_handler.Run(ModelError(FROM_HERE, "Test error")); base::RunLoop().RunUntilIdle(); - // ClearMetadataWhileStopped() should not be called on Stop() if the state is + // ClearMetadataIfStopped() should not be called on Stop() if the state is // FAILED. ASSERT_EQ(DataTypeController::FAILED, controller()->state()); - EXPECT_CALL(*delegate(), ClearMetadataWhileStopped).Times(0); + EXPECT_CALL(*delegate(), ClearMetadataIfStopped).Times(0); controller()->Stop(SyncStopMetadataFate::CLEAR_METADATA, base::DoNothing()); ASSERT_EQ(DataTypeController::FAILED, controller()->state()); }
diff --git a/components/sync/service/sync_prefs.cc b/components/sync/service/sync_prefs.cc index 6531a73..fbdc9d2 100644 --- a/components/sync/service/sync_prefs.cc +++ b/components/sync/service/sync_prefs.cc
@@ -214,7 +214,13 @@ } else { // All types except for History and Tabs are enabled by default. type_enabled = type != UserSelectableType::kHistory && - type != UserSelectableType::kTabs; + type != UserSelectableType::kTabs +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + // Passwords are off by default on Desktop and have + // dedicated opt-in UI. + && type != UserSelectableType::kPasswords +#endif + ; } #if BUILDFLAG(IS_IOS) @@ -284,6 +290,25 @@ return pref_service_->IsPreferenceManagedByCustodian(pref_name); } +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) +int SyncPrefs::GetNumberOfAccountsWithPasswordsSelected() const { + int n_accounts = 0; + for (auto [serialized_gaia_id_hash, selected_types] : + pref_service_->GetDict(prefs::internal::kSelectedTypesPerAccount)) { + // `selected_types` should be a dict but doesn't hurt to check and be safe. + bool enabled = + selected_types.is_dict() && + selected_types.GetDict() + .FindBool(GetPrefNameForType(UserSelectableType::kPasswords)) + .value_or(false); + if (enabled) { + n_accounts++; + } + } + return n_accounts; +} +#endif + void SyncPrefs::SetSelectedTypes(bool keep_everything_synced, UserSelectableTypeSet registered_types, UserSelectableTypeSet selected_types) { @@ -846,6 +871,62 @@ pref_service->SetBoolean(kObsoleteAutofillWalletImportEnabledMigrated, true); } +// static +void SyncPrefs::MigrateGlobalDataTypePrefsToAccount( + PrefService* pref_service, + const signin::GaiaIdHash& gaia_id_hash) { + CHECK(gaia_id_hash.IsValid()); + + // Note: This method does *not* ensure that the migration only runs once - + // that's the caller's responsibility! (In practice, that's + // MaybeMigrateSyncingUserToSignedIn()). + + ScopedDictPrefUpdate update_selected_types_dict( + pref_service, prefs::internal::kSelectedTypesPerAccount); + base::Value::Dict* account_settings = + update_selected_types_dict->EnsureDict(gaia_id_hash.ToBase64()); + + // The values of the "global" data type prefs get copied to the + // account-specific ones. + bool everything_enabled = + pref_service->GetBoolean(prefs::internal::kSyncKeepEverythingSynced); + // History and Tabs should remain enabled only if they were both enabled + // previously, so they're specially tracked here. + bool history_and_tabs_enabled = false; + if (everything_enabled) { + // Most of the per-account prefs default to "true", so nothing needs to be + // done for those. The exceptions are History and Tabs, which need to be + // enabled explicitly. + history_and_tabs_enabled = true; + } else { + // "Sync everything" is off, so copy over the individual value for each + // type. + for (UserSelectableType type : UserSelectableTypeSet::All()) { + const char* pref_name = GetPrefNameForType(type); + CHECK(pref_name); + // Copy value from global to per-account pref. + account_settings->Set(pref_name, pref_service->GetBoolean(pref_name)); + } + // Special case: History and Tabs remain enabled only if they were both + // enabled previously. + history_and_tabs_enabled = + pref_service->GetBoolean( + GetPrefNameForType(UserSelectableType::kHistory)) && + pref_service->GetBoolean(GetPrefNameForType(UserSelectableType::kTabs)); + } + account_settings->Set(GetPrefNameForType(UserSelectableType::kHistory), + history_and_tabs_enabled); + account_settings->Set(GetPrefNameForType(UserSelectableType::kTabs), + history_and_tabs_enabled); + + // Usually, the "SyncToSignin" migration (aka phase 2) will have completed + // previously. But just in case it hasn't, make sure it doesn't run in the + // future - it's not neeced, and in fact it might mess up some of the things + // that were just migrated here. + pref_service->SetInteger(kSyncToSigninMigrationState, + kMigratedPart2AndFullyDone); +} + void SyncPrefs::MarkPartialSyncToSigninMigrationFullyDone() { // If the first part of the migration has run, but the second part has not, // then mark the migration as fully done - at this point (after signout)
diff --git a/components/sync/service/sync_prefs.h b/components/sync/service/sync_prefs.h index fc3fc4a..d22eedf 100644 --- a/components/sync/service/sync_prefs.h +++ b/components/sync/service/sync_prefs.h
@@ -106,6 +106,12 @@ // parent/guardian of a child account). bool IsTypeManagedByCustodian(UserSelectableType type) const; +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + // On Desktop, kPasswords isn't considered "selected" by default in transport + // mode. This method returns how many accounts selected (enabled) the type. + int GetNumberOfAccountsWithPasswordsSelected() const; +#endif + // Sets the selection state for all |registered_types| and "keep everything // synced" flag. // |keep_everything_synced| indicates that all current and future types @@ -251,6 +257,14 @@ static void MigrateAutofillWalletImportEnabledPref(PrefService* pref_service); + // Copies the global versions of the selected-types prefs (used for syncing + // users) to the per-account prefs for the given `gaia_id_hash` (used for + // signed-in non-syncing users). To be used when an existing syncing user is + // migrated to signed-in. + static void MigrateGlobalDataTypePrefsToAccount( + PrefService* pref_service, + const signin::GaiaIdHash& gaia_id_hash); + private: static void RegisterTypeSelectedPref(PrefRegistrySimple* prefs, UserSelectableType type);
diff --git a/components/sync/service/sync_prefs_unittest.cc b/components/sync/service/sync_prefs_unittest.cc index fc6c1e6..df763bf 100644 --- a/components/sync/service/sync_prefs_unittest.cc +++ b/components/sync/service/sync_prefs_unittest.cc
@@ -332,6 +332,11 @@ UserSelectableType::kPasswords, UserSelectableType::kAutofill, UserSelectableType::kPayments}; +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + // On Desktop, kPasswords is disabled by default. + expected_types.Remove(UserSelectableType::kPasswords); +#endif + #if BUILDFLAG(IS_IOS) // On iOS, Bookmarks and Reading list require a dedicated opt-in. EXPECT_EQ( @@ -367,6 +372,12 @@ UserSelectableType::kBookmarks, UserSelectableType::kReadingList, UserSelectableType::kPasswords, UserSelectableType::kAutofill, UserSelectableType::kPayments, UserSelectableType::kPreferences}; + +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + // On Desktop, kPasswords is disabled by default. + expected_types.Remove(UserSelectableType::kPasswords); +#endif + EXPECT_EQ(sync_prefs_->GetSelectedTypesForAccount(gaia_id_hash_), expected_types); } @@ -632,6 +643,32 @@ } #endif // BUILDFLAG(IS_IOS) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) +TEST_F(SyncPrefsTest, GetNumberOfAccountsWithPasswordsSelected) { + EXPECT_EQ(sync_prefs_->GetNumberOfAccountsWithPasswordsSelected(), 0); + + sync_prefs_->SetSelectedTypeForAccount(UserSelectableType::kPasswords, true, + gaia_id_hash_); + + EXPECT_EQ(sync_prefs_->GetNumberOfAccountsWithPasswordsSelected(), 1); + + const auto other_gaia_id_hash = signin::GaiaIdHash::FromGaiaId("other"); + sync_prefs_->SetSelectedTypeForAccount(UserSelectableType::kPasswords, true, + other_gaia_id_hash); + + EXPECT_EQ(sync_prefs_->GetNumberOfAccountsWithPasswordsSelected(), 2); + + sync_prefs_->SetSelectedTypeForAccount(UserSelectableType::kPasswords, false, + gaia_id_hash_); + + EXPECT_EQ(sync_prefs_->GetNumberOfAccountsWithPasswordsSelected(), 1); + + sync_prefs_->KeepAccountSettingsPrefsOnlyForUsers({}); + + EXPECT_EQ(sync_prefs_->GetNumberOfAccountsWithPasswordsSelected(), 0); +} +#endif + enum BooleanPrefState { PREF_FALSE, PREF_TRUE, PREF_UNSET }; // Similar to SyncPrefsTest, but does not create a SyncPrefs instance. This lets @@ -1172,6 +1209,151 @@ } } +TEST_F(SyncPrefsMigrationTest, GlobalToAccount_DefaultState) { + base::test::ScopedFeatureList enable_sync_to_signin( + kReplaceSyncPromosWithSignInPromos); + + // Everything is in the default state. Notably, "Sync Everything" is true. + + // Pre-migration (without any explicit per-account settings), most supported + // types are considered selected by default - except for kHistory and kTabs. + // Note that this is not exhaustive - depending on feature flags, additional + // types may be supported and default-enabled. + const UserSelectableTypeSet default_enabled_types{ + UserSelectableType::kAutofill, UserSelectableType::kBookmarks, + UserSelectableType::kPasswords, UserSelectableType::kPayments, + UserSelectableType::kPreferences, UserSelectableType::kReadingList}; + ASSERT_TRUE(SyncPrefs(&pref_service_) + .GetSelectedTypesForAccount(gaia_id_hash_) + .HasAll(default_enabled_types)); + ASSERT_FALSE( + SyncPrefs(&pref_service_) + .GetSelectedTypesForAccount(gaia_id_hash_) + .HasAny({UserSelectableType::kHistory, UserSelectableType::kTabs})); + + SyncPrefs::MigrateGlobalDataTypePrefsToAccount(&pref_service_, gaia_id_hash_); + + // All supported types should be considered selected for this account now, + // including kHistory and kTabs. + SyncPrefs prefs(&pref_service_); + UserSelectableTypeSet selected_types = + prefs.GetSelectedTypesForAccount(gaia_id_hash_); + EXPECT_TRUE(selected_types.HasAll(default_enabled_types)); + EXPECT_TRUE(selected_types.Has(UserSelectableType::kHistory)); + EXPECT_TRUE(selected_types.Has(UserSelectableType::kTabs)); +} + +TEST_F(SyncPrefsMigrationTest, GlobalToAccount_CustomState) { + base::test::ScopedFeatureList enable_sync_to_signin( + kReplaceSyncPromosWithSignInPromos); + + // The user has chosen specific data types to sync. In this example, Bookmarks + // and Preferences are disabled. + const UserSelectableTypeSet old_selected_types{ + UserSelectableType::kAutofill, UserSelectableType::kHistory, + UserSelectableType::kPasswords, UserSelectableType::kPayments, + UserSelectableType::kReadingList, UserSelectableType::kTabs}; + { + SyncPrefs old_prefs(&pref_service_); + old_prefs.SetSelectedTypes( + /*keep_everything_synced=*/false, + /*registered_types=*/UserSelectableTypeSet::All(), old_selected_types); + } + + // Pre-migration (without any explicit per-account settings), most supported + // types are considered selected by default, including Bookmarks and + // Preferences - but not History or Tabs. + // Note that this is not exhaustive - depending on feature flags, additional + // types may be supported and default-enabled. + ASSERT_TRUE(SyncPrefs(&pref_service_) + .GetSelectedTypesForAccount(gaia_id_hash_) + .HasAll({UserSelectableType::kAutofill, + UserSelectableType::kBookmarks, + UserSelectableType::kPasswords, + UserSelectableType::kPayments, + UserSelectableType::kPreferences, + UserSelectableType::kReadingList})); + ASSERT_FALSE( + SyncPrefs(&pref_service_) + .GetSelectedTypesForAccount(gaia_id_hash_) + .HasAny({UserSelectableType::kHistory, UserSelectableType::kTabs})); + + SyncPrefs::MigrateGlobalDataTypePrefsToAccount(&pref_service_, gaia_id_hash_); + + // After the migration, exactly the same types should be selected as before. + SyncPrefs prefs(&pref_service_); + EXPECT_EQ(prefs.GetSelectedTypesForAccount(gaia_id_hash_), + old_selected_types); +} + +TEST_F(SyncPrefsMigrationTest, GlobalToAccount_HistoryDisabled) { + base::test::ScopedFeatureList enable_sync_to_signin( + kReplaceSyncPromosWithSignInPromos); + + // All types except for kHistory are selected in the global prefs. + { + SyncPrefs old_prefs(&pref_service_); + UserSelectableTypeSet selected_types = UserSelectableTypeSet::All(); + selected_types.Remove(UserSelectableType::kHistory); + old_prefs.SetSelectedTypes( + /*keep_everything_synced=*/false, + /*registered_types=*/UserSelectableTypeSet::All(), selected_types); + } + + SyncPrefs::MigrateGlobalDataTypePrefsToAccount(&pref_service_, gaia_id_hash_); + + // After the migration, both kHistory and kTabs should be disabled, since + // there is only a single toggle for both of them. + SyncPrefs prefs(&pref_service_); + UserSelectableTypeSet selected_types = + prefs.GetSelectedTypesForAccount(gaia_id_hash_); + EXPECT_FALSE(selected_types.Has(UserSelectableType::kHistory)); + EXPECT_FALSE(selected_types.Has(UserSelectableType::kTabs)); +} + +TEST_F(SyncPrefsMigrationTest, GlobalToAccount_TabsDisabled) { + base::test::ScopedFeatureList enable_sync_to_signin( + kReplaceSyncPromosWithSignInPromos); + + // All types except for kHistory are selected in the global prefs. + { + SyncPrefs old_prefs(&pref_service_); + UserSelectableTypeSet selected_types = UserSelectableTypeSet::All(); + selected_types.Remove(UserSelectableType::kTabs); + old_prefs.SetSelectedTypes( + /*keep_everything_synced=*/false, + /*registered_types=*/UserSelectableTypeSet::All(), selected_types); + } + + SyncPrefs::MigrateGlobalDataTypePrefsToAccount(&pref_service_, gaia_id_hash_); + + // After the migration, both kHistory and kTabs should be disabled, since + // there is only a single toggle for both of them. + SyncPrefs prefs(&pref_service_); + UserSelectableTypeSet selected_types = + prefs.GetSelectedTypesForAccount(gaia_id_hash_); + EXPECT_FALSE(selected_types.Has(UserSelectableType::kHistory)); + EXPECT_FALSE(selected_types.Has(UserSelectableType::kTabs)); +} + +TEST_F(SyncPrefsMigrationTest, + GlobalToAccount_SuppressesSyncToSigninMigration) { + base::test::ScopedFeatureList enable_sync_to_signin( + kReplaceSyncPromosWithSignInPromos); + + SyncPrefs::MigrateGlobalDataTypePrefsToAccount(&pref_service_, gaia_id_hash_); + + // After the GlobalToAccount migration has run, the SyncToSignin migration + // should not have any effect anymore. + SyncPrefs prefs(&pref_service_); +#if BUILDFLAG(IS_IOS) + prefs.MaybeMigratePasswordsToPerAccountPref( + SyncPrefs::SyncAccountState::kSignedInNotSyncing, gaia_id_hash_); +#endif // BUILDFLAG(IS_IOS) + EXPECT_FALSE(prefs.MaybeMigratePrefsForSyncToSigninPart1( + SyncPrefs::SyncAccountState::kSignedInNotSyncing, gaia_id_hash_)); +} + } // namespace } // namespace syncer
diff --git a/components/sync/service/sync_user_settings.h b/components/sync/service/sync_user_settings.h index e4076a1..2caf95d3 100644 --- a/components/sync/service/sync_user_settings.h +++ b/components/sync/service/sync_user_settings.h
@@ -57,6 +57,13 @@ virtual bool IsTypeManagedByPolicy(UserSelectableType type) const = 0; virtual bool IsTypeManagedByCustodian(UserSelectableType type) const = 0; +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + // On Desktop, kPasswords isn't considered "selected" by default in transport + // mode. This method returns how many accounts selected (enabled) the type. + // TODO(crbug.com/1503669): Remove this once the type is enabled by default. + virtual int GetNumberOfAccountsWithPasswordsSelected() const = 0; +#endif + // Whether the "Sync everything" is enabled. This only has an effect if // Sync-the-feature is enabled. Note that even if this is true, some types may // be disabled e.g. due to enterprise policy.
diff --git a/components/sync/service/sync_user_settings_impl.cc b/components/sync/service/sync_user_settings_impl.cc index e7edee7..362a0a77 100644 --- a/components/sync/service/sync_user_settings_impl.cc +++ b/components/sync/service/sync_user_settings_impl.cc
@@ -126,6 +126,12 @@ return prefs_->IsTypeManagedByCustodian(type); } +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) +int SyncUserSettingsImpl::GetNumberOfAccountsWithPasswordsSelected() const { + return prefs_->GetNumberOfAccountsWithPasswordsSelected(); +} +#endif + void SyncUserSettingsImpl::SetSelectedTypes(bool sync_everything, UserSelectableTypeSet types) { UserSelectableTypeSet registered_types = GetRegisteredSelectableTypes();
diff --git a/components/sync/service/sync_user_settings_impl.h b/components/sync/service/sync_user_settings_impl.h index c0ad7c8..3349841 100644 --- a/components/sync/service/sync_user_settings_impl.h +++ b/components/sync/service/sync_user_settings_impl.h
@@ -60,6 +60,9 @@ UserSelectableTypeSet GetSelectedTypes() const override; bool IsTypeManagedByPolicy(UserSelectableType type) const override; bool IsTypeManagedByCustodian(UserSelectableType type) const override; +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + int GetNumberOfAccountsWithPasswordsSelected() const override; +#endif void SetSelectedTypes(bool sync_everything, UserSelectableTypeSet types) override; void SetSelectedType(UserSelectableType type, bool is_type_on) override;
diff --git a/components/sync/service/sync_user_settings_impl_unittest.cc b/components/sync/service/sync_user_settings_impl_unittest.cc index 93082056..9d4ef7b19 100644 --- a/components/sync/service/sync_user_settings_impl_unittest.cc +++ b/components/sync/service/sync_user_settings_impl_unittest.cc
@@ -179,6 +179,11 @@ UserSelectableType::kApps, UserSelectableType::kExtensions, UserSelectableType::kThemes, UserSelectableType::kSavedTabGroups}; +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + // On Desktop, kPasswords is disabled by default. + expected_disabled_types.Put(UserSelectableType::kPasswords); +#endif + EXPECT_EQ(selected_types, Difference(registered_types, expected_disabled_types)); }
diff --git a/components/sync/service/syncable_service_based_model_type_controller.cc b/components/sync/service/syncable_service_based_model_type_controller.cc index 016abda..184d5ee 100644 --- a/components/sync/service/syncable_service_based_model_type_controller.cc +++ b/components/sync/service/syncable_service_based_model_type_controller.cc
@@ -84,11 +84,11 @@ GetBridgeDelegate()->RecordMemoryUsageAndCountsHistograms(); } - void ClearMetadataWhileStopped() override { + void ClearMetadataIfStopped() override { if (!bridge_) { return; } - GetBridgeDelegate()->ClearMetadataWhileStopped(); + GetBridgeDelegate()->ClearMetadataIfStopped(); } private:
diff --git a/components/sync/test/fake_model_type_controller_delegate.cc b/components/sync/test/fake_model_type_controller_delegate.cc index 4075433..b0f26657 100644 --- a/components/sync/test/fake_model_type_controller_delegate.cc +++ b/components/sync/test/fake_model_type_controller_delegate.cc
@@ -117,10 +117,9 @@ return response; } -void FakeModelTypeControllerDelegate::ClearMetadataWhileStopped() { - // If Sync is not actually stopped, ignore this call. - // This mirrors logic in ClientTagBasedModelTypeProcessor and - // BookmarkModelTypeProcessor. +void FakeModelTypeControllerDelegate::ClearMetadataIfStopped() { + // If Sync is not actually stopped, ignore this call. This mirrors logic in + // ClientTagBasedModelTypeProcessor and BookmarkModelTypeProcessor. if (sync_started_) { return; }
diff --git a/components/sync/test/fake_model_type_controller_delegate.h b/components/sync/test/fake_model_type_controller_delegate.h index b0c3d46..0c41849 100644 --- a/components/sync/test/fake_model_type_controller_delegate.h +++ b/components/sync/test/fake_model_type_controller_delegate.h
@@ -50,7 +50,7 @@ void SimulateModelError(const ModelError& error); // The number of times sync metadata was cleared, via either - // OnSyncStopping(CLEAR_METADATA) or ClearMetadataWhileStopped() while sync + // OnSyncStopping(CLEAR_METADATA) or ClearMetadataIfStopped() while sync // was actually stopped. // TODO(crbug.com/1504481): Replace this with something like "HasMetadata". int clear_metadata_count() const; @@ -64,7 +64,7 @@ void GetTypeEntitiesCountForDebugging( base::OnceCallback<void(const TypeEntitiesCount&)> callback) const override; - void ClearMetadataWhileStopped() override; + void ClearMetadataIfStopped() override; base::WeakPtr<ModelTypeControllerDelegate> GetWeakPtr();
diff --git a/components/sync/test/sync_user_settings_mock.h b/components/sync/test/sync_user_settings_mock.h index cf44f8d..e97c7f7 100644 --- a/components/sync/test/sync_user_settings_mock.h +++ b/components/sync/test/sync_user_settings_mock.h
@@ -38,6 +38,12 @@ IsTypeManagedByCustodian, (UserSelectableType), (const override)); +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + MOCK_METHOD(int, + GetNumberOfAccountsWithPasswordsSelected, + (), + (const override)); +#endif MOCK_METHOD(void, SetSelectedTypes, (bool, UserSelectableTypeSet),
diff --git a/components/sync/test/test_sync_user_settings.cc b/components/sync/test/test_sync_user_settings.cc index e348214..492257e 100644 --- a/components/sync/test/test_sync_user_settings.cc +++ b/components/sync/test/test_sync_user_settings.cc
@@ -108,6 +108,12 @@ return false; } +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) +int TestSyncUserSettings::GetNumberOfAccountsWithPasswordsSelected() const { + return selected_types_.Has(UserSelectableType::kPasswords) ? 1 : 0; +} +#endif + ModelTypeSet TestSyncUserSettings::GetPreferredDataTypes() const { ModelTypeSet types = UserSelectableTypesToModelTypes(GetSelectedTypes()); types.PutAll(AlwaysPreferredUserTypes());
diff --git a/components/sync/test/test_sync_user_settings.h b/components/sync/test/test_sync_user_settings.h index 219901f..200adb5 100644 --- a/components/sync/test/test_sync_user_settings.h +++ b/components/sync/test/test_sync_user_settings.h
@@ -38,6 +38,9 @@ UserSelectableTypeSet GetSelectedTypes() const override; bool IsTypeManagedByPolicy(UserSelectableType type) const override; bool IsTypeManagedByCustodian(UserSelectableType type) const override; +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + int GetNumberOfAccountsWithPasswordsSelected() const override; +#endif void SetSelectedTypes(bool sync_everything, UserSelectableTypeSet types) override; void SetSelectedType(UserSelectableType type, bool is_type_on) override;
diff --git a/components/sync_bookmarks/bookmark_model_type_processor.cc b/components/sync_bookmarks/bookmark_model_type_processor.cc index 7c9d9c43..1cf0494 100644 --- a/components/sync_bookmarks/bookmark_model_type_processor.cc +++ b/components/sync_bookmarks/bookmark_model_type_processor.cc
@@ -348,7 +348,7 @@ model_metadata.model_type_state().initial_sync_state())) { // There used to be a tracker, which is dropped now due to // `pending_clear_metadata_`. This isn't very different to - // ClearMetadataWhileStopped(), in the sense that the need to wipe the + // ClearMetadataIfStopped(), in the sense that the need to wipe the // local model needs to be considered. TriggerWipeModelUponSyncDisabledBehavior(); } @@ -391,7 +391,7 @@ // Since the model isn't initially tracking metadata, move away from // kOnceIfTrackingMetadata so the behavior doesn't kick in, in case sync is // turned on later and back to off. This should be practically unreachable - // because usually ClearMetadataWhileStopped() would be invoked earlier, + // because usually ClearMetadataIfStopped() would be invoked earlier, // but let's be extra safe and avoid relying on this behavior. wipe_model_upon_sync_disabled_behavior_ = syncer::WipeModelUponSyncDisabledBehavior::kNever; @@ -784,7 +784,7 @@ max_bookmarks_till_sync_enabled_ = limit; } -void BookmarkModelTypeProcessor::ClearMetadataWhileStopped() { +void BookmarkModelTypeProcessor::ClearMetadataIfStopped() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); // If Sync is not actually stopped, ignore this call.
diff --git a/components/sync_bookmarks/bookmark_model_type_processor.h b/components/sync_bookmarks/bookmark_model_type_processor.h index ebc3c90..7878ac37 100644 --- a/components/sync_bookmarks/bookmark_model_type_processor.h +++ b/components/sync_bookmarks/bookmark_model_type_processor.h
@@ -70,7 +70,7 @@ base::OnceCallback<void(const syncer::TypeEntitiesCount&)> callback) const override; void RecordMemoryUsageAndCountsHistograms() override; - void ClearMetadataWhileStopped() override; + void ClearMetadataIfStopped() override; // Encodes all sync metadata into a string, representing a state that can be // restored via ModelReadyToSync() below. @@ -213,7 +213,7 @@ size_t max_bookmarks_till_sync_enabled_; // Marks whether metadata should be cleared upon ModelReadyToSync(). True if - // ClearMetadataWhileStopped() is called before ModelReadyToSync(). + // ClearMetadataIfStopped() is called before ModelReadyToSync(). bool pending_clear_metadata_ = false; // WeakPtrFactory for this processor for ModelTypeController.
diff --git a/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc b/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc index e7e4e34..803e9eb 100644 --- a/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc +++ b/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc
@@ -1632,17 +1632,17 @@ model_metadata.last_initial_merge_remote_updates_exceeded_limit()); } -TEST_F(BookmarkModelTypeProcessorTest, ShouldClearMetadataWhileStopped) { +TEST_F(BookmarkModelTypeProcessorTest, ShouldClearMetadataIfStopped) { SimulateModelReadyToSyncWithInitialSyncDone(); processor()->OnSyncStopping(syncer::KEEP_METADATA); ASSERT_TRUE(processor()->IsTrackingMetadata()); base::HistogramTester histogram_tester; - // Expect saving empty metadata upon call to ClearMetadataWhileStopped(). + // Expect saving empty metadata upon call to ClearMetadataIfStopped(). EXPECT_CALL(*schedule_save_closure(), Run); - processor()->ClearMetadataWhileStopped(); + processor()->ClearMetadataIfStopped(); // Should clear the tracker even if already stopped. EXPECT_FALSE(processor()->IsTrackingMetadata()); // Expect an entry to the histogram. @@ -1652,16 +1652,16 @@ } TEST_F(BookmarkModelTypeProcessorTest, - ShouldClearMetadataWhileStoppedUponModelReadyToSync) { + ShouldClearMetadataIfStoppedUponModelReadyToSync) { ASSERT_FALSE(processor()->IsTrackingMetadata()); base::HistogramTester histogram_tester; // Expect no call to save metadata before ModelReadyToSync(). EXPECT_CALL(*schedule_save_closure(), Run).Times(0); - // Call ClearMetadataWhileStopped() before ModelReadyToSync(). This should set + // Call ClearMetadataIfStopped() before ModelReadyToSync(). This should set // the flag for a pending clearing of metadata. - processor()->ClearMetadataWhileStopped(); + processor()->ClearMetadataIfStopped(); // Nothing recorded to the histograms yet. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); histogram_tester.ExpectTotalCount( @@ -1697,7 +1697,7 @@ base::HistogramTester histogram_tester; - processor()->ClearMetadataWhileStopped(); + processor()->ClearMetadataIfStopped(); // Should NOT have cleared the metadata since the processor is not stopped. EXPECT_TRUE(processor()->IsTrackingMetadata()); @@ -1705,18 +1705,18 @@ } TEST_F(BookmarkModelTypeProcessorTest, - ShouldNotClearMetadataWhileStoppedIfPreviouslyStoppedWithClearMetadata) { + ShouldNotClearMetadataIfStoppedIfPreviouslyStoppedWithClearMetadata) { SimulateModelReadyToSyncWithInitialSyncDone(); SimulateOnSyncStarting(); processor()->OnSyncStopping(syncer::CLEAR_METADATA); ASSERT_FALSE(processor()->IsTrackingMetadata()); - // Expect no call to save metadata upon ClearMetadataWhileStopped(). + // Expect no call to save metadata upon ClearMetadataIfStopped(). EXPECT_CALL(*schedule_save_closure(), Run).Times(0); base::HistogramTester histogram_tester; - processor()->ClearMetadataWhileStopped(); + processor()->ClearMetadataIfStopped(); // Expect no entry to the histogram. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); histogram_tester.ExpectTotalCount( @@ -1874,16 +1874,16 @@ } TEST_F(BookmarkModelTypeProcessorTest, - ShouldNotClearMetadataWhileStoppedWithoutMetadataInitially) { + ShouldNotClearMetadataIfStoppedWithoutMetadataInitially) { SimulateModelReadyToSyncWithoutLocalMetadata(); ASSERT_FALSE(processor()->IsTrackingMetadata()); base::HistogramTester histogram_tester; - // Call ClearMetadataWhileStopped() without a prior call to OnSyncStopping(). - processor()->ClearMetadataWhileStopped(); + // Call ClearMetadataIfStopped() without a prior call to OnSyncStopping(). + processor()->ClearMetadataIfStopped(); - // Expect no call to save metadata upon ClearMetadataWhileStopped(). + // Expect no call to save metadata upon ClearMetadataIfStopped(). EXPECT_CALL(*schedule_save_closure(), Run).Times(0); // Expect no entry to the histogram. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); @@ -1892,14 +1892,14 @@ } TEST_F(BookmarkModelTypeProcessorTest, - ShouldNotClearMetadataWhileStoppedUponModelReadyToSyncWithoutMetadata) { + ShouldNotClearMetadataIfStoppedUponModelReadyToSyncWithoutMetadata) { base::HistogramTester histogram_tester; // Expect no call to save metadata. EXPECT_CALL(*schedule_save_closure(), Run).Times(0); - // Call ClearMetadataWhileStopped() before ModelReadyToSync(). This should set + // Call ClearMetadataIfStopped() before ModelReadyToSync(). This should set // the flag for a pending clearing of metadata. - processor()->ClearMetadataWhileStopped(); + processor()->ClearMetadataIfStopped(); SimulateModelReadyToSyncWithoutLocalMetadata(); ASSERT_FALSE(processor()->IsTrackingMetadata()); @@ -1928,10 +1928,10 @@ base::HistogramTester histogram_tester; - // Expect saving empty metadata upon call to ClearMetadataWhileStopped(). + // Expect saving empty metadata upon call to ClearMetadataIfStopped(). EXPECT_CALL(*schedule_save_closure(), Run); - processor()->ClearMetadataWhileStopped(); + processor()->ClearMetadataIfStopped(); // Should clear the tracker even if already stopped. EXPECT_FALSE(processor()->IsTrackingMetadata()); // Expect an entry to the histogram. @@ -1953,9 +1953,9 @@ // Expect no call to save metadata before ModelReadyToSync(). EXPECT_CALL(*schedule_save_closure(), Run).Times(0); - // Call ClearMetadataWhileStopped() before ModelReadyToSync(). This should set + // Call ClearMetadataIfStopped() before ModelReadyToSync(). This should set // the flag for a pending clearing of metadata. - processor()->ClearMetadataWhileStopped(); + processor()->ClearMetadataIfStopped(); // Nothing recorded to the histograms yet. histogram_tester.ExpectTotalCount("Sync.ClearMetadataWhileStopped", 0); histogram_tester.ExpectTotalCount(
diff --git a/components/sync_sessions/session_sync_bridge_unittest.cc b/components/sync_sessions/session_sync_bridge_unittest.cc index 01fd767..f103b8e 100644 --- a/components/sync_sessions/session_sync_bridge_unittest.cc +++ b/components/sync_sessions/session_sync_bridge_unittest.cc
@@ -1655,7 +1655,7 @@ InitializeBridge(); // Clear the metadata. This will lose the placeholder tab permanently. - real_processor()->ClearMetadataWhileStopped(); + real_processor()->ClearMetadataIfStopped(); EXPECT_TRUE(bridge()->IsLocalDataOutOfSyncForTest()); StartSyncing();
diff --git a/components/url_matcher/BUILD.gn b/components/url_matcher/BUILD.gn index 1526014..9c2e9ef 100644 --- a/components/url_matcher/BUILD.gn +++ b/components/url_matcher/BUILD.gn
@@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//testing/libfuzzer/fuzzer_test.gni") + component("url_matcher") { sources = [ "regex_set_matcher.cc", @@ -44,3 +46,12 @@ "//testing/gtest", ] } + +fuzzer_test("url_matcher_fuzzer") { + sources = [ "url_matcher_fuzzer.cc" ] + deps = [ + ":url_matcher", + "//base", + "//base:i18n", + ] +}
diff --git a/components/url_matcher/url_matcher_fuzzer.cc b/components/url_matcher/url_matcher_fuzzer.cc new file mode 100644 index 0000000..0aabdff --- /dev/null +++ b/components/url_matcher/url_matcher_fuzzer.cc
@@ -0,0 +1,70 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <stddef.h> +#include <stdint.h> + +#include <fuzzer/FuzzedDataProvider.h> +#include <string> +#include "base/at_exit.h" +#include "base/i18n/icu_util.h" +#include "base/logging.h" + +#include "components/url_matcher/url_matcher.h" +#include "url/gurl.h" + +namespace url_matcher { +class Environment { + public: + Environment() { + logging::SetMinLogLevel(logging::LOG_FATAL); + CHECK(base::i18n::InitializeICU()); + } + base::AtExitManager at_exit_manager; +}; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + static Environment env; + FuzzedDataProvider provider(data, size); + const base::MatcherStringPattern::ID kConditionSetId = + provider.ConsumeIntegralInRange<int>(1, 256); + + // Fuzzing GURLCharacter Set + GURL url(provider.ConsumeRandomLengthString(size)); + if (!url.is_valid() || url.is_empty()) { + return -1; + } + URLMatcher matcher; + URLMatcherConditionFactory* factory = matcher.condition_factory(); + + URLMatcherConditionSet::Conditions conditions; + // Fuzzed Conditions + conditions.insert(factory->CreateHostSuffixCondition( + provider.ConsumeRandomLengthString(size))); + conditions.insert(factory->CreatePathContainsCondition( + provider.ConsumeRemainingBytesAsString())); + // Regex for any URL, valid RE2 can be fuzzed + conditions.insert(factory->CreateURLMatchesCondition( + "(https:\\/\\/www\\.|http:\\/\\/www\\.|https:\\/\\/|http:\\/\\/" + ")?[a-zA-Z0-9]{2,}(" + "\\.[a-zA-Z0-9]{2,})(\\.[a-zA-Z0-9]{2,})?")); + + // useful conditions from unittests + conditions.insert(factory->CreateHostContainsCondition("www.")); + conditions.insert(factory->CreateHostContainsCondition("com")); + conditions.insert(factory->CreatePathEqualsCondition("/webhp")); + conditions.insert(factory->CreatePathContainsCondition("/we")); + conditions.insert(factory->CreatePathContainsCondition("hp")); + conditions.insert(factory->CreateQueryEqualsCondition("test=val&a=b")); + conditions.insert(factory->CreateQueryContainsCondition("test=v")); + conditions.insert(factory->CreateQuerySuffixCondition("l&a=b")); + + URLMatcherConditionSet::Vector insert; + insert.push_back(base::MakeRefCounted<URLMatcherConditionSet>(kConditionSetId, + conditions)); + matcher.AddConditionSets(insert); + matcher.MatchURL(url); + return 0; +} +} // namespace url_matcher
diff --git a/content/browser/devtools/protocol/network_handler.cc b/content/browser/devtools/protocol/network_handler.cc index 1f59190..45c2941 100644 --- a/content/browser/devtools/protocol/network_handler.cc +++ b/content/browser/devtools/protocol/network_handler.cc
@@ -559,15 +559,17 @@ return Security::SecurityStateEnum::Secure; } -DevToolsURLLoaderInterceptor::InterceptionStage ToInterceptorStage( +absl::optional<DevToolsURLLoaderInterceptor::InterceptionStage> +ToInterceptorStage( const protocol::Network::InterceptionStage& interceptor_stage) { - if (interceptor_stage == protocol::Network::InterceptionStageEnum::Request) + if (interceptor_stage == protocol::Network::InterceptionStageEnum::Request) { return DevToolsURLLoaderInterceptor::REQUEST; + } if (interceptor_stage == - protocol::Network::InterceptionStageEnum::HeadersReceived) + protocol::Network::InterceptionStageEnum::HeadersReceived) { return DevToolsURLLoaderInterceptor::RESPONSE; - NOTREACHED(); - return DevToolsURLLoaderInterceptor::REQUEST; + } + return absl::nullopt; } double timeDelta(base::TimeTicks time, @@ -2567,10 +2569,15 @@ "Cannot intercept resources of type '%s'", resource_type.c_str())); } } - interceptor_patterns.emplace_back( - pattern->GetUrlPattern("*"), std::move(resource_types), - ToInterceptorStage(pattern->GetInterceptionStage( - protocol::Network::InterceptionStageEnum::Request))); + auto interception_stage = pattern->GetInterceptionStage( + protocol::Network::InterceptionStageEnum::Request); + auto stage = ToInterceptorStage(interception_stage); + if (!stage.has_value()) { + return Response::InvalidParams(base::StringPrintf( + "Unsupported interception stage '%s'", interception_stage.c_str())); + } + interceptor_patterns.emplace_back(pattern->GetUrlPattern("*"), + std::move(resource_types), stage.value()); } if (!host_)
diff --git a/docs/security/shepherd.md b/docs/security/shepherd.md index 37b7f2c..010cf8d6 100644 --- a/docs/security/shepherd.md +++ b/docs/security/shepherd.md
@@ -395,12 +395,18 @@ * Reproduce using iOS device or desktop Safari. * Assign severity, impact, and component labels. -* Label **ExternalDependency**. -* Label **Hotlist-WebKit**. This label is monitored by Apple friends. -* File a security bug at [bugs.webkit.org](https://bugs.webkit.org), and CC - chrome-ios-security-bugs@google.com. This alias is monitored by the iOS Chrome - team so they can be notified when the WebKit bug is fixed. -* Note the WebKit bug ID in the crbug report. +* If the issue is in WebKit: + * Label **ExternalDependency**. + * Label **Hotlist-WebKit**. This label is monitored by Apple friends. + * Do not fill **FoundIn**. It is applicable to Chrome versions and we can't + backmerge WebKit fixes. + * File a security bug at [bugs.webkit.org](https://bugs.webkit.org), and CC + chrome-ios-security-bugs@google.com. This alias is monitored by the iOS + Chrome team so they can be notified when the WebKit bug is fixed. Even + better: suggest the reporter to do it themselves and CC you. This way they + are getting a better visibility and credit. + * Note the WebKit bug ID in the crbug report. + * All security issues need owners, the WebKit ones can be assigned to ajuma@. ### Find An Owner To Fix The Bug
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index 6248a66d..9802214 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h
@@ -1906,6 +1906,7 @@ ACCESSIBILITY_PRIVATE_GETTTSDLCCONTENTS = 1844, OS_DIAGNOSTICS_CREATEFANROUTINE = 1845, OS_DIAGNOSTICS_ISFANROUTINEARGUMENTSUPPORTED = 1846, + AUTOTESTPRIVATE_OVERRIDEORCARESPONSE = 1847, // Last entry: Add new entries above, then run: // tools/metrics/histograms/update_extension_histograms.py ENUM_BOUNDARY
diff --git a/gpu/command_buffer/service/dawn_context_provider.cc b/gpu/command_buffer/service/dawn_context_provider.cc index 93bcddb..3ec67cc 100644 --- a/gpu/command_buffer/service/dawn_context_provider.cc +++ b/gpu/command_buffer/service/dawn_context_provider.cc
@@ -363,6 +363,17 @@ descriptor.requiredFeatures = features.data(); descriptor.requiredFeatureCount = std::size(features); + // Use best limits for the device. + wgpu::SupportedLimits supportedLimits = {}; + if (!adapter.GetLimits(&supportedLimits)) { + LOG(ERROR) << "Failed to call adapter.GetLimits()."; + return false; + } + + wgpu::RequiredLimits deviceCreationLimits = {}; + deviceCreationLimits.limits = supportedLimits.limits; + descriptor.requiredLimits = &deviceCreationLimits; + // ANGLE always tries creating D3D11 device with debug layer when dcheck is // on, so tries creating dawn device with backend validation as well. constexpr bool enable_backend_validation =
diff --git a/gpu/command_buffer/service/shared_context_state.cc b/gpu/command_buffer/service/shared_context_state.cc index e6fa0b6..214ab40 100644 --- a/gpu/command_buffer/service/shared_context_state.cc +++ b/gpu/command_buffer/service/shared_context_state.cc
@@ -1011,9 +1011,15 @@ NOTREACHED_NORETURN(); #endif } else { - // TODO(crbug.com/1090476): Query Dawn for this value once an API exists for - // capabilities. +#if BUILDFLAG(SKIA_USE_DAWN) + DCHECK(dawn_context_provider()); + wgpu::SupportedLimits limits = {}; + auto succeded = dawn_context_provider()->GetDevice().GetLimits(&limits); + CHECK(succeded); + max_texture_size = limits.limits.maxTextureDimension2D; +#else max_texture_size = 8192; +#endif } // Ensure max_texture_size_ is less than INT_MAX so that gfx::Rect and friends // can be used to accurately represent all valid sub-rects, with overflow
diff --git a/infra/config/generated/testing/test_suites.pyl b/infra/config/generated/testing/test_suites.pyl index f2b5a1c4..1ec4a18d 100644 --- a/infra/config/generated/testing/test_suites.pyl +++ b/infra/config/generated/testing/test_suites.pyl
@@ -1515,7 +1515,6 @@ 'interactive_ui_tests': {}, 'net_unittests': {}, 'pdf_unittests': {}, - 'ppapi_unittests': {}, 'remoting_unittests': {}, 'services_unittests': {}, 'sync_integration_tests': {
diff --git a/infra/config/targets/basic_suites.star b/infra/config/targets/basic_suites.star index d686e500..10c07bda 100644 --- a/infra/config/targets/basic_suites.star +++ b/infra/config/targets/basic_suites.star
@@ -1803,7 +1803,6 @@ "interactive_ui_tests": None, "net_unittests": None, "pdf_unittests": None, - "ppapi_unittests": None, "remoting_unittests": None, "services_unittests": None, "sync_integration_tests": targets.legacy_test_config(
diff --git a/ios/chrome/browser/passwords/model/ios_chrome_password_manager_client.mm b/ios/chrome/browser/passwords/model/ios_chrome_password_manager_client.mm index 7d1231c..62d6dee 100644 --- a/ios/chrome/browser/passwords/model/ios_chrome_password_manager_client.mm +++ b/ios/chrome/browser/passwords/model/ios_chrome_password_manager_client.mm
@@ -58,7 +58,9 @@ namespace { -const syncer::SyncService* GetSyncServiceForBrowserState( +// Used for callbacks that expect a const pointer, since base::Callback isn't +// smart enough to allow binding the SyncServiceFactory method directly. +const syncer::SyncService* GetConstSyncServicePtr( ChromeBrowserState* browser_state) { return SyncServiceFactory::GetForBrowserStateIfExists(browser_state); } @@ -71,10 +73,10 @@ password_feature_manager_( GetPrefs(), GetLocalStatePrefs(), - GetSyncServiceForBrowserState(bridge_.browserState)), - credentials_filter_(this, - base::BindRepeating(&GetSyncServiceForBrowserState, - bridge_.browserState)), + SyncServiceFactory::GetForBrowserStateIfExists(bridge_.browserState)), + credentials_filter_( + this, + base::BindRepeating(&GetConstSyncServicePtr, bridge_.browserState)), helper_(this) { saving_passwords_enabled_.Init( password_manager::prefs::kCredentialsEnableService, GetPrefs()); @@ -180,7 +182,7 @@ const syncer::SyncService* IOSChromePasswordManagerClient::GetSyncService() const { - return GetSyncServiceForBrowserState(bridge_.browserState); + return GetConstSyncServicePtr(bridge_.browserState); } PasswordStoreInterface*
diff --git a/ios/chrome/browser/ui/bookmarks/home/bookmarks_account_storage_promo_egtest.mm b/ios/chrome/browser/ui/bookmarks/home/bookmarks_account_storage_promo_egtest.mm index ab1888c..66180db 100644 --- a/ios/chrome/browser/ui/bookmarks/home/bookmarks_account_storage_promo_egtest.mm +++ b/ios/chrome/browser/ui/bookmarks/home/bookmarks_account_storage_promo_egtest.mm
@@ -239,14 +239,16 @@ [BookmarkEarlGreyUI openBookmarks]; // Verify both local and account sections show for a signed-in account. - [[EarlGrey - selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString( - IDS_IOS_BOOKMARKS_PROFILE_SECTION_TITLE))] - assertWithMatcher:grey_sufficientlyVisible()]; - [[EarlGrey - selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString( - IDS_IOS_BOOKMARKS_ACCOUNT_SECTION_TITLE))] - assertWithMatcher:grey_sufficientlyVisible()]; + [[EarlGrey selectElementWithMatcher: + grey_allOf(grey_accessibilityLabel(l10n_util::GetNSString( + IDS_IOS_BOOKMARKS_PROFILE_SECTION_TITLE)), + grey_sufficientlyVisible(), nil)] + assertWithMatcher:grey_notNil()]; + [[EarlGrey selectElementWithMatcher: + grey_allOf(grey_accessibilityLabel(l10n_util::GetNSString( + IDS_IOS_BOOKMARKS_ACCOUNT_SECTION_TITLE)), + grey_sufficientlyVisible(), nil)] + assertWithMatcher:grey_notNil()]; // Sign-out. [SigninEarlGrey signOut]; @@ -260,11 +262,12 @@ selectElementWithMatcher:grey_accessibilityLabel(@"Mobile Bookmarks")] assertWithMatcher:grey_sufficientlyVisible()]; - // Verify that the acocunt model is not shown. - [[EarlGrey - selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString( - IDS_IOS_BOOKMARKS_ACCOUNT_SECTION_TITLE))] - assertWithMatcher:grey_notVisible()]; + // Verify that the account model is not shown. + [[EarlGrey selectElementWithMatcher: + grey_allOf(grey_accessibilityLabel(l10n_util::GetNSString( + IDS_IOS_BOOKMARKS_ACCOUNT_SECTION_TITLE)), + grey_sufficientlyVisible(), nil)] + assertWithMatcher:grey_nil()]; } @end
diff --git a/ios/chrome/browser/ui/bring_android_tabs/BUILD.gn b/ios/chrome/browser/ui/bring_android_tabs/BUILD.gn index 5a95128..9dd053e 100644 --- a/ios/chrome/browser/ui/bring_android_tabs/BUILD.gn +++ b/ios/chrome/browser/ui/bring_android_tabs/BUILD.gn
@@ -160,6 +160,7 @@ "//ios/chrome/app/strings", "//ios/chrome/browser/signin/model:fake_system_identity", "//ios/chrome/browser/ui/authentication:eg_test_support+eg2", + "//ios/chrome/browser/ui/first_run:eg_test_support+eg2", "//ios/chrome/common/ui/confirmation_alert:constants", "//ios/chrome/common/ui/promo_style:constants", "//ios/chrome/test/earl_grey:eg_test_support+eg2",
diff --git a/ios/chrome/browser/ui/bring_android_tabs/DEPS b/ios/chrome/browser/ui/bring_android_tabs/DEPS index ef2d314..3b9649f 100644 --- a/ios/chrome/browser/ui/bring_android_tabs/DEPS +++ b/ios/chrome/browser/ui/bring_android_tabs/DEPS
@@ -1,5 +1,6 @@ specific_include_rules = { "bring_android_tabs_test_utils\.mm": [ "+ios/chrome/browser/ui/authentication", + "+ios/chrome/browser/ui/first_run/first_run_app_interface.h", ], }
diff --git a/ios/chrome/browser/ui/bring_android_tabs/bring_android_tabs_test_utils.mm b/ios/chrome/browser/ui/bring_android_tabs/bring_android_tabs_test_utils.mm index b0518aad..b048e81 100644 --- a/ios/chrome/browser/ui/bring_android_tabs/bring_android_tabs_test_utils.mm +++ b/ios/chrome/browser/ui/bring_android_tabs/bring_android_tabs_test_utils.mm
@@ -11,6 +11,7 @@ #import "ios/chrome/browser/ui/bring_android_tabs/bring_android_tabs_app_interface.h" #import "ios/chrome/browser/ui/bring_android_tabs/bring_android_tabs_test_session.h" #import "ios/chrome/browser/ui/bring_android_tabs/constants.h" +#import "ios/chrome/browser/ui/first_run/first_run_app_interface.h" #import "ios/chrome/common/ui/promo_style/constants.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h" @@ -69,6 +70,10 @@ : kPromoStyleSecondaryActionAccessibilityIdentifier); // Default browser promo dismissal. TapPromoStyleButton(kPromoStyleSecondaryActionAccessibilityIdentifier); + // Omnibox position choice promo dismissal. + if ([FirstRunAppInterface isOmniboxPositionChoiceEnabled]) { + TapPromoStyleButton(kPromoStylePrimaryActionAccessibilityIdentifier); + } if (sync) { [ChromeEarlGrey waitForSyncTransportStateActiveWithTimeout:kSyncOperationTimeout];
diff --git a/ios/chrome/browser/ui/first_run/first_run_app_interface.h b/ios/chrome/browser/ui/first_run/first_run_app_interface.h index 9df0fb5c..b82eee7 100644 --- a/ios/chrome/browser/ui/first_run/first_run_app_interface.h +++ b/ios/chrome/browser/ui/first_run/first_run_app_interface.h
@@ -24,6 +24,9 @@ // Returns whether sync has finished its first run setup. + (BOOL)isInitialSyncFeatureSetupComplete; +// Returns whether the omnibox position choice is enabled. ++ (BOOL)isOmniboxPositionChoiceEnabled; + @end #endif // IOS_CHROME_BROWSER_UI_FIRST_RUN_FIRST_RUN_APP_INTERFACE_H_
diff --git a/ios/chrome/browser/ui/first_run/first_run_app_interface.mm b/ios/chrome/browser/ui/first_run/first_run_app_interface.mm index 78109f7f..67b5865 100644 --- a/ios/chrome/browser/ui/first_run/first_run_app_interface.mm +++ b/ios/chrome/browser/ui/first_run/first_run_app_interface.mm
@@ -13,6 +13,7 @@ #import "ios/chrome/browser/shared/coordinator/scene/scene_controller.h" #import "ios/chrome/browser/shared/coordinator/scene/scene_controller_testing.h" #import "ios/chrome/browser/shared/model/application_context/application_context.h" +#import "ios/chrome/browser/shared/public/features/features.h" #import "ios/chrome/browser/sync/model/sync_service_factory.h" #import "ios/chrome/test/app/chrome_test_util.h" @@ -41,4 +42,8 @@ ->IsInitialSyncFeatureSetupComplete(); } ++ (BOOL)isOmniboxPositionChoiceEnabled { + return IsBottomOmniboxPromoFlagEnabled(BottomOmniboxPromoType::kFRE); +} + @end
diff --git a/ios/chrome/browser/ui/first_run/first_run_constants.h b/ios/chrome/browser/ui/first_run/first_run_constants.h index 9fb7ede3..15c863f 100644 --- a/ios/chrome/browser/ui/first_run/first_run_constants.h +++ b/ios/chrome/browser/ui/first_run/first_run_constants.h
@@ -26,6 +26,11 @@ // run. extern NSString* const kFirstRunDefaultBrowserScreenAccessibilityIdentifier; +// The accessibility identifier for the Omnibox position choice screen shown in +// first run. +extern NSString* const + kFirstRunOmniboxPositionChoiceScreenAccessibilityIdentifier; + // URL for the terms of service text. extern NSString* const kTermsOfServiceURL;
diff --git a/ios/chrome/browser/ui/first_run/first_run_constants.mm b/ios/chrome/browser/ui/first_run/first_run_constants.mm index c87ea7f6..3f4b849 100644 --- a/ios/chrome/browser/ui/first_run/first_run_constants.mm +++ b/ios/chrome/browser/ui/first_run/first_run_constants.mm
@@ -21,6 +21,9 @@ NSString* const kFirstRunDefaultBrowserScreenAccessibilityIdentifier = @"firstRunDefaultBrowserScreenAccessibilityIdentifier"; +NSString* const kFirstRunOmniboxPositionChoiceScreenAccessibilityIdentifier = + @"firstRunOmniboxPositionChoiceScreenAccessibilityIdentifier"; + // URL for the terms of service text. NSString* const kTermsOfServiceURL = @"internal://terms-of-service";
diff --git a/ios/chrome/browser/ui/first_run/first_run_egtest.mm b/ios/chrome/browser/ui/first_run/first_run_egtest.mm index c2e67e31..21baecf7c7 100644 --- a/ios/chrome/browser/ui/first_run/first_run_egtest.mm +++ b/ios/chrome/browser/ui/first_run/first_run_egtest.mm
@@ -93,8 +93,8 @@ grey_ancestor(disclaimer), grey_sufficientlyVisible(), nil); } -// Dismiss default browser promo. -void DismissDefaultBrowserPromo() { +// Dismisses the remaining screens in FRE after sign-in and sync. +void DismissScreensAfterSigninAndSync() { id<GREYMatcher> buttonMatcher = grey_allOf( grey_ancestor(grey_accessibilityID( first_run::kFirstRunDefaultBrowserScreenAccessibilityIdentifier)), @@ -105,6 +105,18 @@ [[[EarlGrey selectElementWithMatcher:buttonMatcher] assertWithMatcher:grey_notNil()] performAction:grey_tap()]; + + if ([FirstRunAppInterface isOmniboxPositionChoiceEnabled]) { + id<GREYMatcher> omniboxPositionScreenPrimaryButton = grey_allOf( + grey_ancestor(grey_accessibilityID( + first_run:: + kFirstRunOmniboxPositionChoiceScreenAccessibilityIdentifier)), + grey_accessibilityID(kPromoStylePrimaryActionAccessibilityIdentifier), + nil); + + [[[EarlGrey selectElementWithMatcher:omniboxPositionScreenPrimaryButton] + assertWithMatcher:grey_notNil()] performAction:grey_tap()]; + } } } // namespace @@ -420,7 +432,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [self verifySyncOrHistoryEnabled:YES]; } @@ -448,7 +460,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [self verifySyncOrHistoryEnabled:YES]; } @@ -480,7 +492,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is off. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [self verifySyncOrHistoryEnabled:NO]; } @@ -537,7 +549,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI tapSettingsMenuButton:chrome_test_util::ManageSyncSettingsButton()]; @@ -593,7 +605,7 @@ // Accept sync. [self acceptSyncOrHistory]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [SigninEarlGrey verifySyncUIEnabled:YES]; } @@ -646,7 +658,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [self verifySyncOrHistoryEnabled:YES]; // Close settings. @@ -683,7 +695,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [self verifySyncOrHistoryEnabled:NO]; // Close settings. @@ -714,7 +726,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [self verifySyncOrHistoryEnabled:NO]; } @@ -767,7 +779,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [SigninEarlGrey verifySyncUIEnabled:YES]; } @@ -855,7 +867,7 @@ // Check signed in. [SigninEarlGrey verifySignedInWithFakeIdentity:fakeSupervisedIdentity]; // Check sync is on. - DismissDefaultBrowserPromo(); + DismissScreensAfterSigninAndSync(); [ChromeEarlGreyUI openSettingsMenu]; [self verifySyncOrHistoryEnabled:YES]; }
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/BUILD.gn b/ios/chrome/browser/ui/first_run/omnibox_position/BUILD.gn index 7bb47f6c..515f41b 100644 --- a/ios/chrome/browser/ui/first_run/omnibox_position/BUILD.gn +++ b/ios/chrome/browser/ui/first_run/omnibox_position/BUILD.gn
@@ -6,10 +6,16 @@ sources = [ "omnibox_position_choice_coordinator.h", "omnibox_position_choice_coordinator.mm", + "omnibox_position_choice_mediator.h", + "omnibox_position_choice_mediator.mm", ] deps = [ ":omnibox_position_ui", + "//components/prefs", "//ios/chrome/browser/first_run/model", + "//ios/chrome/browser/shared/model/browser", + "//ios/chrome/browser/shared/model/browser_state", + "//ios/chrome/browser/shared/model/prefs:pref_names", "//ios/chrome/browser/shared/public/features", "//ios/chrome/browser/ui/first_run:interruptible_chrome_coordinator", "//ios/chrome/browser/ui/first_run:screen_delegate", @@ -18,11 +24,42 @@ source_set("omnibox_position_ui") { sources = [ + "omnibox_position_choice_consumer.h", + "omnibox_position_choice_mutator.h", "omnibox_position_choice_view_controller.h", "omnibox_position_choice_view_controller.mm", ] deps = [ + "//ios/chrome/app/strings", "//ios/chrome/browser/shared/public/features", + "//ios/chrome/browser/shared/ui/symbols", + "//ios/chrome/browser/ui/first_run:constants", + "//ios/chrome/browser/ui/settings/address_bar_preference/cells", + "//ios/chrome/browser/ui/toolbar/public", "//ios/chrome/common/ui/promo_style", + "//ios/chrome/common/ui/util", + "//ui/base", ] } + +source_set("eg2_tests") { + configs += [ "//build/config/ios:xctest_config" ] + testonly = true + sources = [ "omnibox_position_egtest.mm" ] + deps = [ + "//base", + "//build:branding_buildflags", + "//components/search_engines", + "//ios/chrome/app/strings", + "//ios/chrome/browser/shared/model/prefs:pref_names", + "//ios/chrome/browser/shared/public/features", + "//ios/chrome/browser/ui/authentication:eg_test_support+eg2", + "//ios/chrome/browser/ui/first_run:constants", + "//ios/chrome/common/ui/promo_style:constants", + "//ios/chrome/test/earl_grey:eg_test_support+eg2", + "//ios/chrome/test/earl_grey:switches", + "//ios/testing/earl_grey:eg_test_support+eg2", + "//ui/base", + ] + frameworks = [ "UIKit.framework" ] +}
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/DEPS b/ios/chrome/browser/ui/first_run/omnibox_position/DEPS new file mode 100644 index 0000000..04299b7 --- /dev/null +++ b/ios/chrome/browser/ui/first_run/omnibox_position/DEPS
@@ -0,0 +1,4 @@ +include_rules = [ + "+ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_option_item_view.h", + "+ios/chrome/browser/ui/toolbar/public/toolbar_type.h", +]
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_consumer.h b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_consumer.h new file mode 100644 index 0000000..220efef --- /dev/null +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_consumer.h
@@ -0,0 +1,20 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_CONSUMER_H_ +#define IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_CONSUMER_H_ + +#import <Foundation/Foundation.h> + +#import "ios/chrome/browser/ui/toolbar/public/toolbar_type.h" + +/// Consumer for the omnibx position choice mediator. +@protocol OmniboxPositionChoiceConsumer + +/// Sets the omnibox position to `position`. +- (void)setSelectedToolbarForOmnibox:(ToolbarType)position; + +@end + +#endif // IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_CONSUMER_H_
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_coordinator.mm b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_coordinator.mm index 9f57884..357eb011 100644 --- a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_coordinator.mm +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_coordinator.mm
@@ -5,18 +5,22 @@ #import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_coordinator.h" #import "ios/chrome/browser/first_run/model/first_run_metrics.h" +#import "ios/chrome/browser/shared/model/browser/browser.h" +#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h" #import "ios/chrome/browser/shared/public/features/features.h" #import "ios/chrome/browser/ui/first_run/first_run_screen_delegate.h" +#import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.h" #import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.h" @interface OmniboxPositionChoiceCoordinator () < PromoStyleViewControllerDelegate> - @end @implementation OmniboxPositionChoiceCoordinator { /// View controller of the omnibox position choice screen. OmniboxPositionChoiceViewController* _viewController; + /// Mediator of the omnibox position choice screen. + OmniboxPositionChoiceMediator* _mediator; /// Whether the screen is being shown in the FRE. BOOL _firstRun; /// First run screen delegate. @@ -52,9 +56,17 @@ CHECK(IsBottomOmniboxPromoFlagEnabled(BottomOmniboxPromoType::kAny)); [super start]; + _mediator = [[OmniboxPositionChoiceMediator alloc] init]; + _mediator.originalPrefService = self.browser->GetBrowserState() + ->GetOriginalChromeBrowserState() + ->GetPrefs(); + _viewController = [[OmniboxPositionChoiceViewController alloc] init]; - _viewController.delegate = self; _viewController.modalInPresentation = YES; + _viewController.delegate = self; + _viewController.mutator = _mediator; + + _mediator.consumer = _viewController; if (_firstRun) { BOOL animated = self.baseNavigationController.topViewController != nil; @@ -76,6 +88,7 @@ completion:nil]; } _viewController = nil; + _mediator = nil; _baseNavigationController = nil; _first_run_delegate = nil; [super stop]; @@ -84,17 +97,18 @@ #pragma mark - PromoStyleViewControllerDelegate - (void)didTapPrimaryActionButton { - // TODO(crbug.com/1503638): Implement primary action. + [_mediator saveSelectedPosition]; [self dismissScreen]; } - (void)didTapSecondaryActionButton { - // TODO(crbug.com/1503638): Implement secondary action. + [_mediator discardSelectedPosition]; [self dismissScreen]; } #pragma mark - Private +/// Dismisses the omnibox position choice view controller. - (void)dismissScreen { if (_firstRun) { [_first_run_delegate screenWillFinishPresenting];
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.h b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.h new file mode 100644 index 0000000..c3459a24 --- /dev/null +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.h
@@ -0,0 +1,32 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_MEDIATOR_H_ +#define IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_MEDIATOR_H_ + +#import <UIKit/UIKit.h> + +#import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mutator.h" + +@protocol OmniboxPositionChoiceConsumer; +class PrefService; + +/// Mediator that handles the omnibox position selection operations. +@interface OmniboxPositionChoiceMediator + : NSObject <OmniboxPositionChoiceMutator> + +/// The consumer for this object. +@property(nonatomic, weak) id<OmniboxPositionChoiceConsumer> consumer; +/// Pref service from the original browser state, used to set preferred omnibox +/// position. +@property(nonatomic, assign) PrefService* originalPrefService; + +/// Saves the selected omnibox position. +- (void)saveSelectedPosition; +/// Discards the selected omnibox position. +- (void)discardSelectedPosition; + +@end + +#endif // IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_MEDIATOR_H_
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.mm b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.mm new file mode 100644 index 0000000..7a5cb02 --- /dev/null +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.mm
@@ -0,0 +1,65 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mediator.h" + +#import "components/prefs/pref_service.h" +#import "ios/chrome/browser/shared/model/prefs/pref_names.h" +#import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_consumer.h" + +@interface OmniboxPositionChoiceMediator () + +/// The selected omnibox position. +@property(nonatomic, assign) ToolbarType selectedPosition; + +@end + +@implementation OmniboxPositionChoiceMediator + +- (instancetype)init { + self = [super init]; + if (self) { + _selectedPosition = ToolbarType::kPrimary; + } + return self; +} + +- (void)saveSelectedPosition { + if (self.originalPrefService) { + _originalPrefService->SetBoolean( + prefs::kBottomOmnibox, + self.selectedPosition == ToolbarType::kSecondary); + } + // TODO(crbug.com/1503638): Record selected position histogram. +} + +- (void)discardSelectedPosition { + // TODO(crbug.com/1503638): Record selected position histogram. +} + +#pragma mark - Setters + +- (void)setConsumer:(id<OmniboxPositionChoiceConsumer>)consumer { + _consumer = consumer; + [self.consumer setSelectedToolbarForOmnibox:self.selectedPosition]; +} + +- (void)setSelectedPosition:(ToolbarType)position { + _selectedPosition = position; + [self.consumer setSelectedToolbarForOmnibox:position]; +} + +#pragma mark - OmniboxPositionChoiceMutator + +- (void)selectTopOmnibox { + self.selectedPosition = ToolbarType::kPrimary; + // TODO(crbug.com/1503638): Recoard user action. +} + +- (void)selectBottomOmnibox { + self.selectedPosition = ToolbarType::kSecondary; + // TODO(crbug.com/1503638): Record user action. +} + +@end
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mutator.h b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mutator.h new file mode 100644 index 0000000..c730200 --- /dev/null +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mutator.h
@@ -0,0 +1,18 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_MUTATOR_H_ +#define IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_MUTATOR_H_ + +/// Mutator of the omnibox position choice. +@protocol OmniboxPositionChoiceMutator + +/// Selects the top omnibox option. +- (void)selectTopOmnibox; +/// Selects the bottom omnibox option. +- (void)selectBottomOmnibox; + +@end + +#endif // IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_MUTATOR_H_
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.h b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.h index 9d3d0b2..26b41bbb 100644 --- a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.h +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.h
@@ -5,10 +5,17 @@ #ifndef IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_VIEW_CONTROLLER_H_ #define IOS_CHROME_BROWSER_UI_FIRST_RUN_OMNIBOX_POSITION_OMNIBOX_POSITION_CHOICE_VIEW_CONTROLLER_H_ +#import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_consumer.h" #import "ios/chrome/common/ui/promo_style/promo_style_view_controller.h" +@protocol OmniboxPositionChoiceMutator; + /// View controller of omnibox position choice screen. -@interface OmniboxPositionChoiceViewController : PromoStyleViewController +@interface OmniboxPositionChoiceViewController + : PromoStyleViewController <OmniboxPositionChoiceConsumer> + +/// Mutator of the omnibox position choice model. +@property(nonatomic, weak) id<OmniboxPositionChoiceMutator> mutator; @end
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.mm b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.mm index bf0e3c9..6e28e74 100644 --- a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.mm +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.mm
@@ -5,21 +5,98 @@ #import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_view_controller.h" #import "ios/chrome/browser/shared/public/features/features.h" +#import "ios/chrome/browser/shared/ui/symbols/symbols.h" +#import "ios/chrome/browser/ui/first_run/first_run_constants.h" +#import "ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_choice_mutator.h" +#import "ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_option_item_view.h" +#import "ios/chrome/common/ui/util/constraints_ui_util.h" +#import "ios/chrome/grit/ios_strings.h" +#import "ui/base/l10n/l10n_util_mac.h" -@implementation OmniboxPositionChoiceViewController +@implementation OmniboxPositionChoiceViewController { + /// The view for the top address bar preference option. + AddressBarOptionView* _topAddressBar; + /// The view for the bottom address bar preference option. + AddressBarOptionView* _bottomAddressBar; +} #pragma mark - UIViewController +- (instancetype)init { + self = [super init]; + if (self) { + _topAddressBar = [[AddressBarOptionView alloc] + initWithSymbolName:kTopOmniboxOptionSymbol + labelText:l10n_util::GetNSString( + IDS_IOS_TOP_ADDRESS_BAR_OPTION)]; + _bottomAddressBar = [[AddressBarOptionView alloc] + initWithSymbolName:kBottomOmniboxOptionSymbol + labelText:l10n_util::GetNSString( + IDS_IOS_BOTTOM_ADDRESS_BAR_OPTION)]; + } + return self; +} + - (void)viewDidLoad { CHECK(IsBottomOmniboxPromoFlagEnabled(BottomOmniboxPromoType::kAny)); // TODO(crbug.com/1503638): Implement this and remove placeholder text. + self.view.accessibilityIdentifier = + first_run::kFirstRunOmniboxPositionChoiceScreenAccessibilityIdentifier; self.bannerName = @"default_browser_screen_banner"; self.titleText = @"**Tailor to Your Needs**"; self.subtitleText = @"**Decide the position of the search bar to tailor your " @"needs and browsing habits**"; self.primaryActionString = @"**Finish**"; + [_topAddressBar addTarget:self + action:@selector(didTapTopAddressBarView) + forControlEvents:UIControlEventTouchUpInside]; + + [_bottomAddressBar addTarget:self + action:@selector(didTapBottomAddressBarView) + forControlEvents:UIControlEventTouchUpInside]; + + UIStackView* addressBarView = [[UIStackView alloc] + initWithArrangedSubviews:@[ _topAddressBar, _bottomAddressBar ]]; + addressBarView.translatesAutoresizingMaskIntoConstraints = NO; + addressBarView.distribution = UIStackViewDistributionFillEqually; + [self.specificContentView addSubview:addressBarView]; + + AddSameConstraintsToSides( + self.specificContentView, addressBarView, + LayoutSides::kTop | LayoutSides::kLeading | LayoutSides::kTrailing); + + [NSLayoutConstraint activateConstraints:@[ + [self.specificContentView.bottomAnchor + constraintGreaterThanOrEqualToAnchor:addressBarView.bottomAnchor], + ]]; + [super viewDidLoad]; } +#pragma mark - OmniboxPositionChoiceConsumer + +- (void)setSelectedToolbarForOmnibox:(ToolbarType)position { + _topAddressBar.selected = position == ToolbarType::kPrimary; + _bottomAddressBar.selected = position == ToolbarType::kSecondary; +} + +#pragma mark - Private + +/// Notifies the mutator to update the selected omnibox position to top. +- (void)didTapTopAddressBarView { + if (_topAddressBar.selected) { + return; + } + [self.mutator selectTopOmnibox]; +} + +/// Notifies the mutator to update the selected omnibox position to bottom. +- (void)didTapBottomAddressBarView { + if (_bottomAddressBar.selected) { + return; + } + [self.mutator selectBottomOmnibox]; +} + @end
diff --git a/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_egtest.mm b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_egtest.mm new file mode 100644 index 0000000..badacbc --- /dev/null +++ b/ios/chrome/browser/ui/first_run/omnibox_position/omnibox_position_egtest.mm
@@ -0,0 +1,169 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "base/ios/ios_util.h" +#import "base/strings/string_util.h" +#import "base/strings/sys_string_conversions.h" +#import "build/branding_buildflags.h" +#import "components/search_engines/search_engines_switches.h" +#import "ios/chrome/browser/shared/model/prefs/pref_names.h" +#import "ios/chrome/browser/shared/public/features/features.h" +#import "ios/chrome/browser/ui/authentication/signin_matchers.h" +#import "ios/chrome/browser/ui/first_run/first_run_constants.h" +#import "ios/chrome/common/ui/promo_style/constants.h" +#import "ios/chrome/grit/ios_strings.h" +#import "ios/chrome/test/earl_grey/chrome_actions.h" +#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" +#import "ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h" +#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" +#import "ios/chrome/test/earl_grey/chrome_matchers.h" +#import "ios/chrome/test/earl_grey/chrome_test_case.h" +#import "ios/chrome/test/earl_grey/test_switches.h" +#import "ios/testing/earl_grey/app_launch_configuration.h" +#import "ios/testing/earl_grey/app_launch_manager.h" +#import "ios/testing/earl_grey/earl_grey_test.h" +#import "ui/base/l10n/l10n_util.h" + +namespace { + +/// Label of the top address bar option. +NSString* TopAddressBarLabelText() { + return l10n_util::GetNSString(IDS_IOS_TOP_ADDRESS_BAR_OPTION); +} + +/// Label of the bottom address bar option. +NSString* BottomAddressBarLabelText() { + return l10n_util::GetNSString(IDS_IOS_BOTTOM_ADDRESS_BAR_OPTION); +} + +/// Matcher for the top address bar option. +id<GREYMatcher> TopAddressBarOption() { + return chrome_test_util::ButtonWithAccessibilityLabel( + TopAddressBarLabelText()); +} + +/// Matcher for the bottom address bar option. +id<GREYMatcher> BottomAddressBarOption() { + return chrome_test_util::ButtonWithAccessibilityLabel( + BottomAddressBarLabelText()); +} + +/// Matcher for the top address bar option when selected. +id<GREYMatcher> TopAddressBarOptionSelected() { + return grey_allOf(grey_selected(), TopAddressBarOption(), nil); +} + +/// Matcher for the bottom address bar option when selected. +id<GREYMatcher> BottomAddressBarOptionSelected() { + return grey_allOf(grey_selected(), BottomAddressBarOption(), nil); +} + +/// Returns GREYElementInteraction for `matcher`, using `scrollViewMatcher` to +/// scroll. +void TapPromoStyleButton(NSString* buttonIdentifier) { + id<GREYMatcher> buttonMatcher = grey_accessibilityID(buttonIdentifier); + id<GREYMatcher> scrollViewMatcher = + grey_accessibilityID(kPromoStyleScrollViewAccessibilityIdentifier); + // Needs to scroll slowly to make sure to not miss a cell if it is not + // currently on the screen. It should not be bigger than the visible part + // of the collection view. + id<GREYAction> searchAction = grey_scrollInDirection(kGREYDirectionDown, 200); + GREYElementInteraction* element = + [[EarlGrey selectElementWithMatcher:buttonMatcher] + usingSearchAction:searchAction + onElementWithMatcher:scrollViewMatcher]; + [element performAction:grey_tap()]; +} + +/// Skip the FRE screens before omnibox position choice. +void SkipScreensBeforeOmniboxPositionChoice() { + // Skip sign-in. + TapPromoStyleButton(kPromoStyleSecondaryActionAccessibilityIdentifier); + // Skip default browser. + TapPromoStyleButton(kPromoStyleSecondaryActionAccessibilityIdentifier); +} + +} // namespace + +@interface OmniboxPositionFirstRunTestCase : ChromeTestCase + +@end + +@implementation OmniboxPositionFirstRunTestCase + +- (void)setUp { + [[self class] testForStartup]; + [super setUp]; +} + +- (AppLaunchConfiguration)appConfigurationForTestCase { + AppLaunchConfiguration config; + // Disable the search engine choice at the end of FRE. + // TODO(b/289998773): Re-enable it. Update EG test so that they + // close this view if they need to interact more after the FRE. + config.additional_args.push_back(std::string("--") + + switches::kDisableSearchEngineChoiceScreen); + config.additional_args.push_back(std::string("-") + + test_switches::kSignInAtStartup); + config.additional_args.push_back("-FirstRunForceEnabled"); + config.additional_args.push_back("true"); + config.features_enabled.push_back(kBottomOmniboxPromoFRE); + // Relaunch app at each test to rewind the startup state. + config.relaunch_policy = ForceRelaunchByKilling; + return config; +} + +#pragma mark - First run tests + +// Tests selecting top omnibox in FRE when top is selected by default. +- (void)testSelectTopOmniboxByDefault { + if ([ChromeEarlGrey isIPadIdiom]) { + EARL_GREY_TEST_SKIPPED( + @"Skipped for iPad (no choice for omnibox position on tablet)"); + } + + SkipScreensBeforeOmniboxPositionChoice(); + + // The top address bar option should be selected. + [[EarlGrey selectElementWithMatcher:TopAddressBarOptionSelected()] + assertWithMatcher:grey_notNil()]; + + // Confirm selection. + TapPromoStyleButton(kPromoStylePrimaryActionAccessibilityIdentifier); + + // Verify that the preferred omnibox position is top. + GREYAssertFalse([ChromeEarlGrey userBooleanPref:prefs::kBottomOmnibox], + @"Failed to set preferred omnibox position to top"); +} + +// Tests selecting bottom omnibox in FRE when top is selected by default. +- (void)testSelectBottomOmnibox { + if ([ChromeEarlGrey isIPadIdiom]) { + EARL_GREY_TEST_SKIPPED( + @"Skipped for iPad (no choice for omnibox position on tablet)"); + } + + SkipScreensBeforeOmniboxPositionChoice(); + + // The top address bar option should be selected. + [[EarlGrey selectElementWithMatcher:TopAddressBarOptionSelected()] + assertWithMatcher:grey_notNil()]; + + // Tap on the bottom address bar option. + [[EarlGrey selectElementWithMatcher:BottomAddressBarOption()] + performAction:grey_tap()]; + + // The bottom address bar option should be selected. + [[EarlGrey selectElementWithMatcher:BottomAddressBarOptionSelected()] + assertWithMatcher:grey_notNil()]; + + // Confirm selection. + TapPromoStyleButton(kPromoStylePrimaryActionAccessibilityIdentifier); + + // Verify that the preferred omnibox position is bottom. + GREYAssertTrue([ChromeEarlGrey userBooleanPref:prefs::kBottomOmnibox], + @"Failed to set preferred omnibox position to bottom"); +} + +@end
diff --git a/ios/chrome/browser/ui/price_notifications/price_notifications_price_tracking_egtest.mm b/ios/chrome/browser/ui/price_notifications/price_notifications_price_tracking_egtest.mm index 3f70a74..232218e 100644 --- a/ios/chrome/browser/ui/price_notifications/price_notifications_price_tracking_egtest.mm +++ b/ios/chrome/browser/ui/price_notifications/price_notifications_price_tracking_egtest.mm
@@ -35,12 +35,6 @@ } - (void)testPriceTrackingDismissButton { - // TODO(crbug.com/1478755): Investigate why this test fails with - // ReplaceSyncWithSignin. - if ([ChromeEarlGrey isReplaceSyncWithSigninEnabled]) { - EARL_GREY_TEST_SKIPPED(@"crbug.com/1478755: Temporarily disabled."); - } - [self signinPriceTrackingUser]; [self openTrackingPriceUI];
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/transitions/tab_grid_transition_handler.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/transitions/tab_grid_transition_handler.mm index b1aef15..ed16fe88 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/transitions/tab_grid_transition_handler.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/transitions/tab_grid_transition_handler.mm
@@ -21,8 +21,12 @@ TabGridTransitionDirection _direction; UIViewController<TabGridTransitionLayoutProviding>* _tabGridViewController; - BVCContainerViewController* _bvcContainerViewController; + BVCContainerViewController* _BVCContainerViewController; + // Transition item for the selected cell in tab grid. + TabGridTransitionItem* _tabGridCellItem; + + // Transition animation to execute. id<TabGridTransitionAnimation> _animation; } @@ -42,7 +46,8 @@ _transitionType = transitionType; _direction = direction; _tabGridViewController = tabGridViewController; - _bvcContainerViewController = bvcContainerViewController; + _BVCContainerViewController = bvcContainerViewController; + _tabGridCellItem = tabGridViewController.transitionLayout.activeCell; } return self; } @@ -97,18 +102,16 @@ // Prepares items for the Browser to Tab Grid transition. - (void)prepareBrowserToTabGridTransition { - [_bvcContainerViewController willMoveToParentViewController:nil]; + [_BVCContainerViewController willMoveToParentViewController:nil]; } // Prepares items for the Tab Grid to Browser transition. - (void)prepareTabGridToBrowserTransition { - [_tabGridViewController addChildViewController:_bvcContainerViewController]; + [_tabGridViewController addChildViewController:_BVCContainerViewController]; + _BVCContainerViewController.view.frame = _tabGridViewController.view.bounds; + [_tabGridViewController.view addSubview:_BVCContainerViewController.view]; - _bvcContainerViewController.view.frame = _tabGridViewController.view.bounds; - [_tabGridViewController.view addSubview:_bvcContainerViewController.view]; - - _bvcContainerViewController.view.accessibilityViewIsModal = YES; - _bvcContainerViewController.view.alpha = 0; + _BVCContainerViewController.view.accessibilityViewIsModal = YES; } // Performs Browser to TabGrid transition animation. @@ -127,19 +130,18 @@ // Takes all necessary actions to finish Browser to TabGrid transition. - (void)finalizeBrowserToTabGridTransition { - [_bvcContainerViewController.view removeFromSuperview]; - [_bvcContainerViewController removeFromParentViewController]; + [_BVCContainerViewController.view removeFromSuperview]; + [_BVCContainerViewController removeFromParentViewController]; [_tabGridViewController setNeedsStatusBarAppearanceUpdate]; } // Takes all necessary actions to finish TabGrid to Browser transition. - (void)finalizeTabGridToBrowserTransition { - _bvcContainerViewController.view.alpha = 1; - [_bvcContainerViewController + [_BVCContainerViewController didMoveToParentViewController:_tabGridViewController]; - [_bvcContainerViewController setNeedsStatusBarAppearanceUpdate]; + [_BVCContainerViewController setNeedsStatusBarAppearanceUpdate]; } // Performs transition animation. @@ -181,19 +183,17 @@ } // Returns Browser to TabGrid normal motion animation. +// TODO(crbug.com/1499268): Finish this animation. - (id<TabGridTransitionAnimation>)browserToTabGridNormalAnimation { // Main animation. - TabGridTransitionItem* cellItem = - _tabGridViewController.transitionLayout.activeCell; - PointZoomAnimationParameters animationParam = PointZoomAnimationParameters{ .direction = PointZoomAnimationParameters::AnimationDirection::kContracting, - .destinationFrame = cellItem.originalFrame, - .destinationCornerRadius = cellItem.view.layer.cornerRadius}; + .destinationFrame = _tabGridCellItem.originalFrame, + .destinationCornerRadius = _tabGridCellItem.view.layer.cornerRadius}; id<TabGridTransitionAnimation> mainAnimation = [[PointZoomTransitionAnimation alloc] - initWithView:_bvcContainerViewController.view + initWithView:_BVCContainerViewController.view animationParameters:animationParam]; // Combine animation. @@ -204,30 +204,39 @@ } // Returns TabGrid to Browser normal motion animation. +// TODO(crbug.com/1499268): Finish this animation. - (id<TabGridTransitionAnimation>)tabGridToBrowserNormalAnimation { - // TODO(crbug.com/1499268): Update this animation. - id<TabGridTransitionAnimation> outroAnimation = - [[CenteredZoomTransitionAnimation alloc] - initWithView:_bvcContainerViewController.view - direction:CenteredZoomTransitionAnimationDirection::kExpanding]; + // Set the frame to be the same as the active cell. + _BVCContainerViewController.view.frame = _tabGridCellItem.originalFrame; + // Set the frame to be the same as the active cell. + PointZoomAnimationParameters animationParam = PointZoomAnimationParameters{ + .direction = PointZoomAnimationParameters::AnimationDirection::kExpanding, + .destinationFrame = _tabGridViewController.view.bounds, + .destinationCornerRadius = DeviceCornerRadius()}; + id<TabGridTransitionAnimation> mainAnimation = + [[PointZoomTransitionAnimation alloc] + initWithView:_BVCContainerViewController.view + animationParameters:animationParam]; + + // Combine animation. id<TabGridTransitionAnimation> combinedIntroAndMainAnimations = [[TabGridTransitionAnimationGroup alloc] - initWithAnimations:@[ outroAnimation ]]; + initWithAnimations:@[ mainAnimation ]]; return combinedIntroAndMainAnimations; } // Returns Browser to TabGrid reduced motion animation. - (id<TabGridTransitionAnimation>)browserToTabGridReducedMotionAnimation { return [[CenteredZoomTransitionAnimation alloc] - initWithView:_bvcContainerViewController.view + initWithView:_BVCContainerViewController.view direction:CenteredZoomTransitionAnimationDirection::kContracting]; } // Returns TabGrid to Browser reduced motion animation. - (id<TabGridTransitionAnimation>)tabGridToBrowserReducedMotionAnimation { return [[CenteredZoomTransitionAnimation alloc] - initWithView:_bvcContainerViewController.view + initWithView:_BVCContainerViewController.view direction:CenteredZoomTransitionAnimationDirection::kExpanding]; }
diff --git a/ios/chrome/browser/ui/unit_conversion/unit_conversion_coordinator.mm b/ios/chrome/browser/ui/unit_conversion/unit_conversion_coordinator.mm index f3982a5..b0a3d66 100644 --- a/ios/chrome/browser/ui/unit_conversion/unit_conversion_coordinator.mm +++ b/ios/chrome/browser/ui/unit_conversion/unit_conversion_coordinator.mm
@@ -16,16 +16,20 @@ const CGFloat kPopOverSourceRectWidth = 1; const CGFloat kPopOverSourceRectHeight = 1; +// The height offset to add to the half sheet detent's height. +const CGFloat kHalfSheetDetentHeightOffset = 40; + } // namespace @interface UnitConversionCoordinator () < UIAdaptivePresentationControllerDelegate> +// The view controller managed by this coordinator. +@property(nonatomic, strong) UnitConversionViewController* viewController; + @end @implementation UnitConversionCoordinator { - // The view controller managed by this coordinator. - UnitConversionViewController* _viewController; // Mediator to handle the units updates and conversion. UnitConversionMediator* _mediator; @@ -112,10 +116,33 @@ popover.adaptiveSheetPresentationController; sheetPresentationController.delegate = _viewController; sheetPresentationController.prefersEdgeAttachedInCompactHeight = YES; - sheetPresentationController.detents = @[ - UISheetPresentationControllerDetent.mediumDetent, - UISheetPresentationControllerDetent.largeDetent, - ]; + + if (@available(iOS 16, *)) { + __weak UnitConversionCoordinator* weakSelf = self; + auto resolver = ^CGFloat( + id<UISheetPresentationControllerDetentResolutionContext> context) { + CGFloat sheetHeight = + weakSelf.viewController.preferredContentSize.height + + kHalfSheetDetentHeightOffset; + BOOL tooLarge = (sheetHeight > context.maximumDetentValue); + return tooLarge ? context.maximumDetentValue : sheetHeight; + }; + + UISheetPresentationControllerDetent* customDetent = + [UISheetPresentationControllerDetent + customDetentWithIdentifier:nil + resolver:resolver]; + + sheetPresentationController.detents = + @[ customDetent, UISheetPresentationControllerDetent.largeDetent ]; + + } else { + sheetPresentationController.detents = @[ + UISheetPresentationControllerDetent.mediumDetent, + UISheetPresentationControllerDetent.largeDetent + ]; + } + [self.baseViewController presentViewController:navigationController animated:YES completion:nil];
diff --git a/ios/chrome/browser/ui/unit_conversion/unit_conversion_view_controller.mm b/ios/chrome/browser/ui/unit_conversion/unit_conversion_view_controller.mm index f3f1f3cc..0b28a11 100644 --- a/ios/chrome/browser/ui/unit_conversion/unit_conversion_view_controller.mm +++ b/ios/chrome/browser/ui/unit_conversion/unit_conversion_view_controller.mm
@@ -58,6 +58,9 @@ const NSInteger kUnitTypeRow = 0; const NSInteger kUnitValueFieldRow = 1; +// The height offset to add to the computed preferredContentSize's height. +const CGFloat kTableViewHeightOffset = 16; + // Returns the `UnitType` group for the given `unit`. ios::provider::UnitType TypeByUnit(NSUnit* unit) { if ([unit isKindOfClass:[NSUnitArea class]]) { @@ -107,6 +110,11 @@ // The `Report an issue` button. UIButton* _reportAnIssueButton; + + // A copy of `self.view.bounds.size.height` before its change, made during + // calls to viewDidLayoutSubviews, and used to reduce the number of calls to + // calculatePreferredContentHeight. + CGFloat _previousHeight; } @property(nonatomic, strong) NSUnit* targetUnit; @@ -135,13 +143,13 @@ if (self) { _unitValue = unitValue; _sourceUnit = sourceUnit; + _previousHeight = 0; } return self; } - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; - // Capture the tableView's width and use it to calculate the footer's size. CGFloat width = self.tableView.bounds.size.width; CGSize size = [_reportAnIssueButton @@ -157,6 +165,14 @@ _tableViewFooterView.frame = frame; self.tableView.tableFooterView = _tableViewFooterView; } + + // Check for height change before computing the new height. + if (!AreCGFloatsEqual(_previousHeight, self.view.bounds.size.height)) { + self.preferredContentSize = + CGSizeMake(self.preferredContentSize.width, + [self calculatePreferredContentHeight]); + _previousHeight = self.view.bounds.size.height; + } } - (void)viewDidLoad { @@ -233,6 +249,11 @@ #pragma mark - Private +// Computes the new height based on the height `tableView`. +- (CGFloat)calculatePreferredContentHeight { + return self.tableView.contentSize.height + kTableViewHeightOffset; +} + - (void)closeButtonTapped:(UIButton*)sender { [self.delegate didTapCloseUnitConversionController:self]; }
diff --git a/ios/chrome/browser/web/BUILD.gn b/ios/chrome/browser/web/BUILD.gn index 5111b5e..9e84fea 100644 --- a/ios/chrome/browser/web/BUILD.gn +++ b/ios/chrome/browser/web/BUILD.gn
@@ -490,7 +490,6 @@ "//ios/chrome/browser/ui/infobars/banners:public", "//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/start_surface:feature_flags", - "//ios/chrome/browser/web:feature_flags", "//ios/chrome/test:eg_test_support+eg2", "//ios/chrome/test/earl_grey:eg_test_support+eg2", "//ios/net:test_support",
diff --git a/ios/chrome/browser/web/restore_egtest.mm b/ios/chrome/browser/web/restore_egtest.mm index f96389b..763dc18 100644 --- a/ios/chrome/browser/web/restore_egtest.mm +++ b/ios/chrome/browser/web/restore_egtest.mm
@@ -11,7 +11,6 @@ #import "base/test/ios/wait_util.h" #import "ios/chrome/browser/shared/public/features/features.h" #import "ios/chrome/browser/ui/start_surface/start_surface_features.h" -#import "ios/chrome/browser/web/features.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h" @@ -367,7 +366,8 @@ - (AppLaunchConfiguration)appConfigurationForTestCase { AppLaunchConfiguration config = [super appConfigurationForTestCase]; - config.features_disabled.push_back(web::kRestoreSessionFromCache); + config.features_disabled.push_back( + web::features::kForceSynthesizedRestoreSession); return config; }
diff --git a/ios/chrome/browser/web/visible_url_egtest.mm b/ios/chrome/browser/web/visible_url_egtest.mm index 68637597..9fc9ca3 100644 --- a/ios/chrome/browser/web/visible_url_egtest.mm +++ b/ios/chrome/browser/web/visible_url_egtest.mm
@@ -12,7 +12,6 @@ #import "base/strings/utf_string_conversions.h" #import "components/version_info/version_info.h" #import "ios/chrome/browser/shared/model/url/chrome_url_constants.h" -#import "ios/chrome/browser/web/features.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h" @@ -471,7 +470,8 @@ - (AppLaunchConfiguration)appConfigurationForTestCase { AppLaunchConfiguration config = [super appConfigurationForTestCase]; - config.features_disabled.push_back(web::kRestoreSessionFromCache); + config.features_disabled.push_back( + web::features::kForceSynthesizedRestoreSession); return config; }
diff --git a/ios/chrome/test/earl_grey2/BUILD.gn b/ios/chrome/test/earl_grey2/BUILD.gn index b288dc7..7aebd47 100644 --- a/ios/chrome/test/earl_grey2/BUILD.gn +++ b/ios/chrome/test/earl_grey2/BUILD.gn
@@ -191,6 +191,7 @@ "//ios/chrome/browser/ui/download:eg2_tests", "//ios/chrome/browser/ui/find_bar:eg2_tests", "//ios/chrome/browser/ui/first_run:eg2_tests", + "//ios/chrome/browser/ui/first_run/omnibox_position:eg2_tests", "//ios/chrome/browser/ui/fullscreen:eg2_tests", "//ios/chrome/browser/ui/history:eg2_tests", "//ios/chrome/browser/ui/incognito_interstitial:eg2_tests",
diff --git a/ios/web/common/features.h b/ios/web/common/features.h index 1b3a9b79..8797382b5 100644 --- a/ios/web/common/features.h +++ b/ios/web/common/features.h
@@ -80,6 +80,11 @@ // Feature flag to enable the session serialization optimizations. BASE_DECLARE_FEATURE(kEnableSessionSerializationOptimizations); +// Feature flag that force the use of the synthesized native WKWebView +// session instead of the (maybe inexistent) saved native session. The +// purpose of this flag it to allow to testing this code path. +BASE_DECLARE_FEATURE(kForceSynthesizedRestoreSession); + // When true, the new loadSimulatedRequest API should be used when displaying // error pages. bool IsLoadSimulatedRequestAPIEnabled();
diff --git a/ios/web/common/features.mm b/ios/web/common/features.mm index f5971496..51aad0d7 100644 --- a/ios/web/common/features.mm +++ b/ios/web/common/features.mm
@@ -90,6 +90,11 @@ "EnableSessionSerializationOptimizations", base::FEATURE_DISABLED_BY_DEFAULT); +// This feature will always be disabled and will only be enabled by tests. +BASE_FEATURE(kForceSynthesizedRestoreSession, + "ForceSynthesizedRestoreSession", + base::FEATURE_DISABLED_BY_DEFAULT); + bool IsLoadSimulatedRequestAPIEnabled() { if (@available(iOS 15, *)) { return base::FeatureList::IsEnabled(kUseLoadSimulatedRequestForOfflinePage);
diff --git a/ios/web/navigation/navigation_manager_impl.mm b/ios/web/navigation/navigation_manager_impl.mm index d7fe5f10..6614829 100644 --- a/ios/web/navigation/navigation_manager_impl.mm +++ b/ios/web/navigation/navigation_manager_impl.mm
@@ -5,11 +5,13 @@ #import "ios/web/navigation/navigation_manager_impl.h" #import <Foundation/Foundation.h> + #import <algorithm> #import <memory> #import <utility> #import "base/containers/span.h" +#import "base/feature_list.h" #import "base/functional/bind.h" #import "base/functional/callback.h" #import "base/ios/ios_util.h" @@ -199,6 +201,13 @@ void NavigationManagerImpl::SetNativeSessionFetcher( SessionDataBlobFetcher native_session_fetcher) { CHECK(session_data_blob_fetchers_.empty()); + if (base::FeatureList::IsEnabled(features::kForceSynthesizedRestoreSession)) { + // If the use of synthesized native WKWebView session is force, then drop + // the `native_session_fetcher`. This simulate a missing native session + // and force the synthese of a native WKWebView session. + return; + } + AppendSessionDataBlobFetcher(std::move(native_session_fetcher), SessionDataBlobSource::kSessionCache); }
diff --git a/net/http/transport_security_state_static.pins b/net/http/transport_security_state_static.pins index 891bc9a..ce789d6 100644 --- a/net/http/transport_security_state_static.pins +++ b/net/http/transport_security_state_static.pins
@@ -43,9 +43,9 @@ # hash function for preloaded entries again (we have already done so once). # -# Last updated: 2023-11-22 12:54 UTC +# Last updated: 2023-11-23 12:55 UTC PinsListTimestamp -1700657657 +1700744155 TestSPKI sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
diff --git a/net/http/transport_security_state_static_pins.json b/net/http/transport_security_state_static_pins.json index 233097c8..248fe83a 100644 --- a/net/http/transport_security_state_static_pins.json +++ b/net/http/transport_security_state_static_pins.json
@@ -31,7 +31,7 @@ // the 'static_spki_hashes' and 'bad_static_spki_hashes' fields in 'pinsets' // refer to, and the timestamp at which the pins list was last updated. // -// Last updated: 2023-11-22 12:54 UTC +// Last updated: 2023-11-23 12:55 UTC // { "pinsets": [
diff --git a/printing/printing_features.cc b/printing/printing_features.cc index 9348da76..c4285ccf 100644 --- a/printing/printing_features.cc +++ b/printing/printing_features.cc
@@ -105,13 +105,6 @@ BASE_FEATURE(kEnableCloudScanAfterPreview, "EnableCloudScanAfterPreview", base::FEATURE_ENABLED_BY_DEFAULT); - -// The naming mismatch below is intentional to preserve compatibility while -// making code usage clearer. This is temporary and will be removed once -// b/216105729 is officially fixed and the local workflow is supported. -BASE_FEATURE(kEnableLocalScanAfterPreview, - "EnablePrintScanAfterPreview", - base::FEATURE_ENABLED_BY_DEFAULT); #endif // BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS) } // namespace features
diff --git a/printing/printing_features.h b/printing/printing_features.h index e2b1a0f..107ac7f0 100644 --- a/printing/printing_features.h +++ b/printing/printing_features.h
@@ -74,19 +74,6 @@ // a pre-print-preview snapshot and sending it to the cloud for analysis. COMPONENT_EXPORT(PRINTING_BASE) BASE_DECLARE_FEATURE(kEnableCloudScanAfterPreview); - -// Allows the scanning to happen post-print-preview when -// OnPrintEnterpriseConnector has a local agent service_provider instead of -// doing a pre-print-preview snapshot and sending it to a local agent for -// analysis. This applies to the following service_provider values: -// - local_user_agent -// - local_system_agent -// - brcm_chrm_cas -// -// TODO(b/216105729): Remove once the local content scanning post-preview UX is -// officially supported. -COMPONENT_EXPORT(PRINTING_BASE) -BASE_DECLARE_FEATURE(kEnableLocalScanAfterPreview); #endif // BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS) } // namespace features
diff --git a/services/on_device_model/on_device_model.gni b/services/on_device_model/on_device_model.gni index b7fc033..d9302b5e 100644 --- a/services/on_device_model/on_device_model.gni +++ b/services/on_device_model/on_device_model.gni
@@ -2,11 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//build/config/gclient_args.gni") - declare_args() { # If true //components/optimization_guide/internal will be enabled. - enable_ml_internal = - checkout_src_internal && ((is_win && target_cpu != "arm64" && - target_cpu != "arm") || is_mac || is_linux) + enable_ml_internal = false }
diff --git a/skia/features.gni b/skia/features.gni index 7eee129..337585a 100644 --- a/skia/features.gni +++ b/skia/features.gni
@@ -7,8 +7,10 @@ declare_args() { # Enable experimental Skia Graphite Dawn backend. Current enabled on Windows, - # macOS and iOS when Blink is used. - skia_use_dawn = is_mac || is_win || (is_ios && use_blink) + # macOS, Android, and iOS when Blink is used. + skia_use_dawn = is_mac || is_win || + (is_android && target_cpu != "x86" && target_cpu != "x64") || + (is_ios && use_blink) # Enable experimental Skia Graphite Metal backend. Intended only for debugging # on non-official developer builds.
diff --git a/testing/buildbot/client.v8.chromium.json b/testing/buildbot/client.v8.chromium.json index 439a53d..0345936b 100644 --- a/testing/buildbot/client.v8.chromium.json +++ b/testing/buildbot/client.v8.chromium.json
@@ -305,20 +305,6 @@ "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "ppapi_unittests", - "swarming": { - "dimensions": { - "os": "Ubuntu-22.04" - }, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "ppapi_unittests", - "test_id_prefix": "ninja://ppapi:ppapi_unittests/" - }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, "name": "remoting_unittests", "swarming": { "dimensions": { @@ -763,20 +749,6 @@ "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" }, - "name": "ppapi_unittests", - "swarming": { - "dimensions": { - "os": "Ubuntu-22.04" - }, - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "ppapi_unittests", - "test_id_prefix": "ninja://ppapi:ppapi_unittests/" - }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, "name": "remoting_unittests", "swarming": { "dimensions": {
diff --git a/testing/buildbot/client.v8.fyi.json b/testing/buildbot/client.v8.fyi.json index 7da132a..bfeeb61 100644 --- a/testing/buildbot/client.v8.fyi.json +++ b/testing/buildbot/client.v8.fyi.json
@@ -2173,7 +2173,6 @@ "net_unittests", "pdf_unittests", "pdfium_test", - "ppapi_unittests", "printing_unittests", "remoting_unittests", "sandbox_linux_unittests",
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl index f2b5a1c4..1ec4a18d 100644 --- a/testing/buildbot/test_suites.pyl +++ b/testing/buildbot/test_suites.pyl
@@ -1515,7 +1515,6 @@ 'interactive_ui_tests': {}, 'net_unittests': {}, 'pdf_unittests': {}, - 'ppapi_unittests': {}, 'remoting_unittests': {}, 'services_unittests': {}, 'sync_integration_tests': {
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index 83fb418..50e842b 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -6544,7 +6544,6 @@ 'net_unittests', 'pdf_unittests', 'pdfium_test', - 'ppapi_unittests', 'printing_unittests', 'remoting_unittests', 'sandbox_linux_unittests',
diff --git a/third_party/blink/renderer/bindings/generated_in_modules.gni b/third_party/blink/renderer/bindings/generated_in_modules.gni index 956db20..39b919f 100644 --- a/third_party/blink/renderer/bindings/generated_in_modules.gni +++ b/third_party/blink/renderer/bindings/generated_in_modules.gni
@@ -116,10 +116,10 @@ generated_dictionary_sources_in_modules = [ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_aac_encoder_config.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_aac_encoder_config.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data_config.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data_config.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data_config.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_auction_data_config.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_properties.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_properties.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ad_request_config.cc", @@ -136,16 +136,16 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_android_pay_method_data.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_app_banner_prompt_result.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_app_banner_prompt_result.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_config.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_config.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group_key.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group_key.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group_size.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group_size.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad_interest_group.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_ad.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_additional_bid_signature.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_additional_bid_signature.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_auction_report_buyers_config.cc", @@ -188,10 +188,10 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_audio_worklet_node_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_inputs.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_inputs.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs_js_on.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs_js_on.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs_js_on.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs_js_on.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_device_public_key_inputs.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_device_public_key_inputs.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_device_public_key_outputs.cc", @@ -264,12 +264,14 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_canvas_filter_dictionary.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_canvas_rendering_context_2d_settings.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_canvas_rendering_context_2d_settings.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_config.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_config.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_capture_handle.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_capture_handle.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_config.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_config.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_captured_mouse_event_init.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_captured_mouse_event_init.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_captured_wheel_action.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_captured_wheel_action.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_channel_merger_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_channel_merger_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_channel_splitter_options.cc", @@ -430,10 +432,10 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gamepad_event_init.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_get_notification_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_get_notification_options.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_goog_media_constraints_set.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_goog_media_constraints_set.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_goog_media_constraints.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_goog_media_constraints.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_goog_media_constraints_set.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_goog_media_constraints_set.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_google_play_billing_method_data.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_google_play_billing_method_data.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_bind_group_descriptor.cc", @@ -448,10 +450,10 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_blend_component.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_blend_state.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_blend_state.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding_layout.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding_layout.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding_layout.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding_layout.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_descriptor.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_descriptor.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_canvas_configuration.cc", @@ -490,10 +492,10 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_external_image.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_image_bitmap.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_image_bitmap.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_texture_tagged.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_texture_tagged.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_texture.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_texture.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_texture_tagged.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_texture_tagged.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_data_layout.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_data_layout.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_multisample_state.cc", @@ -566,10 +568,10 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_vertex_state.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_drawing_segment.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_drawing_segment.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_hints_query_result.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_hints_query_result.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_hints.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_hints.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_hints_query_result.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_hints_query_result.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_model_constraint.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_model_constraint.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_handwriting_point.cc", @@ -726,14 +728,14 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_midi_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_midi_permission_descriptor.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_midi_permission_descriptor.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_batch_normalization_options.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_batch_normalization_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_clamp_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_clamp_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_compute_result.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_compute_result.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_context_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_context_options.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_batch_normalization_options.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_batch_normalization_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_conv_2d_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_conv_2d_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_conv_transpose_2d_options.cc", @@ -756,10 +758,10 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_resample_2d_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_split_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_split_options.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_tensor_info.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_tensor_info.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_tensor.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_tensor.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_tensor_info.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_tensor_info.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_transpose_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ml_transpose_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_multi_cache_query_options.cc", @@ -866,8 +868,6 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_presentation_source.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_pressure_observer_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_pressure_observer_options.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_protected_audience_private_aggregation_config.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_protected_audience_private_aggregation_config.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_private_aggregation_debug_mode_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_private_aggregation_debug_mode_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_private_aggregation_histogram_contribution.cc", @@ -882,6 +882,8 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_private_attribution_network.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_private_attribution_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_private_attribution_options.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_protected_audience_private_aggregation_config.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_protected_audience_private_aggregation_config.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_creation_options.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_creation_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_descriptor.cc", @@ -960,10 +962,10 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_error_init.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_init.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_init.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_pair_stats.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_pair_stats.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_pair.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_pair.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_pair_stats.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_pair_stats.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_stats.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_candidate_stats.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_parameters.cc", @@ -998,12 +1000,12 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtcp_parameters.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_capabilities.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_capabilities.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec_capability.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec_capability.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec_parameters.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec_parameters.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_codec.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_coding_parameters.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_coding_parameters.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_contributing_source.cc", @@ -1134,14 +1136,14 @@ "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_decoder_support.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_config.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_config.h", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options_for_av_1.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options_for_av_1.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options_for_avc.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options_for_avc.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options_for_vp_9.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options_for_vp_9.h", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options.cc", - "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_encode_options.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_init.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_init.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_video_encoder_support.cc",
diff --git a/third_party/blink/renderer/bindings/idl_in_modules.gni b/third_party/blink/renderer/bindings/idl_in_modules.gni index 616a51a..67163aff 100644 --- a/third_party/blink/renderer/bindings/idl_in_modules.gni +++ b/third_party/blink/renderer/bindings/idl_in_modules.gni
@@ -117,8 +117,6 @@ "//third_party/blink/renderer/modules/contacts_picker/contacts_manager.idl", "//third_party/blink/renderer/modules/contacts_picker/contacts_select_options.idl", "//third_party/blink/renderer/modules/contacts_picker/navigator_contacts.idl", - "//third_party/blink/renderer/modules/cookie_deprecation_label/cookie_deprecation_label.idl", - "//third_party/blink/renderer/modules/cookie_deprecation_label/navigator_cookie_deprecation_label.idl", "//third_party/blink/renderer/modules/content_index/content_description.idl", "//third_party/blink/renderer/modules/content_index/content_icon_definition.idl", "//third_party/blink/renderer/modules/content_index/content_index.idl", @@ -126,6 +124,8 @@ "//third_party/blink/renderer/modules/content_index/content_index_event_init.idl", "//third_party/blink/renderer/modules/content_index/service_worker_global_scope_content_index.idl", "//third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.idl", + "//third_party/blink/renderer/modules/cookie_deprecation_label/cookie_deprecation_label.idl", + "//third_party/blink/renderer/modules/cookie_deprecation_label/navigator_cookie_deprecation_label.idl", "//third_party/blink/renderer/modules/cookie_store/cookie_change_event.idl", "//third_party/blink/renderer/modules/cookie_store/cookie_change_event_init.idl", "//third_party/blink/renderer/modules/cookie_store/cookie_init.idl", @@ -170,6 +170,7 @@ "//third_party/blink/renderer/modules/credentialmanagement/federated_credential_request_options.idl", "//third_party/blink/renderer/modules/credentialmanagement/identity_claim_requirement.idl", "//third_party/blink/renderer/modules/credentialmanagement/identity_credential.idl", + "//third_party/blink/renderer/modules/credentialmanagement/identity_credential_error.idl", "//third_party/blink/renderer/modules/credentialmanagement/identity_credential_logout_r_ps_request.idl", "//third_party/blink/renderer/modules/credentialmanagement/identity_credential_request_options.idl", "//third_party/blink/renderer/modules/credentialmanagement/identity_provider.idl", @@ -438,6 +439,7 @@ "//third_party/blink/renderer/modules/mediastream/capture_handle_config.idl", "//third_party/blink/renderer/modules/mediastream/captured_mouse_event.idl", "//third_party/blink/renderer/modules/mediastream/captured_mouse_event_init.idl", + "//third_party/blink/renderer/modules/mediastream/captured_wheel_action.idl", "//third_party/blink/renderer/modules/mediastream/constrain_boolean_parameters.idl", "//third_party/blink/renderer/modules/mediastream/constrain_dom_string_parameters.idl", "//third_party/blink/renderer/modules/mediastream/constrain_double_range.idl", @@ -456,10 +458,10 @@ "//third_party/blink/renderer/modules/mediastream/media_stream_track_content_hint.idl", "//third_party/blink/renderer/modules/mediastream/media_stream_track_event.idl", "//third_party/blink/renderer/modules/mediastream/media_stream_track_event_init.idl", + "//third_party/blink/renderer/modules/mediastream/media_stream_track_video_stats.idl", "//third_party/blink/renderer/modules/mediastream/media_track_capabilities.idl", "//third_party/blink/renderer/modules/mediastream/media_track_constraint_set.idl", "//third_party/blink/renderer/modules/mediastream/media_track_constraints.idl", - "//third_party/blink/renderer/modules/mediastream/media_stream_track_video_stats.idl", "//third_party/blink/renderer/modules/mediastream/media_track_settings.idl", "//third_party/blink/renderer/modules/mediastream/media_track_supported_constraints.idl", "//third_party/blink/renderer/modules/mediastream/navigator_media_stream.idl", @@ -1062,7 +1064,6 @@ "//third_party/blink/renderer/modules/webgpu/gpu_pipeline_base.idl", "//third_party/blink/renderer/modules/webgpu/gpu_pipeline_descriptor_base.idl", "//third_party/blink/renderer/modules/webgpu/gpu_pipeline_error.idl", - "//third_party/blink/renderer/modules/credentialmanagement/identity_credential_error.idl", "//third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.idl", "//third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout_descriptor.idl", "//third_party/blink/renderer/modules/webgpu/gpu_primitive_state.idl",
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 f713b0e..83d77bf5 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
@@ -142,6 +142,10 @@ case CSSPrimitiveValue::UnitType::kDotsPerCentimeter: return kCalcResolution; + // Identifier + case CSSPrimitiveValue::UnitType::kIdent: + return kCalcIdent; + default: return kCalcOther; } @@ -290,6 +294,25 @@ return true; } +// Either all the arguments are numerics and have the same unit type (e.g. +// progress(1em from 0em to 1em)), or they are all numerics and can be resolved +// to the canonical unit (e.g. progress(1deg from 0rad to 1deg)). Note: this +// can't be eagerly simplified - progress(1em from 0px to 1em). +bool CanEagerlySimplifyProgressArgs( + const CSSMathExpressionOperation::Operands& operands) { + return std::all_of(operands.begin(), operands.end(), + [](const CSSMathExpressionNode* node) { + return node->IsNumericLiteral() && + node->ComputeValueInCanonicalUnit().has_value(); + }) || + std::all_of(operands.begin(), operands.end(), + [&](const CSSMathExpressionNode* node) { + return node->IsNumericLiteral() && + node->ResolvedUnitType() == + operands.front()->ResolvedUnitType(); + }); +} + using UnitsHashMap = HashMap<CSSPrimitiveValue::UnitType, double>; struct CSSMathExpressionNodeWithOperator { DISALLOW_NEW(); @@ -772,6 +795,7 @@ case kCalcPercentLength: case kCalcPercent: case kCalcOther: + case kCalcIdent: NOTREACHED(); break; } @@ -792,6 +816,7 @@ case kCalcTime: case kCalcResolution: case kCalcOther: + case kCalcIdent: NOTREACHED(); break; } @@ -846,28 +871,33 @@ static const CalculationResultCategory kAddSubtractResult[kCalcOther][kCalcOther] = { /* CalcNumber */ {kCalcNumber, kCalcOther, kCalcOther, kCalcOther, - kCalcOther, kCalcOther, kCalcOther, kCalcOther}, + kCalcOther, kCalcOther, kCalcOther, kCalcOther, + kCalcOther}, /* CalcLength */ {kCalcOther, kCalcLength, kCalcPercentLength, kCalcPercentLength, - kCalcOther, kCalcOther, kCalcOther, kCalcOther}, + kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther}, /* CalcPercent */ {kCalcOther, kCalcPercentLength, kCalcPercent, kCalcPercentLength, - kCalcOther, kCalcOther, kCalcOther, kCalcOther}, + kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther}, /* CalcPercentLength */ {kCalcOther, kCalcPercentLength, kCalcPercentLength, kCalcPercentLength, - kCalcOther, kCalcOther, kCalcOther, kCalcOther}, + kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther}, /* CalcAngle */ {kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcAngle, kCalcOther, - kCalcOther, kCalcOther}, + kCalcOther, kCalcOther, kCalcOther}, /* CalcTime */ {kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcTime, - kCalcOther, kCalcOther}, + kCalcOther, kCalcOther, kCalcOther}, /* CalcFrequency */ {kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther, - kCalcFrequency, kCalcOther}, + kCalcFrequency, kCalcOther, kCalcOther}, /* CalcResolution */ {kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther, - kCalcOther, kCalcResolution}}; + kCalcOther, kCalcResolution, kCalcOther}, + /* CalcIdent */ + {kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther, kCalcOther, + kCalcOther, kCalcOther, kCalcOther}, +}; static CalculationResultCategory DetermineCategory( const CSSMathExpressionNode& left_side, @@ -924,6 +954,23 @@ return category; } +// ------ Start of CSSMathExpressionIdentifierLiteral member functions - + +CSSMathExpressionIdentifierLiteral::CSSMathExpressionIdentifierLiteral( + AtomicString identifier) + : CSSMathExpressionNode(UnitCategory(CSSPrimitiveValue::UnitType::kIdent), + false /* has_comparisons*/, + false /* needs_tree_scope_population*/), + identifier_(std::move(identifier)) {} + +scoped_refptr<const CalculationExpressionNode> +CSSMathExpressionIdentifierLiteral::ToCalculationExpression( + const CSSLengthResolver&) const { + return base::MakeRefCounted<CalculationExpressionIdentifierNode>(identifier_); +} + +// ------ End of CSSMathExpressionIdentifierLiteral member functions ---- + // ------ Start of CSSMathExpressionOperation member functions ------ bool CSSMathExpressionOperation::AllOperandsAreNumeric() const { @@ -1487,6 +1534,7 @@ case CSSMathOperator::kRem: case CSSMathOperator::kHypot: case CSSMathOperator::kAbs: + case CSSMathOperator::kProgress: case CSSMathOperator::kSign: return absl::nullopt; case CSSMathOperator::kInvalid: @@ -1570,7 +1618,8 @@ case CSSMathOperator::kRem: case CSSMathOperator::kHypot: case CSSMathOperator::kAbs: - case CSSMathOperator::kSign: { + case CSSMathOperator::kSign: + case CSSMathOperator::kProgress: { Vector<scoped_refptr<const CalculationExpressionNode>> operands; operands.reserve(operands_.size()); for (const CSSMathExpressionNode* operand : operands_) { @@ -1593,8 +1642,11 @@ op = CalculationOperator::kHypot; } else if (operator_ == CSSMathOperator::kAbs) { op = CalculationOperator::kAbs; - } else { + } else if (operator_ == CSSMathOperator::kSign) { op = CalculationOperator::kSign; + } else { + CHECK(operator_ == CSSMathOperator::kProgress); + op = CalculationOperator::kProgress; } return CalculationExpressionOperationNode::CreateSimplified( std::move(operands), op); @@ -1712,6 +1764,7 @@ case CSSMathOperator::kSign: // When stepped value functions are involved, we can't resolve the // expression into a length array. + case CSSMathOperator::kProgress: return false; case CSSMathOperator::kInvalid: NOTREACHED(); @@ -1828,6 +1881,20 @@ return result.ReleaseString(); } + case CSSMathOperator::kProgress: { + CHECK_EQ(operands_.size(), 3u); + StringBuilder result; + result.Append(ToString(operator_)); + result.Append('('); + result.Append(operands_.front()->CustomCSSText()); + result.Append(" from "); + result.Append(operands_[1]->CustomCSSText()); + result.Append(" to "); + result.Append(operands_.back()->CustomCSSText()); + result.Append(')'); + + return result.ReleaseString(); + } case CSSMathOperator::kInvalid: NOTREACHED(); return String(); @@ -1907,6 +1974,8 @@ } return first_type; } + case CSSMathOperator::kProgress: + return CSSPrimitiveValue::UnitType::kNumber; case CSSMathOperator::kInvalid: NOTREACHED(); return CSSPrimitiveValue::UnitType::kUnknown; @@ -1914,6 +1983,8 @@ case kCalcPercentLength: case kCalcOther: return CSSPrimitiveValue::UnitType::kUnknown; + case kCalcIdent: + return CSSPrimitiveValue::UnitType::kIdent; } NOTREACHED(); @@ -2023,6 +2094,10 @@ (value == 0 || std::isnan(value)) ? value : ((value > 0) ? 1 : -1); return signum; } + case CSSMathOperator::kProgress: { + CHECK_EQ(operands.size(), 3u); + return operands[0] / (operands[2] - operands[1]); + } case CSSMathOperator::kInvalid: NOTREACHED(); break; @@ -2259,6 +2334,8 @@ case CSSValueID::kAnchor: case CSSValueID::kAnchorSize: return RuntimeEnabledFeatures::CSSAnchorPositioningEnabled(); + case CSSValueID::kProgress: + return RuntimeEnabledFeatures::CSSProgressNotationEnabled(); // TODO(crbug.com/1284199): Support other math functions. default: return false; @@ -2336,6 +2413,69 @@ anchor_query_type, anchor_specifier, *value, fallback); } + // https://drafts.csswg.org/css-values-5/#progress-func + CSSMathExpressionNode* ParseProgressNotation( + CSSValueID function_id, + CSSParserTokenRange& tokens, + const HashMap<CSSValueID, double> color_channel_keyword_values, + int depth) { + if (function_id != CSSValueID::kProgress) { + return nullptr; + } + // <progress()> = progress(<calc-sum> from <calc-sum> to <calc-sum>) + // 0 1 2 3 4 + HeapVector<Member<const CSSMathExpressionNode>> nodes; + tokens.ConsumeWhitespace(); + if (CSSMathExpressionNode* node = + ParseValueExpression(tokens, color_channel_keyword_values, depth)) { + nodes.push_back(node); + } + if (tokens.ConsumeIncludingWhitespace().Id() != CSSValueID::kFrom) { + return nullptr; + } + if (CSSMathExpressionNode* node = + ParseValueExpression(tokens, color_channel_keyword_values, depth)) { + nodes.push_back(node); + } + if (tokens.ConsumeIncludingWhitespace().Id() != CSSValueID::kTo) { + return nullptr; + } + if (CSSMathExpressionNode* node = + ParseValueExpression(tokens, color_channel_keyword_values, depth)) { + nodes.push_back(node); + } + if (nodes.size() != 3u) { + return nullptr; + } + if (!tokens.AtEnd()) { + return nullptr; + } + if (nodes[0]->Category() != nodes[1]->Category() || + nodes[0]->Category() != nodes[2]->Category()) { + return nullptr; + } + // Note: we don't need to resolve percents in such case, + // as all the operands are numeric literals, + // so p% / (t% - f%) will lose %. + if (CanEagerlySimplifyProgressArgs(nodes)) { + Vector<double> canonical_values; + canonical_values.reserve(nodes.size()); + for (const CSSMathExpressionNode* operand : nodes) { + absl::optional<double> canonical_value = + operand->ComputeValueInCanonicalUnit(); + CHECK(canonical_value.has_value()); + canonical_values.push_back(canonical_value.value()); + } + double progress_value = + canonical_values[0] / (canonical_values[2] - canonical_values[1]); + return CSSMathExpressionNumericLiteral::Create( + progress_value, CSSPrimitiveValue::UnitType::kNumber); + } + return MakeGarbageCollected<CSSMathExpressionOperation>( + CalculationResultCategory::kCalcNumber, std::move(nodes), + CSSMathOperator::kProgress); + } + CSSMathExpressionNode* ParseMathFunction( CSSValueID function_id, CSSParserTokenRange& tokens, @@ -2350,6 +2490,12 @@ return anchor_query; } } + if (RuntimeEnabledFeatures::CSSProgressNotationEnabled()) { + if (CSSMathExpressionNode* progress = ParseProgressNotation( + function_id, tokens, color_channel_keyword_values, depth)) { + return progress; + } + } // "arguments" refers to comma separated ones. wtf_size_t min_argument_count = 1; @@ -2880,6 +3026,11 @@ return Create(pixels_and_percent.GetPixelsAndPercent()); } + if (node.IsIdentifier()) { + return CSSMathExpressionIdentifierLiteral::Create( + To<CalculationExpressionIdentifierNode>(node).Value()); + } + if (node.IsAnchorQuery()) { const auto& anchor_query = To<CalculationExpressionAnchorQueryNode>(node); CSSAnchorQueryType type = anchor_query.Type() == CSSAnchorQueryType::kAnchor @@ -3001,6 +3152,16 @@ return CSSMathExpressionOperation::CreateSignRelatedFunction( std::move(operands), op); } + case CalculationOperator::kProgress: { + CHECK_EQ(children.size(), 3u); + CSSMathExpressionOperation::Operands operands; + operands.push_back(Create(*children.front())); + operands.push_back(Create(*children[1])); + operands.push_back(Create(*children.back())); + return MakeGarbageCollected<CSSMathExpressionOperation>( + CalculationResultCategory::kCalcNumber, std::move(operands), + CSSMathOperator::kProgress); + } case CalculationOperator::kInvalid: NOTREACHED(); return nullptr;
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 692b79c..2d2b31f9 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
@@ -66,6 +66,7 @@ kCalcTime, kCalcFrequency, kCalcResolution, + kCalcIdent, kCalcOther, }; @@ -91,6 +92,7 @@ virtual bool IsNumericLiteral() const { return false; } virtual bool IsOperation() const { return false; } virtual bool IsAnchorQuery() const { return false; } + virtual bool IsIdentifierLiteral() const { return false; } virtual bool IsMathFunction() const { return false; } @@ -255,6 +257,90 @@ } }; +// Used for media-feature name in media-progress(), +// for container name in container-progress(). +// Will possibly be used in container name for container units function. +class CORE_EXPORT CSSMathExpressionIdentifierLiteral final + : public CSSMathExpressionNode { + public: + static CSSMathExpressionIdentifierLiteral* Create(AtomicString identifier) { + return MakeGarbageCollected<CSSMathExpressionIdentifierLiteral>( + std::move(identifier)); + } + + explicit CSSMathExpressionIdentifierLiteral(AtomicString identifier); + + CSSMathExpressionNode* Copy() const final { return Create(identifier_); } + + const AtomicString& GetValue() const { return identifier_; } + + bool IsIdentifierLiteral() const final { return true; } + + const CSSMathExpressionNode& PopulateWithTreeScope( + const TreeScope* tree_scope) const final { + NOTREACHED(); + return *this; + } + + bool IsZero() const final { return false; } + String CustomCSSText() const final { return identifier_; } + scoped_refptr<const CalculationExpressionNode> ToCalculationExpression( + const CSSLengthResolver&) const final; + absl::optional<PixelsAndPercent> ToPixelsAndPercent( + const CSSLengthResolver&) const final { + return absl::nullopt; + } + double DoubleValue() const final { + NOTREACHED(); + return 0; + } + absl::optional<double> ComputeValueInCanonicalUnit() const final { + return absl::nullopt; + } + double ComputeLengthPx(const CSSLengthResolver& length_resolver) const final { + NOTREACHED(); + return 0; + } + bool AccumulateLengthArray(CSSLengthArray& length_array, + double multiplier) const final { + return false; + } + void AccumulateLengthUnitTypes( + CSSPrimitiveValue::LengthTypeFlags& types) const final {} + bool IsComputationallyIndependent() const final { return true; } + bool operator==(const CSSMathExpressionNode& other) const final { + return other.IsIdentifierLiteral() && + DynamicTo<CSSMathExpressionIdentifierLiteral>(other)->GetValue() == + GetValue(); + } + CSSPrimitiveValue::UnitType ResolvedUnitType() const final { + return CSSPrimitiveValue::UnitType::kIdent; + } + void Trace(Visitor* visitor) const final { + CSSMathExpressionNode::Trace(visitor); + } + +#if DCHECK_IS_ON() + bool InvolvesPercentageComparisons() const final { return false; } +#endif + + protected: + double ComputeDouble(const CSSLengthResolver& length_resolver) const final { + NOTREACHED(); + return 0; + } + + private: + AtomicString identifier_; +}; + +template <> +struct DowncastTraits<CSSMathExpressionIdentifierLiteral> { + static bool AllowFrom(const CSSMathExpressionNode& node) { + return node.IsIdentifierLiteral(); + } +}; + class CORE_EXPORT CSSMathExpressionOperation final : public CSSMathExpressionNode { public:
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 e7f24f2..e6b3f1b 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
@@ -501,6 +501,93 @@ } } +TEST(CSSMathExpressionNode, IdentifierLiteralConversion) { + const CSSMathExpressionIdentifierLiteral* css_node = + CSSMathExpressionIdentifierLiteral::Create(AtomicString("test")); + EXPECT_TRUE(css_node->IsIdentifierLiteral()); + EXPECT_EQ(css_node->Category(), kCalcIdent); + EXPECT_EQ(css_node->GetValue(), AtomicString("test")); + scoped_refptr<const CalculationExpressionNode> calc_node = + css_node->ToCalculationExpression(CSSToLengthConversionData()); + EXPECT_TRUE(calc_node->IsIdentifier()); + EXPECT_EQ(To<CalculationExpressionIdentifierNode>(*calc_node).Value(), + AtomicString("test")); + auto* node = CSSMathExpressionNode::Create(*calc_node); + EXPECT_TRUE(node->IsIdentifierLiteral()); + EXPECT_EQ(To<CSSMathExpressionIdentifierLiteral>(node)->GetValue(), + AtomicString("test")); +} + +TEST(CSSMathExpressionNode, TestProgressNotation) { + const struct TestCase { + const std::string input; + const double output; + } test_cases[] = { + {"progress(1px from 0px to 4px)", 0.25f}, + {"progress(10deg from 0deg to 10deg)", 1.0f}, + {"progress(progress(10% from 20% to 40%) * 1px from 0.5px to 1px)", 1.0f}, + }; + + for (const auto& test_case : test_cases) { + CSSTokenizer tokenizer(String(test_case.input.c_str())); + const auto tokens = tokenizer.TokenizeToEOF(); + const CSSParserTokenRange range(tokens); + const CSSParserContext* context = MakeGarbageCollected<CSSParserContext>( + kHTMLStandardMode, SecureContextMode::kInsecureContext); + const CSSMathExpressionNode* res = CSSMathExpressionNode::ParseMathFunction( + CSSValueID::kCalc, range, *context, true, kCSSAnchorQueryTypesNone); + EXPECT_EQ(res->DoubleValue(), test_case.output); + CSSToLengthConversionData resolver; + scoped_refptr<const CalculationExpressionNode> node = + res->ToCalculationExpression(resolver); + EXPECT_EQ(node->Evaluate(FLT_MAX, nullptr), test_case.output); + } +} + +TEST(CSSMathExpressionNode, TestProgressNotationComplex) { + const struct TestCase { + const std::string input; + const double output; + } test_cases[] = { + {"progress(abs(5%) from hypot(3%, 4%) to 10%)", 1.0f}, + }; + + for (const auto& test_case : test_cases) { + CSSTokenizer tokenizer(String(test_case.input.c_str())); + const auto tokens = tokenizer.TokenizeToEOF(); + const CSSParserTokenRange range(tokens); + const CSSParserContext* context = MakeGarbageCollected<CSSParserContext>( + kHTMLStandardMode, SecureContextMode::kInsecureContext); + const CSSMathExpressionNode* res = CSSMathExpressionNode::ParseMathFunction( + CSSValueID::kCalc, range, *context, true, kCSSAnchorQueryTypesNone); + EXPECT_TRUE(res); + EXPECT_TRUE(res->IsOperation()); + CSSToLengthConversionData resolver; + scoped_refptr<const CalculationExpressionNode> node = + res->ToCalculationExpression(resolver); + EXPECT_FLOAT_EQ(node->Evaluate(FLT_MAX, nullptr), test_case.output); + } +} + +TEST(CSSMathExpressionNode, TestInvalidProgressNotation) { + const std::string test_cases[] = { + "progress(1% from 0px to 4px)", + "progress(1px, 0px, 4px)", + "progress(10deg from 0 to 10deg)", + }; + + for (const auto& test_case : test_cases) { + CSSTokenizer tokenizer(String(test_case.c_str())); + const auto tokens = tokenizer.TokenizeToEOF(); + const CSSParserTokenRange range(tokens); + const CSSParserContext* context = MakeGarbageCollected<CSSParserContext>( + kHTMLStandardMode, SecureContextMode::kInsecureContext); + const CSSMathExpressionNode* res = CSSMathExpressionNode::ParseMathFunction( + CSSValueID::kCalc, range, *context, true, kCSSAnchorQueryTypesNone); + EXPECT_FALSE(res); + } +} + } // anonymous namespace } // namespace blink
diff --git a/third_party/blink/renderer/core/css/css_math_operator.cc b/third_party/blink/renderer/core/css/css_math_operator.cc index 72b2265..b341c96d 100644 --- a/third_party/blink/renderer/core/css/css_math_operator.cc +++ b/third_party/blink/renderer/core/css/css_math_operator.cc
@@ -61,6 +61,8 @@ return "abs"; case CSSMathOperator::kSign: return "sign"; + case CSSMathOperator::kProgress: + return "progress"; default: NOTREACHED(); return String();
diff --git a/third_party/blink/renderer/core/css/css_math_operator.h b/third_party/blink/renderer/core/css/css_math_operator.h index afee8f2..c5bb9dd7 100644 --- a/third_party/blink/renderer/core/css/css_math_operator.h +++ b/third_party/blink/renderer/core/css/css_math_operator.h
@@ -28,6 +28,7 @@ kHypot, kAbs, kSign, + kProgress, kInvalid };
diff --git a/third_party/blink/renderer/core/css/css_primitive_value.h b/third_party/blink/renderer/core/css/css_primitive_value.h index 187eedb..476a11e 100644 --- a/third_party/blink/renderer/core/css/css_primitive_value.h +++ b/third_party/blink/renderer/core/css/css_primitive_value.h
@@ -150,6 +150,7 @@ // Other units kFlex, kInteger, + kIdent, // This value is used to handle quirky margins in reflow roots (body, td, // and th) like WinIE. The basic idea is that a stylesheet can use the value
diff --git a/third_party/blink/renderer/core/css/css_properties.json5 b/third_party/blink/renderer/core/css/css_properties.json5 index 645a70fc..3f5bec6 100644 --- a/third_party/blink/renderer/core/css/css_properties.json5 +++ b/third_party/blink/renderer/core/css/css_properties.json5
@@ -3167,10 +3167,13 @@ inherited: true, field_group: "*", field_template: "primitive", - default_value: "true", - name_for_methods: "RespectImageOrientation", - type_name: "bool", + field_size: 1, + type_name: "RespectImageOrientationEnum", + default_value: "kRespectImageOrientation", converter: "ConvertImageOrientation", + include_paths: [ + "third_party/blink/renderer/platform/graphics/image_orientation.h" + ], }, { name: "dynamic-range-limit",
diff --git a/third_party/blink/renderer/core/css/css_property_equality.cc b/third_party/blink/renderer/core/css/css_property_equality.cc index bc5b073..052021e3 100644 --- a/third_party/blink/renderer/core/css/css_property_equality.cc +++ b/third_party/blink/renderer/core/css/css_property_equality.cc
@@ -460,7 +460,7 @@ case CSSPropertyID::kHyphens: return a.GetHyphens() == b.GetHyphens(); case CSSPropertyID::kImageOrientation: - return a.RespectImageOrientation() == b.RespectImageOrientation(); + return a.ImageOrientation() == b.ImageOrientation(); case CSSPropertyID::kImageRendering: return a.ImageRendering() == b.ImageRendering(); case CSSPropertyID::kInitialLetter:
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 1476c47..8c18c42 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
@@ -4187,23 +4187,18 @@ CSSParserTokenRange& range, const CSSParserContext& context, const CSSParserLocalContext&) const { - if (range.Peek().Id() == CSSValueID::kFromImage) { - return css_parsing_utils::ConsumeIdent(range); - } - if (range.Peek().Id() == CSSValueID::kNone) { - return css_parsing_utils::ConsumeIdent(range); - } - return nullptr; + return css_parsing_utils::ConsumeIdent<CSSValueID::kFromImage, + CSSValueID::kNone>(range); } const CSSValue* ImageOrientation::CSSValueFromComputedStyleInternal( const ComputedStyle& style, const LayoutObject*, bool allow_visited_style) const { - if (style.RespectImageOrientation() == kRespectImageOrientation) { - return CSSIdentifierValue::Create(CSSValueID::kFromImage); - } - return CSSIdentifierValue::Create(CSSValueID::kNone); + const CSSValueID value = style.ImageOrientation() == kRespectImageOrientation + ? CSSValueID::kFromImage + : CSSValueID::kNone; + return CSSIdentifierValue::Create(value); } const CSSValue* ImageRendering::CSSValueFromComputedStyleInternal(
diff --git a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc index 15eed06cb..7135af7d 100644 --- a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc +++ b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
@@ -2542,9 +2542,8 @@ RespectImageOrientationEnum StyleBuilderConverter::ConvertImageOrientation( StyleResolverState& state, const CSSValue& value) { - // The default is kFromImage, so branch on the only other valid value, kNone - auto* identifier_value = DynamicTo<CSSIdentifierValue>(value); - return identifier_value && identifier_value->GetValueID() == CSSValueID::kNone + // The default is kFromImage, so branch on the only other valid value, kNone. + return To<CSSIdentifierValue>(value).GetValueID() == CSSValueID::kNone ? kDoNotRespectImageOrientation : kRespectImageOrientation; }
diff --git a/third_party/blink/renderer/core/events/event_type_names.json5 b/third_party/blink/renderer/core/events/event_type_names.json5 index 9085f76..32ce9e1d 100644 --- a/third_party/blink/renderer/core/events/event_type_names.json5 +++ b/third_party/blink/renderer/core/events/event_type_names.json5
@@ -65,8 +65,9 @@ "canmakepayment", "canplay", "canplaythrough", - "capturehandlechange", "capturedmousechange", + "capturedzoomlevelchange", + "capturehandlechange", "change", "characterboundsupdate", "characteristicvaluechanged",
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc index bc47fa5..72b5bcb 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc
@@ -1928,7 +1928,7 @@ this, DocumentUpdateReason::kCanvas); const_cast<HTMLCanvasElement*>(this)->EnsureComputedStyle(); } - return LayoutObject::ShouldRespectImageOrientation(GetLayoutObject()); + return LayoutObject::GetImageOrientation(GetLayoutObject()); } // Temporary plumbing
diff --git a/third_party/blink/renderer/core/html/image_document.cc b/third_party/blink/renderer/core/html/image_document.cc index 397962e6..b2fa120 100644 --- a/third_party/blink/renderer/core/html/image_document.cc +++ b/third_party/blink/renderer/core/html/image_document.cc
@@ -225,8 +225,7 @@ DCHECK(image_element_); DCHECK(image_element_->CachedImage()); return image_element_->CachedImage()->IntrinsicSize( - LayoutObject::ShouldRespectImageOrientation( - image_element_->GetLayoutObject())); + LayoutObject::GetImageOrientation(image_element_->GetLayoutObject())); } void ImageDocument::CreateDocumentStructure(
diff --git a/third_party/blink/renderer/core/layout/layout_image.cc b/third_party/blink/renderer/core/layout/layout_image.cc index d55ab3f..f309f04 100644 --- a/third_party/blink/renderer/core/layout/layout_image.cc +++ b/third_party/blink/renderer/core/layout/layout_image.cc
@@ -83,11 +83,12 @@ NOT_DESTROYED(); LayoutReplaced::StyleDidChange(diff, old_style); - bool old_orientation = - old_style ? old_style->RespectImageOrientation() - : ComputedStyleInitialValues::InitialRespectImageOrientation(); - if (Style() && StyleRef().RespectImageOrientation() != old_orientation) + RespectImageOrientationEnum old_orientation = + old_style ? old_style->ImageOrientation() + : ComputedStyleInitialValues::InitialImageOrientation(); + if (StyleRef().ImageOrientation() != old_orientation) { IntrinsicSizeChanged(); + } } void LayoutImage::SetImageResource(LayoutImageResource* image_resource) {
diff --git a/third_party/blink/renderer/core/layout/layout_image_resource.cc b/third_party/blink/renderer/core/layout/layout_image_resource.cc index 017b9eb..c0ffb4a 100644 --- a/third_party/blink/renderer/core/layout/layout_image_resource.cc +++ b/third_party/blink/renderer/core/layout/layout_image_resource.cc
@@ -128,9 +128,8 @@ DCHECK(cached_image_); // Always respect the orientation of opaque origin images to avoid leaking // image data. Otherwise pull orientation from the layout object's style. - RespectImageOrientationEnum respect_orientation = - LayoutObject::ShouldRespectImageOrientation(layout_object_); - return cached_image_->ForceOrientationIfNecessary(respect_orientation); + return cached_image_->ForceOrientationIfNecessary( + layout_object_->StyleRef().ImageOrientation()); } IntrinsicSizingInfo LayoutImageResource::GetNaturalDimensions( @@ -162,7 +161,7 @@ if (!cached_image_) return gfx::SizeF(); gfx::SizeF size(cached_image_->IntrinsicSize( - LayoutObject::ShouldRespectImageOrientation(layout_object_))); + layout_object_->StyleRef().ImageOrientation())); if (multiplier != 1 && HasIntrinsicSize()) { size = ApplyClampedZoom(size, multiplier); }
diff --git a/third_party/blink/renderer/core/layout/layout_image_resource_style_image.cc b/third_party/blink/renderer/core/layout/layout_image_resource_style_image.cc index 318d38217..d4fd38d 100644 --- a/third_party/blink/renderer/core/layout/layout_image_resource_style_image.cc +++ b/third_party/blink/renderer/core/layout/layout_image_resource_style_image.cc
@@ -83,18 +83,15 @@ gfx::SizeF LayoutImageResourceStyleImage::ConcreteObjectSize( float multiplier, const gfx::SizeF& default_object_size) const { - return style_image_->ImageSize( - multiplier, default_object_size, - LayoutObject::ShouldRespectImageOrientation(layout_object_)); + return style_image_->ImageSize(multiplier, default_object_size, + ImageOrientation()); } IntrinsicSizingInfo LayoutImageResourceStyleImage::GetNaturalDimensions( float multiplier) const { // Always respect the orientation of opaque origin images to avoid leaking // image data. Otherwise pull orientation from the layout object's style. - RespectImageOrientationEnum respect_orientation = - LayoutObject::ShouldRespectImageOrientation(layout_object_); - return style_image_->GetNaturalSizingInfo(multiplier, respect_orientation); + return style_image_->GetNaturalSizingInfo(multiplier, ImageOrientation()); } RespectImageOrientationEnum LayoutImageResourceStyleImage::ImageOrientation() @@ -102,7 +99,7 @@ // Always respect the orientation of opaque origin images to avoid leaking // image data. Otherwise pull orientation from the layout object's style. RespectImageOrientationEnum respect_orientation = - LayoutObject::ShouldRespectImageOrientation(layout_object_); + layout_object_->StyleRef().ImageOrientation(); return style_image_->ForceOrientationIfNecessary(respect_orientation); }
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc index ebe62499..5c6438b 100644 --- a/third_party/blink/renderer/core/layout/layout_object.cc +++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -3699,14 +3699,10 @@ return false; } -RespectImageOrientationEnum LayoutObject::ShouldRespectImageOrientation( +RespectImageOrientationEnum LayoutObject::GetImageOrientation( const LayoutObject* layout_object) { - if (layout_object && layout_object->Style() && - layout_object->StyleRef().RespectImageOrientation() != - kRespectImageOrientation) - return kDoNotRespectImageOrientation; - - return kRespectImageOrientation; + return layout_object ? layout_object->StyleRef().ImageOrientation() + : ComputedStyleInitialValues::InitialImageOrientation(); } inline void LayoutObject::ClearLayoutRootIfNeeded() const {
diff --git a/third_party/blink/renderer/core/layout/layout_object.h b/third_party/blink/renderer/core/layout/layout_object.h index fc6154e6..e8e57ff 100644 --- a/third_party/blink/renderer/core/layout/layout_object.h +++ b/third_party/blink/renderer/core/layout/layout_object.h
@@ -2898,8 +2898,13 @@ NOT_DESTROYED(); } - static RespectImageOrientationEnum ShouldRespectImageOrientation( - const LayoutObject*); + // Get the 'image-orientation' value for a (potentially null) LayoutObject. + // + // Returns the initial value ('from-image') if passed a nullptr, else the + // value of the 'image-orientation' property. (If it is known at the callsite + // that the LayoutObject* is non-null then just access its ComputedStyle + // directly.) + static RespectImageOrientationEnum GetImageOrientation(const LayoutObject*); bool IsRelayoutBoundary() const;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc b/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc index 94f588e..e7c3a95 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc
@@ -276,12 +276,12 @@ LogicalOofInsets ComputeOutOfFlowInsets( const ComputedStyle& style, const LogicalSize& available_logical_size, - const WritingDirectionMode& self_writing_direction, NGAnchorEvaluatorImpl* anchor_evaluator) { // Compute in physical, because anchors may be in different `writing-mode` or // `direction`. + const WritingDirectionMode writing_direction = style.GetWritingDirection(); const PhysicalSize available_size = ToPhysicalSize( - available_logical_size, self_writing_direction.GetWritingMode()); + available_logical_size, writing_direction.GetWritingMode()); absl::optional<LayoutUnit> left; if (const Length& left_length = style.UsedLeft(); !left_length.IsAuto()) { anchor_evaluator->SetAxis(/* is_y_axis */ false, @@ -318,8 +318,8 @@ } // Convert the physical insets to logical. - PhysicalToLogical<absl::optional<LayoutUnit>&> insets( - self_writing_direction, top, right, bottom, left); + PhysicalToLogical<absl::optional<LayoutUnit>&> insets(writing_direction, top, + right, bottom, left); return {insets.InlineStart(), insets.InlineEnd(), insets.BlockStart(), insets.BlockEnd()}; }
diff --git a/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.h b/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.h index 707ae25..5fc3180 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.h +++ b/third_party/blink/renderer/core/layout/ng/ng_absolute_utils.h
@@ -50,7 +50,6 @@ CORE_EXPORT LogicalOofInsets ComputeOutOfFlowInsets(const ComputedStyle& style, const LogicalSize& available_size, - const WritingDirectionMode& self_writing_direction, NGAnchorEvaluatorImpl* anchor_evaluator); struct CORE_EXPORT InsetModifiedContainingBlock {
diff --git a/third_party/blink/renderer/core/layout/ng/ng_absolute_utils_test.cc b/third_party/blink/renderer/core/layout/ng/ng_absolute_utils_test.cc index 1d40e86..d80c913 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_absolute_utils_test.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_absolute_utils_test.cc
@@ -115,15 +115,12 @@ {WritingMode::kHorizontalTb, TextDirection::kLtr}, /* offset_to_padding_box */ PhysicalOffset()); - WritingDirectionMode self_writing_direction = - node.Style().GetWritingDirection(); - const LogicalOofInsets insets = - ComputeOutOfFlowInsets(node.Style(), space.AvailableSize(), - self_writing_direction, &anchor_evaluator); + const LogicalOofInsets insets = ComputeOutOfFlowInsets( + node.Style(), space.AvailableSize(), &anchor_evaluator); const InsetModifiedContainingBlock imcb = ComputeInsetModifiedContainingBlock( node, space.AvailableSize(), insets, static_position, - container_writing_direction, self_writing_direction); + container_writing_direction, node.Style().GetWritingDirection()); ComputeOofInlineDimensions(node, node.Style(), space, imcb, border_padding, absl::nullopt, container_writing_direction, /* anchor_evaluator */ nullptr, dimensions); @@ -154,15 +151,12 @@ {WritingMode::kHorizontalTb, TextDirection::kLtr}, /* offset_to_padding_box */ PhysicalOffset()); - WritingDirectionMode self_writing_direction = - node.Style().GetWritingDirection(); - const LogicalOofInsets insets = - ComputeOutOfFlowInsets(node.Style(), space.AvailableSize(), - self_writing_direction, &anchor_evaluator); + const LogicalOofInsets insets = ComputeOutOfFlowInsets( + node.Style(), space.AvailableSize(), &anchor_evaluator); const InsetModifiedContainingBlock imcb = ComputeInsetModifiedContainingBlock( node, space.AvailableSize(), insets, static_position, - container_writing_direction, self_writing_direction); + container_writing_direction, node.Style().GetWritingDirection()); ComputeOofBlockDimensions(node, node.Style(), space, imcb, border_padding, absl::nullopt, container_writing_direction, /* anchor_evaluator */ nullptr, dimensions);
diff --git a/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc b/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc index ee82056..36c1023 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc
@@ -1855,7 +1855,7 @@ const LogicalOofInsets insets = ComputeOutOfFlowInsets( candidate_style, node_info.constraint_space.AvailableSize(), - candidate_writing_direction, anchor_evaluator); + anchor_evaluator); { auto& document = node_info.node.GetDocument();
diff --git a/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc b/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc index 31bd825..17d0b095 100644 --- a/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc +++ b/third_party/blink/renderer/core/layout/shapes/shape_outside_info.cc
@@ -173,7 +173,7 @@ RespectImageOrientationEnum respect_orientation = style_image->ForceOrientationIfNecessary( - LayoutObject::ShouldRespectImageOrientation(layout_box_)); + layout_box_->StyleRef().ImageOrientation()); const DeprecatedLayoutSize& image_size = RoundedLayoutSize(style_image->ImageSize(
diff --git a/third_party/blink/renderer/core/loader/resource/image_resource_content.h b/third_party/blink/renderer/core/loader/resource/image_resource_content.h index 699cae5a..8ad7414f 100644 --- a/third_party/blink/renderer/core/loader/resource/image_resource_content.h +++ b/third_party/blink/renderer/core/loader/resource/image_resource_content.h
@@ -36,7 +36,7 @@ class ResourceFetcher; class ResourceResponse; class UseCounter; -enum RespectImageOrientationEnum; +enum RespectImageOrientationEnum : uint8_t; struct ResourcePriority; // ImageResourceContent is a container that holds fetch result of
diff --git a/third_party/blink/renderer/core/paint/background_image_geometry.cc b/third_party/blink/renderer/core/paint/background_image_geometry.cc index d0eb4da..cfadd21 100644 --- a/third_party/blink/renderer/core/paint/background_image_geometry.cc +++ b/third_party/blink/renderer/core/paint/background_image_geometry.cc
@@ -375,6 +375,73 @@ DCHECK(positioning_box); } +PhysicalBoxStrut BackgroundImageGeometry::VisualOverflowOutsets() const { + PhysicalRect border_box; + if (positioning_box_->IsBox()) { + border_box = To<LayoutBox>(positioning_box_)->PhysicalBorderBoxRect(); + } else { + border_box = To<LayoutInline>(positioning_box_)->PhysicalLinesBoundingBox(); + } + PhysicalRect visual_overflow = + positioning_box_->Layer() + ->LocalBoundingBoxIncludingSelfPaintingDescendants(); + return PhysicalBoxStrut(visual_overflow.Y() - border_box.Y(), + border_box.Right() - visual_overflow.Right(), + border_box.Bottom() - visual_overflow.Bottom(), + visual_overflow.X() - border_box.X()); +} + +PhysicalBoxStrut BackgroundImageGeometry::InnerBorderOutsets( + const PhysicalRect& dest_rect, + const PhysicalRect& positioning_area) const { + gfx::RectF inner_border_rect = + RoundedBorderGeometry::PixelSnappedRoundedInnerBorder( + positioning_box_->StyleRef(), positioning_area) + .Rect(); + PhysicalBoxStrut outset; + // TODO(rendering-core) The LayoutUnit(float) constructor always rounds + // down. We should FromFloatFloor or FromFloatCeil to move toward the border. + outset.left = LayoutUnit(inner_border_rect.x()) - dest_rect.X(); + outset.top = LayoutUnit(inner_border_rect.y()) - dest_rect.Y(); + outset.right = dest_rect.Right() - LayoutUnit(inner_border_rect.right()); + outset.bottom = dest_rect.Bottom() - LayoutUnit(inner_border_rect.bottom()); + return outset; +} + +SnappedAndUnsnappedBorderOutsets BackgroundImageGeometry::ObscuredBorderOutsets( + const PhysicalRect& dest_rect, + const PhysicalRect& positioning_area) const { + const ComputedStyle& style = positioning_box_->StyleRef(); + gfx::RectF inner_border_rect = + RoundedBorderGeometry::PixelSnappedRoundedInnerBorder(style, + positioning_area) + .Rect(); + + BorderEdge edges[4]; + style.GetBorderEdgeInfo(edges); + const PhysicalBoxStrut box_outsets = positioning_box_->BorderOutsets(); + SnappedAndUnsnappedBorderOutsets adjust; + if (edges[static_cast<unsigned>(BoxSide::kTop)].ObscuresBackground()) { + adjust.snapped.top = LayoutUnit(inner_border_rect.y()) - dest_rect.Y(); + adjust.unsnapped.top = box_outsets.top; + } + if (edges[static_cast<unsigned>(BoxSide::kRight)].ObscuresBackground()) { + adjust.snapped.right = + dest_rect.Right() - LayoutUnit(inner_border_rect.right()); + adjust.unsnapped.right = box_outsets.right; + } + if (edges[static_cast<unsigned>(BoxSide::kBottom)].ObscuresBackground()) { + adjust.snapped.bottom = + dest_rect.Bottom() - LayoutUnit(inner_border_rect.bottom()); + adjust.unsnapped.bottom = box_outsets.bottom; + } + if (edges[static_cast<unsigned>(BoxSide::kLeft)].ObscuresBackground()) { + adjust.snapped.left = LayoutUnit(inner_border_rect.x()) - dest_rect.X(); + adjust.unsnapped.left = box_outsets.left; + } + return adjust; +} + bool BackgroundImageGeometry::HasBackgroundFixedToViewport( const LayoutBoxModelObject& object) { if (!object.IsBackgroundAttachmentFixedObject()) { @@ -406,25 +473,10 @@ PhysicalBoxStrut& unsnapped_dest_adjust, PhysicalBoxStrut& snapped_dest_adjust) const { switch (fill_layer.Clip()) { - case EFillBox::kNoClip: { - PhysicalRect border_box; - if (positioning_box_->IsBox()) { - border_box = To<LayoutBox>(positioning_box_)->PhysicalBorderBoxRect(); - } else { - border_box = - To<LayoutInline>(positioning_box_)->PhysicalLinesBoundingBox(); - } - PhysicalRect visual_overflow = - positioning_box_->Layer() - ->LocalBoundingBoxIncludingSelfPaintingDescendants(); - unsnapped_dest_adjust = - PhysicalBoxStrut(visual_overflow.Y() - border_box.Y(), - border_box.Right() - visual_overflow.Right(), - border_box.Bottom() - visual_overflow.Bottom(), - visual_overflow.X() - border_box.X()); + case EFillBox::kNoClip: + unsnapped_dest_adjust = VisualOverflowOutsets(); snapped_dest_adjust = unsnapped_dest_adjust; return; - } case EFillBox::kFillBox: // Spec: For elements with associated CSS layout box, the used values for // fill-box compute to content-box. @@ -449,21 +501,8 @@ } else { // Force the snapped dest rect to match the inner border to // avoid gaps between the background and border. - // TODO(rendering-core) The LayoutUnit(float) constructor always - // rounds down. We should FromFloatFloor or FromFloatCeil to - // move toward the border. - gfx::RectF inner_border_rect = - RoundedBorderGeometry::PixelSnappedRoundedInnerBorder( - positioning_box_->StyleRef(), unsnapped_positioning_area) - .Rect(); - snapped_dest_adjust.left = - LayoutUnit(inner_border_rect.x()) - unsnapped_dest_rect_.X(); - snapped_dest_adjust.top = - LayoutUnit(inner_border_rect.y()) - unsnapped_dest_rect_.Y(); - snapped_dest_adjust.right = unsnapped_dest_rect_.Right() - - LayoutUnit(inner_border_rect.right()); - snapped_dest_adjust.bottom = unsnapped_dest_rect_.Bottom() - - LayoutUnit(inner_border_rect.bottom()); + snapped_dest_adjust = InnerBorderOutsets(unsnapped_dest_rect_, + unsnapped_positioning_area); } return; case EFillBox::kStrokeBox: @@ -489,33 +528,10 @@ // the size and position of the borders, sometimes adjusting the inner // border by more than a pixel when done (particularly under magnifying // zoom). - BorderEdge edges[4]; - positioning_box_->StyleRef().GetBorderEdgeInfo(edges); - gfx::RectF inner_border_rect = - RoundedBorderGeometry::PixelSnappedRoundedInnerBorder( - positioning_box_->StyleRef(), unsnapped_positioning_area) - .Rect(); - PhysicalBoxStrut box_outsets = positioning_box_->BorderOutsets(); - if (edges[static_cast<unsigned>(BoxSide::kTop)].ObscuresBackground()) { - snapped_dest_adjust.top = - LayoutUnit(inner_border_rect.y()) - unsnapped_dest_rect_.Y(); - unsnapped_dest_adjust.top = box_outsets.top; - } - if (edges[static_cast<unsigned>(BoxSide::kRight)].ObscuresBackground()) { - snapped_dest_adjust.right = unsnapped_dest_rect_.Right() - - LayoutUnit(inner_border_rect.right()); - unsnapped_dest_adjust.right = box_outsets.right; - } - if (edges[static_cast<unsigned>(BoxSide::kBottom)].ObscuresBackground()) { - snapped_dest_adjust.bottom = unsnapped_dest_rect_.Bottom() - - LayoutUnit(inner_border_rect.bottom()); - unsnapped_dest_adjust.bottom = box_outsets.bottom; - } - if (edges[static_cast<unsigned>(BoxSide::kLeft)].ObscuresBackground()) { - snapped_dest_adjust.left = - LayoutUnit(inner_border_rect.x()) - unsnapped_dest_rect_.X(); - unsnapped_dest_adjust.left = box_outsets.left; - } + SnappedAndUnsnappedBorderOutsets outsets = ObscuredBorderOutsets( + unsnapped_dest_rect_, unsnapped_positioning_area); + snapped_dest_adjust = outsets.snapped; + unsnapped_dest_adjust = outsets.unsnapped; } return; case EFillBox::kText: @@ -557,18 +573,8 @@ // the size and position of the borders, sometimes adjusting the inner // border by more than a pixel when done (particularly under magnifying // zoom). - gfx::RectF inner_border_rect = - RoundedBorderGeometry::PixelSnappedRoundedInnerBorder( - positioning_box_->StyleRef(), unsnapped_positioning_area) - .Rect(); - snapped_box_outset.left = - LayoutUnit(inner_border_rect.x()) - unsnapped_positioning_area.X(); - snapped_box_outset.top = - LayoutUnit(inner_border_rect.y()) - unsnapped_positioning_area.Y(); - snapped_box_outset.right = unsnapped_positioning_area.Right() - - LayoutUnit(inner_border_rect.right()); - snapped_box_outset.bottom = unsnapped_positioning_area.Bottom() - - LayoutUnit(inner_border_rect.bottom()); + snapped_box_outset = InnerBorderOutsets(unsnapped_positioning_area, + unsnapped_positioning_area); } return; case EFillBox::kStrokeBox: @@ -694,9 +700,9 @@ // generated content) and unsnapped for content that has intrinsic // dimensions. Once we choose here we stop tracking whether the tile size is // snapped or unsnapped. - IntrinsicSizingInfo sizing_info = image->GetNaturalSizingInfo( - positioning_box_->StyleRef().EffectiveZoom(), - LayoutObject::ShouldRespectImageOrientation(box_)); + IntrinsicSizingInfo sizing_info = + image->GetNaturalSizingInfo(positioning_box_->StyleRef().EffectiveZoom(), + box_->StyleRef().ImageOrientation()); PhysicalSize image_aspect_ratio = PhysicalSize::FromSizeFFloor(sizing_info.aspect_ratio); PhysicalSize positioning_area_size = !image->HasIntrinsicSize() @@ -752,11 +758,10 @@ tile_size_.height = positioning_area_size.height; } } else if (layer_width.IsAuto() && layer_height.IsAuto()) { - PhysicalSize concrete_image_size = - PhysicalSize::FromSizeFFloor(image->ImageSize( - positioning_box_->StyleRef().EffectiveZoom(), - gfx::SizeF(positioning_area_size), - LayoutObject::ShouldRespectImageOrientation(box_))); + PhysicalSize concrete_image_size = PhysicalSize::FromSizeFFloor( + image->ImageSize(positioning_box_->StyleRef().EffectiveZoom(), + gfx::SizeF(positioning_area_size), + box_->StyleRef().ImageOrientation())); tile_size_ = concrete_image_size; }
diff --git a/third_party/blink/renderer/core/paint/background_image_geometry.h b/third_party/blink/renderer/core/paint/background_image_geometry.h index 20be2ed7..fe236edd 100644 --- a/third_party/blink/renderer/core/paint/background_image_geometry.h +++ b/third_party/blink/renderer/core/paint/background_image_geometry.h
@@ -23,6 +23,11 @@ class NGPhysicalBoxFragment; struct PaintInfo; +struct SnappedAndUnsnappedBorderOutsets { + PhysicalBoxStrut snapped; + PhysicalBoxStrut unsnapped; +}; + class BackgroundImageGeometry { STACK_ALLOCATED(); @@ -165,6 +170,14 @@ const PhysicalSize&, const PhysicalSize&); + PhysicalBoxStrut VisualOverflowOutsets() const; + PhysicalBoxStrut InnerBorderOutsets( + const PhysicalRect& dest_rect, + const PhysicalRect& positioning_area) const; + SnappedAndUnsnappedBorderOutsets ObscuredBorderOutsets( + const PhysicalRect& dest_rect, + const PhysicalRect& positioning_area) const; + // The offset of the background image within the background positioning area. PhysicalOffset OffsetInBackground(const FillLayer&) const;
diff --git a/third_party/blink/renderer/core/paint/box_model_object_painter.cc b/third_party/blink/renderer/core/paint/box_model_object_painter.cc index 26d56b9..4e7dc68 100644 --- a/third_party/blink/renderer/core/paint/box_model_object_painter.cc +++ b/third_party/blink/renderer/core/paint/box_model_object_painter.cc
@@ -77,18 +77,16 @@ const FillLayer& bg_layer, BackgroundBleedAvoidance bleed_avoidance, bool is_painting_background_in_contents_space) const { - PhysicalBoxSides sides_to_include; - RespectImageOrientationEnum respect_orientation = - LayoutObject::ShouldRespectImageOrientation(&box_model_); + const ComputedStyle& style = box_model_.StyleRef(); + RespectImageOrientationEnum respect_orientation = style.ImageOrientation(); if (auto* style_image = bg_layer.GetImage()) { respect_orientation = style_image->ForceOrientationIfNecessary(respect_orientation); } return BoxPainterBase::FillLayerInfo( - box_model_.GetDocument(), box_model_.StyleRef(), - box_model_.IsScrollContainer(), color, bg_layer, bleed_avoidance, - respect_orientation, sides_to_include, box_model_.IsLayoutInline(), - is_painting_background_in_contents_space); + box_model_.GetDocument(), style, box_model_.IsScrollContainer(), color, + bg_layer, bleed_avoidance, respect_orientation, PhysicalBoxSides(), + box_model_.IsLayoutInline(), is_painting_background_in_contents_space); } } // namespace blink
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc index 1c04186..391c2a4 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
@@ -1875,14 +1875,14 @@ BackgroundBleedAvoidance bleed_avoidance, bool is_painting_background_in_contents_space) const { const NGPhysicalBoxFragment& fragment = PhysicalFragment(); - RespectImageOrientationEnum respect_orientation = - LayoutObject::ShouldRespectImageOrientation(fragment.GetLayoutObject()); + const ComputedStyle& style = fragment.Style(); + RespectImageOrientationEnum respect_orientation = style.ImageOrientation(); if (auto* style_image = bg_layer.GetImage()) { respect_orientation = style_image->ForceOrientationIfNecessary(respect_orientation); } return BoxPainterBase::FillLayerInfo( - fragment.GetLayoutObject()->GetDocument(), fragment.Style(), + fragment.GetLayoutObject()->GetDocument(), style, fragment.IsScrollContainer(), color, bg_layer, bleed_avoidance, respect_orientation, box_fragment_.SidesToInclude(), fragment.GetLayoutObject()->IsLayoutInline(),
diff --git a/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc b/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc index 7ac15e3..abf39101 100644 --- a/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc +++ b/third_party/blink/renderer/core/paint/nine_piece_image_painter.cc
@@ -94,8 +94,7 @@ const gfx::SizeF& unzoomed_image_size, PhysicalBoxSides sides_to_include) { const RespectImageOrientationEnum respect_orientation = - style.RespectImageOrientation() ? kRespectImageOrientation - : kDoNotRespectImageOrientation; + style.ImageOrientation(); // |image_size| is in the image's native resolution and |slice_scale| defines // the effective size of a CSS pixel in the image. const gfx::SizeF image_size = image.SizeAsFloat(respect_orientation); @@ -215,8 +214,7 @@ // image with either "native" size (raster images) or size scaled by effective // zoom. const RespectImageOrientationEnum respect_orientation = - style.RespectImageOrientation() ? kRespectImageOrientation - : kDoNotRespectImageOrientation; + style.ImageOrientation(); const gfx::SizeF default_object_size(border_image_rect.size); gfx::SizeF image_size = style_image->ImageSize( style.EffectiveZoom(), default_object_size, respect_orientation);
diff --git a/third_party/blink/renderer/core/paint/svg_mask_painter.cc b/third_party/blink/renderer/core/paint/svg_mask_painter.cc index 1d0a4232..b3cf1d9a 100644 --- a/third_party/blink/renderer/core/paint/svg_mask_painter.cc +++ b/third_party/blink/renderer/core/paint/svg_mask_painter.cc
@@ -194,9 +194,9 @@ const FillLayer& layer, const gfx::RectF& positioning_area) const { const StyleImage* image = layer.GetImage(); - const IntrinsicSizingInfo sizing_info = image->GetNaturalSizingInfo( - object_.StyleRef().EffectiveZoom(), - LayoutObject::ShouldRespectImageOrientation(&object_)); + const IntrinsicSizingInfo sizing_info = + image->GetNaturalSizingInfo(object_.StyleRef().EffectiveZoom(), + object_.StyleRef().ImageOrientation()); switch (layer.SizeType()) { case EFillSizeType::kSizeLength: { @@ -229,9 +229,9 @@ tile_size.set_height(sizing_info.size.height()); } } else if (layer_width.IsAuto() && layer_height.IsAuto()) { - tile_size = image->ImageSize( - object_.StyleRef().EffectiveZoom(), positioning_area.size(), - LayoutObject::ShouldRespectImageOrientation(&object_)); + tile_size = image->ImageSize(object_.StyleRef().EffectiveZoom(), + positioning_area.size(), + object_.StyleRef().ImageOrientation()); } return tile_size; } @@ -539,7 +539,7 @@ const FillInfo fill_info = { style.GetInterpolationQuality(), static_cast<cc::PaintFlags::DynamicRangeLimit>(style.DynamicRangeLimit()), - LayoutObject::ShouldRespectImageOrientation(&object), + style.ImageOrientation(), object, }; SVGMaskGeometry geometry(object);
diff --git a/third_party/blink/renderer/core/paint/timing/image_element_timing.cc b/third_party/blink/renderer/core/paint/timing/image_element_timing.cc index 21f7a0ac..b52883f8 100644 --- a/third_party/blink/renderer/core/paint/timing/image_element_timing.cc +++ b/third_party/blink/renderer/core/paint/timing/image_element_timing.cc
@@ -140,7 +140,7 @@ return; RespectImageOrientationEnum respect_orientation = - LayoutObject::ShouldRespectImageOrientation(&layout_object); + layout_object.StyleRef().ImageOrientation(); gfx::RectF intersection_rect = ElementTimingUtils::ComputeIntersectionRect( frame, image_border, current_paint_chunk_properties);
diff --git a/third_party/blink/renderer/modules/BUILD.gn b/third_party/blink/renderer/modules/BUILD.gn index f7b4ca86..90dede8 100644 --- a/third_party/blink/renderer/modules/BUILD.gn +++ b/third_party/blink/renderer/modules/BUILD.gn
@@ -479,6 +479,7 @@ "mediarecorder/video_track_recorder_unittest.cc", "mediasession/media_session_test.cc", "mediastream/browser_capture_media_stream_track_test.cc", + "mediastream/capture_controller_test.cc", "mediastream/local_media_stream_audio_source_test.cc", "mediastream/low_latency_video_renderer_algorithm_unittest.cc", "mediastream/media_constraints_test.cc",
diff --git a/third_party/blink/renderer/modules/mediastream/capture_controller.cc b/third_party/blink/renderer/modules/mediastream/capture_controller.cc index 0c2b4f2..6f1eac24 100644 --- a/third_party/blink/renderer/modules/mediastream/capture_controller.cc +++ b/third_party/blink/renderer/modules/mediastream/capture_controller.cc
@@ -4,6 +4,7 @@ #include "third_party/blink/renderer/modules/mediastream/capture_controller.h" +#include "third_party/blink/public/common/page/page_zoom.h" #include "third_party/blink/renderer/modules/mediastream/media_stream_video_track.h" #include "third_party/blink/renderer/modules/mediastream/user_media_client.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" @@ -89,6 +90,38 @@ FinalizeFocusDecision(); } +ScriptPromise CaptureController::sendWheel(CapturedWheelAction* action) { + // TODO(crbug.com/1466247): Implement. + NOTIMPLEMENTED(); + return ScriptPromise(); +} + +int CaptureController::getMinZoomLevel() { + // We expect `100 * kMinimumPageZoomFactor` to be an integer. But if it's not, + // over-reporting the minimum is preferable, as it would mean the application + // still asks to set zoom levels which aren't below the minimum. + return static_cast<int>(std::ceil(100 * kMinimumPageZoomFactor)); +} + +int CaptureController::getMaxZoomLevel() { + // We expect `100 * kMaximumPageZoomFactor` to be an integer. But if it's not, + // under-reporting the maximum is preferable, as it would mean the application + // still asks to set zoom levels which aren't above the maximum. + return static_cast<int>(std::floor(100 * kMaximumPageZoomFactor)); +} + +ScriptPromise CaptureController::getZoomLevel() { + // TODO(crbug.com/1466247): Implement. + NOTIMPLEMENTED(); + return ScriptPromise(); +} + +ScriptPromise CaptureController::setZoomLevel(int zoom_level) { + // TODO(crbug.com/1466247): Implement. + NOTIMPLEMENTED(); + return ScriptPromise(); +} + void CaptureController::SetVideoTrack(MediaStreamTrack* video_track, std::string descriptor_id) { DCHECK(IsMainThread());
diff --git a/third_party/blink/renderer/modules/mediastream/capture_controller.h b/third_party/blink/renderer/modules/mediastream/capture_controller.h index 39ee9c9..91d056eb 100644 --- a/third_party/blink/renderer/modules/mediastream/capture_controller.h +++ b/third_party/blink/renderer/modules/mediastream/capture_controller.h
@@ -7,6 +7,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_capture_start_focus_behavior.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_captured_wheel_action.h" #include "third_party/blink/renderer/core/dom/events/event_target.h" #include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h" #include "third_party/blink/renderer/modules/mediastream/media_stream_track.h" @@ -30,6 +31,14 @@ // https://w3c.github.io/mediacapture-screen-share/#dom-capturecontroller-setfocusbehavior void setFocusBehavior(V8CaptureStartFocusBehavior, ExceptionState&); + // IDL interface, APIs related to Captured Surface Control + // TODO(crbug.com/1466247): Link to spec. + ScriptPromise sendWheel(CapturedWheelAction* action); + int getMinZoomLevel(); + int getMaxZoomLevel(); + ScriptPromise getZoomLevel(); + ScriptPromise setZoomLevel(int zoom_level); + void SetIsBound(bool value) { is_bound_ = value; } bool IsBound() const { return is_bound_; } @@ -44,6 +53,10 @@ // https://screen-share.github.io/mouse-events/#capture-controller-extensions DEFINE_ATTRIBUTE_EVENT_LISTENER(capturedmousechange, kCapturedmousechange) + // TODO(crbug.com/1466247): Link to spec. + DEFINE_ATTRIBUTE_EVENT_LISTENER(capturedzoomlevelchange, + kCapturedzoomlevelchange) + // Close the window of opportunity to make the focus decision. // Further calls to setFocusBehavior() will raise an exception. // https://w3c.github.io/mediacapture-screen-share/#dfn-finalize-focus-decision-algorithm
diff --git a/third_party/blink/renderer/modules/mediastream/capture_controller.idl b/third_party/blink/renderer/modules/mediastream/capture_controller.idl index 73e8f6b..10b50ec 100644 --- a/third_party/blink/renderer/modules/mediastream/capture_controller.idl +++ b/third_party/blink/renderer/modules/mediastream/capture_controller.idl
@@ -4,6 +4,10 @@ // https://w3c.github.io/mediacapture-screen-share/#dom-capturecontroller +// For APIs marked as RuntimeEnabled=CapturedSurfaceControl, see the spec at: +// https://screen-share.github.io/captured-surface-control/ +// TODO(crbug.com/1466247): Measure these APIs. + enum CaptureStartFocusBehavior { "focus-capturing-application", "focus-captured-surface", @@ -26,4 +30,17 @@ // https://screen-share.github.io/mouse-events/#capture-controller-extensions [RuntimeEnabled=CapturedMouseEvents] attribute EventHandler oncapturedmousechange; + + [RuntimeEnabled=CapturedSurfaceControl] + Promise<undefined> sendWheel(CapturedWheelAction action); + + [RuntimeEnabled=CapturedSurfaceControl] long getMinZoomLevel(); + [RuntimeEnabled=CapturedSurfaceControl] long getMaxZoomLevel(); + + [RuntimeEnabled=CapturedSurfaceControl] Promise<long> getZoomLevel(); + [RuntimeEnabled=CapturedSurfaceControl] + Promise<undefined> setZoomLevel(long zoomLevel); + + [RuntimeEnabled=CapturedSurfaceControl] + attribute EventHandler oncapturedzoomlevelchange; };
diff --git a/third_party/blink/renderer/modules/mediastream/capture_controller_test.cc b/third_party/blink/renderer/modules/mediastream/capture_controller_test.cc new file mode 100644 index 0000000..2bf97f85 --- /dev/null +++ b/third_party/blink/renderer/modules/mediastream/capture_controller_test.cc
@@ -0,0 +1,24 @@ +// Copyright 2023 The Chromium Authors +// 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/mediastream/capture_controller.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h" + +namespace blink { + +class CaptureControllerTest : public testing::Test { + public: + ~CaptureControllerTest() override = default; +}; + +TEST_F(CaptureControllerTest, ReasonableMinimumAndMaximum) { + V8TestingScope v8_scope; + CaptureController* controller = + MakeGarbageCollected<CaptureController>(v8_scope.GetExecutionContext()); + EXPECT_LT(controller->getMinZoomLevel(), controller->getMaxZoomLevel()); +} + +} // namespace blink
diff --git a/third_party/blink/renderer/modules/mediastream/captured_wheel_action.idl b/third_party/blink/renderer/modules/mediastream/captured_wheel_action.idl new file mode 100644 index 0000000..8b5f0d5 --- /dev/null +++ b/third_party/blink/renderer/modules/mediastream/captured_wheel_action.idl
@@ -0,0 +1,12 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// https://screen-share.github.io/captured-surface-control/ + +dictionary CapturedWheelAction { + long x = 0; + long y = 0; + long wheelDeltaX = 0; + long wheelDeltaY = 0; +};
diff --git a/third_party/blink/renderer/platform/blink_platform_unittests_bundle_data.filelist b/third_party/blink/renderer/platform/blink_platform_unittests_bundle_data.filelist index 7ab3343..70adf54 100644 --- a/third_party/blink/renderer/platform/blink_platform_unittests_bundle_data.filelist +++ b/third_party/blink/renderer/platform/blink_platform_unittests_bundle_data.filelist
@@ -210,6 +210,7 @@ ../../web_tests/images/resources/avif/silver-full-range-srgb-420-8bpc.avif ../../web_tests/images/resources/avif/silver.png ../../web_tests/images/resources/avif/small-with-gainmap-adobe.avif +../../web_tests/images/resources/avif/small-with-gainmap-iso-hdrbase-forward.avif ../../web_tests/images/resources/avif/small-with-gainmap-iso.avif ../../web_tests/images/resources/avif/star-animated-10bpc-with-alpha.avif ../../web_tests/images/resources/avif/star-animated-10bpc.avif
diff --git a/third_party/blink/renderer/platform/geometry/calculation_expression_node.cc b/third_party/blink/renderer/platform/geometry/calculation_expression_node.cc index 932e8cf..f51d40e 100644 --- a/third_party/blink/renderer/platform/geometry/calculation_expression_node.cc +++ b/third_party/blink/renderer/platform/geometry/calculation_expression_node.cc
@@ -255,6 +255,30 @@ } } } + case CalculationOperator::kProgress: { + DCHECK_EQ(children.size(), 3u); + Vector<float, 3> operand_pixels; + bool can_simplify = true; + for (scoped_refptr<const CalculationExpressionNode>& child : children) { + const auto* pixels_and_percent = + DynamicTo<CalculationExpressionPixelsAndPercentNode>(*child); + if (!pixels_and_percent || pixels_and_percent->Percent()) { + can_simplify = false; + break; + } + operand_pixels.push_back(pixels_and_percent->Pixels()); + } + if (can_simplify) { + float progress_px = operand_pixels[0]; + float from_px = operand_pixels[1]; + float to_px = operand_pixels[2]; + float progress = progress_px / (to_px - from_px); + return base::MakeRefCounted<CalculationExpressionPixelsAndPercentNode>( + PixelsAndPercent(progress)); + } + return base::MakeRefCounted<CalculationExpressionOperationNode>( + std::move(children), op); + } case CalculationOperator::kInvalid: NOTREACHED(); return nullptr; @@ -373,6 +397,13 @@ return value > 0 ? 1 : -1; } } + case CalculationOperator::kProgress: { + DCHECK(!children_.empty()); + float progress = children_[0]->Evaluate(max_value, anchor_evaluator); + float from = children_[1]->Evaluate(max_value, anchor_evaluator); + float to = children_[2]->Evaluate(max_value, anchor_evaluator); + return progress / (to - from); + } case CalculationOperator::kInvalid: break; // TODO(crbug.com/1284199): Support other math functions. @@ -422,7 +453,8 @@ case CalculationOperator::kRem: case CalculationOperator::kHypot: case CalculationOperator::kAbs: - case CalculationOperator::kSign: { + case CalculationOperator::kSign: + case CalculationOperator::kProgress: { DCHECK(children_.size()); Vector<scoped_refptr<const CalculationExpressionNode>> cloned_operands; cloned_operands.reserve(children_.size()); @@ -490,6 +522,8 @@ return first_child_type; } + case CalculationOperator::kProgress: + return ResultType::kNumber; case CalculationOperator::kInvalid: NOTREACHED(); return result_type_;
diff --git a/third_party/blink/renderer/platform/geometry/calculation_expression_node.h b/third_party/blink/renderer/platform/geometry/calculation_expression_node.h index 8b6cd9bab..f22e0214 100644 --- a/third_party/blink/renderer/platform/geometry/calculation_expression_node.h +++ b/third_party/blink/renderer/platform/geometry/calculation_expression_node.h
@@ -30,6 +30,7 @@ kHypot, kAbs, kSign, + kProgress, kInvalid }; @@ -52,6 +53,7 @@ bool HasAutoAnchorPositioning() const { return has_auto_anchor_positioning_; } virtual bool IsNumber() const { return false; } + virtual bool IsIdentifier() const { return false; } virtual bool IsPixelsAndPercent() const { return false; } virtual bool IsOperation() const { return false; } virtual bool IsAnchorQuery() const { return false; } @@ -62,7 +64,7 @@ virtual ~CalculationExpressionNode() = default; #if DCHECK_IS_ON() - enum class ResultType { kInvalid, kNumber, kPixelsAndPercent }; + enum class ResultType { kInvalid, kNumber, kPixelsAndPercent, kIdent }; virtual ResultType ResolvedResultType() const = 0; @@ -111,6 +113,48 @@ } }; +class PLATFORM_EXPORT CalculationExpressionIdentifierNode final + : public CalculationExpressionNode { + public: + explicit CalculationExpressionIdentifierNode(AtomicString identifier) + : identifier_(std::move(identifier)) { +#if DCHECK_IS_ON() + result_type_ = ResultType::kIdent; +#endif + } + + const AtomicString& Value() const { return identifier_; } + + // Implement |CalculationExpressionNode|: + float Evaluate(float max_value, const Length::AnchorEvaluator*) const final { + return 0.0f; + } + bool Equals(const CalculationExpressionNode& other) const final { + return other.IsIdentifier() && + DynamicTo<CalculationExpressionIdentifierNode>(other)->Value() == + Value(); + } + scoped_refptr<const CalculationExpressionNode> Zoom( + double factor) const final { + return this; + } + bool IsIdentifier() const final { return true; } + +#if DCHECK_IS_ON() + ResultType ResolvedResultType() const final { return ResultType::kIdent; } +#endif + + private: + AtomicString identifier_; +}; + +template <> +struct DowncastTraits<CalculationExpressionIdentifierNode> { + static bool AllowFrom(const CalculationExpressionNode& node) { + return node.IsIdentifier(); + } +}; + class PLATFORM_EXPORT CalculationExpressionPixelsAndPercentNode final : public CalculationExpressionNode { public:
diff --git a/third_party/blink/renderer/platform/geometry/calculation_expression_node_test.cc b/third_party/blink/renderer/platform/geometry/calculation_expression_node_test.cc index abcec470..079d861 100644 --- a/third_party/blink/renderer/platform/geometry/calculation_expression_node_test.cc +++ b/third_party/blink/renderer/platform/geometry/calculation_expression_node_test.cc
@@ -199,4 +199,17 @@ EXPECT_FALSE(pixels_and_percent_node->HasExplicitPercent()); } +TEST(CalculationExpressionOperationNodeTest, ProgressNotation) { + EXPECT_EQ(BuildOperationNode({3.f, 0.f, 1.f}, CalculationOperator::kProgress) + ->Evaluate(FLT_MAX, nullptr), + 3.f); + EXPECT_EQ( + BuildOperationNode({10.f, 5.f, 10.f}, CalculationOperator::kProgress) + ->Evaluate(FLT_MAX, nullptr), + 2.f); + EXPECT_TRUE(std::isnan( + BuildOperationNode({0.f, 0.f, 0.f}, CalculationOperator::kProgress) + ->Evaluate(FLT_MAX, nullptr))); +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/image_orientation.h b/third_party/blink/renderer/platform/graphics/image_orientation.h index 4973e848..90c15b76 100644 --- a/third_party/blink/renderer/platform/graphics/image_orientation.h +++ b/third_party/blink/renderer/platform/graphics/image_orientation.h
@@ -40,7 +40,7 @@ class AffineTransform; -enum RespectImageOrientationEnum { +enum RespectImageOrientationEnum : uint8_t { kDoNotRespectImageOrientation = 0, kRespectImageOrientation = 1 };
diff --git a/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder.cc b/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder.cc index dafe472..3540929 100644 --- a/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder.cc +++ b/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder.cc
@@ -218,8 +218,7 @@ stream->num_read_bytes += num_bytes; } -template <typename T> -inline float FractionToFloat(T numerator, uint32_t denominator) { +float FractionToFloat(auto numerator, uint32_t denominator) { // First cast to double and not float because uint32_t->float conversion can // cause precision loss. return static_cast<double>(numerator) / denominator; @@ -1247,13 +1246,6 @@ const float alternate_headroom = std::exp2(FractionToFloat( metadata.alternateHdrHeadroomN, metadata.alternateHdrHeadroomD)); const bool base_is_hdr = base_headroom > alternate_headroom; - if (base_is_hdr != metadata.backwardDirection) { - // TODO(crbug.com/1451889): support gain maps computed as the ratio of SDR - // over HDR. Currently, SkGainmapShader expects the gain map to always be - // computed as the ratio of HDR over SDR. - DVLOG(1) << "Unsupported gain map type"; - return false; - } out_gainmap_info.fDisplayRatioSdr = base_is_hdr ? alternate_headroom : base_headroom; out_gainmap_info.fDisplayRatioHdr = @@ -1268,12 +1260,23 @@ DVLOG(1) << "Invalid gainmap metadata: a denominator value is zero"; return false; } - // Using double and not float because uint32_t->float conversion can cause - // precision loss. - out_gainmap_info.fGainmapRatioMin[i] = std::exp2( - FractionToFloat(metadata.gainMapMinN[i], metadata.gainMapMinD[i])); - out_gainmap_info.fGainmapRatioMax[i] = std::exp2( - FractionToFloat(metadata.gainMapMaxN[i], metadata.gainMapMaxD[i])); + + float min_log2 = + FractionToFloat(metadata.gainMapMinN[i], metadata.gainMapMinD[i]); + float max_log2 = + FractionToFloat(metadata.gainMapMaxN[i], metadata.gainMapMaxD[i]); + if (base_is_hdr != metadata.backwardDirection) { + // When base_is_hdr != metadata.backwardDirection, it means that the + // gain map was computed as log2(HDR/SDR) instead of log2(SDR/HDR). + // But log2(1/x) = -log2(x) so we just need to negate the min/max values + // which are used to scale the gain map. + // Note that we no longer have min<max but Skia does not check this. + min_log2 *= -1.0f; + max_log2 *= -1.0f; + } + out_gainmap_info.fGainmapRatioMin[i] = std::exp2(min_log2); + out_gainmap_info.fGainmapRatioMax[i] = std::exp2(max_log2); + // Numerator and denominator intentionally swapped to get 1.0/gamma. out_gainmap_info.fGainmapGamma[i] = FractionToFloat(metadata.gainMapGammaD[i], metadata.gainMapGammaN[i]);
diff --git a/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder_test.cc b/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder_test.cc index 23c7db7..1e26d6c 100644 --- a/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder_test.cc +++ b/third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder_test.cc
@@ -1039,31 +1039,28 @@ EXPECT_NEAR(gainmap_info.fGainmapRatioMin[2], 1.0, kEpsilon); EXPECT_NEAR(gainmap_info.fGainmapRatioMin[3], 1.0, kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapRatioMax[0], std::pow(2., 2.753770), - kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapRatioMax[1], std::pow(2., 2.753770), - kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapRatioMax[2], std::pow(2., 2.753770), - kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapRatioMax[3], 1., kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[0], std::exp2(2.753770), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[1], std::exp2(2.753770), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[2], std::exp2(2.753770), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[3], 1.0, kEpsilon); EXPECT_NEAR(gainmap_info.fGainmapGamma[0], 1. / 0.31108, kEpsilon); EXPECT_NEAR(gainmap_info.fGainmapGamma[1], 1. / 0.31108, kEpsilon); EXPECT_NEAR(gainmap_info.fGainmapGamma[2], 1. / 0.31108, kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapGamma[3], 1., kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[3], 1.0, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonSdr[0], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonSdr[1], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonSdr[2], 0.015625, kEpsilon); - EXPECT_NEAR(gainmap_info.fEpsilonSdr[3], 1., kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonSdr[3], 1.0, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonHdr[0], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonHdr[1], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonHdr[2], 0.015625, kEpsilon); - EXPECT_NEAR(gainmap_info.fEpsilonHdr[3], 1., kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonHdr[3], 1.0, kEpsilon); - EXPECT_NEAR(gainmap_info.fDisplayRatioSdr, 1, kEpsilon); - EXPECT_NEAR(gainmap_info.fDisplayRatioHdr, std::pow(2., 2.8), kEpsilon); + EXPECT_NEAR(gainmap_info.fDisplayRatioSdr, 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fDisplayRatioHdr, std::exp2(2.8), kEpsilon); // Check that the gainmap can be decoded. std::unique_ptr<ImageDecoder> gainmap_decoder = CreateAVIFDecoder(); @@ -1079,9 +1076,6 @@ features::kAvifGainmapHdrImages}, /*disabled_features=*/{}); - // Image was generated by converting - // blink/web_tests/images/resources/gainmap-trattore0.jpg - // with avifenc. scoped_refptr<SharedBuffer> data = ReadFile("/images/resources/avif/small-with-gainmap-iso.avif"); std::unique_ptr<ImageDecoder> decoder = CreateAVIFDecoder(); @@ -1099,28 +1093,82 @@ EXPECT_NEAR(gainmap_info.fGainmapRatioMin[2], 1.0, kEpsilon); EXPECT_NEAR(gainmap_info.fGainmapRatioMin[3], 1.0, kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapRatioMax[0], std::pow(2., 1.4427), kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapRatioMax[1], std::pow(2., 1.4427), kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapRatioMax[2], std::pow(2., 1.4427), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[0], std::exp2(1.4427), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[1], std::exp2(1.4427), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[2], std::exp2(1.4427), kEpsilon); EXPECT_NEAR(gainmap_info.fGainmapRatioMax[3], 1., kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapGamma[0], 1., kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapGamma[1], 1., kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapGamma[2], 1., kEpsilon); - EXPECT_NEAR(gainmap_info.fGainmapGamma[3], 1., kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[0], 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[1], 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[2], 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[3], 1.0, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonSdr[0], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonSdr[1], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonSdr[2], 0.015625, kEpsilon); - EXPECT_NEAR(gainmap_info.fEpsilonSdr[3], 1., kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonSdr[3], 1.0, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonHdr[0], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonHdr[1], 0.015625, kEpsilon); EXPECT_NEAR(gainmap_info.fEpsilonHdr[2], 0.015625, kEpsilon); - EXPECT_NEAR(gainmap_info.fEpsilonHdr[3], 1., kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonHdr[3], 1.0, kEpsilon); - EXPECT_NEAR(gainmap_info.fDisplayRatioSdr, 1, kEpsilon); - EXPECT_NEAR(gainmap_info.fDisplayRatioHdr, std::pow(2., 1.4427), kEpsilon); + EXPECT_NEAR(gainmap_info.fDisplayRatioSdr, 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fDisplayRatioHdr, std::exp2(1.4427), kEpsilon); + + // Check that the gainmap can be decoded. + std::unique_ptr<ImageDecoder> gainmap_decoder = CreateAVIFDecoder(); + gainmap_decoder->SetData(gainmap_data, true); + ImageFrame* gainmap_frame = decoder->DecodeFrameBufferAtIndex(0); + EXPECT_TRUE(gainmap_frame); +} + +TEST(StaticAVIFTests, GetIsoGainmapInfoAndDataHdrToSdr) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitWithFeatures( + /*enabled_features=*/{features::kGainmapHdrImages, + features::kAvifGainmapHdrImages}, + /*disabled_features=*/{}); + + scoped_refptr<SharedBuffer> data = ReadFile( + "/images/resources/avif/small-with-gainmap-iso-hdrbase-forward.avif"); + std::unique_ptr<ImageDecoder> decoder = CreateAVIFDecoder(); + decoder->SetData(data, true); + SkGainmapInfo gainmap_info; + scoped_refptr<SegmentReader> gainmap_data; + const bool has_gainmap = + decoder->GetGainmapInfoAndData(gainmap_info, gainmap_data); + ASSERT_TRUE(has_gainmap); + + // Check gainmap metadata. + constexpr double kEpsilon = 0.00001; + EXPECT_NEAR(gainmap_info.fGainmapRatioMin[0], std::exp2(1.536), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMin[1], std::exp2(1.488), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMin[2], std::exp2(1.548), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMin[3], 1.0, kEpsilon); + + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[0], std::exp2(-0.372), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[1], std::exp2(-0.396), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[2], std::exp2(-0.444), kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapRatioMax[3], 1.0, kEpsilon); + + EXPECT_NEAR(gainmap_info.fGainmapGamma[0], 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[1], 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[2], 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fGainmapGamma[3], 1.0, kEpsilon); + + EXPECT_NEAR(gainmap_info.fEpsilonSdr[0], 0.015625, kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonSdr[1], 0.015625, kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonSdr[2], 0.015625, kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonSdr[3], 1.0, kEpsilon); + + EXPECT_NEAR(gainmap_info.fEpsilonHdr[0], 0.015625, kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonHdr[1], 0.015625, kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonHdr[2], 0.015625, kEpsilon); + EXPECT_NEAR(gainmap_info.fEpsilonHdr[3], 1.0, kEpsilon); + + EXPECT_NEAR(gainmap_info.fDisplayRatioSdr, 1.0, kEpsilon); + EXPECT_NEAR(gainmap_info.fDisplayRatioHdr, std::exp2(2.0), kEpsilon); // Check that the gainmap can be decoded. std::unique_ptr<ImageDecoder> gainmap_decoder = CreateAVIFDecoder();
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 index 7b4c37e..6b75dd0 100644 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -602,6 +602,13 @@ status: {"Android": "", "default": "test"}, }, { + name: "CapturedSurfaceControl", + // TODO(crbug.com/1466247): Once implementation is further along, + // set "default" to "experimental". (Note that Android support + // is not planned.) + status: {"Android": ""}, + }, + { name: "CaptureHandle", depends_on: ["GetDisplayMedia"], status: {"Android": "", "default": "stable"}, @@ -1038,6 +1045,12 @@ status: "test", base_feature: "none", }, + // https://drafts.csswg.org/css-values-5/#progress + // progress(), media-progress(), container-progress() + { + name: "CSSProgressNotation", + status: "experimental", + }, { // Shipping in M120. Flag should be removed after M120 has been // shipping to stable for a few weeks.
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 8701123..50c56b00 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -1491,6 +1491,12 @@ crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-011.html [ Failure ] crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-012.html [ Failure ] crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-015.html [ Failure ] +crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-020.html [ Failure ] +crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-021.html [ Failure ] +crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-022.html [ Failure ] +crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-023.html [ Failure ] +crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-024.html [ Failure ] +crbug.com/1491198 external/wpt/css/selectors/selectors-4/lang-025.html [ Failure ] # ====== Style team owned tests to here ====== @@ -2698,13 +2704,7 @@ crbug.com/626703 [ Mac ] virtual/webcodecs-without-task-runner-with-custom-deleter/external/wpt/webcodecs/videoDecoder-codec-specific.https.any.worker.html?h265_hevc [ Failure ] # ====== New tests from wpt-importer added here ====== -crbug.com/626703 external/wpt/css/selectors/selectors-4/lang-023.html [ Failure ] -crbug.com/626703 external/wpt/css/selectors/selectors-4/lang-024.html [ Failure ] crbug.com/626703 external/wpt/css/css-nesting/has-nesting.html [ Failure ] -crbug.com/626703 external/wpt/css/selectors/selectors-4/lang-020.html [ Failure ] -crbug.com/626703 external/wpt/css/selectors/selectors-4/lang-021.html [ Failure ] -crbug.com/626703 external/wpt/css/selectors/selectors-4/lang-022.html [ Failure ] -crbug.com/626703 external/wpt/css/selectors/selectors-4/lang-025.html [ Failure ] crbug.com/626703 external/wpt/png/apng/acTL-plays-one.html [ Failure ] crbug.com/626703 external/wpt/png/apng/fcTL-blend-source-nearly-transparent.html [ Timeout ] crbug.com/626703 external/wpt/png/apng/fcTL-blend-source-transparent.html [ Timeout ]
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json index 4ba270f..7ab1be67 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
@@ -393219,7 +393219,7 @@ [] ], "exp.json": [ - "886729f2e8a3c7969f25ab7276090aade2039a90", + "8a86edec3b8e5ed460ca8d00242d97e5f110a35f", [] ], "floor.json": [ @@ -466821,6 +466821,13 @@ {} ] ], + "CSSConditionRule-conditionText.html": [ + "bccfc3135a4c80695b90638c42268f8a35d7f2fd", + [ + null, + {} + ] + ], "CSSContainerRule.tentative.html": [ "4e01c0b47003a413c0853ba96011d10962ad00a5", [
diff --git a/third_party/blink/web_tests/external/wpt/css/css-values/progress-computed.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-values/progress-computed.tentative.html new file mode 100644 index 0000000..cb1edff --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-values/progress-computed.tentative.html
@@ -0,0 +1,26 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-values-5/#progress"> +<link rel="author" title="sakhapov@chromuim.org"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../support/numeric-testcommon.js"></script> +<div id="target"></div> +<script> + +// Identity tests +test_math_used('progress(1 from 0 to 1)', '1', {type:'number'}); + +// Nestings +test_math_used('progress(progress(1 from 0 to 1) from progress(0px from 0px to 1px) to progress(1deg from 0deg to 1deg))', '1', {type:'number'}); +test_math_used('progress(sign(-10px) * 10px from (10px - 10px) to 10px * progress(1deg from 0deg to 1deg))', '-1', {type:'number'}); + +// General calculations +test_math_used('calc(progress(100px from 0px to 50px) * 10px + 100px)', '120px'); +test_math_used('calc(progress(100 from 0 to sign(50px)))', '100', {type:'number'}); +test_math_used('calc(progress(abs(5%) from hypot(3%, 4%) to 10%))', '1', {type:'number', approx:0.001}); + +// Type checking +test_math_used('calc(progress(1 from 0 to 1) * 10px)', '10px'); +test_math_used('calc(progress(1 from 0 to 1) * 1s)', '1s', {type:'time'}); +test_math_used('calc(progress(1 from 0 to 1) * 1deg)', '1deg', {type:'angle', approx:0.001}); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-values/progress-invalid.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-values/progress-invalid.tentative.html new file mode 100644 index 0000000..e009eef4 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-values/progress-invalid.tentative.html
@@ -0,0 +1,44 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-values-5/#progress"> +<link rel="author" title="sakhapov@chromuim.org"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../support/parsing-testcommon.js"></script> +<script> +function test_invalid_number(value) { + test_invalid_value('opacity', value); +} +function test_invalid_length(value) { + // 'letter-spacing' accepts <length> only, not <percentage> or any mixes. + test_invalid_value('letter-spacing', value); +} + +// Syntax checking +test_invalid_number('progress()'); +test_invalid_number('progress( )'); +test_invalid_number('progress(,)'); +test_invalid_number('progress(1 from )'); +test_invalid_number('progress(1)'); +test_invalid_number('progress(50% to 0)'); +test_invalid_number('progress(0 from 1 to)'); +test_invalid_number('progress(from to)'); +test_invalid_number('progress(from 1 to 0)'); +test_invalid_number('progress(from 1 to 0 1)'); +test_invalid_number('progress(from 1 0)'); +test_invalid_number('progress(0 from to 0)'); +test_invalid_number('progress(to to to to to)'); +test_invalid_number('progress(0, from, 10, to 200)'); +test_invalid_number('progress(0, from, 10, to, 200)'); +test_invalid_number('progress(0, from 10, to 200)'); +test_invalid_number('progress(0, 10, 200)'); + +// General tests +test_invalid_number('progress(5% from 0 to 8'); +test_invalid_number('progress(5% from 0deg to 8deg'); +test_invalid_number('progress(5 from 0deg to 8deg'); +test_invalid_number('progress(5 from 0% to 8deg'); +test_invalid_number('progress(5 from 0% to sign(10px)'); +test_invalid_number('progress(5% from 0px to 10px'); +test_invalid_length('calc(1px * progress(10deg from 0 to 10))'); +test_invalid_length('calc(1px * progress(10 from 0px to 10))'); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-values/progress-serialize.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-values/progress-serialize.tentative.html new file mode 100644 index 0000000..6ea12f2 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-values/progress-serialize.tentative.html
@@ -0,0 +1,56 @@ +<!DOCTYPE html> +<link rel="help" href="https://drafts.csswg.org/css-values-5/#progress"> +<link rel="author" title="sakhapov@chromuim.org"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../support/serialize-testcommon.js"></script> +<div id=target></div> +<script> +function test_serialization(t,s,c) { + test_specified_serialization('opacity', t, s); + test_specified_serialization('transform', `scale(${t})`, `scale(${s})`); + test_computed_serialization('opacity', t, c); + test_computed_serialization('transform', `scale(${t})`, `matrix(${c}, 0, 0, ${c}, 0, 0)`); +} + +test_serialization( + 'progress(100px from 0px to 100px)', + 'calc(1)', + '1', +); +test_serialization( + 'progress(10em from 0px to 10em)', + 'calc(progress(10em from 0px to 10em))', + '1', +); +test_serialization( + 'progress(10em from 0px to 10rem)', + 'calc(progress(10em from 0px to 10rem))', + '1', +); +test_serialization( + 'progress(100px from (10px - 10px) to 100px)', + 'calc(1)', + '1', +); +test_serialization( + 'progress(1% from (10% - 10%) to 100%)', + 'calc(0.01)', + '0.01', +); +test_serialization( + 'calc(0.5 * progress(100px from 0px to 100px))', + 'calc(0.5)', + '0.5' +); +test_specified_serialization( + 'width', + 'calc(50px * progress(100px from 0px to 100px))', + 'calc(50px)' +); +test_computed_serialization( + 'width', + 'calc(1px * progress(abs(10%) from (10% - 10%) to 100% / 10))', + '1px', +); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/css/cssom/CSSConditionRule-conditionText.html b/third_party/blink/web_tests/external/wpt/css/cssom/CSSConditionRule-conditionText.html new file mode 100644 index 0000000..bccfc31 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/cssom/CSSConditionRule-conditionText.html
@@ -0,0 +1,23 @@ +<!doctype html> +<title>CSSConditionRule.conditionText</title> +<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> +<link rel="help" href="https://drafts.csswg.org/css-conditional-3/#cssconditionrule"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> +@media not all { + :root { color: lime } +} +</style> +<script> +test(function(t) { + let rule = document.styleSheets[0].cssRules[0]; + assert_true(rule instanceof CSSConditionRule); + assert_equals(rule.conditionText, "not all"); + rule.conditionText = 1; + assert_equals(rule.conditionText, "not all"); + rule.conditionText = "all"; + assert_equals(rule.conditionText, "not all"); + assert_not_equals(getComputedStyle(document.documentElement).color, "rgb(0, 255, 0)"); +}); +</script>
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/request-interception-invalid-stage-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/request-interception-invalid-stage-expected.txt new file mode 100644 index 0000000..f8ce8770 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/request-interception-invalid-stage-expected.txt
@@ -0,0 +1,10 @@ +Tests the browser does not crash when an invalid interception stage is requested (crbug.com/1500377) +{ + error : { + code : -32602 + message : Unsupported interception stage 'FOO' + } + id : <number> + sessionId : <string> +} +
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/request-interception-invalid-stage.js b/third_party/blink/web_tests/http/tests/inspector-protocol/network/request-interception-invalid-stage.js new file mode 100644 index 0000000..3b82ad5c --- /dev/null +++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/request-interception-invalid-stage.js
@@ -0,0 +1,13 @@ +(async function(testRunner) { + var {page, session, dp} = await testRunner.startBlank( + `Tests the browser does not crash when an invalid interception stage is requested (crbug.com/1500377)`); + + session.protocol.Network.enable(); + session.protocol.Page.enable(); + + const result = await session.protocol.Network.setRequestInterception( + {patterns: [{urlPattern: '*', interceptionStage: 'FOO'}]}); + testRunner.log(result); + + testRunner.completeTest(); +})
diff --git a/third_party/blink/web_tests/images/resources/avif/README.md b/third_party/blink/web_tests/images/resources/avif/README.md index a4aee4c..e9b2e88 100644 --- a/third_party/blink/web_tests/images/resources/avif/README.md +++ b/third_party/blink/web_tests/images/resources/avif/README.md
@@ -195,4 +195,27 @@ Then the file was edited with a hex editor to associate the xmp to the aux image. +### small-with-gainmap-iso.avif +A small image with a gainmap as a "tmap" derived item. + +The image was generated by converting +blink/web_tests/images/resources/gainmap-trattore0.jpg with `avifenc` built with +`AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP` enabled and libxml2 available (installed on +the system or with `AVIF_LOCAL_LIBXML2`). + +### small-with-gainmap-iso-hdrbase-forward.avif +A small image with a gainmap as a "tmap" derived item. The gainmap is computed +as log2(HDR/SDR) instead of log2(SDR/HDR). + +This image was generated with the following commands using avifgainmaputil +from libavif and the small-with-gainmap-iso.avif test file: + +``` +$ avifgainmaputil swapbase small-with-gainmap-iso.avif \ + /tmp/small-with-gainmap-iso-swapped.avif --qgain-map 80 --qcolor 80 +$ avifgainmaputil combine /tmp/small-with-gainmap-iso-swapped.avif \ + small-with-gainmap-iso.avif small-with-gainmap-iso-hdrbase-forward.avif \ + --qgain-map 80 --qcolor 80 +``` + ### TODO(crbug.com/960620): Figure out how the rest of files were generated.
diff --git a/third_party/blink/web_tests/images/resources/avif/small-with-gainmap-iso-hdrbase-forward.avif b/third_party/blink/web_tests/images/resources/avif/small-with-gainmap-iso-hdrbase-forward.avif new file mode 100644 index 0000000..510d1dd8 --- /dev/null +++ b/third_party/blink/web_tests/images/resources/avif/small-with-gainmap-iso-hdrbase-forward.avif Binary files differ
diff --git a/third_party/closure_compiler/externs/file_manager_private.js b/third_party/closure_compiler/externs/file_manager_private.js index 552345f6..67fdf54c 100644 --- a/third_party/closure_compiler/externs/file_manager_private.js +++ b/third_party/closure_compiler/externs/file_manager_private.js
@@ -985,7 +985,8 @@ * errorName: string, * pauseParams: (!chrome.fileManagerPrivate.PauseParams|undefined), * outputs: (!Array<Entry>|undefined), - * destinationVolumeId: string + * destinationVolumeId: string, + * skippedEncryptedFiles: Array<string> * }} */ chrome.fileManagerPrivate.ProgressStatus;
diff --git a/third_party/cros_system_api b/third_party/cros_system_api index 209d515..ba5195a 160000 --- a/third_party/cros_system_api +++ b/third_party/cros_system_api
@@ -1 +1 @@ -Subproject commit 209d5157d57fabac8ab61af5be7c5a4770c80436 +Subproject commit ba5195aeb44e0f6659b10c7463f6f2c355fad2dc
diff --git a/third_party/dawn b/third_party/dawn index 1862fc4..ca401b3 160000 --- a/third_party/dawn +++ b/third_party/dawn
@@ -1 +1 @@ -Subproject commit 1862fc490314e49777e253499ab3008d88223280 +Subproject commit ca401b32db3e3f969c541ecff8bdeff246afd594
diff --git a/third_party/devtools-frontend-internal b/third_party/devtools-frontend-internal index efe97a4..c4374dc 160000 --- a/third_party/devtools-frontend-internal +++ b/third_party/devtools-frontend-internal
@@ -1 +1 @@ -Subproject commit efe97a4717421c08b1724e81f38e4b2aa67fa1a0 +Subproject commit c4374dcc2760704adfbd4df64d14c89faab8ab57
diff --git a/third_party/devtools-frontend/src b/third_party/devtools-frontend/src index c0b9c1d..5e6e1f8 160000 --- a/third_party/devtools-frontend/src +++ b/third_party/devtools-frontend/src
@@ -1 +1 @@ -Subproject commit c0b9c1d55ce45863d35215f0083917a27a1cbe75 +Subproject commit 5e6e1f8975c2c9f24262f7b36af820525cb56604
diff --git a/third_party/neon_2_sse/BUILD.gn b/third_party/neon_2_sse/BUILD.gn index 0f5d7a30..3b00035 100644 --- a/third_party/neon_2_sse/BUILD.gn +++ b/third_party/neon_2_sse/BUILD.gn
@@ -10,9 +10,6 @@ config("neon_2_sse_flags") { if (target_cpu == "x64") { cflags = [ "-Wno-deprecated-declarations" ] - if (target_os == "mac") { - cflags += [ "-Wno-gnu-inline-cpp-without-extern" ] - } } }
diff --git a/third_party/perfetto b/third_party/perfetto index 41a5723..f389d82 160000 --- a/third_party/perfetto +++ b/third_party/perfetto
@@ -1 +1 @@ -Subproject commit 41a5723e9fbd48efbe79c8b2d46bf6e13aa67682 +Subproject commit f389d82070a13a09ac799e6d8b457d1daf25fb27
diff --git a/third_party/skia b/third_party/skia index e13594d..7903ebb 160000 --- a/third_party/skia +++ b/third_party/skia
@@ -1 +1 @@ -Subproject commit e13594df88a12baf3e1ba7ae8b98feaeb1f5482a +Subproject commit 7903ebbe9a940d5792860cc447e11898253c7858
diff --git a/third_party/tflite/BUILD.gn b/third_party/tflite/BUILD.gn index 0d46ae8c..87eb9f5 100644 --- a/third_party/tflite/BUILD.gn +++ b/third_party/tflite/BUILD.gn
@@ -715,14 +715,4 @@ } public_configs = [ ":tflite_config" ] - - # In some configs "neon_check.h" includes "NEON_2_SSE.h" with no path. - # "NEON_2_SSE.h" comes from neon_2_sse. The target neon_2_sse has a config - # that adds to the "include_dirs". This means any file including - # "neon_check.h" needs the config, so that neon_2_sse should be in - # public_deps. Unfortunately neon_2_sse also adds some compiler flags we do - # not want propagated. For the time being, allow this in the standalone - # target (which is assumed to be for third-party code that is OK to have - # these switches). - public_deps_for_standalone = [ "//third_party/neon_2_sse" ] }
diff --git a/third_party/tflite/tflite_target.gni b/third_party/tflite/tflite_target.gni index c4d3e3c..a840c92a 100644 --- a/third_party/tflite/tflite_target.gni +++ b/third_party/tflite/tflite_target.gni
@@ -36,7 +36,7 @@ # conditional_deps = [ ":tflite_internal" ] # } -# Set of variables that are forwarded to the actual target. +# Set of variables that are forwarded to the actual minimal_vars_to_forward_to_target = [ "cflags", "configs", @@ -94,14 +94,9 @@ configs += invoker.configs_to_add } + # Standalone targets should not depend upon base. if (type == "_standalone") { - # Standalone targets should not depend upon base. assert_no_deps = [ "//base" ] - if (defined(invoker.public_deps_for_standalone)) { - public_deps += invoker.public_deps_for_standalone - } - } else { - not_needed(invoker, [ "public_deps_for_standalone" ]) } } } @@ -113,7 +108,6 @@ "conditional_public_deps", "configs_to_add", "configs_to_remove", - "public_deps_for_standalone", ] template("tflite_static_library") {
diff --git a/third_party/vulkan-deps b/third_party/vulkan-deps index fe7ac47..05e2e58 160000 --- a/third_party/vulkan-deps +++ b/third_party/vulkan-deps
@@ -1 +1 @@ -Subproject commit fe7ac4762e4704386b0b6b949c720614e0930d5d +Subproject commit 05e2e582257cbeb1303ed863f2f9c412202769c7
diff --git a/third_party/webgpu-cts/src b/third_party/webgpu-cts/src index 35005a9..591c6553 160000 --- a/third_party/webgpu-cts/src +++ b/third_party/webgpu-cts/src
@@ -1 +1 @@ -Subproject commit 35005a9ead81cb87feade372e8d1358dc75f0b17 +Subproject commit 591c655330a7611cfbe3167bbd48b1ad2d066151
diff --git a/third_party/webrtc b/third_party/webrtc index d026993..0b78094 160000 --- a/third_party/webrtc +++ b/third_party/webrtc
@@ -1 +1 @@ -Subproject commit d0269937a0e5ddbd9fafd35f2507b5236648edf6 +Subproject commit 0b78094234ea4eb12ea7b13ee178b4306af519a6
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index c9e4efc..c795151 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -19508,6 +19508,7 @@ <int value="1844" label="ACCESSIBILITY_PRIVATE_GETTTSDLCCONTENTS"/> <int value="1845" label="OS_DIAGNOSTICS_CREATEFANROUTINE"/> <int value="1846" label="OS_DIAGNOSTICS_ISFANROUTINEARGUMENTSUPPORTED"/> + <int value="1847" label="AUTOTESTPRIVATE_OVERRIDEORCARESPONSE"/> </enum> <enum name="ExtensionInProgressRequestState"> @@ -36013,6 +36014,7 @@ <int value="-746042208" label="QuickCommands:enabled"/> <int value="-745969829" label="BackGestureRefactorAndroid:enabled"/> <int value="-745616196" label="ClickToCall:disabled"/> + <int value="-745267150" label="OptimizationGuideOnDeviceModel:enabled"/> <int value="-745082968" label="SyncDeviceInfoInTransportMode:disabled"/> <int value="-745005043" label="enable-experimental-accessibility-switch-access-setup-guide"/> @@ -41292,6 +41294,7 @@ <int value="1783967606" label="PageContentAnnotations:enabled"/> <int value="1784129660" label="OmniboxDocumentProviderNoSetting:enabled"/> <int value="1784514956" label="QuickAnswersForMoreLocales:enabled"/> + <int value="1784982889" label="OptimizationGuideOnDeviceModel:disabled"/> <int value="1785093465" label="enable-document-passive-event-listeners"/> <int value="1785274337" label="AutofillEnableOfferNotificationCrossTabTracking:disabled"/>
diff --git a/tools/metrics/histograms/metadata/chromeos/enums.xml b/tools/metrics/histograms/metadata/chromeos/enums.xml index a0d0804..4f529224 100644 --- a/tools/metrics/histograms/metadata/chromeos/enums.xml +++ b/tools/metrics/histograms/metadata/chromeos/enums.xml
@@ -584,6 +584,31 @@ </int> </enum> +<enum name="ChromeOSSamlApiError"> + <summary> + Different errors that can occur while using Credentials Passing API in + ChromeOS. + </summary> + <int value="0" label="Not supported key type"> + IdP sent unsupported key type + </int> + <int value="1" label="Not supported create account"> + Gaia wanted to create an account while feature is not supported + </int> + <int value="2" label="Not valid create account"> + Gaia wanted to create an account for a user that wasn't added. + </int> + <int value="3" label="Not valid confirm token"> + IdP confirmed token that wasn't added + </int> + <int value="4" label="Not supported message"> + IdP sent a message that isn't supported in SAML API. + </int> + <int value="5" label="Missing password confirmation"> + IdP didn't send user's password confirmation + </int> +</enum> + <enum name="ChromeOSSamlApiUsed"> <summary> ChromeOS login flow by Identity Provider. Can be either GAIA-based, SAML
diff --git a/tools/metrics/histograms/metadata/chromeos/histograms.xml b/tools/metrics/histograms/metadata/chromeos/histograms.xml index 23a71ac4..be450bbf 100644 --- a/tools/metrics/histograms/metadata/chromeos/histograms.xml +++ b/tools/metrics/histograms/metadata/chromeos/histograms.xml
@@ -2102,6 +2102,13 @@ </token> </histogram> +<histogram name="ChromeOS.SAML.APIError" enum="ChromeOSSamlApiError" + expires_after="2024-05-20"> + <owner>mohammedabdon@chromium.org</owner> + <owner>ayag@google.com</owner> + <summary>Recorded when the Credentials Passing API call fails.</summary> +</histogram> + <histogram name="ChromeOS.SAML.APILogin" enum="ChromeOSSamlApiUsed" expires_after="2023-04-02"> <owner>mslus@chromium.org</owner>
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index 3f96169..4256433c 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json
@@ -14,7 +14,7 @@ }, "mac": { "hash": "95a1bfa6062923757305afc90f1c37bf54d027e8", - "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/mac/41a5723e9fbd48efbe79c8b2d46bf6e13aa67682/trace_processor_shell" + "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/mac/a0675ae1e8536c32389d45e083ef30081859822f/trace_processor_shell" }, "mac_arm64": { "hash": "10ae4aaabedc85f42808a67cbb5951199d4c326e", @@ -22,7 +22,7 @@ }, "linux": { "hash": "cece5651c28bd802b751415b240da56cc780f8a1", - "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/linux/41a5723e9fbd48efbe79c8b2d46bf6e13aa67682/trace_processor_shell" + "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/linux/f389d82070a13a09ac799e6d8b457d1daf25fb27/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/ui/chromeos/file_manager_strings.grdp b/ui/chromeos/file_manager_strings.grdp index c6dc34b..53a45cd 100644 --- a/ui/chromeos/file_manager_strings.grdp +++ b/ui/chromeos/file_manager_strings.grdp
@@ -658,6 +658,21 @@ <message name="IDS_FILE_BROWSER_COPY_FILESYSTEM_ERROR" desc="File Manager error message."> Copy operation failed. <ph name="ERROR_MESSAGE">$1<ex>An error occurred (code: ABORT)</ex></ph> </message> + <message name="IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_SINGLE_FILE" desc="File Manager error message. An encrypted (Google Drive CSE) file wasn't copied."> + <ph name="FILE_NAME">$1<ex>encrypted.pdf</ex></ph> could not be copied because it is encrypted. + </message> + <message name="IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_SINGLE_FILE" desc="File Manager error message. An encrypted (Google Drive CSE) file wasn't moved.."> + <ph name="FILE_NAME">$1<ex>encrypted.pdf</ex></ph> could not be moved because it is encrypted. + </message> + <message name="IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_FILES" desc="File Manager error message. Several encrypted (Google Drive CSE) files weren't moved."> + <ph name="NUMBER_OF_FILES">$1<ex>3</ex></ph> files could not be copied because they are encrypted. + </message> + <message name="IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_FILES" desc="File Manager error message. Several encrypted (Google Drive CSE) files weren't moved."> + <ph name="NUMBER_OF_FILES">$1<ex>3</ex></ph> files could not be moved because they are encrypted. + </message> + <message name="IDS_FILE_BROWSER_ENCRYPTED_DETAILS" desc="File manager secondary error message when encrypted (Google Drive CSE) files caused an error."> + Contact your administrator for details. + </message> <message name="IDS_FILE_BROWSER_EMPTY_TRASH_UNEXPECTED_ERROR" desc="File manager error whilst emptying trash"> Failed to empty the trash. </message>
diff --git a/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_FILES.png.sha1 b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_FILES.png.sha1 new file mode 100644 index 0000000..0345f3a --- /dev/null +++ b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_FILES.png.sha1
@@ -0,0 +1 @@ +5fe4e81cfec0372868ca18b5a616ecc96dedbce8 \ No newline at end of file
diff --git a/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_SINGLE_FILE.png.sha1 b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_SINGLE_FILE.png.sha1 new file mode 100644 index 0000000..4622a87 --- /dev/null +++ b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_COPY_SKIPPED_ENCRYPTED_SINGLE_FILE.png.sha1
@@ -0,0 +1 @@ +876e137eb1426dace0f4e055d66902a950dadeba \ No newline at end of file
diff --git a/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_ENCRYPTED_DETAILS.png.sha1 b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_ENCRYPTED_DETAILS.png.sha1 new file mode 100644 index 0000000..4622a87 --- /dev/null +++ b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_ENCRYPTED_DETAILS.png.sha1
@@ -0,0 +1 @@ +876e137eb1426dace0f4e055d66902a950dadeba \ No newline at end of file
diff --git a/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_FILES.png.sha1 b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_FILES.png.sha1 new file mode 100644 index 0000000..2069e8d --- /dev/null +++ b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_FILES.png.sha1
@@ -0,0 +1 @@ +9c33463266039101f182db9115fc041767fbb99b \ No newline at end of file
diff --git a/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_SINGLE_FILE.png.sha1 b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_SINGLE_FILE.png.sha1 new file mode 100644 index 0000000..6c85290 --- /dev/null +++ b/ui/chromeos/file_manager_strings_grdp/IDS_FILE_BROWSER_MOVE_SKIPPED_ENCRYPTED_SINGLE_FILE.png.sha1
@@ -0,0 +1 @@ +6ebf147d6794728a2b721e36176d35166979bd7a \ No newline at end of file
diff --git a/ui/file_manager/file_manager/background/js/file_operation_handler.ts b/ui/file_manager/file_manager/background/js/file_operation_handler.ts index 1f04779..06e4e08 100644 --- a/ui/file_manager/file_manager/background/js/file_operation_handler.ts +++ b/ui/file_manager/file_manager/background/js/file_operation_handler.ts
@@ -125,6 +125,7 @@ item.state = ProgressItemState.CANCELED; } else { // ERROR item.state = ProgressItemState.ERROR; + item.skippedEncryptedFiles = event.skippedEncryptedFiles; // Check if there was a policy error. if (event.policyError) { item.policyError =
diff --git a/ui/file_manager/file_manager/common/js/entry_utils.ts b/ui/file_manager/file_manager/common/js/entry_utils.ts index d7108fdd..4573f2b 100644 --- a/ui/file_manager/file_manager/common/js/entry_utils.ts +++ b/ui/file_manager/file_manager/common/js/entry_utils.ts
@@ -4,7 +4,7 @@ import type {EntryLocation} from '../../externs/entry_location.js'; import type {FakeEntry, FilesAppDirEntry, FilesAppEntry} from '../../externs/files_app_entry_interfaces.js'; -import {EntryType, FileData} from '../../externs/ts/state.js'; +import {CurrentDirectory, EntryType, FileData} from '../../externs/ts/state.js'; import type {VolumeInfo} from '../../externs/volume_info.js'; import type {VolumeManager} from '../../externs/volume_manager.js'; import {constants} from '../../foreground/js/constants.js'; @@ -139,7 +139,8 @@ /** * Returns true if fileData's entry is inside any part of Drive. */ -export function isEntryInsideDrive(fileData: FileData): boolean { +export function isEntryInsideDrive(fileData: FileData| + CurrentDirectory): boolean { const {rootType} = fileData; return !!rootType && (rootType === VolumeManagerCommon.RootType.DRIVE ||
diff --git a/ui/file_manager/file_manager/common/js/progress_center_common.ts b/ui/file_manager/file_manager/common/js/progress_center_common.ts index 54658da..4e157f4 100644 --- a/ui/file_manager/file_manager/common/js/progress_center_common.ts +++ b/ui/file_manager/file_manager/common/js/progress_center_common.ts
@@ -133,6 +133,12 @@ policyFileName: string|null = null; /** + * List of files skipped during the operation because we couldn't decrypt + * them. + */ + skippedEncryptedFiles: string[] = []; + + /** * Sets the extra button text and callback. Use this to add an additional * button with configurable functionality. * @param text Text to use for the button.
diff --git a/ui/file_manager/file_manager/containers/search_container.ts b/ui/file_manager/file_manager/containers/search_container.ts index 449eff47..6b16930a 100644 --- a/ui/file_manager/file_manager/containers/search_container.ts +++ b/ui/file_manager/file_manager/containers/search_container.ts
@@ -5,6 +5,7 @@ import {CrInputElement} from 'chrome://resources/cr_elements/cr_input/cr_input.js'; import {queryRequiredElement} from '../common/js/dom_utils.js'; +import {isEntryInsideDrive} from '../common/js/entry_utils.js'; import {recordUserAction} from '../common/js/metrics.js'; import {str, strf} from '../common/js/translations.js'; import {VolumeManagerCommon} from '../common/js/volume_manager_types.js'; @@ -61,8 +62,8 @@ default: !dirPath, }, ]; - if (dirPath) { - if (dir?.rootType === VolumeManagerCommon.RootType.DRIVE) { + if (dirPath.length > 0) { + if (dir && isEntryInsideDrive(dir)) { // For Google Drive we currently do not have the ability to search a // specific folder. Thus the only options shown, when the user is // triggering search from a location in Drive, is Everywhere (set up
diff --git a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.ts b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.ts index 054271bb..6324de4 100644 --- a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.ts +++ b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.ts
@@ -459,7 +459,7 @@ const encrypted = this.metadataModel_.getCache(entries, ['contentMimeType']) - .some( + .every( (metadata, i) => entries[i] ? isEncrypted(entries[i]!, metadata.contentMimeType) : false); @@ -1216,7 +1216,7 @@ } // Don't allow copy of encrypted files. if (this.metadataModel_.getCache(entries, ['contentMimeType']) - .some( + .every( (metadata, i) => entries[i] ? isEncrypted(entries[i]!, metadata.contentMimeType) : false)) {
diff --git a/ui/file_manager/file_manager/foreground/js/ui/progress_center_panel.js b/ui/file_manager/file_manager/foreground/js/ui/progress_center_panel.js index de4a956..bbf1b99 100644 --- a/ui/file_manager/file_manager/foreground/js/ui/progress_center_panel.js +++ b/ui/file_manager/file_manager/foreground/js/ui/progress_center_panel.js
@@ -264,6 +264,27 @@ if (item.policyError) { return getStrForPolicyError(item); } + if (item.skippedEncryptedFiles !== undefined && + item.skippedEncryptedFiles.length > 0) { + switch (item.type) { + case ProgressItemType.COPY: + return item.skippedEncryptedFiles.length == 1 ? + strf( + 'COPY_SKIPPED_ENCRYPTED_SINGLE_FILE', + item.skippedEncryptedFiles[0]) : + strf( + 'COPY_SKIPPED_ENCRYPTED_FILES', + item.skippedEncryptedFiles.length); + case ProgressItemType.MOVE: + return item.skippedEncryptedFiles.length == 1 ? + strf( + 'MOVE_SKIPPED_ENCRYPTED_SINGLE_FILE', + item.skippedEncryptedFiles[0]) : + strf( + 'MOVE_SKIPPED_ENCRYPTED_FILES', + item.skippedEncryptedFiles.length); + } + } // General error return item.message; case ProgressItemState.CANCELED: @@ -373,6 +394,9 @@ } if (item.state === ProgressItemState.ERROR) { + if (item.skippedEncryptedFiles.length > 0) { + return str('ENCRYPTED_DETAILS'); + } if (!item.policyError) { // General error doesn't have secondary text. return '';
diff --git a/ui/file_manager/integration_tests/file_manager/drive_specific.js b/ui/file_manager/integration_tests/file_manager/drive_specific.js index 221a0fb5..b84d7f0c 100644 --- a/ui/file_manager/integration_tests/file_manager/drive_specific.js +++ b/ui/file_manager/integration_tests/file_manager/drive_specific.js
@@ -1794,6 +1794,7 @@ appId, ['#progress-panel', `xf-panel-item[panel-type="${panelType}"]`]); chrome.test.assertEq( - 'Copy operation failed. The file or the directory is not usable.', + ENTRIES.testCSEFileInDirectory.nameText + + ' could not be copied because it is encrypted.', panel.attributes['primary-text']); };
diff --git a/ui/file_manager/integration_tests/file_manager/search.js b/ui/file_manager/integration_tests/file_manager/search.js index be34904..4c5ca817 100644 --- a/ui/file_manager/integration_tests/file_manager/search.js +++ b/ui/file_manager/integration_tests/file_manager/search.js
@@ -1134,3 +1134,43 @@ await directoryTree.navigateToPath('/My files/Downloads/photos'); await remoteCall.waitForElement(appId, '#search-wrapper[collapsed]'); }; + +/** + * Check that if we are either at the top directory of Google Drive or in one of + * the nested directories, we show the correct location. As we always search the + * entire Google Drive, we should always show My Drive as the selected location. + */ +testcase.verifyDriveLocationOption = async () => { + // Open Files app on Downloads. + const appId = await setupAndWaitUntilReady(RootPath.DRIVE, [], [ + ENTRIES.hello, + ENTRIES.sharedDirectory, + ENTRIES.sharedDirectoryFile, + ]); + + // Navigate to Google Drive; make sure we have the desired files. + const directoryTree = await DirectoryTreePageObject.create(appId, remoteCall); + await directoryTree.navigateToPath('/My Drive'); + await remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows([ + ENTRIES.sharedDirectory, + ENTRIES.hello, + ])); + + // Search the Drive for all files with "b" in their name. + await remoteCall.typeSearchText(appId, 'hello'); + await remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows([ + ENTRIES.hello, + ])); + + // Check that the location shows My Drive. + chrome.test.assertEq( + 'Google Drive', await getSelectedOptionText(appId, 'location')); + + await directoryTree.navigateToPath('/My Drive/Shared'); + await remoteCall.typeSearchText(appId, 'file'); + await remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows([ + ENTRIES.sharedDirectoryFile, + ])); + chrome.test.assertEq( + 'Google Drive', await getSelectedOptionText(appId, 'location')); +};