Chromium is now migrating to `std::variant`, and this change does the
same in Brave.
This change was done with a script:
```sh
function delete_line_with {
echo "Deleting lines with $1"
git grep -l "$1" \
| grep -E "\.(h|cc|mm|py)$" \
| sort \
| uniq \
| xargs sed -e "/$(echo "$1" | sed -e 's/[\/&]/\\&/g')/d"
}
function add_header {
echo "Adding header $1"
git diff --name-only \
| xargs ../tools/add_header.py --header "$1"
git grep -l "std::variant" \
| xargs ../tools/add_header.py --header "$1"
}
delete_line_with "\"third_party/abseil-cpp/absl/types/variant.h\""
add_header "<variant>"
git cl format
```
Chromium change:
https://chromium.googlesource.com/chromium/src/+/c01ae649582b75bce39769132a5a41bec8e2d3e4
commit c01ae649582b75bce39769132a5a41bec8e2d3e4
Author: Victor Hugo Vianna Silva <victorvianna@google.com>
Date: Mon Mar 10 19:15:52 2025 -0700
Make absl::variant a typedef for std::variant
This is a re-upload of https://crrev.com/c/5469234, see original
description below. Differences from the original CL:
- Windows symbol definition files were regenerated with
generate_def_files.py.
- New build fixes in password_store_consumer.h,
plus_address_jit_allocator_unittest.cc and mojo_proxy_test.cc.
- Revert change in enclave_protocol_utils.cc, it doesn't seem needed
anymore.
We estimate that ~75% of the regression shown by the
android-binary-size bot will recover after PGO profiles are updated.
See comments 34 to 42 in the linked bug for some numbers.
Original CL description:
"
Discussion thread: https://groups.google.com/u/1/a/chromium.org/g/cxx/c/0EhbuwD-Dpw/m/lbGjN1sxAgAJ
This commit is an updated/tuned version of
David Benjamin's patches (5313884, 5314107).
This only changes the types around. It doesn't rewrite the existing
uses, which we can do incrementally.
"
Binary-Size: See commit description.
Bug: 40242126
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
// Copyright (c) 2024 The Brave Authors. All rights reserved.
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// 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/.
|
|
|
|
// Based on Chromium code subject to the following license:
|
|
// 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 "brave/browser/ui/commander/command_source.h"
|
|
|
|
#include <variant>
|
|
|
|
namespace commander {
|
|
|
|
CommandItem::CommandItem() = default;
|
|
CommandItem::CommandItem(const std::u16string& title,
|
|
double score,
|
|
const std::vector<gfx::Range>& ranges)
|
|
: title(title), score(score), matched_ranges(ranges) {}
|
|
CommandItem::~CommandItem() = default;
|
|
CommandItem::CommandItem(CommandItem&& other) = default;
|
|
CommandItem& CommandItem::operator=(CommandItem&& other) = default;
|
|
|
|
CommandItem::Type CommandItem::GetType() {
|
|
if (std::get_if<CompositeCommand>(&command)) {
|
|
return kComposite;
|
|
}
|
|
return kOneShot;
|
|
}
|
|
|
|
} // namespace commander
|