30 Commits
Author SHA1 Message Date
Netzenbot 9971db0e0e Fix cookie IPC race in browsing data test utility (#36125)
The upstream Chromium test BrowserContextDestructionVsCookieRemoval
flakes because document.cookie (set via JavaScript in the renderer)
uses a different Mojo pipe than GetAllCookies (queried from the browser
via CookieManager), with no ordering guarantee between the two.

Brave amplifies this from the upstream ~0.6 % rate because Ephemeral
Storage forces every cookie operation through IPC (disabling Chromium's
cookie cache optimization in CookieJar::IPCNeeded).

Add a chromium_src override for browsing_data_test_util.cc that calls
HasDataForType after SetDataForType.  For cookies this forces a
round-trip through RestrictedCookieManager → CookieStore, serialising
with the prior SetCanonicalCookieAsync on the same CookieMonster task
runner and guaranteeing the cookie is committed before any subsequent
GetAllCookies query.

The BrowserContextDestructionVsCookieRemoval test has a separate issue:
BlockUntilCompletion() never returns after the incognito profile is
destroyed during data removal.  CookieIncognitoDeletion also hangs in
incognito mode.  Both remain disabled in the filter file.

Resolves brave/brave-browser#54537
2026-05-07 11:57:37 -04:00
Simon Hong 29d4eb4164 Enable clear-browsing-data-dialog-v2 (#33458)
Resolves brave/brave-browser#52296

Implements Brave's customized version of Chromium's v2 clear browsing
data dialog with the following enhancements:

* Add two-tab layout ("Clear data" and "On exit") for better UX
* Customize time picker with Leo design tokens and chip styling
* Add cr-chip customization via chromium_src override
* Remove feature flag to enable v2 dialog by default
* Some patch is added to reuse upstream's method by exporting
2026-02-06 10:00:47 +09:00
Pavel Beloborodov ade0a8fc47 Fixed clearing Brave WebSettings. (#32972)
* Fixed clearing Brave WebSettings.
2026-01-14 15:42:34 +00:00
Emerick Rogul 32f9f997bc [cr144] Disable kDbdRevampDesktop for now
We don't want to take on the Delete Browser Data dialog redesign at the moment,
per product. When disabling this feature, I fixed up the alphabetical ordering
of the include_rules in the BUILD.gn file.

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

commit fd52f33cff1c7c1d24b2c6851f881cf415b7c61f
Author: Mohamad Arab <arabm@google.com>
Date:   Thu Oct 30 07:43:24 2025 -0700

    DBDRevamp: Enable `kDbdRevampDesktop` by default.

    This change enables the revamped browsing data deletion UI on desktop platforms by default.

    launch/4402795

    Change-Id: I73964f2882762b122bb9af0ea69f2969cba7babe
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7100958
    Reviewed-by: Christian Dullweber <dullweber@chromium.org>
    Commit-Queue: Mohamad Arab <arabm@google.com>
    Cr-Commit-Position: refs/heads/main@{#1537916}
2025-12-21 17:12:37 -05:00
Brian R. Bondy 72cadbd0c6 AIChat build flag and gn var (#31988)
* Add AI Chat build flag to components/ai_chat

* Add AI Chat build flag to browser/ui

* Add AI Chat build flag to browser/resources

* Add AI Chat build flag to chromium overrides

* Add AI Chat build flag to other components

* Add AI Chat build flag to core browser files

* Add AI Chat build flag to app and renderer

* Add AI Chat build flag to remaining files

* Set enable_ai_chat to !is_brave_origin_branded

* Review comments

Including gn_check errors in chromium_src

* Exclude ai_chat Jest tests when not enabled
2025-11-11 11:20:34 -05:00
Darnell Andries 11732b92c4 [CodeHealth] Use base::FindOrNull where applicable pt. 1 (#30927)
* Use `base::FindOrNull` where applicable pt. 1

* Use `base::FindPtrOrNull` where applicable
2025-09-02 10:58:18 -07:00
Aleksei Khoroshilov a41bf5350b Replace "src/" includes with <> in chromium_src. (#30096)
This change updates how brave/chromium_src overrides can reference original files: it adds ability to use #include <...> along with #include "src/...". This is enabled by replacing -I../../brave/chromium_src with -iquote../../brave_chromium_src, which adds an include search path only for #include "..." directives.

With this approach, other files in the build tree can reference brave/chromium_src overrides using #include "...", while the overrides themselves can reference original Chromium files using #include <...>. Since Chromium uses #include "..." for all in-tree files, we can leverage this convention and configure our overrides so that we can drop support for #include "src/" later by removing -I../../.. and making rbe_exec_root modification obsolete (the main goal).
2025-07-24 17:37:44 +07:00
Claudio DeSouza c950721941 [cr138] Fix BrowsingDataType leo override
Chromium changes:
https://chromium.googlesource.com/chromium/src/+/30974a8a2b9b0ecdea5c944ae4c85053e5d6cbcd

commit 30974a8a2b9b0ecdea5c944ae4c85053e5d6cbcd
Author: Zaina Al-Mashni <zalmashni@google.com>
Date:   Tue May 6 11:21:04 2025 -0700

    [Settings] Convert the DataType checkboxes to an expandable list in DBD

    This change does the following:
    - Converts the checkboxes in the DBD settings page from a static list
    to an expandable one.
    - Default (History, cache and site data) and selected datatypes are
    always visible in the expandedOptions list.
    - Others datatypes are hidden until the user clicks on show more in the moreOptions list.
    - The two lists do not change after the page is created and maintain the same order.

    Demo (WAI - checkboxes unchanged):
    NO_IFTTT=This is the initial addition for the LINT.IfChange/ThenChange.

    Demo: https://drive.google.com/file/d/19A2L4DO3EXRYBx24WOBVdwnSPQySRbUR/
    https: //drive.google.com/file/d/1eKPy9agH47D4Yxrv6BgBQuzRoA9VtY0s/
    Bug: 397187800
    Change-Id: Ib8ae012d4c536ec004d535ffb3217797462850f0
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6490751
    Reviewed-by: Rainhard Findling <rainhard@chromium.org>
    Reviewed-by: Christian Dullweber <dullweber@chromium.org>
    Commit-Queue: Zaina Al-Mashni <zalmashni@google.com>
    Reviewed-by: John Lee <johntlee@chromium.org>
    Auto-Submit: Zaina Al-Mashni <zalmashni@google.com>
    Commit-Queue: John Lee <johntlee@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1456473}
2025-06-11 18:56:27 +01:00
Pavel Beloborodov 32c4ca7523 Do not removed shields settings with empty primary pattern. (#27819) 2025-02-28 17:33:22 +07:00
cdesouza-chromium d0becfcd17 [CodeHealth] Apply modernize-concat-nested-namespaces (#26498)
This change modernises several namespace declarations, to be shorter, as
this notation has been available since cxx17.

https://clang.llvm.org/extra/clang-tidy/checks/modernize/concat-nested-namespaces.html
2024-11-12 17:00:09 +00:00
Jocelyn Liu efcb1df7c6 Remove enable_ai_chat buildflag 2024-10-31 20:15:18 -07:00
mkarolin f020ea0235 [WIP] CookieTreeModel has been deprecated.
Chromium change:

https://chromium.googlesource.com/chromium/src/+/521df922220371bc6ffe4718b9dfbde7a5ef91fc

commit 521df922220371bc6ffe4718b9dfbde7a5ef91fc
Author: Mariam Ali <alimariam@google.com>
Date:   Tue Mar 26 10:05:20 2024 +0000

    [Deprecate CookiesTreeModel] Remove feature flag

    Bug: 40205603, b:277057437
2024-05-03 16:54:13 -04:00
Claudio DeSouza 8472d263ec string_view/std::array now with iterator type
Updates to the toolchain have landed an llvm change where
`std::array<std::string_view>` has an iterator type, rether than just
using a pointer. This change corrects our instantiations of such
iterators.

llvm change:
https://github.com/llvm/llvm-project/commit/5174b3802575425dcbc58680ccce10961fdb8b67
2024-05-03 16:54:02 -04:00
Claudio DeSouza 7290de6155 BrowsingDataType::NUM_TYPES deleted
With the deletion of this enum entry, a couple of overrides for
`BRAVE_AI_CHAT` were broken. This change chooses alternative tokens to
preserve the original operations.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/26663c6f6e10e6b937f793d3f15136965cfeab86

commit 26663c6f6e10e6b937f793d3f15136965cfeab86
Author: Victor Hugo Vianna Silva <victorvianna@google.com>
Date:   Wed Feb 28 14:10:44 2024 +0000

    Modernize some browsing_data enums

    No behavior change.
    * Remove BrowsingDataType::BOOKMARKS, it was unused.
    * For BrowsingDataType and ClearBrowsingDataTab, instead of having a
    NUM_ENTRIES sentinel (last value + 1), use a MAX_VALUE one (last value).
    This spares some NOTREACHED() in switch statements.
    * Rename BrowsingDataType::COOKIES to SITE_DATA, which was requested
    in [1]. In truth, the code seems to refer to this concept somewhat
    inconsistently [2][3], so I didn't bother updating any more sites.

    [1] https://chromium-review.googlesource.com/c/chromium/src/+/5328206/comment/eaa5ea52_60fdd066/
    [2] https://source.chromium.org/chromium/chromium/src/+/main:components/sync_preferences/common_syncable_prefs_database.cc;l=57;drc=51c82e52f085a1ceed092f144aa1dd3d3d45dd7f
    [3] https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/java/src/org/chromium/chrome/browser/browsing_data/ClearBrowsingDataFragment.java;l=261;drc=e4d49966e41eefba6e176601f5dfdc95303d62ea

    Bug: None
2024-04-08 23:09:21 -04:00
Emerick Rogul 726280724a Disable kDeprecateCookiesTreeModel feature
The cookies tree model is being deprecated but we still rely on this feature to
show site-specific cookie data, so keep this feature flag enabled.

Chromium change:
https://source.chromium.org/chromium/chromium/src/+/94db528d01463917123009ea2a2ed8110a38121f

commit 94db528d01463917123009ea2a2ed8110a38121f
Author: Mariam Ali <alimariam@google.com>
Date:   Fri Feb 9 13:59:50 2024 +0000

    [Deprecate CookiesTreeModel] Enable feature by default

    Bug: b:40205603, b:277057109
2024-03-27 17:18:50 -04:00
cdesouza-chromium d1384a7872 [CodeHealth] Replace absl::optional with std::* (#21156)
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/_QN8adIJBQAJ
    https://docs.google.com/document/d/1AW7q9HCLOk738OCj8Z2U_AKVUC0YIFZWuyRvv09XTHk/edit

    Binary-Size: See discussion above.
    Fuchsia-Binary-Size: See discussion above.
    Bug: 1373619
2023-12-01 10:16:12 +00:00
cdesouza-chromium f2ff15cadb [CodeHealth] Use inline namespace-global constants (#20992)
This change adds `inline` to all `constexpr` namespace-global constants
in the codebase, to improve codegen around these constants.
2023-11-16 07:00:46 +00:00
cdesouza-chromium 75bbf7d53c Convert various extern strings to constexpr (#20959)
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.
2023-11-15 09:02:30 +00:00
Brandon-T 06bc0b8974 Fix #33451: Refactor ai_chat component for iOS (#20425)
Refactor ai_chat_tab_helper to platform generic, so that iOS can use the same core code for its APIs.

With this change, iOS is able to supply a web-page, URL, and all of the things Desktop does.

Fix layering violation.

Fix iOS not compiling due to unit tests that include "content".

Renamed from AIChatDriver to ConversationDriver
2023-11-08 13:02:32 -05:00
Claudio DeSouza be214871df Remove uses of StringPiece and its variants
Upstream is set to deprecated, and delete all occurrences of
`base::StringPiece`, and replace it with `std::string_view`, and
according correspondent types.

This change removes the use of `base::StringPiece`, and of the headers
as well across the Brave codebase.
2023-09-22 16:26:38 +03:00
vadimsandJay Harris 3cccec9142 implemented history clearing handler + reset leo confirmation (#20179)
* implemented history clearing handler + reset leo confirmation

---------

Signed-off-by: Vadym Struts <vstruts@brave.com>
Co-authored-by: Jay Harris <jay.harris@outlook.co.nz>
2023-09-21 23:57:19 +02:00
Aleksey Khoroshilov ae5328be76 Enforce IWYU export pragma in chromium_src headers for src/ includes (#16957)
* Add presubmit check for IWYU export in chromium_src headers.

* Add // IWYU pragma: export to "src/" and "../gen/" includes.

* Export brave grit headers.

* Allow multiple includes for net_log_event_type_list.h.

* Std is not used in search_engines_handler.h.

* Fix recently added headers.
2023-02-14 07:57:35 -05:00
Aleksey Khoroshilov 3b0a9340c0 Remove unnecessary same dir rules in DEPS. 2021-12-08 14:48:24 +07:00
Aleksey Khoroshilov 5a33f242de Remove unnecessary DEPS rules. 2021-12-08 14:48:21 +07:00
Aleksey Khoroshilov 860f6ec6cb Replace relative paths in chromium_src to src-based.
# Conflicts:
#	chromium_src/chrome/browser/ui/dialogs/outdated_upgrade_bubble.cc
#	chromium_src/chrome/browser/ui/views/bubble/bubble_contents_wrapper.cc
#	chromium_src/chrome/browser/ui/views/page_info/page_info_bubble_view.cc
#	chromium_src/chrome/browser/ui/views/page_info/page_info_view_factory.h
#	chromium_src/chrome/common/webui_url_constants.cc
#	chromium_src/components/safe_browsing/content/browser/client_side_model_loader.cc
#	chromium_src/components/translate/core/browser/translate_prefs.cc
#	chromium_src/third_party/blink/renderer/core/loader/subresource_redirect_util.cc
#	chromium_src/third_party/blink/renderer/core/loader/subresource_redirect_util.h
2021-12-08 14:47:35 +07:00
bridiver 2abcbe8926 fix relative include paths for DEPS 2021-02-09 10:23:43 -07:00
bridiver fb3c0f5561 buildtools/checkdeps/checkdeps.py brave --extra-repos=brave runs succesfully 2021-02-06 13:34:00 -07:00
mkarolin fffa31132e Fixes include paths in chromium_src overrides.
Adjusts with the correct number of ".." in the includes.
2020-07-01 18:12:03 -04:00
Simon Hong a85a399a16 Clear shields settings via clear browsing data dialog
So far, shields settings are also cleard with "All time" time range.
With "All time" range option, browser nuke whole plugins type data.
With non "All time" range option, browser only clears plugins type for
empty resource ids which is flash type.
This commit makes browser clear shields data also with non "All time" range.
2020-02-21 07:52:59 +09:00
Max Karolinskiy 02e63a950d Clear browsing data on exit when instructed by the user.
Fixes brave/brave-browser#492

1. Adds a new "On exit" tab to chrome://settings/clearBrowserData dialog
with the same options as on the "Advanced" tab and a "Save" button. By
default all "On exit" options are turned off. When an option is modified
from the current state the Save button becomes enabled and allows the
user to save the "on exit" options. The options are saved to profile's
preferences: new *OnExit preferences have been added for each option.

2. Clear browsing data on exit functionality is triggered from
BraveBrowserMainParts::PreShutdown override. For each loaded profile
the code checks if user selected any on exit options and if so then a
BrowsingDataRemover is called.

3. Adds BraveClearDataOnExitTest and BraveClearDataOnExitTwoBrowsersTest
browser tests that verify that:
- the removal of the browsing data is triggered only when an "on exit"
  preference is set;
- the removal flags are constrcuted correctly;
- the removal is called only when the browser is exiting (tests with
  OTR/Guest/multiple profiles).
2019-02-28 22:42:45 -05:00