This PR removes a lot of unnecessary uses of `EXPECT_STREQ` combined
with calls to `c_str()`, and converts these comparisons simply to
`std::string` comparisons using `EXPECT_EQ`. This is functionally the
same, but it is arguably easier to read in general.
Resolves https://github.com/brave/brave-browser/issues/46600
This change adds a new delegate method to `TabDelegate` which allows handling when a context menu preview is tapped and introduces the proper implementation in `TabCWVUIHandler` to call it.
This build failure seems to be a result of a recent IWYU fix for
`string_util.h`, and this particular source relying on transient
inclusions.
This fixes adds the necessary header. Some follow up work will be pushed
to remove all uses of `getenv` in our codebase, as we should be using
the `//base` counterpart.
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
The `CHECK(<expr>, base::NotFatalUntil::M141)` causes thousands
reports at backtrace.
Reverting it here through patch for the case if the next minor c137 bump
will not have the commit. At the upstream it was landed on
`137.0.7151.79`.
Chromium commit
https://source.chromium.org/chromium/chromium/src/+/35b700af4f3e058dbb7b84346e4d293408d09736
[M137] Revert "Sync ProcessorEntity: Upgrade remaining DCHECKs"
Original change's description:
> Revert "Sync ProcessorEntity: Upgrade remaining DCHECKs"
>
> This reverts commit 6752bab9ae006f82bdd1bf73a475ffffd2fa2d00.
>
> Reason for revert: Still crashing on M137
>
> Bug: 408182457, 419310731
> Original change's description:
> > Sync ProcessorEntity: Upgrade remaining DCHECKs
> >
> > This CL upgrades most of the remaining DCHECKs in ProcessorEntity to
> > proper CHECKs, mostly with base::NotFatalUntil::M141.
> > A few that are obviously-valid don't have NotFatalUntil, and one that
> > is questionable is just removed.
> >
> > Also includes some minor other cleanups, like inlining a one-line
> > helper method with a single call site.
> >
> > Bug: 408182457
> > Change-Id: I7e385de3b6d2953ff9cac62f40e3ebb5651219b8
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6461075
> > Reviewed-by: Maksim Moskvitin <mmoskvitin@google.com>
> > Commit-Queue: Marc Treib <treib@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1448230}
>
> Bug: 408182457
> Change-Id: Ib5d538c4ebd2aabb9cb0cd27416fba02187945cc
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6578201
> Auto-Submit: Maksim Moskvitin <mmoskvitin@google.com>
> Commit-Queue: Mikel Astiz <mastiz@chromium.org>
> Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
> Reviewed-by: Mikel Astiz <mastiz@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1464694}
Bug: 419802535,408182457,419310731,408182457
Change-Id: Ib5d538c4ebd2aabb9cb0cd27416fba02187945cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6612682
Resolves https://github.com/brave/brave-browser/issues/46539
* [AI Chat]: Don't destroy conversations while there is an in progress request (even if it has no UI bound)
* [AI Chat]: Move tests to AIChatService
* [AI Chat]: Test that finishing generation deletes the conversation
* [AI Chat]: Update comment to indicate the conversation will be unloaded when the request completes
* [AI Chat]: remove |is_request_in_progress|
* [AI Chat]: Update comment about how IsRequestInProgress is being (ab)used
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 change ensures that we always save possible mutations that are currently in-memory only (to be fixed in the future) and also allows the `saveAllTabs` to attempt a synchronous update when the app is terminating
* Fix incorrect [AdblockEngine initWithSerializedData:error:] error flow not returning nil as documentation states.
* Fix incorrect [AdblockEngine initWithRules:error:] error flow not returning nil as documentation states.
* Add debug menu option for corrupting adblock DAT cache.
* Fallback to loading cached plaintext (combined) rule list when failing to load or deserialize from DAT.
* Cleanup cached serialized engine file or combined rules file when failing to compile from the cache.
This ensures CoreData updates for tabs that are saved when the app is backgrounded happen off the main thread which can cause some hangs with large tab sets and quick multitasking
This moves the `-[SFSpeechRecognizer supportsOnDeviceRecognition]` call to be done off main as its known to block the thread its called and cause hangs.
This removes the code that adds a web view to the view hierarchy in order to make a snapshot as this is no longer necessary and should fix a hang that is caused by when a web view changes windows
This swaps a call that fetched all of the users recently closed tabs when trying to determine if the action for opening the most recently opened tab should be added to the toolbar to only fetch a single item.