[CodeHealth][cr146] base::Contains() to be deleted (#33668)

[CodeHealth] `base::Contains()` to be deleted

The remaining cases of `base::Contains` in the codebase can be just
`std::ranges::contains`.

This change was done mechanically, with the following script

```bash
files_using_header="$(git grep -l base::Contains | tr '\n' ' ')"
sed -i 's/base::Contains/std::ranges::contains/g' \
  ${files_using_header}
../tools/add_header.py --header '<algorithm>' ${files_using_header}
files_including_header="$(git grep -l base/containers/contains.h | tr '\n' ' ')"
../tools/add_header.py --header '"base/containers/contains.h"' \
  --remove ${files_including_header}
git cl format
```

This CL also cherry-picks the contents of https://crrev.com/c/7380987 to
permit the use of certain range operations.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/4e6249c911b515cc237707ba751290c6dbe9970f

commit 4e6249c911b515cc237707ba751290c6dbe9970f
Author: Victor Hugo Vianna Silva <victorvianna@google.com>
Date:   Sun Jan 18 11:32:26 2026 -0800

    Reland "Delete unused base::Contains()"

    This is a reland of commit 15af921783afac76cfc7d5beb04e4816ac0ffac7

    Original change's description:
    > Delete unused base::Contains()
    >
    > All callers were migrated.
    >
    > Fixed: 470391351
    > Change-Id: I404da9186a45c2c47669592242fac972ef70dfa3
    > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7459699
    > Auto-Submit: Victor Vianna <victorvianna@google.com>
    > Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
    > Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
    > Cr-Commit-Position: refs/heads/main@{#1570540}

    Bug: 470391351
    Change-Id: I858f7880bf8cb1857085eb44836dee4a0becf7ae
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7490440
    Owners-Override: Matthew Denton <mpdenton@chromium.org>
    Commit-Queue: Victor Vianna <victorvianna@google.com>
    Reviewed-by: Victor Vianna <victorvianna@google.com>
    Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
    Cr-Commit-Position: refs/heads/main@{#1570926}
This commit is contained in:
cdesouza-chromium
2026-02-05 13:09:25 -03:00
committed by GitHub
parent ec28381c31
commit cfaf4c8d49
65 changed files with 257 additions and 241 deletions
+3 -2
View File
@@ -5,7 +5,8 @@
#include "brave/app/command_utils.h"
#include "base/containers/contains.h"
#include <algorithm>
#include "base/containers/flat_set.h"
#include "base/test/scoped_feature_list.h"
#include "brave/components/commands/common/features.h"
@@ -24,7 +25,7 @@ TEST(CommandUtilsUnitTest, AllAcceleratedCommandsShouldBeAvailable) {
const auto& commands = commands::GetCommands();
for (const auto& accelerator : accelerators) {
EXPECT_TRUE(base::Contains(commands, accelerator.command_id))
EXPECT_TRUE(std::ranges::contains(commands, accelerator.command_id))
<< "Accelerated command '" << accelerator.command_id
<< "' was not present in the list of commands.";
}
+12 -11
View File
@@ -5,7 +5,8 @@
#include "brave/browser/ai_chat/upload_file_helper.h"
#include "base/containers/contains.h"
#include <algorithm>
#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@@ -126,16 +127,16 @@ TEST_F(UploadFileHelperTest, AcceptedFileExtensions) {
EXPECT_EQ(dialog_params_.type, ui::SelectFileDialog::SELECT_OPEN_MULTI_FILE);
ASSERT_TRUE(dialog_params_.file_types);
ASSERT_EQ(1u, dialog_params_.file_types->extensions.size());
EXPECT_TRUE(base::Contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("png")));
EXPECT_TRUE(base::Contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("jpeg")));
EXPECT_TRUE(base::Contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("jpg")));
EXPECT_TRUE(base::Contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("webp")));
EXPECT_TRUE(base::Contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("pdf")));
EXPECT_TRUE(std::ranges::contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("png")));
EXPECT_TRUE(std::ranges::contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("jpeg")));
EXPECT_TRUE(std::ranges::contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("jpg")));
EXPECT_TRUE(std::ranges::contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("webp")));
EXPECT_TRUE(std::ranges::contains(dialog_params_.file_types->extensions[0],
FILE_PATH_LITERAL("pdf")));
#if BUILDFLAG(IS_ANDROID)
EXPECT_THAT(dialog_params_.accept_types,
testing::UnorderedElementsAre(u"image/png", u"image/jpeg",
+1 -2
View File
@@ -9,7 +9,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "brave/browser/widevine/widevine_permission_request.h"
#include "brave/browser/widevine/widevine_utils.h"
#include "brave/components/constants/pref_names.h"
@@ -36,7 +35,7 @@ using component_updater::ComponentUpdateService;
namespace {
#if !BUILDFLAG(IS_ANDROID)
bool IsAlreadyRegistered(ComponentUpdateService* cus) {
return base::Contains(cus->GetComponentIDs(), kWidevineComponentId);
return std::ranges::contains(cus->GetComponentIDs(), kWidevineComponentId);
}
#if !BUILDFLAG(IS_LINUX)
content::WebContents* GetActiveWebContents() {
+3 -3
View File
@@ -13,7 +13,6 @@
#include "base/check.h"
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
@@ -320,8 +319,9 @@ void BraveNewsTabHelper::OnPublishersChanged() {
feed.subscribed =
subscriptions.enabled_publishers().contains(
feed.combined_publisher_id) ||
base::Contains(subscriptions.direct_feeds(), feed.feed_url,
[](const auto& direct_feed) { return direct_feed.url; });
std::ranges::contains(
subscriptions.direct_feeds(), feed.feed_url,
[](const auto& direct_feed) { return direct_feed.url; });
}
controller_->GetPublishers(
base::BindOnce(&BraveNewsTabHelper::OnReceivedNewPublishers,
@@ -11,7 +11,6 @@
#include "base/android/jni_android.h"
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/feature_list.h"
#include "base/json/json_writer.h"
@@ -119,8 +118,8 @@ bool BraveRewardsNativeWorker::ShouldShowSelfCustodyInvite(JNIEnv* env) {
std::string country_code = brave_rewards_service_->GetCountryCode();
const std::vector<std::string> providers =
brave_rewards_service_->GetExternalWalletProviders();
if (!base::Contains(providers,
brave_rewards::internal::constant::kWalletSolana)) {
if (!std::ranges::contains(
providers, brave_rewards::internal::constant::kWalletSolana)) {
return false;
}
@@ -135,8 +134,8 @@ bool BraveRewardsNativeWorker::ShouldShowSelfCustodyInvite(JNIEnv* env) {
return true;
}
return base::Contains(allow, country_code) ||
(!block.empty() && !base::Contains(block, country_code));
return std::ranges::contains(allow, country_code) ||
(!block.empty() && !std::ranges::contains(block, country_code));
}
void BraveRewardsNativeWorker::CreateRewardsWallet(
@@ -494,8 +493,8 @@ bool BraveRewardsNativeWorker::CanConnectAccount(JNIEnv* env) {
return true;
}
return base::Contains(allow, country_code) ||
(!block.empty() && !base::Contains(block, country_code));
return std::ranges::contains(allow, country_code) ||
(!block.empty() && !std::ranges::contains(block, country_code));
});
}
@@ -5,7 +5,8 @@
#include "brave/components/brave_wallet/browser/asset_discovery_manager.h"
#include "base/containers/contains.h"
#include <algorithm>
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/test/bind.h"
@@ -190,10 +191,10 @@ TEST_F(AssetDiscoveryManagerUnitTest, GetFungibleSupportedChains) {
auto chains1 = asset_discovery_manager_->GetFungibleSupportedChains();
auto chains2 = asset_discovery_manager_->GetFungibleSupportedChains();
auto chains3 = asset_discovery_manager_->GetFungibleSupportedChains();
EXPECT_TRUE(base::Contains(
EXPECT_TRUE(std::ranges::contains(
chains1,
mojom::ChainId::New(mojom::CoinType::ETH, mojom::kMainnetChainId)));
EXPECT_TRUE(base::Contains(
EXPECT_TRUE(std::ranges::contains(
chains1,
mojom::ChainId::New(mojom::CoinType::SOL, mojom::kSolanaMainnet)));
@@ -205,15 +206,15 @@ TEST_F(AssetDiscoveryManagerUnitTest, GetNonFungibleSupportedChains) {
// Gnosis chain ID should not be included if it's not a custom network
auto chains = asset_discovery_manager_->GetNonFungibleSupportedChains();
EXPECT_EQ(chains.size(), 8UL);
EXPECT_TRUE(base::Contains(
EXPECT_TRUE(std::ranges::contains(
chains,
mojom::ChainId::New(mojom::CoinType::ETH, mojom::kMainnetChainId)));
EXPECT_TRUE(base::Contains(
EXPECT_TRUE(std::ranges::contains(
chains,
mojom::ChainId::New(mojom::CoinType::SOL, mojom::kSolanaMainnet)));
// Verify none of the chain IDs == mojom::kGnosisChainId
EXPECT_FALSE(base::Contains(
EXPECT_FALSE(std::ranges::contains(
chains,
mojom::ChainId::New(mojom::CoinType::ETH, mojom::kGnosisChainId)));
@@ -225,7 +226,7 @@ TEST_F(AssetDiscoveryManagerUnitTest, GetNonFungibleSupportedChains) {
EXPECT_EQ(chains.size(), 9UL);
// Verify one of the chain IDs is mojom::kGnosisChainId
EXPECT_TRUE(base::Contains(
EXPECT_TRUE(std::ranges::contains(
chains,
mojom::ChainId::New(mojom::CoinType::ETH, mojom::kGnosisChainId)));
}
@@ -3,9 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include <memory>
#include "base/containers/contains.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/path_service.h"
@@ -329,8 +329,8 @@ IN_PROC_BROWSER_TEST_F(EmailAliasesBrowserNoFeatureTest, NoContextMenuItem) {
ContextMenuWaiter menu_waiter(IDC_NEW_EMAIL_ALIAS);
RunContextMenuOn("type-email");
menu_waiter.WaitForMenuOpenAndClose();
EXPECT_FALSE(base::Contains(menu_waiter.GetCapturedEnabledCommandIds(),
IDC_NEW_EMAIL_ALIAS));
EXPECT_FALSE(std::ranges::contains(menu_waiter.GetCapturedEnabledCommandIds(),
IDC_NEW_EMAIL_ALIAS));
EXPECT_FALSE(menu_waiter.IsCommandExecuted());
}
@@ -341,8 +341,8 @@ IN_PROC_BROWSER_TEST_F(EmailAliasesBrowserTest,
ContextMenuWaiter menu_waiter(IDC_NEW_EMAIL_ALIAS);
RunContextMenuOn("type-url");
menu_waiter.WaitForMenuOpenAndClose();
EXPECT_FALSE(base::Contains(menu_waiter.GetCapturedEnabledCommandIds(),
IDC_NEW_EMAIL_ALIAS));
EXPECT_FALSE(std::ranges::contains(menu_waiter.GetCapturedEnabledCommandIds(),
IDC_NEW_EMAIL_ALIAS));
EXPECT_FALSE(menu_waiter.IsCommandExecuted());
}
@@ -11,7 +11,6 @@
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
@@ -73,7 +72,7 @@ bool PrepareTabForFirstPartyStorageCleanup(
}
const auto tab_tld =
net::URLToEphemeralStorageDomain(contents->GetLastCommittedURL());
if (tab_tld.empty() || !base::Contains(ephemeral_domains, tab_tld)) {
if (tab_tld.empty() || !std::ranges::contains(ephemeral_domains, tab_tld)) {
return false;
}
@@ -8,7 +8,6 @@
#include <algorithm>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/callback_helpers.h"
@@ -732,7 +731,7 @@ TEST_F(PlaylistServiceUnitTest, AddItemsToList) {
service->GetPlaylistItem(
item_id, base::BindLambdaForTesting([](mojom::PlaylistItemPtr item) {
ASSERT_EQ(item->parents.size(), 1u);
EXPECT_TRUE(base::Contains(item->parents, kDefaultPlaylistID));
EXPECT_TRUE(std::ranges::contains(item->parents, kDefaultPlaylistID));
}));
}
@@ -754,8 +753,9 @@ TEST_F(PlaylistServiceUnitTest, AddItemsToList) {
service->GetPlaylistItem(
id, base::BindLambdaForTesting([&](mojom::PlaylistItemPtr item) {
EXPECT_EQ(item->parents.size(), 2u);
EXPECT_TRUE(base::Contains(item->parents, kDefaultPlaylistID));
EXPECT_TRUE(base::Contains(item->parents, another_playlist_id));
EXPECT_TRUE(std::ranges::contains(item->parents, kDefaultPlaylistID));
EXPECT_TRUE(
std::ranges::contains(item->parents, another_playlist_id));
}));
}
@@ -810,7 +810,7 @@ TEST_F(PlaylistServiceUnitTest, MoveItem) {
service->GetPlaylistItem(
item_id, base::BindLambdaForTesting([](mojom::PlaylistItemPtr item) {
ASSERT_EQ(item->parents.size(), 1u);
ASSERT_TRUE(base::Contains(item->parents, kDefaultPlaylistID));
ASSERT_TRUE(std::ranges::contains(item->parents, kDefaultPlaylistID));
}));
}
@@ -843,7 +843,8 @@ TEST_F(PlaylistServiceUnitTest, MoveItem) {
service->GetPlaylistItem(
item_id, base::BindLambdaForTesting([&](mojom::PlaylistItemPtr item) {
ASSERT_EQ(item->parents.size(), 1u);
ASSERT_TRUE(base::Contains(item->parents, another_playlist_id));
ASSERT_TRUE(
std::ranges::contains(item->parents, another_playlist_id));
}));
}
@@ -1101,7 +1102,8 @@ TEST_F(PlaylistServiceUnitTest, RemoveItemFromPlaylist) {
service->GetPlaylistItem(
id, base::BindLambdaForTesting([&](mojom::PlaylistItemPtr item) {
EXPECT_EQ(item->parents.size(), 1u);
EXPECT_TRUE(base::Contains(item->parents, another_playlist_id));
EXPECT_TRUE(
std::ranges::contains(item->parents, another_playlist_id));
}));
}
}
@@ -1285,10 +1287,10 @@ TEST_F(PlaylistServiceUnitTest, MigratePlaylistOrder) {
}
// Playlist order pref should have only default playlist id
EXPECT_TRUE(base::Contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(kDefaultPlaylistID)));
EXPECT_FALSE(base::Contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(*playlist->id)));
EXPECT_TRUE(std::ranges::contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(kDefaultPlaylistID)));
EXPECT_FALSE(std::ranges::contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(*playlist->id)));
// Call migration
auto new_order_list = prefs()->GetList(kPlaylistOrderPref).Clone();
@@ -1296,8 +1298,8 @@ TEST_F(PlaylistServiceUnitTest, MigratePlaylistOrder) {
prefs()->SetList(kPlaylistOrderPref, std::move(new_order_list));
// After migration, the order pref should have both default and new playlist
EXPECT_TRUE(base::Contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(*playlist->id)));
EXPECT_TRUE(std::ranges::contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(*playlist->id)));
// Remove a playlist from playlists pref and not from order pref.
// https://github.com/brave/brave-browser/issues/35500
@@ -1311,14 +1313,14 @@ TEST_F(PlaylistServiceUnitTest, MigratePlaylistOrder) {
prefs()->SetList(kPlaylistOrderPref, std::move(new_order_list));
// After migration, the dangled item in the order pref should be gone.
EXPECT_FALSE(base::Contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(*playlist->id)));
EXPECT_FALSE(std::ranges::contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(*playlist->id)));
}
TEST_F(PlaylistServiceUnitTest, PlaylistOrderSync) {
// Pre-condition: Order pref should only have the default playlist
EXPECT_TRUE(base::Contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(kDefaultPlaylistID)));
EXPECT_TRUE(std::ranges::contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(kDefaultPlaylistID)));
EXPECT_EQ(1u, prefs()->GetList(kPlaylistOrderPref).size());
// After creating a new playlist, order pref should contain that.
@@ -1328,14 +1330,14 @@ TEST_F(PlaylistServiceUnitTest, PlaylistOrderSync) {
base::BindLambdaForTesting(
[&](mojom::PlaylistPtr playlist) { new_id = *playlist->id; }));
EXPECT_TRUE(base::Contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(new_id)));
EXPECT_TRUE(std::ranges::contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(new_id)));
EXPECT_EQ(2u, prefs()->GetList(kPlaylistOrderPref).size());
// After creating the playlist, order pref shouldn't contain that.
playlist_service()->RemovePlaylist(new_id);
EXPECT_FALSE(base::Contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(new_id)));
EXPECT_FALSE(std::ranges::contains(prefs()->GetList(kPlaylistOrderPref),
base::Value(new_id)));
EXPECT_EQ(1u, prefs()->GetList(kPlaylistOrderPref).size());
}
@@ -3,11 +3,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/weak_ptr.h"
@@ -190,10 +190,10 @@ class ClientHintsBrowserTest : public InProcessBrowserTest,
for (const auto& elem : network::GetClientHintToNameMap()) {
const auto& header = elem.second;
if (request.headers.contains(header)) {
if (base::Contains(default_hints_, header)) {
if (std::ranges::contains(default_hints_, header)) {
default_client_hints_headers_seen_.insert(header);
continue;
} else if (base::Contains(allowed_hints_, header)) {
} else if (std::ranges::contains(allowed_hints_, header)) {
allowed_client_hints_headers_seen_.insert(header);
continue;
}
+4 -5
View File
@@ -11,7 +11,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/containers/map_util.h"
@@ -163,7 +162,7 @@ void AcceleratorService::UpdateDefaultAccelerators() {
std::ranges::copy_if(
new_accelerators, std::back_inserter(added[command_id]),
[&old_accelerators, &system_managed](const auto& accelerator) {
return !base::Contains(old_accelerators, accelerator) ||
return !std::ranges::contains(old_accelerators, accelerator) ||
// If the accelerator is marked as a system command, be sure to
// reset it.
system_managed.contains(accelerator);
@@ -173,7 +172,7 @@ void AcceleratorService::UpdateDefaultAccelerators() {
std::ranges::copy_if(
old_accelerators, std::back_inserter(removed[command_id]),
[&new_accelerators](const auto& accelerator) {
return !base::Contains(new_accelerators, accelerator);
return !std::ranges::contains(new_accelerators, accelerator);
});
}
@@ -344,8 +343,8 @@ std::vector<int> AcceleratorService::AssignAccelerator(
if (std::erase_if(
accelerators, [&accelerator, &system_managed, &default_accelerators,
other_command_id](const auto& other) {
bool is_default_accelerator =
base::Contains(default_accelerators[other_command_id], other);
bool is_default_accelerator = std::ranges::contains(
default_accelerators[other_command_id], other);
// Note: We don't erase system managed default accelerators, as
// the system can register the same accelerator for multiple
// commands, and we don't want resetting one to reset the other.
+4 -5
View File
@@ -10,7 +10,6 @@
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/logging.h"
@@ -534,8 +533,8 @@ void SharedPinnedTabService::OnTabRemoved(
DVLOG(2) << __FUNCTION__;
DCHECK(remove);
if (base::Contains(closing_browsers_, tab_strip_model,
&Browser::tab_strip_model)) {
if (std::ranges::contains(closing_browsers_, tab_strip_model,
&Browser::tab_strip_model)) {
// We don't close pinned tabs if this browser is being closed.
return;
}
@@ -583,8 +582,8 @@ void SharedPinnedTabService::OnActiveTabChanged(
return;
}
if (base::Contains(closing_browsers_, tab_strip_model,
&Browser::tab_strip_model)) {
if (std::ranges::contains(closing_browsers_, tab_strip_model,
&Browser::tab_strip_model)) {
return;
}
@@ -7,12 +7,12 @@
#import <Cocoa/Cocoa.h>
#include <algorithm>
#include <optional>
#include "base/check.h"
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
@@ -36,7 +36,7 @@ bool CanConvertToAcceleratorMapping(int command_id) {
return false;
}
return base::Contains(commands::GetCommands(), command_id);
return std::ranges::contains(commands::GetCommands(), command_id);
}
bool CanConvertToAcceleratorMapping(NSMenuItem* item) {
+1 -2
View File
@@ -13,7 +13,6 @@
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/task/sequenced_task_runner.h"
@@ -693,7 +692,7 @@ void BraveBrowserView::OnAcceleratorsChanged(
// Unregister removed accelerators
for (const auto& old_accelerator : old_accelerators) {
if (base::Contains(accelerators, old_accelerator)) {
if (std::ranges::contains(accelerators, old_accelerator)) {
continue;
}
focus_manager->UnregisterAccelerator(old_accelerator, this);
@@ -9,7 +9,6 @@
#include <utility>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "brave/app/vector_icons/vector_icons.h"
#include "brave/browser/themes/brave_theme_service.h"
@@ -354,8 +353,8 @@ void BraveLocationBarView::ChildVisibilityChanged(views::View* child) {
// the size changes when an icon is shown or hidden. The LocationBarView
// does not listen to ChildVisibilityChanged events so we must make we Layout
// and re-caculate trailing decorator positions when a child changes.
if (base::Contains(GetLeftMostTrailingViews(), child) ||
base::Contains(GetRightMostTrailingViews(), child)) {
if (std::ranges::contains(GetLeftMostTrailingViews(), child) ||
std::ranges::contains(GetRightMostTrailingViews(), child)) {
DeprecatedLayoutImmediately();
SchedulePaint();
}
@@ -7,7 +7,8 @@
#include "brave/browser/ui/webui/brave_browser_command/brave_browser_command_handler.h"
#include "base/containers/contains.h"
#include <algorithm>
#include "brave/browser/brave_rewards/rewards_service_factory.h"
#include "brave/components/ai_chat/core/common/buildflags/buildflags.h"
#include "brave/components/brave_education/education_urls.h"
@@ -76,7 +77,7 @@ BraveBrowserCommandHandler::~BraveBrowserCommandHandler() = default;
void BraveBrowserCommandHandler::CanExecuteCommand(
brave_browser_command::mojom::Command command_id,
CanExecuteCommandCallback callback) {
if (!base::Contains(supported_commands_, command_id)) {
if (!std::ranges::contains(supported_commands_, command_id)) {
std::move(callback).Run(false);
return;
}
@@ -106,7 +107,7 @@ void BraveBrowserCommandHandler::CanExecuteCommand(
void BraveBrowserCommandHandler::ExecuteCommand(
brave_browser_command::mojom::Command command_id,
ExecuteCommandCallback callback) {
if (!base::Contains(supported_commands_, command_id)) {
if (!std::ranges::contains(supported_commands_, command_id)) {
std::move(callback).Run(false);
return;
}
@@ -8,7 +8,6 @@
#include <algorithm>
#include <vector>
#include "base/containers/contains.h"
#include "brave/browser/ai_chat/ai_chat_service_factory.h"
#include "brave/browser/ui/sidebar/sidebar_service_factory.h"
#include "brave/components/ai_chat/core/browser/ai_chat_service.h"
@@ -164,9 +163,9 @@ void BraveLeoAssistantHandler::HandleGetLeoIconVisibility(
const auto hidden_items = service->GetHiddenDefaultSidebarItems();
AllowJavascript();
ResolveJavascriptCallback(
args[0], !base::Contains(hidden_items,
sidebar::SidebarItem::BuiltInItemType::kChatUI,
&sidebar::SidebarItem::built_in_item_type));
args[0], !std::ranges::contains(
hidden_items, sidebar::SidebarItem::BuiltInItemType::kChatUI,
&sidebar::SidebarItem::built_in_item_type));
}
void BraveLeoAssistantHandler::HandleResetLeoData(
@@ -74,7 +74,7 @@ void TestLauncher::MaybeSaveSummaryAsJSON(
// This may be called from TestLauncher_ChromiumImpl::OnTestFinished() when a
// lot of test has failed and the TestLauncher decides to do an early exit.
if (teamcity_reporter_ &&
Contains(additional_tags, "BROKEN_TEST_EARLY_EXIT")) {
std::ranges::contains(additional_tags, "BROKEN_TEST_EARLY_EXIT")) {
// TestLauncher will call exit(1) before returning from OnTestFinished(), so
// log the test suite shutdown here while we can.
teamcity_reporter_->OnBrokenTestEarlyExit();
@@ -8,7 +8,6 @@
#include <utility>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
@@ -77,7 +76,7 @@ bool CanImportURL(const GURL& url) {
}
}
if (base::Contains(chrome::ChromeDebugURLs(), fixed_url.spec())) {
if (std::ranges::contains(chrome::ChromeDebugURLs(), fixed_url.spec())) {
return true;
}
@@ -3,12 +3,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include <optional>
#include <string>
#include "base/check.h"
#include "base/check_is_test.h"
#include "base/containers/contains.h"
#include "brave/components/brave_wallet/common/buildflags/buildflags.h"
#define BRAVE_PERMISSION_REQUEST_MANAGER_GET_REQUESTING_ORIGIN \
@@ -83,10 +83,10 @@ void PermissionRequestManager::AcceptDenyCancel(
cancelled_requests.size()) == requests_.size());
for (const auto& request : requests_) {
if (base::Contains(accepted_requests, request.get())) {
if (std::ranges::contains(accepted_requests, request.get())) {
PermissionGrantedIncludingDuplicates(request.get(),
/*is_one_time=*/false);
} else if (base::Contains(denied_requests, request.get())) {
} else if (std::ranges::contains(denied_requests, request.get())) {
PermissionDeniedIncludingDuplicates(request.get());
} else {
CancelRequestIncludingDuplicates(request.get());
@@ -3,7 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include "base/containers/contains.h"
#include <algorithm>
#include "base/sanitizer_buildflags.h"
#include "build/build_config.h"
@@ -24,7 +25,7 @@ constexpr std::array<std::string_view, 1> kFieldTrialExceptions = {
// that we always disable, so we must skip this CHECK for those flags.
#define GetEnabledFieldTrialByFeatureName(FEATURE) \
GetEnabledFieldTrialByFeatureName(FEATURE) || \
base::Contains(kFieldTrialExceptions, FEATURE)
std::ranges::contains(kFieldTrialExceptions, FEATURE)
#endif
#include <content/test/content_test_suite.cc>
@@ -3,10 +3,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include "net/url_request/redirect_util.h"
#include <algorithm>
#include <optional>
#include "base/containers/contains.h"
#include "net/url_request/redirect_util.h"
#include "net/url_request/url_request_job.h"
#define UpdateHttpRequest UpdateHttpRequest_ChromiumImpl
@@ -32,7 +33,7 @@ void RedirectUtil::UpdateHttpRequest(
should_clear_upload);
// Hack for capping referrers at the network layer.
if (removed_headers) {
if (base::Contains(*removed_headers, "X-Brave-Cap-Referrer")) {
if (std::ranges::contains(*removed_headers, "X-Brave-Cap-Referrer")) {
GURL capped_referrer = URLRequestJob::ComputeReferrerForPolicy(
ReferrerPolicy::REDUCE_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN,
GURL(redirect_info.new_referrer), redirect_info.new_url);
@@ -20,7 +20,6 @@
#include "base/base64.h"
#include "base/check.h"
#include "base/containers/checked_iterators.h"
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/field_trial_params.h"
@@ -982,7 +981,7 @@ void ModelService::MaybeDeleteCustomModels(CustomModelPredicate predicate) {
void ModelService::SetDefaultModelKey(const std::string& new_key) {
const auto& models = GetModels();
bool does_model_exist = base::Contains(
bool does_model_exist = std::ranges::contains(
models, new_key, [](const mojom::ModelPtr& model) { return model->key; });
if (!does_model_exist) {
@@ -9,7 +9,6 @@
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/strings/string_number_conversions.h"
#include "brave/components/brave_ads/content/browser/creatives/search_result_ad/creative_search_result_ad_constants.h"
#include "brave/components/brave_ads/content/browser/creatives/search_result_ad/creative_search_result_ad_mojom_test_util.h"
@@ -110,7 +109,7 @@ class CreativeAdMojomWebPageEntitiesConstructor final {
std::vector<schema_org::mojom::PropertyPtr>* mojom_properties,
const std::string& name,
T value) {
if (!base::Contains(excluded_property_names_, name)) {
if (!std::ranges::contains(excluded_property_names_, name)) {
AddMojomProperty<T>(mojom_properties, name, std::move(value));
}
}
@@ -8,7 +8,6 @@
#include <algorithm>
#include "base/check_op.h"
#include "base/containers/contains.h"
namespace brave_ads {
@@ -58,7 +57,7 @@ void ConfirmationTokens::Remove(
std::erase_if(
confirmation_tokens_,
[&confirmation_tokens](const ConfirmationTokenInfo& confirmation_token) {
return base::Contains(confirmation_tokens, confirmation_token);
return std::ranges::contains(confirmation_tokens, confirmation_token);
});
}
@@ -69,7 +68,7 @@ void ConfirmationTokens::RemoveAll() {
bool ConfirmationTokens::Exists(
const ConfirmationTokenInfo& confirmation_token) const {
return base::Contains(confirmation_tokens_, confirmation_token);
return std::ranges::contains(confirmation_tokens_, confirmation_token);
}
size_t ConfirmationTokens::Count() const {
@@ -8,7 +8,6 @@
#include <algorithm>
#include "base/check_op.h"
#include "base/containers/contains.h"
namespace brave_ads {
@@ -54,7 +53,7 @@ bool PaymentTokens::RemoveToken(const PaymentTokenInfo& payment_token) {
void PaymentTokens::RemoveTokens(const PaymentTokenList& payment_tokens) {
std::erase_if(payment_tokens_,
[&payment_tokens](const PaymentTokenInfo& payment_token) {
return base::Contains(payment_tokens, payment_token);
return std::ranges::contains(payment_tokens, payment_token);
});
}
@@ -64,7 +63,7 @@ void PaymentTokens::RemoveAllTokens() {
}
bool PaymentTokens::TokenExists(const PaymentTokenInfo& payment_token) {
return base::Contains(payment_tokens_, payment_token);
return std::ranges::contains(payment_tokens_, payment_token);
}
size_t PaymentTokens::Count() const {
@@ -5,7 +5,8 @@
#include "brave/components/brave_ads/core/internal/serving/prediction/model_based/input_variable/creative_ad_model_based_predictor_input_variable_util.h"
#include "base/containers/contains.h"
#include <algorithm>
#include "brave/components/brave_ads/core/internal/segments/segment_alias.h"
#include "brave/components/brave_ads/core/internal/segments/segment_constants.h"
#include "brave/components/brave_ads/core/internal/segments/segment_util.h"
@@ -26,11 +27,11 @@ ComputeSegmentInputVariable(
CreativeAdModelBasedPredictorSegmentInputVariablesInfo segment_input_variable;
segment_input_variable.child_matches.value =
base::Contains(top_child_segments, segment);
std::ranges::contains(top_child_segments, segment);
segment_input_variable.child_matches.weight = weights.child;
segment_input_variable.parent_matches.value =
base::Contains(top_parent_segments, GetParentSegment(segment));
std::ranges::contains(top_parent_segments, GetParentSegment(segment));
segment_input_variable.parent_matches.weight = weights.parent;
return segment_input_variable;
@@ -10,7 +10,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
@@ -106,9 +105,9 @@ SubscriptionsSnapshot BraveNewsPrefManager::GetSubscriptions() {
void BraveNewsPrefManager::SetPublisherSubscribed(
const std::string& publisher_id,
brave_news::mojom::UserEnabled enabled) {
bool is_direct_feed =
base::Contains(GetDirectFeeds(), publisher_id,
[](const auto& direct_feed) { return direct_feed.id; });
bool is_direct_feed = std::ranges::contains(
GetDirectFeeds(), publisher_id,
[](const auto& direct_feed) { return direct_feed.id; });
if (is_direct_feed && enabled == mojom::UserEnabled::DISABLED) {
ScopedDictPrefUpdate update(&*prefs_, prefs::kBraveNewsDirectFeeds);
@@ -5,9 +5,9 @@
#include "brave/components/brave_news/browser/brave_news_pref_manager.h"
#include <algorithm>
#include <memory>
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "brave/components/brave_news/common/brave_news.mojom.h"
#include "brave/components/brave_news/common/pref_names.h"
@@ -81,8 +81,8 @@ TEST_F(BraveNewsPrefManagerTest, ChannelsDiffIsSane) {
diff = five.DiffChannels(four);
EXPECT_EQ(2u, diff.changed.size());
EXPECT_TRUE(base::Contains(diff.changed, "Politics"));
EXPECT_TRUE(base::Contains(diff.changed, "FooBar"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "Politics"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "FooBar"));
}
TEST_F(BraveNewsPrefManagerTest, PublishersDiffIsSane) {
@@ -120,7 +120,7 @@ TEST_F(BraveNewsPrefManagerTest, PublishersDiffIsSane) {
EXPECT_TRUE(distinct_changes.contains(direct_three));
EXPECT_EQ(1u, diff.removed.size());
EXPECT_TRUE(base::Contains(diff.removed, direct_one));
EXPECT_TRUE(std::ranges::contains(diff.removed, direct_one));
}
TEST_F(BraveNewsPrefManagerTest, DirectFeedCanBeInspectedAndRemoved) {
@@ -9,7 +9,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "brave/components/brave_news/browser/channel_migrator.h"
@@ -66,7 +65,8 @@ Channels ChannelsController::GetChannelsFromPublishers(
for (const auto& locale_info : it.second->locales) {
for (auto& [channel_id, channel] : channels) {
// We already know we're subscribed to this channel in this locale.
if (base::Contains(channel->subscribed_locales, locale_info->locale)) {
if (std::ranges::contains(channel->subscribed_locales,
locale_info->locale)) {
continue;
}
@@ -9,7 +9,6 @@
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "brave/components/api_request_helper/api_request_helper.h"
#include "brave/components/brave_news/browser/brave_news_controller.h"
@@ -144,7 +143,7 @@ TEST_F(BraveNewsChannelsControllerTest, GetAllChannelsLoadsSubscribedState) {
auto one = channels.find("One");
ASSERT_NE(channels.end(), one);
EXPECT_TRUE(base::Contains(one->second->subscribed_locales, "en_US"));
EXPECT_TRUE(std::ranges::contains(one->second->subscribed_locales, "en_US"));
auto two = channels.find("Two");
ASSERT_NE(channels.end(), two);
@@ -156,7 +155,7 @@ TEST_F(BraveNewsChannelsControllerTest, GetAllChannelsLoadsSubscribedState) {
auto five = channels.find("Five");
ASSERT_NE(channels.end(), five);
EXPECT_TRUE(base::Contains(five->second->subscribed_locales, "en_US"));
EXPECT_TRUE(std::ranges::contains(five->second->subscribed_locales, "en_US"));
}
TEST_F(BraveNewsChannelsControllerTest,
@@ -172,13 +171,13 @@ TEST_F(BraveNewsChannelsControllerTest,
// In the en_US region, only the channel 'One' should be subscribed.
for (const auto& it : channels) {
EXPECT_EQ(it.first == "One",
base::Contains(it.second->subscribed_locales, "en_US"));
std::ranges::contains(it.second->subscribed_locales, "en_US"));
}
// In the ja_JA region, only the channel 'Five' should be subscribed.
for (const auto& it : channels) {
EXPECT_EQ(it.first == "Five",
base::Contains(it.second->subscribed_locales, "ja_JA"));
std::ranges::contains(it.second->subscribed_locales, "ja_JA"));
}
}
@@ -9,7 +9,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/values.h"
#include "brave/components/brave_news/common/brave_news.mojom-shared.h"
#include "brave/components/brave_news/common/brave_news.mojom.h"
@@ -69,9 +68,9 @@ TEST(BraveNewsCombinedFeedParsing, GetItemWithChannels) {
auto channels = feed_items[0]->get_article()->data->channels;
EXPECT_EQ(3u, channels.size());
EXPECT_TRUE(base::Contains(channels, "One"));
EXPECT_TRUE(base::Contains(channels, "Two"));
EXPECT_TRUE(base::Contains(channels, "Three"));
EXPECT_TRUE(std::ranges::contains(channels, "One"));
EXPECT_TRUE(std::ranges::contains(channels, "Two"));
EXPECT_TRUE(std::ranges::contains(channels, "Three"));
}
TEST(BraveNewsCombinedFeedParsing, FailBadProtocol) {
@@ -15,7 +15,6 @@
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
@@ -293,8 +292,8 @@ bool ShouldDisplayFeedItem(const mojom::FeedItemPtr& feed_item,
for (const auto& channel_id : locale_info->channels) {
if (channels.contains(channel_id)) {
const auto& channel = channels.at(channel_id);
if (base::Contains(channel->subscribed_locales,
locale_info->locale)) {
if (std::ranges::contains(channel->subscribed_locales,
locale_info->locale)) {
VLOG(2) << "Showing article because publisher "
<< data->publisher_id << ": " << publisher->publisher_name
<< " is in channel " << locale_info->locale << "."
@@ -14,7 +14,6 @@
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/map_util.h"
#include "base/containers/span.h"
#include "base/logging.h"
@@ -124,7 +123,7 @@ ArticleInfos GetArticleInfos(const std::string& locale,
auto channels = GetChannelsForPublisher(locale, publisher);
if (std::ranges::any_of(kSensitiveChannels,
[&](const std::string& channel) {
return base::Contains(channels, channel);
return std::ranges::contains(channels, channel);
})) {
non_discoverable_publishers.insert(publisher_id);
}
@@ -12,7 +12,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
@@ -135,8 +134,8 @@ TEST_F(BraveNewsFeedGenerationInfoTest, CanCreateFeedGenerationInfo) {
EXPECT_EQ(3u, content_groups.size());
auto has_group = [&content_groups](const std::string& group) {
return base::Contains(content_groups, group,
[](const auto& other) { return other.first; });
return std::ranges::contains(content_groups, group,
[](const auto& other) { return other.first; });
};
EXPECT_TRUE(has_group(kTopNewsChannel));
EXPECT_TRUE(has_group(kFooChannel));
@@ -198,7 +197,7 @@ TEST_F(BraveNewsFeedGenerationInfoTest,
auto channels = info.EligibleChannels();
EXPECT_EQ(1u, channels.size());
EXPECT_TRUE(base::Contains(channels, kFooChannel));
EXPECT_TRUE(std::ranges::contains(channels, kFooChannel));
}
TEST(BraveNewsFeedSampling, GetArticleInfosSkipsNull) {
@@ -15,7 +15,6 @@
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/containers/map_util.h"
#include "base/containers/span.h"
@@ -219,7 +218,8 @@ std::vector<mojom::FeedItemV2Ptr> GenerateBlockFromContentGroups(
if (/*is_channel*/ content_group.second) {
auto channels =
publisher_id_to_channels->data.find(article->publisher_id);
if (base::Contains(channels->second, content_group.first)) {
if (std::ranges::contains(channels->second,
content_group.first)) {
return meta.weighting;
}
@@ -694,7 +694,8 @@ void FeedV2Builder::BuildChannelFeed(const SubscriptionsSnapshot& subscriptions,
continue;
}
if (!base::Contains(locale_info_it->get()->channels, channel)) {
if (!std::ranges::contains(locale_info_it->get()->channels,
channel)) {
continue;
}
@@ -1014,7 +1015,7 @@ void FeedV2Builder::GenerateFeed(const SubscriptionsSnapshot& subscriptions,
for (const auto& [channel_id, channel] :
builder->channels_controller_->GetChannelsFromPublishers(
publishers, builder->current_update_->subscriptions)) {
if (base::Contains(channel->subscribed_locales, locale)) {
if (std::ranges::contains(channel->subscribed_locales, locale)) {
channels.push_back(channel_id);
}
}
@@ -14,7 +14,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/time/time.h"
#include "brave/components/brave_news/browser/channels_controller.h"
@@ -152,12 +151,13 @@ std::optional<size_t> PickPeekingCardWithMax(
const auto& article = get_article(index);
// In the morning, weight news higher
if (6 <= exploded.hour && exploded.hour < 10 &&
base::Contains(article->channels, kTopNewsChannel)) {
std::ranges::contains(article->channels, kTopNewsChannel)) {
score += kMorningNewsBoost;
// In the evening, weight entertainment higher
} else if (17 <= exploded.hour && exploded.hour <= 22 &&
base::Contains(article->channels, kEntertainmentChannel)) {
std::ranges::contains(article->channels,
kEntertainmentChannel)) {
score += kEveningEntertainmentBoost;
}
}
@@ -9,7 +9,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
@@ -113,8 +112,9 @@ class BraveNewsPublishersControllerTest : public testing::Test {
}
bool DirectSourceExists(const std::string& publisher_id) {
return base::Contains(pref_manager_->GetSubscriptions().direct_feeds(),
publisher_id, &DirectFeed::id);
return std::ranges::contains(
pref_manager_->GetSubscriptions().direct_feeds(), publisher_id,
&DirectFeed::id);
}
Publishers GetPublishers() {
@@ -10,7 +10,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/containers/map_util.h"
@@ -195,7 +194,7 @@ SuggestionsController::GetSuggestedPublisherIdsWithHistory(
// If this publisher isn't available in the current locale we don't want
// it to affect our suggestions.
if (!base::Contains(locales, locale_)) {
if (!std::ranges::contains(locales, locale_)) {
continue;
}
@@ -9,7 +9,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
@@ -252,11 +251,11 @@ TEST_F(BraveNewsSuggestionsControllerTest,
EXPECT_EQ(3u, suggestions.size());
// Note: Don't care about order here - we're going to be tweaking the weights
// and we don't want the test to fail all the time.
EXPECT_TRUE(base::Contains(suggestions, "1")); // Visited
EXPECT_TRUE(
base::Contains(suggestions, "2")); // Similar to P3 (which is subscribed)
EXPECT_TRUE(
base::Contains(suggestions, "4")); // Similar to P1 (which was visited)
EXPECT_TRUE(std::ranges::contains(suggestions, "1")); // Visited
EXPECT_TRUE(std::ranges::contains(
suggestions, "2")); // Similar to P3 (which is subscribed)
EXPECT_TRUE(std::ranges::contains(suggestions,
"4")); // Similar to P1 (which was visited)
}
TEST_F(BraveNewsSuggestionsControllerTest,
@@ -11,8 +11,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
namespace brave_news {
SubscriptionsDiff::SubscriptionsDiff() = default;
@@ -60,7 +58,7 @@ std::vector<std::string> SubscriptionsSnapshot::GetChannelLocales(
std::vector<std::string> locales;
for (const auto& [locale, locale_channels] : channels_) {
if (base::Contains(locale_channels, channel)) {
if (std::ranges::contains(locale_channels, channel)) {
locales.push_back(locale);
}
}
@@ -76,7 +74,7 @@ bool SubscriptionsSnapshot::GetChannelSubscribed(
continue;
}
return base::Contains(value, channel);
return std::ranges::contains(value, channel);
}
return false;
}
@@ -5,7 +5,8 @@
#include "brave/components/brave_news/common/subscriptions_snapshot.h"
#include "base/containers/contains.h"
#include <algorithm>
#include "testing/gtest/include/gtest/gtest.h"
namespace brave_news {
@@ -30,10 +31,10 @@ TEST(BraveNewsSubscriptionsSnapshot, DirectFeedsAreDiffed) {
auto diff = two.DiffPublishers(one);
EXPECT_EQ(1u, diff.changed.size());
EXPECT_TRUE(base::Contains(diff.changed, "three"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "three"));
EXPECT_EQ(1u, diff.removed.size());
EXPECT_TRUE(base::Contains(diff.removed, "two"));
EXPECT_TRUE(std::ranges::contains(diff.removed, "two"));
}
TEST(BraveNewsSubscriptionsSnapshot, ChannelsAreDiffed) {
@@ -43,8 +44,8 @@ TEST(BraveNewsSubscriptionsSnapshot, ChannelsAreDiffed) {
// Note: Channels aren't removed, their status is changed.
auto diff = two.DiffChannels(one);
EXPECT_EQ(2u, diff.changed.size());
EXPECT_TRUE(base::Contains(diff.changed, "Two"));
EXPECT_TRUE(base::Contains(diff.changed, "Three"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "Two"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "Three"));
}
TEST(BraveNewsSubscriptionsSnapshot, PublishersAreDiffed) {
@@ -54,10 +55,10 @@ TEST(BraveNewsSubscriptionsSnapshot, PublishersAreDiffed) {
// Note: Publishers aren't removed but their status is changed.
auto diff = two.DiffPublishers(one);
EXPECT_EQ(4u, diff.changed.size());
EXPECT_TRUE(base::Contains(diff.changed, "Five"));
EXPECT_TRUE(base::Contains(diff.changed, "Six"));
EXPECT_TRUE(base::Contains(diff.changed, "Two"));
EXPECT_TRUE(base::Contains(diff.changed, "Four"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "Five"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "Six"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "Two"));
EXPECT_TRUE(std::ranges::contains(diff.changed, "Four"));
}
TEST(BraveNewsSubscriptionsSnapshot, NoopHasNoDiff) {
@@ -10,7 +10,6 @@
#include <utility>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/values_util.h"
@@ -45,7 +44,7 @@ void RewardsNotificationServiceImpl::AddNotification(
if (id.empty()) {
id = GenerateRewardsNotificationID();
} else if (only_once) {
if (base::Contains(rewards_notifications_displayed_, id)) {
if (std::ranges::contains(rewards_notifications_displayed_, id)) {
return;
}
}
@@ -9,7 +9,6 @@
#include <utility>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "brave/components/brave_rewards/core/engine/rewards_engine.h"
#include "brave/components/brave_rewards/core/engine/util/environment_config.h"
@@ -71,7 +70,8 @@ mojom::Result GetMe::ParseBody(const std::string& body,
const auto* currencies = dict.FindList("currencies");
if (currencies) {
const std::string currency = "BAT";
user->bat_not_allowed = !base::Contains(*currencies, base::Value(currency));
user->bat_not_allowed =
!std::ranges::contains(*currencies, base::Value(currency));
}
return mojom::Result::OK;
@@ -3,7 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include "base/containers/contains.h"
#include <algorithm>
#include "brave/components/brave_rewards/core/engine/migrations/pref_migration_manager.h"
#include "brave/components/brave_rewards/core/engine/test/rewards_engine_test.h"
#include "brave/components/brave_rewards/core/engine/util/rewards_prefs.h"
@@ -103,8 +104,8 @@ TEST_F(RewardsPrefMigrationTest, Migration13) {
ExecuteMigration(13);
EXPECT_TRUE(base::Contains(client().GetObserverEventsForTesting(),
"external-wallet-connected"));
EXPECT_TRUE(std::ranges::contains(client().GetObserverEventsForTesting(),
"external-wallet-connected"));
}
TEST_F(RewardsPrefMigrationTest, Migration14) {
@@ -11,7 +11,6 @@
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/json/json_value_converter.h"
#include "base/logging.h"
@@ -194,7 +193,7 @@ FindAdBlockFilterListsByLocale(
std::copy_if(region_lists.begin(), region_lists.end(),
std::back_inserter(output),
[&adjusted_locale](const FilterListCatalogEntry& entry) {
return base::Contains(entry.langs, adjusted_locale);
return std::ranges::contains(entry.langs, adjusted_locale);
});
return output;
@@ -9,7 +9,6 @@
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
@@ -220,7 +219,7 @@ TEST(BitcoinSerializer, AddressToScriptPubkey_BitcoinCoreTestVectors) {
continue;
}
if (base::Contains(not_supported_addresses, address)) {
if (std::ranges::contains(not_supported_addresses, address)) {
skipped_tests++;
continue;
}
@@ -12,7 +12,6 @@
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/strings/string_util.h"
@@ -60,8 +59,8 @@ inline constexpr char kZCashDataFolderName[] = "zcash_data";
bool AccountMatchesCoinAndChain(const mojom::AccountId& account_id,
mojom::CoinType coin,
const std::string& chain_id) {
return base::Contains(GetSupportedKeyringsForNetwork(coin, chain_id),
account_id.keyring_id);
return std::ranges::contains(GetSupportedKeyringsForNetwork(coin, chain_id),
account_id.keyring_id);
}
bool ContainsNativeToken(const std::vector<mojom::BlockchainTokenPtr>& tokens,
@@ -7,7 +7,6 @@
#include <utility>
#include "base/containers/contains.h"
#include "brave/components/brave_wallet/browser/brave_wallet_provider_delegate.h"
#include "brave/components/brave_wallet/browser/brave_wallet_utils.h"
#include "brave/components/brave_wallet/browser/keyring_service.h"
@@ -48,8 +47,9 @@ mojom::AccountIdPtr GetCardanoPreferredDappAccount(
auto selected_account = keyring_service->GetSelectedCardanoDappAccount();
bool is_selected_account_allowed =
selected_account &&
base::Contains(*allowed_accounts, GetAccountPermissionIdentifier(
selected_account->account_id));
std::ranges::contains(
*allowed_accounts,
GetAccountPermissionIdentifier(selected_account->account_id));
if (is_selected_account_allowed) {
return selected_account->account_id.Clone();
}
@@ -58,7 +58,7 @@ mojom::AccountIdPtr GetCardanoPreferredDappAccount(
// we use first allowed account.
// Similar behavior implemented in EthereumProviderImpl.
for (const auto& account : keyring_service->GetAllAccountInfos()) {
bool is_account_allowed = base::Contains(
bool is_account_allowed = std::ranges::contains(
*allowed_accounts, GetAccountPermissionIdentifier(account->account_id));
if (is_account_allowed) {
return account->account_id.Clone();
@@ -12,7 +12,6 @@
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/containers/extend.h"
#include "base/containers/span.h"
#include "base/json/json_writer.h"
@@ -129,7 +128,7 @@ void CardanoTestRpcServer::RequestInterceptor(
}
if (auto txid = IsGetTransactionRequest(request)) {
if (base::Contains(confirmed_transactions_, *txid)) {
if (std::ranges::contains(confirmed_transactions_, *txid)) {
cardano_rpc::blockfrost_api::Transaction tx;
tx.hash = *txid;
url_loader_factory_.AddResponse(
@@ -17,7 +17,6 @@
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
@@ -1165,7 +1164,7 @@ bool KeyringService::CreateWalletInternal(const std::string& mnemonic,
}
bool KeyringService::IsKeyringEnabled(mojom::KeyringId keyring_id) const {
return base::Contains(enabled_keyrings_, keyring_id);
return std::ranges::contains(enabled_keyrings_, keyring_id);
}
void KeyringService::CreateKeyrings(const KeyringSeed& keyring_seed) {
@@ -15,7 +15,6 @@
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/extend.h"
#include "base/containers/fixed_flat_map.h"
#include "base/containers/map_util.h"
@@ -1271,7 +1270,7 @@ void NetworkManager::AddHiddenNetwork(mojom::CoinType coin,
base::ListValue* list = update->EnsureList(GetPrefKeyForCoinType(coin));
std::string chain_id_lower =
MakeChainIdLowerCase(chain_id, ToLowerCaseReason::kAddHiddenNetwork);
if (!base::Contains(*list, base::Value(chain_id_lower))) {
if (!std::ranges::contains(*list, base::Value(chain_id_lower))) {
list->Append(chain_id_lower);
}
}
@@ -11,7 +11,6 @@
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
@@ -160,7 +159,7 @@ void SolanaProviderImpl::Connect(std::optional<base::DictValue> arg,
delegate_->GetAllowedAccounts(mojom::CoinType::SOL, identifiers);
if (allowed_accounts) {
std::erase_if(identifiers, [&allowed_accounts](const auto& identifier) {
return base::Contains(*allowed_accounts, identifier);
return std::ranges::contains(*allowed_accounts, identifier);
});
}
delegate_->RequestPermissions(
@@ -9,7 +9,6 @@
#include <utility>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/raw_ref.h"
#include "base/notreached.h"
@@ -390,7 +389,7 @@ std::vector<mojom::AccountInfoPtr> AccountUtils::AllAccounts(
const std::vector<mojom::KeyringId>& keyring_ids) {
std::vector<mojom::AccountInfoPtr> result;
for (auto& acc : keyring_service_->GetAllAccountInfos()) {
if (base::Contains(keyring_ids, acc->account_id->keyring_id)) {
if (std::ranges::contains(keyring_ids, acc->account_id->keyring_id)) {
result.push_back(acc->Clone());
}
}
@@ -5,11 +5,11 @@
#include "brave/components/brave_wallet/common/value_conversion_utils.h"
#include <algorithm>
#include <optional>
#include <string>
#include <vector>
#include "base/containers/contains.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
#include "brave/components/brave_wallet/common/brave_wallet.mojom.h"
@@ -209,15 +209,17 @@ TEST(ValueConversionUtilsUnitTest, NetworkInfoToValueTest) {
chain.decimals);
auto* rpc_urls = value.FindList("rpcUrls");
for (const auto& entry : *rpc_urls) {
ASSERT_TRUE(base::Contains(chain.rpc_endpoints, GURL(entry.GetString())));
ASSERT_TRUE(
std::ranges::contains(chain.rpc_endpoints, GURL(entry.GetString())));
}
for (const auto& entry : *value.FindList("iconUrls")) {
ASSERT_TRUE(base::Contains(chain.icon_urls, entry.GetString()));
ASSERT_TRUE(std::ranges::contains(chain.icon_urls, entry.GetString()));
}
auto* blocked_urls = value.FindList("blockExplorerUrls");
for (const auto& entry : *blocked_urls) {
ASSERT_TRUE(base::Contains(chain.block_explorer_urls, entry.GetString()));
ASSERT_TRUE(
std::ranges::contains(chain.block_explorer_urls, entry.GetString()));
}
auto result = ValueToNetworkInfo(base::Value(value.Clone()));
@@ -5,13 +5,13 @@
#include "brave/components/commands/common/accelerator_parsing.h"
#include <algorithm>
#include <cstddef>
#include <string>
#include <string_view>
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
@@ -119,7 +119,7 @@ ui::KeyEventFlags GetModifierFromKeys(
const std::vector<std::string>& modifiers) {
ui::KeyEventFlags result = ui::EF_NONE;
for (const auto& [modifier, name] : GetAllModifierNames()) {
if (base::Contains(modifiers, name)) {
if (std::ranges::contains(modifiers, name)) {
result |= modifier;
}
}
@@ -12,7 +12,6 @@
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
@@ -122,10 +121,11 @@ bool BraveContentSettingsAgentImpl::IsScriptTemporarilyAllowed(
if (!shields_settings_) {
return false;
}
bool allow = base::Contains(shields_settings_->origins_to_allow_scripts,
url::Origin::Create(script_url).Serialize()) ||
base::Contains(shields_settings_->origins_to_allow_scripts,
script_url.spec());
bool allow =
std::ranges::contains(shields_settings_->origins_to_allow_scripts,
url::Origin::Create(script_url).Serialize()) ||
std::ranges::contains(shields_settings_->origins_to_allow_scripts,
script_url.spec());
if (!allow) {
// Also check rules in the main frame, because this frame rules may be out
// of sync.
@@ -11,7 +11,6 @@
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
@@ -56,7 +55,7 @@ class DebounceTabHelper
}
void ClearRedirectChain() { redirects_.clear(); }
bool IsInRedirectChain(const GURL& url) {
return base::Contains(redirects_, url.host());
return std::ranges::contains(redirects_, url.host());
}
private:
@@ -15,7 +15,6 @@
#include "base/check.h"
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/notreached.h"
@@ -359,7 +358,7 @@ void SidebarService::UpdateItem(const GURL& old_url,
// is different. If both are same, only title will be updated.
// Sidebar can't have two items with same url.
if (old_url != new_url &&
base::Contains(items_, new_url, &SidebarItem::url)) {
std::ranges::contains(items_, new_url, &SidebarItem::url)) {
return;
}
@@ -433,7 +432,8 @@ std::vector<SidebarItem> SidebarService::GetHiddenDefaultSidebarItems() const {
auto to_remove =
std::ranges::remove_if(default_items, [&added_default_items](auto& item) {
return base::Contains(added_default_items, item.built_in_item_type);
return std::ranges::contains(added_default_items,
item.built_in_item_type);
});
default_items.erase(to_remove.begin(), to_remove.end());
return default_items;
@@ -12,7 +12,6 @@
#include <utility>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/values_test_util.h"
@@ -475,14 +474,16 @@ TEST_F(SidebarServiceTest, HideBuiltInItem) {
InitService();
// None of the items should be the hidden one
auto items = service_->items();
EXPECT_FALSE(base::Contains(items, SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
EXPECT_FALSE(std::ranges::contains(items,
SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
// Check serialization also perists that
ResetService();
InitService();
items = service_->items();
EXPECT_FALSE(base::Contains(items, SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
EXPECT_FALSE(std::ranges::contains(items,
SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
}
TEST_F(SidebarServiceTest, NewDefaultItemAdded) {
@@ -514,15 +515,16 @@ TEST_F(SidebarServiceTest, NewDefaultItemAdded) {
// since kSidebarItems was not default value and did not contain them.
// None of the items should be the hidden one
auto items = service_->items();
EXPECT_FALSE(base::Contains(items, SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
EXPECT_FALSE(std::ranges::contains(items,
SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
// All other default items should be present even though not present
// in kSidebarItems pref.
std::vector<SidebarItem::BuiltInItemType> default_items;
std::ranges::copy_if(
kDefaultBuiltInItemTypesForTest, std::back_inserter(default_items),
[&hidden_builtin_types](const auto& built_in_type) {
if (base::Contains(hidden_builtin_types, built_in_type)) {
if (std::ranges::contains(hidden_builtin_types, built_in_type)) {
// Hidden by preference
return false;
}
@@ -614,8 +616,9 @@ TEST_F(SidebarServiceTest, MigratePrefSidebarBuiltInItemsSomeHidden) {
std::ranges::find(items, SidebarItem::BuiltInItemType::kBraveTalk,
&SidebarItem::built_in_item_type);
EXPECT_NE(talk_iter, items.end());
EXPECT_TRUE(base::Contains(items, SidebarItem::BuiltInItemType::kReadingList,
&SidebarItem::built_in_item_type));
EXPECT_TRUE(std::ranges::contains(items,
SidebarItem::BuiltInItemType::kReadingList,
&SidebarItem::built_in_item_type));
// Check service has updated built-in item. Previously url was incorrect. This
// check is to make sure that we don't re-introduce code which stores the URL
// for built-in items.
@@ -782,8 +785,9 @@ TEST_F(SidebarServiceTest, HidesBuiltInItemsViaPref) {
// Verify default state
InitService();
auto items = service_->items();
EXPECT_TRUE(base::Contains(items, SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
EXPECT_TRUE(std::ranges::contains(items,
SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
// Update pref to hide bookmarks item
// Make prefs already have old-style builtin items before service
@@ -797,8 +801,9 @@ TEST_F(SidebarServiceTest, HidesBuiltInItemsViaPref) {
// Verify new state doesn't include bookmarks item
InitService();
items = service_->items();
EXPECT_FALSE(base::Contains(items, SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
EXPECT_FALSE(std::ranges::contains(items,
SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
}
TEST_F(SidebarServiceTest, HidesBuiltInItemsViaService) {
@@ -823,8 +828,9 @@ TEST_F(SidebarServiceTest, HidesBuiltInItemsViaService) {
ResetService();
InitService();
items = service_->items();
EXPECT_FALSE(base::Contains(items, SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
EXPECT_FALSE(std::ranges::contains(items,
SidebarItem::BuiltInItemType::kBookmarks,
&SidebarItem::built_in_item_type));
}
#if BUILDFLAG(ENABLE_BRAVE_TALK)
@@ -17,7 +17,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
@@ -186,7 +185,7 @@ std::vector<std::string> GetAvailableRecognizerLanguages() {
const auto code =
brave_l10n::GetISOLanguageCode(ScopedHString(text).GetAsUTF8());
if (base::Contains(language_codes, code)) {
if (std::ranges::contains(language_codes, code)) {
continue;
}
@@ -13,7 +13,6 @@
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "brave/components/version_info/version_info.h"
@@ -185,22 +184,25 @@ constexpr char kHideChatCategoryForComponentId[] =
bool HideIssueCategory(const std::vector<std::string>& component_ids,
const WebcompatCategory category) {
if (category == WebcompatCategory::kCookieNotice &&
!base::Contains(component_ids, kHideCookieNoticeCategoryForComponentId)) {
!std::ranges::contains(component_ids,
kHideCookieNoticeCategoryForComponentId)) {
return true;
}
if (category == WebcompatCategory::kNewsletter &&
!base::Contains(component_ids, kHideNewsletterCategoryForComponentId)) {
!std::ranges::contains(component_ids,
kHideNewsletterCategoryForComponentId)) {
return true;
}
if (category == WebcompatCategory::kSocial &&
!base::Contains(component_ids, kHideSocialCategoryForComponentId)) {
!std::ranges::contains(component_ids,
kHideSocialCategoryForComponentId)) {
return true;
}
if (category == WebcompatCategory::kChat &&
!base::Contains(component_ids, kHideChatCategoryForComponentId)) {
!std::ranges::contains(component_ids, kHideChatCategoryForComponentId)) {
return true;
}
+27
View File
@@ -0,0 +1,27 @@
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 492a3beed9f74115cfd6a830c9d33938136bfdab..51fc87525e5d8e77bfc3e1afd2e22851a63ac62e 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1424,6 +1424,22 @@ _BANNED_CPP_FUNCTIONS: Sequence[BanRule] = (
# Constrained algorithms: non-modifying sequence operations
'all_of',
'any_of',
+ 'contains',
+ 'contains_subrange',
+ 'starts_with',
+ 'ends_with',
+ 'find_last',
+ 'find_last_if',
+ 'find_last_if_not',
+ 'iota',
+ 'shift_left',
+ 'shift_right',
+ 'fold_left',
+ 'fold_left_first',
+ 'fold_right',
+ 'fold_right_last',
+ 'fold_left_with_iter',
+ 'fold_left_first_with_iter',
'none_of',
'for_each',
'for_each_n',
@@ -5,11 +5,11 @@
#include "brave/third_party/blink/renderer/core/farbling/brave_session_cache.h"
#include <algorithm>
#include <string_view>
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/containers/contains.h"
#include "base/debug/alias.h"
#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
@@ -117,7 +117,7 @@ blink::WebContentSettingsClient* GetContentSettingsClientFor(
"chrome-extension",
"chrome-untrusted",
};
if (protocol.empty() || base::Contains(kExcludedProtocols, protocol) ||
if (protocol.empty() || std::ranges::contains(kExcludedProtocols, protocol) ||
blink::SchemeRegistry::ShouldTreatURLSchemeAsDisplayIsolated(protocol)) {
return nullptr;
}
+3 -2
View File
@@ -3,12 +3,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include <iostream>
#include <string>
#include <string_view>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -124,7 +124,8 @@ class RedirectCC {
for (size_t arg_idx = first_compiler_arg_idx; arg_idx < args_.size();
++arg_idx) {
const base::FilePath::StringViewType arg_piece = args_[arg_idx];
if (!compile_file_found && base::Contains(kCompileFileFlags, arg_piece)) {
if (!compile_file_found &&
std::ranges::contains(kCompileFileFlags, arg_piece)) {
compile_file_found = true;
if (arg_idx + 1 >= args_.size()) {
LOG(ERROR) << "No arg after compile flag " << arg_piece;