Responses marked as downloads (Content-Disposition: attachment) were
being body-sniffed, which meant De-AMP redirected to a canonical URL
instead of downloading the file.
Check for attachment disposition early in the throttle handlers/producers.
These classes were hoisted and renamed. This has been replaced in
Chromium as well. This is a mechanical change for Brave, done with the
following script.
```
git grep -lw 'Value::List' | xargs sed -i 's/\bValue::List\b/ListValue/g'
git grep -lw 'Value::Dict' | xargs sed -i 's/\bValue::Dict\b/DictValue/g'
git cl format
```
Chromium changes:
https://chromium.googlesource.com/chromium/src/+/6bc468d481835992696083e99e556516fb7f5f80
```
commit 6bc468d481835992696083e99e556516fb7f5f80
Author: Avi Drissman <avi@chromium.org>
Date: Thu Jan 29 22:14:50 2026 -0800
Remove aliases for base::DictValue and base::ListValue
This removes a few last stragglers as well.
Fixed: 478100525
Cq-Include-Trybots: luci.chromium.try:win-official,mac-official,linux-official,android-official,android-desktop-x64-official
Change-Id: If92142b8ab0562a82c609b71c6b2a7665cea6ec6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7513889
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1577038}
```
Issue: https://github.com/brave/brave-browser/issues/52435
This value is now set with the help of `BrowserCreatedObserver`.
Chromium changes:
https://chromium.googlesource.com/chromium/src/+/5202ab57139b9c0d8a6be73af944eb5601a09d74
commit 5202ab57139b9c0d8a6be73af944eb5601a09d74
Author: Thomas Lukaszewicz <tluk@chromium.org>
Date: Wed Oct 8 18:22:18 2025 -0700
[bedrock] Remove InProcessBrowserTest::SelectLastActive()
There are no intended behavioral changes in this CL, this is purely
a test refactor.
This CL replaces all remaining uses of SelectFirstBrowser() with
SetBrowser(), forcing tests to be explicit which Browser instance
is being set to default - eliminating the dependency on
BrowserList ordering.
During setup the last-active Browser is now set as the default
Browser instance. In the vast majority of cases (barring possibly
session-restore browser tests) this is the only Browser instance in
the environment.
Bug: 431672609
Change-Id: I0c0eb6e0a7a5b8a7d194c6b27ee3f90ac2972c1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7019129
Commit-Queue: Tom Lukaszewicz <tluk@chromium.org>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527272}
This PR corrects several places where `BASE_FEATURE` is being used to
rely on the two-arg variant of this macro. This particular PR has no
functional changes, and the only feature declarations affected are the
ones for which the feature-name constant, and the actual value are
identical.
The particular issue for this will be left open so subsequent work for
the other features can be followed up on.
Bug: https://github.com/brave/brave-browser/issues/50492
This is being done by upstream to migrate the parser away from using
`JSON_PARSE_CHROMIUM_EXTENSIONS` as a default.
Chromium changes:
https://chromium.googlesource.com/chromium/src/+/606a5254fc9193a310de36fd750861eacce1d612
commit 606a5254fc9193a310de36fd750861eacce1d612
Author: Daniel Cheng <dcheng@chromium.org>
Date: Mon Sep 22 21:42:27 2025 -0700
Remove base::JSONReader::ReadList's default argument for parsing options
Callers should be explicit if they need to opt into non-compliant JSON
parsing that allows Chromium-specific extensions, e.g. comments.
Bug: 446188265
Change-Id: Icec12f00b124837e6820216cd87c9d52af47f4e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6975033
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1519103}
This PR runs a mechanical change to do IWYU on all files using the new
abseil functions, while also removing the old header inclusions for
`base::StringPrintf`.
A presubmit `BanRule` is also being added for the `base::` functions.
Resolves https://github.com/brave/brave-browser/issues/48143
This PR is the run of `gn format` on all `gn` files. This is a
mechanical change done with:
```sh
git ls-files -- "*.gn" | xargs gn format
git ls-files -- "*.gni" | xargs gn format
```
This change has been motivated primarily by an improvement to the
formatters privided by `gn` correcting cases of redundant target naming,
i.e cases where `//foo:foo` is used, and should just be `//foo`.
For this particular `gn` change, see:
https://chromium.googlesource.com/chromium/src/+/c822490a82cdb6ad479159683a92858f7c6f0a58
Resolves https://github.com/brave/brave-browser/issues/48161
This PR has additional replacements for base::StringPrintf with the
underlying abseil implementation absl::StrFormat.
This is mostly a mechanical change.
Resolves https://github.com/brave/brave-browser/issues/48076
Files that use functions from `string_util.h` should include that header
directly instead of relying on transient inclusions.
This is a mechanical change using this script:
```sh
remove_header_if_unused() {
files=$(git grep -l "base/strings/string_util.h")
for file in $files; do
if ! git grep -qE "base::MakeStringPiece|base::MakeWStringView|base::ToLowerASCII|base::ToUpperASCII|base::CompareCaseInsensitiveASCII|base::EqualsCaseInsensitiveASCII|base::EmptyString|base::RemoveChars|base::ReplaceChars|base::TrimPositions|base::TrimString|base::TruncateUTF8ToByteSize|base::TrimWhitespace|base::CollapseWhitespace|base::ContainsOnlyChars|base::IsStringUTF8|base::IsStringASCII|base::EqualsASCII|base::CompareCase|base::StartsWith|base::EndsWith|base::RemovePrefix|base::RemoveSuffix|base::IsAscii|base::IsUnicodeControl|base::IsHexDigit|base::IsUnicodeWhitespace|base::FormatBytesUnlocalized|base::ReplaceFirstSubstringAfterOffset|base::ReplaceSubstringsAfterOffset|base::WriteInto|base::JoinString|base::ReplaceStringPlaceholders|base::MakeStringViewWithNulChars" "$file"; then
sed -i '/base\/strings\/string_util.h/d' "$file"
echo "Removed 'base/strings/string_util.h' from $file"
fi
done
}
add_header_if_needed() {
files=$(git grep -lE "base::MakeStringPiece|base::MakeWStringView|base::ToLowerASCII|base::ToUpperASCII|base::CompareCaseInsensitiveASCII|base::EqualsCaseInsensitiveASCII|base::EmptyString|base::RemoveChars|base::ReplaceChars|base::TrimPositions|base::TrimString|base::TruncateUTF8ToByteSize|base::TrimWhitespace|base::CollapseWhitespace|base::ContainsOnlyChars|base::IsStringUTF8|base::IsStringASCII|base::EqualsASCII|base::CompareCase|base::StartsWith|base::EndsWith|base::RemovePrefix|base::RemoveSuffix|base::IsAscii|base::IsUnicodeControl|base::IsHexDigit|base::IsUnicodeWhitespace|base::FormatBytesUnlocalized|base::ReplaceFirstSubstringAfterOffset|base::ReplaceSubstringsAfterOffset|base::WriteInto|base::JoinString|base::ReplaceStringPlaceholders|base::MakeStringViewWithNulChars")
for file in $files; do
../tools/add_header.py --header '"base/strings/string_util.h"' "$file"
done
}
remove_header_if_unused
add_header_if_needed
```
Resolves https://github.com/brave/brave-browser/issues/46559
This PR simplifies JSON reading in several places by:
- Using `base::JSONReader::ReadDict`
- Using `base::JSONReader::ReadList`
- Using `base::test::ParseJson*`
This changes aim to make the checks around the parsing and its
expectations simpler to read.
This PR marks all the dangling pointers causing test crahses on linux as
`DanglingUntriaged`. This is the first step to gradually permit us to
switch on the our dangling pointer check in our CI. This change does not
include upstream patches, that may be required depending on how
difficult it becomes to fix those.
Resolves https://github.com/brave/brave-browser/issues/41896
Use `constexpr` strings
This PR changes moves away from uses of `const char` with two
approaches. For `.cc` files, these types are turned into constexpr ones,
which gives the compiler more leeway for optimisations.
For the constants on header files, we are converting these instances to
`inline constexpr`, in order to also reduce string duplication across
the binary.
This change was generated with a tool.
This change removes the unnecessary header inclusions for this type that
has been removed in previous iterations.
Chromium change:
https://chromium.googlesource.com/chromium/src/+/ad2fa76e065ded6bc8b1a606b06bd3f3e11c609c
commit ad2fa76e065ded6bc8b1a606b06bd3f3e11c609c
Author: Avi Drissman <avi@chromium.org>
Date: Wed Jul 24 15:48:35 2024 +0000
Remove the NotificationService
Fixed: 40327896
Fixed: 40299241
Fixed: 40746966
Change-Id: Ic0652a24abd58a6bdda66b380d1ffd29b7af7572
`NOTREACHED()` has been marked as `[[noreturn]]`, and therefore will
break in many cases when building the code. The migration variant of the
macro is being used upstream to allow for a gradual migration of each
callsite.
Chromium change:
https://chromium.googlesource.com/chromium/src/+/61831cb39155842c781f63214a7862bfd23e3390
commit 61831cb39155842c781f63214a7862bfd23e3390
Author: Peter Boström <pbos@chromium.org>
Date: Wed May 22 21:32:53 2024 +0000
Reland "Make NOTREACHED() without parameters [[noreturn]]"
This is a reland of commit fdeac78ccd92e2cc578d8cfa04219599520138b4
Original change's description:
> Make NOTREACHED() without parameters [[noreturn]]
>
> Previous callers have been migrated to NOTREACHED_IN_MIGRATION(). This
> also renames the few NOTREACHED_NORETURN() callers in base/ to
> NOTREACHED() to verify that it's still working (no missing-return).
>
> Let's see how many times this needs to be reverted and relanded. :)
>
> Bug: 40580068
> Change-Id: Ib8155e461ea9d0853c9508e28fc45389114da48c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5548908
> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
> Commit-Queue: Lei Zhang <thestig@chromium.org>
> Owners-Override: Lei Zhang <thestig@chromium.org>
> Auto-Submit: Peter Boström <pbos@chromium.org>
> Commit-Queue: Peter Boström <pbos@chromium.org>
> Reviewed-by: Lei Zhang <thestig@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1303439}
Bug: 40580068
Modernising all namespaces in brave to use nested concat namespace
declarations.
This change is part of a large effort to modernise the brave codebase
across the board with `clang-tidy`, in order to allow future use of
`clang-duty`during code reviews. The idea is to apply a few modernisers
across the codebase in order to have less noise when trying to use
clang-tidy with some sort of autmoation.
This extra argument for completion has been added upstream, and some
code in brave could be improved with this. This change however
concentrates in getting the code to build, so a default empty event is
passed in its place.
Chromium change:
https://chromium.googlesource.com/chromium/src/+/0d795c6e8be398088fdd747cb4fa4b7c7e366878
commit 0d795c6e8be398088fdd747cb4fa4b7c7e366878
Author: HuanPo Lin <robertlin@chromium.org>
Date: Thu Mar 28 03:54:05 2024 +0000
preloading: Add NewTabPagePageLoadMetricsObserver
This CL adds NewTabPagePageLoadMetricsObserver and adds base::OnceCallback<void(content::NavigationHandle&)>
navigation_handle_callback to PageNavigator::OpenURL and
WebContentsDelegate::OpenURLFromTab to attach NavigationHandleUserData for identifying whether a navigation is initiated by NewTabPage.
Please refer to
https://docs.google.com/document/d/11VtFdLTjOOQoUi_MnycnNgwtI1liYd_4u7zWzb6OcEY/edit?usp=sharing for more details.
Bug: 1462832
* Refactoring of the BodySnifferThrottle.
* Speedreader throttles moved to the new logic.
* De-amp throttle moved to the new logic.
* Improved De-amp throttle support of the chained AMP pages.
* AiChatResourceSniffer moved to the new logic.
Upstream has removed certain headers from the inclusion chains to reduce
building times, which has broken a few browser tests.
Chromium change:
https://chromium.googlesource.com/chromium/src/+/a47d7859c400272c6e3055f1225d297ab94031e2
commit a47d7859c400272c6e3055f1225d297ab94031e2
Author: Takuto Ikuta <tikuta@chromium.org>
Date: Mon Feb 19 03:46:58 2024 +0000
autofill: remove unnecessary include from browser_test_base.h
This is extracted from https://crrev.com/c/5280997 to reduce compile
time of some test files.
content/public/test/browser_test_base.h is the file removing
unnecessary header.
Bug: b/324519459
These change are being done to make use of `absl::StrFormat` in the
future, and also to get some better codegen with these constants.
There's also some harderning on upstream code to avoid unnecessary
conversions involving constants, which can only be enforced in a
`constexpr` constext.
This change adds the use of the header in places making use of its
content in certain tests. Upstream is doing refactoring changes around
the use of `content::NotificationService`, which has led to these
failures.
This change corrects all sites where pointer fields were still remaining
in the codebase, and replaces them with `raw_ptr<T>`, and `raw_ref<T>`.
This is in accordance with upstream hardening requirements, which are
about to be enforced by chromium's clang plugin, in M114.
This change goes one step further, and replaces pointer with references
in types where nullptr values are not supposed to be supported.
Chromium change:
https://source.chromium.org/chromium/chromium/src/+/cd23b8b9d212daf06dde638488dbaa355d6651fa
commit cd23b8b9d212daf06dde638488dbaa355d6651fa
Author: Daniel Cheng <dcheng@chromium.org>
Date: Fri Sep 16 17:16:24 2022 +0000
Move bind.h, callback{,_forward,_helpers}.h into //base/functional
Forwarding headers remain in the old locations to ease migration.
Include paths for files in //base/functional/ are also fixed up to the
new canonical path; remaining fixups are deferred until followups to
minimize the risk of conflicts.
Bug: 1364441
Task posting v3 handle refactor - II
This change is following upstream refactor for task runner provisioning.
This primarily involves changing how we are fetching the default current
sequence/thread runners.
Chromium change:
https://chromium.googlesource.com/chromium/src/+/edb604e09fa4ac6eb56f447b643085afda6150a9
commit edb604e09fa4ac6eb56f447b643085afda6150a9
Author: Sean Maher <spvw@chromium.org>
Date: Thu Jan 12 15:18:20 2023 +0000
task posting v3: Remove task runner handles from codebase entirely
As the last CL of the task runner handle refactor, this CL removes
Single and Thread task runner handles from the codebase entirely. The
new API for this functionality can be found under
(SingleThread|Sequenced)TaskRunner::CurrentDefaultHandle,
::GetCurrentDefault(), ::HasCurrentDefault(), and
::CurrentHandleOverride(ForTesting).
Bug: 1026641
Chromium change:
https://chromium.googlesource.com/chromium/src/+/07dfbdcdf84741518ae37b7820de32f9e3fab140
commit 07dfbdcdf84741518ae37b7820de32f9e3fab140
Author: Daniel Cheng <dcheng@chromium.org>
Date: Thu Oct 6 17:33:46 2022 +0000
Further restrict implicit value conversions to base::expected.
Only allow implicit conversions from U to base::expected<T, E> if U is
*not* implicitly convertible to E. This makes it harder to write bugs of
the form:
// `e` contains an expected value of `true`, not an unexpected value
// of `123L`.
base::expected<bool, long> e = 123L;
As a Chromium extension to the C++23 std::expected proposal, this also
adds a `base::ok` hint to simplify construction of a `base::expected`
containing a value when the implicit conversion is disallowed.
While the C++23 proposal chose not to go this route, section 3.7 calls
a hypothetical version of this `success`. Chromium chooses to call this
`base::ok` because:
- it is succinct (every column is precious when there's only 80!)
- has precedence, e.g. Rust's Result enum uses Ok.
Bug: 1369769
Chromium change
https://chromium.googlesource.com/chromium/src/+/f93d399969cc7d7836a47b40fae283f70d9e4d51
commit f93d399969cc7d7836a47b40fae283f70d9e4d51
Author: Daniel Cheng <dcheng@chromium.org>
Date: Tue Oct 4 02:11:39 2022 +0000
Add overloads to avoid copying base::Feature with ScopedFeatureList.
A base::Feature should not be copyable; a feature is intended to have a
single global instance, as it caches internal mutable state.
One major reason features are copied is to specify lists of features to
enable or disable in tests. This use case is addressed by the addition
of a base::test::FeatureRef helper.
To aid incremental migration, this CL just adds overloads but makes no
actual migration. Followups will change `std::vector<base::Feature>`
into `std::vector<base::test::FeatureRef>`, and the compatibility
overloads will be removed after that.
A few small test fixes are required to disambiguate callers that
accidentally wrapped lists of features with extra {}'s: with the new
overloads, it becomes ambiguous which std::vector overload to choose.
Simply remove the extra {}'s so that the std::initializer_list
overload is chosen instead.
Bug: 1370572
Chromium change:
https://chromium.googlesource.com/chromium/src/+/9dbbbda3d576a40b107535bf18e150ee68f169ad
commit 9dbbbda3d576a40b107535bf18e150ee68f169ad
Author: Anthony Vallee-Dubois <anthonyvd@chromium.org>
Date: Fri Aug 26 01:25:31 2022 +0000
Add gnu::abi_tag("logically_const") to base::Feature
This is in preparation of landing https://chromium-review.googlesource.com/c/chromium/src/+/3683086, which adds a mutable field to base::Feature. Adding the "logically_const" tag in this way will allow the binary_size bot to ignore the fact that const base::Feature objects will now exist in non-readonly sections of the binary.
Adding this annotation breaks forward declarations, so all of the existing base::Feature forward declarations are replaced by "base/feature_list.h" includes.
Bug: 1341292