Commit Graph
209 Commits
Author SHA1 Message Date
Claudio DeSouza ca54bee157 [cr145] base::to_underlying deleted
We can now use `std::to_underlying` with cxx23 switched on.

```sh
files_using_header="$(git grep -l base::to_underlying | tr '\n' ' ')"
sed -i 's/base::to_underlying/std::to_underlying/g' \
  ${files_using_header}
../tools/add_header.py --header '<utility>' ${files_using_header}
files_including_header="$(git grep -l base/types/cxx23_to_underlying.h | tr '\n' ' ')"
../tools/add_header.py --header '"base/types/cxx23_to_underlying.h"' \
  --remove ${files_including_header}
git cl format
```

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/2a2bf2f67290880f6d15f514309f0739bfda0add

commit 2a2bf2f67290880f6d15f514309f0739bfda0add
Author: Victor Hugo Vianna Silva <victorvianna@google.com>
Date:   Mon Dec 22 09:27:38 2025 -0800

    Migrate usages of base::to_underlying in //ash

    ```
    files_using_header="$(git grep -l base::to_underlying | tr '\n' ' ')"
    sed -i 's/base::to_underlying/std::to_underlying/g' \
      ${files_using_header}
    tools/add_header.py --header '<utility>' ${files_using_header}
    files_including_header="$(git grep -l base/types/cxx23_to_underlying.h | tr '\n' ' ')"
    tools/add_header.py --header '"base/types/cxx23_to_underlying.h"' \
      --remove ${files_including_header}
    git cl format
    ```

    Then some manual fixes.

    Bug: 470039537
    Change-Id: I4c8f291f2edaca23a7ea57dab278662299d5d9b8
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7278357
    Reviewed-by: James Cook <jamescook@chromium.org>
    Commit-Queue: Victor Vianna <victorvianna@google.com>
    Cr-Commit-Position: refs/heads/main@{#1561830}
2026-01-29 13:40:51 -05:00
Claudio DeSouza c164d6759c [cr145] IWYU for callback_helpers.h
This change does IWYU additions for all cases where `base::DoNothing` is
used. Furthermore, this change removes some of the uses of
`base::DoNothing` as an argument default value in a header, removing the
need to add `callback_helpers.h` to those headers.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/e8436cccafc34d6e4d9c060f682345060579d208
https://chromium.googlesource.com/chromium/src/+/227f058d9b9e27370a64b34046d71b9f23106409

commit e8436cccafc34d6e4d9c060f682345060579d208
Author: Lei Zhang <thestig@chromium.org>
Date:   Fri Dec 12 15:16:22 2025 -0800

    Forward declare base::ScopedClosureRunner in some Blink headers

    Avoid including base/functional/callback_helpers.h when not needed. Also
    use base/functional/callback_forward.h since callback_helpers.h was
    providing callback.h. For scrollable_area.h, make this possible by
    getting rid the default arguments to PerformSnapping(),
    SnapAtCurrentPosition(), and SnapForEndPosition(). These methods have
    very few callers, so just pass in all the arguments. Then do IWYU to fix
    the build.

    Change-Id: I5cfd017bd6f392b0d97e99c41d4885fac7140a4c
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7254408
    Commit-Queue: Philip Rogers <pdr@chromium.org>
    Auto-Submit: Lei Zhang <thestig@chromium.org>
    Reviewed-by: Philip Rogers <pdr@chromium.org>
    Reviewed-by: Christoph Schwering <schwering@google.com>
    Reviewed-by: Robert Flack <flackr@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1558318}

commit 227f058d9b9e27370a64b34046d71b9f23106409
Author: Lei Zhang <thestig@chromium.org>
Date:   Thu Dec 11 21:30:12 2025 -0800

    Do IWYU for callback_helpers.h in async_dom_storage_database.cc

    Add callback_helpers.h for base::DoNothing() usage. The transitive
    include that makes this work as-is will be deleted in the near future.

    Change-Id: Id5ba6db705434734a854874923b7bb196392ca6c
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7253640
    Commit-Queue: Mingyu Lei <leimy@chromium.org>
    Auto-Submit: Lei Zhang <thestig@chromium.org>
    Reviewed-by: Mingyu Lei <leimy@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1557849}
2026-01-29 13:40:34 -05:00
cdesouza-chromium eff677dd37 [IWYU] Dropping several superfluous std inclusions (#32803)
This PR removes several superfluous inclusions for `<map>`, `<vector>`,
and `<string>`. This is a mechanical change.

```bash
git ls-files components | grep '\.h$' | xargs grep -l '<vector>$' | \
  xargs grep -L std::vector | \
  xargs ../tools/add_header.py --remove --header '<vector>'

git ls-files components | grep '\.h$' | xargs grep -l '<string>$' | \
  xargs grep -L std::vector | xargs grep -L std::npos | \
  xargs ../tools/add_header.py --remove --header '<string>'

git ls-files components | grep '\.h$' | xargs grep -l '<map>$' | \
  xargs grep -L std::map | xargs grep -L std::multimap | \
  xargs ../tools/add_header.py --remove --header '<map>'
```

Bug: https://github.com/brave/brave-browser/issues/42212
2025-12-15 07:58:59 +00:00
cdesouza-chromium 04a6877680 [IWYU] base/sequence_checker.h (#32198)
This PR applies IWYU fixes for `base/sequence_checker.h`.

The script dataset for this is:

```
HEADER_FUNCTION_SETS = [
    (
        '"base/sequence_checker.h"',
        (
          "SEQUENCE_CHECKER",
          "DETACH_FROM_SEQUENCE",
          "SequenceCheckerDoNothing",
          "SequenceChecker",
          "ScopedValidateSequenceChecker",
        ),
    ),
]
```

Bug: https://github.com/brave/brave-browser/issues/42212
2025-11-11 07:00:07 +00:00
cdesouza-chromium 87584a5158 [CodeHealth] Remove deprecated single-arg Invoke (#31605)
Not needed and deprecated [0]. This PR should be a no-op.

This is a semi-mechanical change.

[0]: https://chromium.googlesource.com/external/github.com/google/googletest.git/+/a05c0915074bcd1b82f232e081da9bb6c205c28d/googlemock/include/gmock/gmock-actions.h#2046

Bug: https://github.com/brave/brave-browser/issues/49857
2025-10-03 12:38:24 +01:00
Claudio DeSouza 12c8cd6c91 [cr141] DetermineAccountToUse deleted
Chromium changes:
https://chromium.googlesource.com/chromium/src/+/b28c039343fef4ae2b4514193c7969df916d1630
https://chromium.googlesource.com/chromium/src/+/125c24ee56dc5860fd442615a9a099570fb957a3

commit b28c039343fef4ae2b4514193c7969df916d1630
Author: Marc Treib <treib@chromium.org>
Date:   Mon Aug 18 09:11:20 2025 -0700

    Sync: Determine account managed-ness in SyncAuthManager

    Currently, multiple data types (at least HISTORY and CONTACT_INFO)
    determine independently, in their DataTypeController, whether the
    primary account is managed or not (and turn themselves off if so).

    This CL adds the managed-ness determination to the core sync machinery
    (specifically SyncAuthManager), from where it's passed to the data types
    via ConfigureContext.

    Note that no data types use this yet - the plan is to first let this
    roll out, ensure it doesn't unduly slow down sync startup etc, and then
    switch over the actual data type implementations.

    Bug: 40897778
    Change-Id: Ife6e4f3bb4a13d68d2f40c06bdf1f2971d0ac49d
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6550026
    Reviewed-by: Ankush Singh <ankushkush@google.com>
    Reviewed-by: Maksim Moskvitin <mmoskvitin@google.com>
    Commit-Queue: Marc Treib <treib@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1502743}

commit 125c24ee56dc5860fd442615a9a099570fb957a3
Author: Marc Treib <treib@chromium.org>
Date:   Mon Aug 18 09:40:47 2025 -0700

    SyncAuthManager: Pull account managed-ness checks into separate class

    This CL introduces a new ActiveAccount subclass, which is responsible
    for determining the account's managed-ness status whenever the account
    changes.

    AI notes: This was kinda-sorta AI-generated, but it took a sequence of
    prompts plus a bunch of manual polishing at the end to get there.
    Overall, kinda cool but not actually saving any time, since you have to
    specify in quite a lot of detail what the outcome should be (and I don't
    see how that could be specified in a reusable way).

    Bug: 40897778
    Change-Id: I9bb92a54fbe0c60fc6d0d5820894f2a64aeef2bd
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6853903
    Commit-Queue: Marc Treib <treib@chromium.org>
    Reviewed-by: Ankush Singh <ankushkush@google.com>
    Cr-Commit-Position: refs/heads/main@{#1502763}
2025-09-22 14:59:43 -04:00
Shivan d02e2aa4ec Enable password sync by default (for new users) (#27268)
Add `UserSelectableType::kPasswords` to list of default-enabled Sync types. 
Also gate this behavior behind a default-enabled flag (in case rollback is needed).
2025-09-18 12:05:42 -07:00
cdesouza-chromium 5eb666f034 [CodeHealth] Run gn format on all files (#30448)
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
2025-08-05 18:08:10 +01:00
Anton Paymyshev 1071efbc82 Fix implicit deps on chromium components (#29914)
signin sync_device_info update_client value_store variations version_info
2025-07-04 22:28:15 +07:00
b901ba9684 sync: Add experimental flag to configure the self-hosted sync service URL (#28463)
* sync: Add experimental flag to configure the self-hosted sync service URL.

* sync: Set the |BRAVE_SYNC_ENDPOINT| directly in kSyncServerUrl/kSyncDevServerUrl using chromium_src overrides instead of passing it via command_line

* sync: Remove the test case for checking if the BRAVE_SYNC_ENDPOINT is set via the command line.

* sync: Improve self-hosted sync URL validation and rename flag

- Enhanced validation to accept only valid HTTPS URLs or trustworthy HTTP origins (e.g., localhost)
- Renamed sync URL flag to brave-override-sync-server-url and updated its description.

* sync: fix build issue due to GN deps

* Update text desc in browser/about_flags.cc

Co-authored-by: Francois Marier <francois@fmarier.org>

* sync: Add tests for Self-host sync server URL validation

Add parameterized browser tests to verify the logic in `BraveMainDelegate` for handling the `--sync-url` command-line switch / feature flag.

The tests cover the following scenarios:
- Secure HTTPS URLs are accepted.
- Insecure HTTP URLs are rejected by default.
- HTTP URLs for localhost are accepted (as a trustworthy origin).
- Insecure HTTP URLs are accepted if the origin is explicitly marked as secure via `--unsafely-treat-insecure-origin-as-secure`.
- The absence of the `--sync-url` switch.

* sync: add a warning when the user provided sync url is invalid

* sync: address test failures likely caused by merge conflicts

* test: Filter HistoryNoticeUtilsTest.WebHistoryStates due to sync endpoint change

The test fails because it expects Google's sync server endpoint while Brave
uses a different sync server endpoint.

---------

Co-authored-by: Brian Clifton <brian@clifton.me>
Co-authored-by: Francois Marier <francois@fmarier.org>
2025-07-01 17:37:39 -07:00
Anton Paymyshev 65012521f9 Fix implicit deps on chromium components (#29840)
image_fetcher infobars keep_alive_registry language metrics network_session_configurator network_time
2025-07-01 21:53:40 +07:00
Terry Mancey c9dbac0d22 [CodeHealth] Remove uses of banned std::to_string (#29669)
This PR replaces the banned std::to_string with its //base counterparts.
https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-features.md#std_sto_i_l_ul_ll_ull_f_d_ld_to_string_banned
2025-06-23 10:38:09 -04:00
Anton Paymyshev 6fe388270a Fix implicit deps on components/sync (#29691) 2025-06-23 19:03:15 +07:00
Anton Paymyshev 18188bafcd Fix implicit deps on components/prefs (#29649) 2025-06-20 14:33:58 +07:00
Anton Paymyshev bcf34bb280 Fix implicit deps on components/sync_preferences (#29626) 2025-06-19 13:26:31 +07:00
Claudio DeSouza a1c590093f [cr138] SyncServiceImpl::OnSyncManagedPrefChange removed
`SyncServiceImpl::OnSelectedTypesChanged` seems to be the equivalent for
what the override was being used for.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/f01471d6254029041ecbaca198271157824a2d17

commit f01471d6254029041ecbaca198271157824a2d17
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Fri May 16 01:42:41 2025 -0700

    [sync] Avoid direct use of SyncPrefObserver from SyncServiceImpl

    No expected behavioral changes.

    SyncUserSettingsImpl is a layer between SyncServiceImpl and SyncPrefs
    and should rather take care of propagating events to SyncServiceImpl.

    In follow-up patches, further simplifications could be pursued, such as
    avoiding SyncPrefObserver altogether for mutations that are exclusively
    triggered by SyncUserSettingsImpl.

    Change-Id: I2dd53149b2c7b9bec9c0ca85fb68b86f1ea3092d
    Bug: 40772592
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6550298
    Commit-Queue: Mikel Astiz <mastiz@chromium.org>
    Reviewed-by: Marc Treib <treib@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1461225}
2025-06-11 17:07:29 -04:00
cdesouza-chromium 3998467be9 [IWYU] Fixing logging inclusions //components (#29511)
This change is one of many fixing inclusion for the following files:

    - `base/notimplemented.h`
    - `base/notreached.h`
    - `base/check.h`
    - `base/dcheck_is_on.h`
    - `base/check_deref.h`
    - `base/check_op.h`
    - `base/logging/log_severity.h`
    - `base/logging.h`

This change is a mechanical change done with the following script:
https://github.com/brave/brave-browser/issues/46707#issuecomment-2960116515

Resolves https://github.com/brave/brave-browser/issues/46707
2025-06-11 16:03:11 +01:00
Claudio DeSouza 8d964c29e9 [cr135] Use SyncAuthManager::Delegate
This delegate has been introduce, which eliminates the passing of
multiple thunks to the constructor. This change has to be applied to
`BraveSyncAuthManager` as well.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/c6a82680f0869c5dca816a37a6018119aa935f94

commit c6a82680f0869c5dca816a37a6018119aa935f94
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Mon Feb 17 03:13:56 2025 -0800

    [sync] Introduce SyncAuthManager::Delegate

    Pure refactoring without behavioral changes.

    This delegate replaces the less readable solution using callbacks,
    following the same approach used by analogous classes such as
    SyncServiceCrypto.

    Change-Id: Ia55d9309b66a13f071ef0060315f59a604b29dfe
    Bug: 387132027
2025-03-18 20:02:10 -04:00
Claudio DeSouza 28ffddc538 [cr134] sync:os_crypt merged into sync
This merely affects how the dependency is included in gn files.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/9756f9dc3c42efd8ae1db5612c8a6fda6564752f

commit 9756f9dc3c42efd8ae1db5612c8a6fda6564752f
Author: Henrique Ferreiro <hferreiro@igalia.com>
Date:   Mon Feb 3 13:02:41 2025 -0800

    Merge //components/os_crypt/sync:{sync,os_crypt} targets

    //components/os_crypt/sync:sync target is an empty group with only
    :os_crypt as public dependency.

    Change-Id: I12e04499cd27440b1d12b7cfa7f6e7e601390ad2
2025-02-18 12:47:00 +00:00
Claudio DeSouza 878c9b1ce0 [cr134] GaiaId a strong type
This used to be passed as a raw string, however it is now wrapped as a
strong typedef.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/5658a5f971a9ab44d4412a11d8c950a111356e57

commit 5658a5f971a9ab44d4412a11d8c950a111356e57
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Fri Nov 29 16:25:24 2024 +0000

    [signin] Adopt class GaiaId components/signin and related files

    SigninPrefs is excuded to reduce the delta, but otherwise most of
    the signin-related code is migrated to adopt class GaiaId instead of
    passing around std::string values to represent obfuscated gaia IDs.

    The class temporarily supports implicit conversion to and from
    std::string, which allows splitting this particular patch without
    tackling the entire chromium codebase.

    Change-Id: I5f8413f3ce6cc5f52e728ebd805118f79326b68b
    Bug: 380416867
2025-02-18 12:46:52 +00:00
AlexeyBarabash 92c41053e2 Fixed crash with unset NetworkTimeHelper::ui_task_runner_ (#27499)
* Fixed crash with unset NetworkTimeHelper::ui_task_runner_; fixes brave/brave-browser#43727
2025-02-05 23:19:50 +02:00
Max Karolinskiy 37b839e0b2 Adds missing DEPS. 2025-01-27 09:41:51 -05:00
Claudio DeSouza cd1e965244 [cr133] Gaia ID now a unique type
Previously this was a common integral, which requires wrapping the user
ID into this type now.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/bee274de563133afa840118c0117889641159a32

commit bee274de563133afa840118c0117889641159a32
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Mon Dec 16 11:54:31 2024 -0800

    Adopt class GaiaId broadly under //chrome except in unit-tests

    This patch disallows implicit conversion to and from std::string for
    class GaiaId, improving type safety and fixing a temporary violation of
    the style guide.

    Unit-tests and iOS are excluded for now via #ifdef's in gaia_id.h to
    continue allowing implicit conversion, to reduce the size of this patch
    and minimize the risk for regressions (as tests continue to pass without
    changes).

    Bug: 380416867
2025-01-27 09:41:23 -05:00
Claudio DeSouza 8fba4101c2 [cr133] Fix cycle for network_time_helper
Chromium change:
https://chromium.googlesource.com/chromium/src/+/b65f07b411077dfec86703fc0f054c1bcb6a2b42

commit b65f07b411077dfec86703fc0f054c1bcb6a2b42
Author: Fergal Daly <fergal@chromium.org>
Date:   Mon Dec 9 07:52:38 2024 +0000

    When language detection is on, set up a binder on all render frames.

    This replaces the Chrome UI-Translate-specific binder when the flag is
    on.

    Bug: 354069716
    Fixed: 377615981
2025-01-27 09:41:16 -05:00
8d3cd1bc66 Revert custom sync url (#27136)
* Revert "Merge pull request #25484 from jagadeshjai/feature__add_option_custom_sync_url"

This reverts commit d547c86d6b and 9757d93508, reversing
changes made to ab6eba7159.

* revert https://github.com/brave/brave-core/pull/27054

* fixed presubmit errors

* Removed code supposed to support `Use Sync staging server` QA preference

Related PR - https://github.com/brave/brave-core/pull/26804

---------

Co-authored-by: AlexeyBarabash <alexey@brave.com>
Co-authored-by: AlexeyBarabash <AlexeyBarabash@users.noreply.github.com>
2025-01-08 11:29:45 -07:00
AlexeyBarabash 81f1d6723c Removed Use Sync staging server at QA preferences (#26804)
This fixes CI build failure appeared at `v1.75.58` and resolved deps violation

Fixes https://github.com/brave/brave-browser/issues/42596
2024-11-29 14:50:25 -05:00
Brian Clifton ff3cb90d20 FIXUP: small edits for CI and string changes 2024-11-27 13:51:46 +05:30
Jagadesh P 03fe158115 Rename brave_components_sync_driver_[sources/deps] -> brave_components_sync_service_[sources/deps].
And Remove some unused includes.
2024-11-27 13:51:46 +05:30
Jagadesh P 76494c7105 [Android][Sync] Move the logic for changing the sync url for staging in Android to |BraveGetSyncServiceURL|. 2024-11-27 13:51:42 +05:30
Jagadesh P 30c781eb6d [Sync] Set the |BRAVE_SYNC_ENDPOINT| directly in kSyncServerUrl/kSyncDevServerUrl using chromium_src overrides instead of passing it via command_line 2024-11-27 13:49:48 +05:30
cdesouza-chromium 0c6e03012a [CodeHealth] Mark global constants as constexpr (#26588)
This PR tags various global constants as `constexpr`. This is a better
approach to constant values, as it can result in better codegen overall.
2024-11-18 12:41:05 +00:00
cdesouza-chromium f52840737b [CodeHealth] Remove all uses of NOTREACHED_NORETURN (#26508)
This PR replaces all occurences of `NOTREACHED_NORETURN` with
`NOTREACHED`, since they are semantically identical.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/5a9d4c5aa85977fc711eb9c0ff1207c5ac1a0959

commit 5a9d4c5aa85977fc711eb9c0ff1207c5ac1a0959
Author: Peter Boström <pbos@chromium.org>
Date:   Tue Nov 12 01:38:46 2024 +0000

    Remove enable_log_error_not_reached

    This flag only applied to NOTREACHED_IN_MIGRATION() for ChromeOS which
    is on its way out.

    Bug: 40580068
2024-11-12 22:47:03 +00:00
Claudio DeSouza 7ea37c4f72 Controller access encapsulated in DataTypeManager
We now have to go through a different interface to query from
`DataTypeManagers` controllers the entity count. This simplifies the
code in place a bit too.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/9ffc40279cbdeb0d1c8d522f432b20c022c23778
https://chromium.googlesource.com/chromium/src/+/580e71ccd3f7b59eafa956e24c720d33c9f8cf0e

commit 9ffc40279cbdeb0d1c8d522f432b20c022c23778
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Tue Oct 1 18:54:34 2024 +0000

    [sync] Encapsulate controller access inside DataTypeManager

    This is the last patch in a series that removes the temporary API in
    DataTypeManager that exposed direct access to the underlying
    controllers.

    Such access is still allowed for testing, but otherwise controllers are
    now fully owned and managed by DataTypeManagerImpl.

    Semi-related, to exposure of DataTypeStatusTable::TypeErrorMap as part
    of DataTypeManager's ConfigureResult is also removed, as it leaks
    internal state and is exclusively used for tests.

    Change-Id: I674c56cf6e49a1149b8a85fea6afc060aaf2d91b
    Bug: 40901755

commit 580e71ccd3f7b59eafa956e24c720d33c9f8cf0e
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Fri Sep 27 13:46:16 2024 +0000

    [sync] Refactor debug-only logic away from SyncServiceImpl

    The functionality to list sync nodes and counters that power
    sync-internals are now part of DataTypeManager's API and the
    implementation moved partially to a dedicated class and file.

    This removes one case where SyncServiceImpl needed to iterate the
    controller map, which should eventually become a private member in
    DataTypeManager.

    Bug: 40901755
2024-10-24 12:14:30 +01:00
AlexeyBarabash 47c01da1fc Fixed device duplication when Google Account cookies are deleted (#25971)
* Fixed device duplication when Google Account cookies are deleted; fixes brave/brave-browser#41615
2024-10-18 08:17:36 +03:00
cdesouza-chromium e59212a5f5 [CodeHealth] Enable -Wunsafe-buffer-usage across brave (#26027)
[CodeHealth] Enable `-Wunsafe-buffer-usage` acrosss brave

This PR removes `brave/` from the blanket exclusion for
`-Wunsafe-buffer-usage`, and adds only certain third party subpaths to
it. Additionally, in order correct the ensuing warning violations, this
PR adds to individual files exclusion annotations, that we can revisit
gradually.

Having this warning on will prevent further violations from popping up
in new places in the codebase. A significant amount of effort has
already been employed in correcting some of these unsafe buffer usages.

For reference:
https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/unsafe_buffers.md

Resolves https://github.com/brave/brave-browser/issues/41660
2024-10-17 03:29:44 +01:00
cdesouza-chromium 1a82e2f29b [DanglinPtr] Fix various unit test violations (#25946)
This change fixes violations on a few tests by:

  - Correcting creation order
  - Using factory types directly, rather than storing a pointer.
2024-10-11 16:46:23 +01:00
Brian Johnson 3313ad628b remove include rules that no longer apply (#25911)
remove include rules that no longer apply and fix existing include rules
2024-10-10 16:19:48 -07:00
cdesouza-chromium e1f8a28431 [CodeHealth] Use constexpr strings (#25810)
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.
2024-10-04 10:01:05 -07:00
Darnell Andries 9727b80571 Merge pull request #25761 from brave/sync-start-p3a
Add metric for sync join
2024-10-03 12:00:25 -07:00
Darnell Andries e8ad58272e Add metric for sync join 2024-10-03 10:20:38 -07:00
Claudio DeSouza 10dda14f2a SyncService::StopAndClear deleted
This event used to be part of the base class. Now with its deletion the
internal function `SyncServiceImpl::StopAndClear` has to be exposed
through `BraveSyncServiceImpl` to keep the existing code in use.

This change turns the private function into a virtual function, to allow
us to keep plugging our own changes into it.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/769c49bea8b02913b69c1607bbe3d2190a3067bb

commit 769c49bea8b02913b69c1607bbe3d2190a3067bb
Author: Victor Hugo Vianna Silva <victorvianna@google.com>
Date:   Wed Aug 21 12:41:28 2024 +0000

    Remove SyncService::StopAndClear()

    The method can be removed from the interface, its last usage was
    removed in crrev.com/c/5800572.

    Bug: 40797392
2024-10-03 17:06:17 +01:00
Brian Clifton f201239c08 Create group policy for sync URL
Fixes https://github.com/brave/brave-browser/issues/20431
2024-09-13 09:54:40 -07:00
mkarolin 7dbed4990b Presubmit fix. 2024-09-10 14:42:54 -04:00
Claudio DeSouza 6c4933e918 ModelType cleaned out upstream
This type, header, and derived types are now gone, with the new
`DataType` being used. This change corrects variable naming, header
inclusions, etc.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/41d2a6c29f4b0a3ed5321841ddf8b3d715f02d58

commit 41d2a6c29f4b0a3ed5321841ddf8b3d715f02d58
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Wed Aug 7 11:47:19 2024 +0000

    [sync] Migrate remaining components/sync from ModelType to DataType

    Pure refactoring without behavioral changes.

    All occurrences of syncer::ModelType are about to be replaced with
    syncer::DataType, following the rationale in the linked bug. This patch
    tackles occurrences under components/sync and some dependencies.

    Most of the changes were auto-generated via commands below, which also
    required manually excluding some undesired changes:
    git grep -l model_type -- components/sync | \
      grep -v model_type\\.h | grep -v data_type\\.h | \
      grep -v BUILD.gn | \
      xargs sed -i 's/model_type/data_type/g'
    git grep -l ModelType -- components/sync | \
      grep -v model_type\\.h | grep -v data_type\\.h | \
      xargs sed -i -E 's/([^.]|^)ModelType/\1DataType/g'
    git grep -l UserSelectableTypeToAllModelTypes | \
      xargs sed -i '/UserSelectableTypeToAllModelTypes/UserSelectableTypeToAllDataTypes
    /g'
    git diff --name-only HEAD | \
      xargs sed -i "s/DataTypeEntityChange/ModelTypeEntityChange/g"
    git diff --name-only HEAD | \
      xargs sed -i "s/InvalidationPerDataType/InvalidationPerModelType/g"
    git diff --name-only HEAD | \
      xargs sed -i "s/Model type/Data type/g"
    git diff --name-only HEAD | \
      xargs sed -i "s/model type/data type/g"
    git cl format

    NO_IFTTT=Matches enums.xml without additional changes

    Change-Id: I1edd7f45f6ff22e0dfd2a959431d38ca4593e7d4
    Bug: 356649891

https://chromium.googlesource.com/chromium/src/+/1cce04152760c71cde8c8fe90bbb1241128a7b13

commit 1cce04152760c71cde8c8fe90bbb1241128a7b13
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Wed Aug 7 17:10:53 2024 +0000

    [sync] Clean up leftovers after ModelType rename to DataType

    A recent patch series renamed syncer::ModelType to syncer::DataType,
    with a temporary alias being introduced for a gradual migration. Now
    that all references have been migrated to the new name, the temporary
    alias can be removed from code.

    The patch also includes some minor leftover renames.

    Change-Id: Ibed5292fd96fdcbe9592b4bd268faa428da50627
    Bug: 356649891
2024-09-10 14:42:37 -04:00
Claudio DeSouza c44772050b ModelType enum and ModelTypeState renamed
This is in line with previous changes, where the prefix `Model` is being
replaced with `Data`. This change corrects the name of types, variables,
inclusion paths, and also renames shadow files.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/1f5656458d6879d589bc1568ee1dab13050d0fc5

commit 1f5656458d6879d589bc1568ee1dab13050d0fc5
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Tue Aug 6 16:15:30 2024 +0000

    [sync] Rename ModelTypeState to DataTypeState

    See linked bug for rationale.

    The proto is renamed without behavioral changes using the commands
    below. Note that some occurrences need to be excluded because they are
    database column names that would require a migration, which also means
    the patch needs careful review.

    git grep -l ModelTypeState | \
      xargs rename 's/model_type_state/data_type_state/'
    git mv components/sync/protocol/model_type_state_helper_unittest.cc \
      components/sync/protocol/data_type_state_helper_unittest.cc
    git add .
    tools/git/mass-rename.py
    git grep -l ModelTypeState | \
      xargs sed -i 's/ModelTypeState/DataTypeState/g'
    git grep -l model_type_state | \
      xargs sed -i 's/model_type_state/data_type_state/g'
    git grep -l _data_type_state | \
      xargs sed -i -E 's/(autofill|history|plus_address_sync|typed_url)_data_type_state/\1_model_type_state/g'
    git cl format

    Some forward declaration orderings and includes were fixed manually.

    Change-Id: I97a371fee5c7688a5090cf034a0418b989f29862
    Bug: 356649891

https://chromium.googlesource.com/chromium/src/+/209e0271904abe753d64602d165b791005a98905

commit 209e0271904abe753d64602d165b791005a98905
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Tue Aug 6 09:13:48 2024 +0000

    [sync] Rename enum ModelType to DataType (with temporary alias)

    Pure refactoring without behavioral changes.

    All occurrences of syncer::ModelType are about to be replaced with
    syncer::DataType, following the rationale in the linked bug.

    As a first step, the enum and some of the functions that come together
    with it are forked, in order to allow a gradual migration.

    The renames in Java code are bundled into this first patch as they
    aren't that many and they are harder to split.

    Change-Id: Ibeeabd0355ee2c86bdfd99b7002c95bc6a1f3ccf
    Bug: 356649891
2024-09-10 14:42:34 -04:00
Claudio DeSouza 0c467ffea9 [sync] Renaming types to avoid ModelType affix
This is merely a name change, which also affects class names, but should
have no functional effect to the code.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/d6859549f6684a0e3317979dc75b6d543328a8f7

commit d6859549f6684a0e3317979dc75b6d543328a8f7
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Mon Aug 5 10:34:29 2024 +0000

    [sync] Rename internal types to avoid ModelType in the name

    See linked bug for rationale.

    Pure refactoring to rename classes, generated using the following
    commands:
    git grep -l ModelType \
      -- components/sync/engine components/sync/test | \
      xargs rename 's/model_type_/data_type_/'
    git add .
    tools/git/mass-rename.py
    git grep -l ModelType | \
      xargs sed -i -E 's/ModelType(Registry|Connector|Configurer|Worker|Debug)/DataType\1/g'
    git grep -l model_type_ | \
      xargs sed -i -E 's/model_type_(registry|connector|configurer|worker|debug)/data_type_\1/g'
    git cl format

    Change-Id: Ied81019c80822909645fc5fc30527fe541316b15
    Bug: 356649891

https://chromium.googlesource.com/chromium/src/+/07a3db9aba9a84f01f61159544006af6f069e517

commit 07a3db9aba9a84f01f61159544006af6f069e517
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Fri Aug 2 06:10:11 2024 +0000

    [sync] Rename ModelTypeController to DataTypeController

    See linked bug for rationale. Pure refactoring with automated renames,
    using the following commands:
    git grep -l ModelTypeController | \
      xargs rename 's/model_type_controller/data_type_controller/'
    git add .
    tools/git/mass-rename.py
    git grep -l ModelTypeController | \
      xargs sed -i 's/ModelTypeController/DataTypeController/g'
    git grep -l model_type_controller | \
      xargs sed -i 's/model_type_controller/data_type_controller/g'
    git cl format

    Change-Id: Iab738f6a0c3f38a71d54d79cda4a7078d3c5486a
    Bug: 356649891

https://chromium.googlesource.com/chromium/src/+/31a57c5eef28c0b7b6098ba7549efc39726d3a30

commit 31a57c5eef28c0b7b6098ba7549efc39726d3a30
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Mon Aug 5 15:45:52 2024 +0000

    [sync] Rename ModelTypeStore to DataTypeStore (part 2 of 2)

    See linked bug for rationale.

    Quick follow-up to https://crrev.com/c/5756944 where the files were
    renamed. In this patch, the classes are renamed too, generated using
    the following commands:
    git grep -l ModelTypeStore | \
      xargs sed -i 's/\([^.]\)ModelTypeStore/\1DataTypeStore/g'
    git grep -l ModelTypeStore | \
      xargs sed -i 's/^ModelTypeStore/DataTypeStore/g'
    git grep -l model_type_store | \
      xargs sed -i 's/model_type_store/data_type_store/g'
    git cl format

    Some DependsOn() orderings were fixed manually, as well as string
    occurrences in ProfileKeyedServiceBrowserTest and calls to the
    factories' GetInstance() functions.

    Note that renaming proto ModelTypeStoreSchemaDescriptor is fine
    because it is used locally (client-side) only and it gets serialized
    into bytes, where the message name isn't encoded.

    Change-Id: I2f3b9d1c73d3bac6339f112d54c12e638ea06d66
    Bug: 356649891
2024-09-10 14:42:34 -04:00
Claudio DeSouza b1e09f1760 [sync] Renaming types/files away from ModelType
This change affects the name of certain types and derived types, as well
as some shadow files we have to override the classes affected.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/d6859549f6684a0e3317979dc75b6d543328a8f7

commit d6859549f6684a0e3317979dc75b6d543328a8f7
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Mon Aug 5 10:34:29 2024 +0000

    [sync] Rename internal types to avoid ModelType in the name

    See linked bug for rationale.

    Pure refactoring to rename classes, generated using the following
    commands:
    git grep -l ModelType \
      -- components/sync/engine components/sync/test | \
      xargs rename 's/model_type_/data_type_/'
    git add .
    tools/git/mass-rename.py
    git grep -l ModelType | \
      xargs sed -i -E 's/ModelType(Registry|Connector|Configurer|Worker|Debug)/DataType\1/g'
    git grep -l model_type_ | \
      xargs sed -i -E 's/model_type_(registry|connector|configurer|worker|debug)/data_type_\1/g'
    git cl format

    Change-Id: Ied81019c80822909645fc5fc30527fe541316b15
    Bug: 356649891
2024-09-10 14:42:33 -04:00
Claudio DeSouza 588ed9e6b2 SyncClient::Initialize taking a list of controllers
This change corrects our overriding and uses of `Initialize`, to have
the controller list passed along. The tests we have for
`BraveSyncServiceImpl` also had to be corrected, with the initialisation
step moved into the service creation step, as the controllers have to be
provided at that point.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/1a3d38447a0c7e217b8bd887d6debc8c58655032

commit 1a3d38447a0c7e217b8bd887d6debc8c58655032
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Thu Aug 1 07:44:06 2024 +0000

    [sync] Inject controllers via Initialize() rather than via SyncClient

    Pure refactoring without behavioral changes.

    Before this patch, the first thing SyncServiceImpl::Initialize() did is
    to create controllers via SyncClient::CreateModelTypeControllers(),
    which brings back the control to the very same platform-specific layer
    (client/factory pair) that initiated the Initialize() call.

    Instead, with this patch, the list of controllers is passed as
    parameter to Initialize(), avoiding a less obvious round trip.

    This also allows controllers to be built in the SyncService factory
    implementation rather than in SyncClient's, centralizing the use of
    DependsOn() factories in the same file.

    Moving controller-creating code from the client to the factory is
    tedious. Hence, in this patch, only ios/web_view is tackled fully. The
    other two cases (chrome/ and ios/browser/) work this around by
    continuing to expose a public CreateModelTypeController() API, exercised
    by the factory.

    Bug: 335688372
2024-09-10 14:42:32 -04:00
Claudio DeSouza 206dd9d7af Sync types renamed to DataTypeSyncBridge/DataTypeController
This change is a combination of two incremental renaming changes, where
types and header names were changed. This has no functional effect.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/07a3db9aba9a84f01f61159544006af6f069e517

commit 07a3db9aba9a84f01f61159544006af6f069e517
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Fri Aug 2 06:10:11 2024 +0000

    [sync] Rename ModelTypeController to DataTypeController

    See linked bug for rationale. Pure refactoring with automated renames,
    using the following commands:
    git grep -l ModelTypeController | \
      xargs rename 's/model_type_controller/data_type_controller/'
    git add .
    tools/git/mass-rename.py
    git grep -l ModelTypeController | \
      xargs sed -i 's/ModelTypeController/DataTypeController/g'
    git grep -l model_type_controller | \
      xargs sed -i 's/model_type_controller/data_type_controller/g'
    git cl format

    Change-Id: Iab738f6a0c3f38a71d54d79cda4a7078d3c5486a
    Bug: 356649891

https://chromium.googlesource.com/chromium/src/+/1c65b5f6e21d577b44f5938c81247f2d5d26d476

commit 1c65b5f6e21d577b44f5938c81247f2d5d26d476
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Fri Aug 2 16:42:30 2024 +0000

    [sync] Rename ModelTypeSyncBridge to DataTypeSyncBridge

    ...as well as ModelType[Change]Processor, motivated by the desire to
    avoid "model type" in the name and prefer "data type" instead. For
    ModelTypeChangeProcessor specifically, the new name also adopts
    "local" in the name to distinguish it from ModelTypeProcessor (now
    DataTypeProcessor).

    See linked bug for more detailed rationale.

    Pure refactoring with automated renames, using the following
    commands:
    git grep -l ModelTypeSyncBridge | \
      xargs rename 's/model_type_sync_bridge/data_type_sync_bridge/'
    git grep -l ModelTypeChangeProcessor | \
      xargs rename 's/model_type_change_processor/data_type_local_change_processor/'
    git grep -l ModelTypeProcessor | \
      xargs rename 's/model_type_processor/data_type_processor/'
    git add .
    tools/git/mass-rename.py
    git grep -l ModelTypeSyncBridge | \
      xargs sed -i 's/ModelTypeSyncBridge/DataTypeSyncBridge/g'
    git grep -l model_type_sync_bridge | \
      xargs sed -i 's/model_type_sync_bridge/data_type_sync_bridge/g'
    git grep -l ModelTypeChangeProcessor | \
      xargs sed -i 's/ModelTypeChangeProcessor/DataTypeLocalChangeProcessor/g'
    git grep -l ModelTypeProcessor | \
      xargs sed -i 's/ModelTypeProcessor/DataTypeProcessor/g'
    git cl format

    Finally, some forward declaration orderings were fixed manually.

    Change-Id: I075d86eb2492e477746f3238fcd3f8f2d3ce483b
    Bug: 356649891
2024-09-10 14:42:32 -04:00
Claudio DeSouza 67ea9649d5 SyncApiComponentFactory renamed to SyncEngineFactory
This change affects type names, as well as the shadowing of one of the
overridden files.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/055d1fc1b35008bb5cd25d829a3141e0e8ac42c9

commit 055d1fc1b35008bb5cd25d829a3141e0e8ac42c9
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Tue Jul 30 10:43:59 2024 +0000

    [sync] Rename SyncApiComponentFactory to SyncEngineFactory

    Pure refactoring without behavioral changes.

    The concept of "sync API" has no meaning nowadays and this class
    hierarchy's scope, after recent changes, is exclusively about dealing
    with SyncEngine and the transport data underneath.

    To make the name more accurate and less abstract, this patch adopts
    SyncEngineFactory.

    Change-Id: I4e241d61de82b4475160e4bc9b60d35316223429
    Bug: 335688372
2024-09-10 14:42:26 -04:00