1 From a577e7a76e6002e50b5ab27514b7f49d4070499c Mon Sep 17 00:00:00 2001
2 From: Max Ihlenfeldt <max@igalia.com>
3 Date: Wed, 30 Aug 2023 16:06:19 +0000
4 Subject: [PATCH 14/33] [meta-browser] Avoid std::ranges::find_if()
6 std::ranges::find_if() was introduced in C++20, and older versions of
7 clang don't support it. We can instead use Chromium's `base::ranges`
8 library, which is supported.
10 Upstream-Status: Inappropriate [specific to older versions of clang]
11 Signed-off-by: Max Ihlenfeldt <max@igalia.com>
13 .../password_manager/core/browser/ui/passwords_grouper.cc | 3 ++-
14 components/webauthn/core/browser/passkey_sync_bridge.cc | 5 +++--
15 2 files changed, 5 insertions(+), 3 deletions(-)
17 diff --git a/components/password_manager/core/browser/ui/passwords_grouper.cc b/components/password_manager/core/browser/ui/passwords_grouper.cc
18 index 1b016e0eb9561..d259c6accf246 100644
19 --- a/components/password_manager/core/browser/ui/passwords_grouper.cc
20 +++ b/components/password_manager/core/browser/ui/passwords_grouper.cc
22 #include "base/containers/flat_set.h"
23 #include "base/strings/escape.h"
24 #include "base/strings/string_util.h"
25 +#include "base/ranges/algorithm.h"
26 #include "components/password_manager/core/browser/affiliation/affiliation_service.h"
27 #include "components/password_manager/core/browser/affiliation/affiliation_utils.h"
28 #include "components/password_manager/core/browser/passkey_credential.h"
29 @@ -277,7 +278,7 @@ absl::optional<PasskeyCredential> PasswordsGrouper::GetPasskeyFor(
30 const std::vector<PasskeyCredential>& passkeys =
31 map_group_id_to_credentials_[group_id_iterator->second].passkeys;
32 const auto passkey_it =
33 - std::ranges::find_if(passkeys, [&credential](const auto& passkey) {
34 + base::ranges::find_if(passkeys, [&credential](const auto& passkey) {
35 return credential.passkey_credential_id == passkey.credential_id();
37 if (passkey_it == passkeys.end()) {
38 diff --git a/components/webauthn/core/browser/passkey_sync_bridge.cc b/components/webauthn/core/browser/passkey_sync_bridge.cc
39 index 93129fed756aa..794c696fcff04 100644
40 --- a/components/webauthn/core/browser/passkey_sync_bridge.cc
41 +++ b/components/webauthn/core/browser/passkey_sync_bridge.cc
43 #include "base/containers/span.h"
44 #include "base/feature_list.h"
45 #include "base/functional/callback_helpers.h"
46 +#include "base/ranges/algorithm.h"
47 #include "base/strings/string_number_conversions.h"
48 #include "base/trace_event/trace_event.h"
49 #include "components/sync/base/features.h"
50 @@ -258,7 +259,7 @@ PasskeySyncBridge::GetPasskeysForRelyingPartyId(
51 bool PasskeySyncBridge::DeletePasskey(const std::string& credential_id) {
52 // Find the credential with the given |credential_id|.
53 const auto passkey_it =
54 - std::ranges::find_if(data_, [&credential_id](const auto& passkey) {
55 + base::ranges::find_if(data_, [&credential_id](const auto& passkey) {
56 return passkey.second.credential_id() == credential_id;
58 if (passkey_it == data_.end()) {
59 @@ -309,7 +310,7 @@ bool PasskeySyncBridge::UpdatePasskey(const std::string& credential_id,
60 PasskeyChange change) {
61 // Find the credential with the given |credential_id|.
62 const auto passkey_it =
63 - std::ranges::find_if(data_, [&credential_id](const auto& passkey) {
64 + base::ranges::find_if(data_, [&credential_id](const auto& passkey) {
65 return passkey.second.credential_id() == credential_id;
67 if (passkey_it == data_.end()) {