Replaces manual `AddObserver/RemoveObserver` pairs in `ViewCounterService`,
`NTPBackgroundImagesBridge`, and `NTPBackgroundImagesServiceWaiter` with
base::ScopedObservation so observer cleanup is automatic and the
lifecycle is consistent with the rest of the codebase.
[Ads] Serve new-tab takeover ads on demand instead of prefetching
Removing prefetching reduces unnecessary complexity.
Ads will instead be served on demand, ensuring they are
only delivered within the campaign’s configured start and
end dates.
Co-authored-by: Aleksei Seren <aseren@brave.com>
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
Remove Android Super Referrals. The feature is no longer supported or
used, and this cleanup helps reduce unused code and simplify the overall
system as part of https://github.com/brave/brave-browser/issues/44403.
This change adds DumpWithoutCrashing calls in key New Tab Takeover (NTT)
code paths to help diagnose potential issues affecting ad performance.
We have observed a noticeable drop in Android metrics since May 2025.
These dumps will help capture additional diagnostic data without causing
crashes, allowing us to better understand and correlate client-side
issues with the recent metric decline.
* [ads] Report new tab page ad metrics via confirmation with an optional fallback to P3A
* [ads] Always serve new tab page ads through the component
* [ads] Do not frequency cap last served new tab page ad
* [ads] Deprecate redundant conditon matcher code
* [ads] Transition to v4 confirmation endpoint
* [ads] Include firstTime in the confirmation payload if it is the first impression for the campaign
* [ads] Deprecate HTTP_IM_A_TEAPOT
* [ads] Do not load unnecessary resources
* [ads] Migrate P3A opted-in status
* [ads] Deprecate AdInfoMatchesSponsoredImage
* [ads] Add ad events to brave://ads-internals
* [ads] Optimize firstTime database query
* [ads] Purge ad events when opting out
* [ads] Add grace period
* [ads] General code health
* [ads] Purge Brave News ads for all users when opting out
This PR replaces the use of `BuildServiceInstanceFor` across brave, as
it has been deprecated, in favour of
`BuildServiceInstanceForBrowserContext`, which return a `unique_ptr`
rather than a naked pointer allocation.
Chromium change:
https://chromium.googlesource.com/chromium/src/+/6121e052e0373a9a0cc84a718ef73e68e3b8a628
commit 6121e052e0373a9a0cc84a718ef73e68e3b8a628
Author: Tom Sepez <tsepez@chromium.org>
Date: Wed Dec 14 21:38:26 2022 +0000
Rework BrowserContextKeyedServiceFactory::BuildServiceInstanceFor().
Avoid releasing an unique_ptr<> only to re-insert the raw value back
into a different one. Instead, maintain ownership at all times.
This is done by overriding the form of BuildServiceInstanceFor() as declared by KeyedServiceFactory, rather than the form of declared by BrowserContextKeyedServiceFactory.
Demonstrate one usage in page_colors_factor.cc as an example, before
taking on the hundreds that remain.
Bug: 1396138
This change replaces all uses of `absl::optional` with `std::*` variants
for optional. This is in line with upstream recent changes making
`absl::optional` a `typedef` to the `std` type.
This change has been done using an automated script:
#!/bin/bash
function replace {
echo "Replacing $1 by $2"
git grep -l "$1" \
| cut -f1 -d: \
| sort \
| uniq \
| grep \
-e "\.h" \
-e "\.cc" \
-e "\.mm" \
-e "\.py" \
| xargs sed -i "s/$1/$2/g"
}
function delete_line_with {
echo "Deleting lines with $1"
git grep -l "$1" \
| cut -f1 -d: \
| sort \
| uniq \
| grep \
-e "\.h" \
-e "\.cc" \
-e "\.mm" \
-e "\.py" \
| xargs sed -i "/$1/d"
}
function add_header {
echo "Adding header $1"
git diff --name-only HEAD \
| xargs ../tools/add_header.py --header "$1"
}
replace "absl::make_optional" "std::make_optional"
replace "absl::optional" "std::optional"
replace "absl::nullopt" "std::nullopt"
replace "absl::in_place" "std::in_place"
replace "absl::in_place_t" "std::in_place_t"
add_header "<optional>"
delete_line_with "\"third_party\/abseil-cpp\/absl\/types\/optional.h\""
git cl format
Chromium change:
https://chromium.googlesource.com/chromium/src/+/d9d21aa16829a7d471a4f3b3a493a31170ed8271
commit d9d21aa16829a7d471a4f3b3a493a31170ed8271
Author: David Benjamin <davidben@chromium.org>
Date: Mon Oct 2 23:29:57 2023 +0000
Make absl::optional a typedef for std::optional
This only changes the types around. It doesn't rewrite existing uses
to std::optional, which we can do incrementally.
absl::optional to std::optional seems to have two visible impacts.
First, the field order is different (bool first vs bool last).
std::optional's order (bool last) seems to be better overall, decreasing
binary size. Second, absl::optional's assertions crash with
__builtin_trap, while std::optional calls __libcpp_verbose_abort which
calls base::ImmediateCrash. __builtin_trap permits the compiler to
combine crash sites within a function but leads to worse crash
debugging. In base::ImmediateCrash, we'd made a conscious decision to
prefer debuggability and pay some binary size for it. The net size
increase brings our optional type in line with that preference.
For more details see the discussion and document below:
https://groups.google.com/a/chromium.org/g/cxx/c/XG3G85_ZF1k/m/_QN8adIJBQAJhttps://docs.google.com/document/d/1AW7q9HCLOk738OCj8Z2U_AKVUC0YIFZWuyRvv09XTHk/edit
Binary-Size: See discussion above.
Fuchsia-Binary-Size: See discussion above.
Bug: 1373619
Upstream has renamed `base::GUID` to `base::Uuid` to avoid name
collisions with some constants in Windows headers. Therefore, all
instances of the `base/guid.h` header, as well as anything using the
former name, must be changed to use `base::Uuid`, in preparation of the
deletion of the legacy name from upstream.
Chromium change:
https://chromium.googlesource.com/chromium/src/+/f800d299bb9374ca8d401c1d326339833cb4280e
commit f800d299bb9374ca8d401c1d326339833cb4280e
Author: Claudio DeSouza <cdesouza@igalia.com>
Date: Thu Jun 8 03:11:20 2023 +0000
Delete base/guid.h
This CL deletes `base/guid.h` from the codebase, as all uses of
`base::GUID` have been replaced with `base::Uuid`. Additionally, all
deprecated functions are also getting deleted, as all uses have been
corrected.
Bug: 1428566, 1195446
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
This change updates the use of base::Value, removing all deprecated
methods around the NTP code. Methods that were using base::Value null
type to signify nothing at return are now using optional, as that more
consisely expresses the interface.