You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: switch default search engine to Brave Search (#26356)
## **Description**
The MetaMask mobile in-app browser currently defaults to Google search,
which shows ads that can lead users to fake/scam websites. This PR
switches the default search engine to Brave Search, providing a
privacy-focused, ad-free search experience that better protects users.
**Changes:**
- Updated `DEFAULT_SEARCH_ENGINE` constant from `'Google'` to `'Brave'`
- Added Brave Search URL (`https://search.brave.com/search?q=`) and
refactored the if/else chain to a module-scoped lookup map
(`SEARCH_ENGINE_URLS`) for cleaner extensibility and to avoid
re-allocation on every call
- Added `'Brave Search'` option to the search engine picker in General
Settings
- Added Redux persist migration (121) to automatically switch all
existing users to Brave, following the same pattern as migration 58
- Updated `processUrlForBrowser` default parameter to use
`AppConstants.DEFAULT_SEARCH_ENGINE` instead of hardcoded `'Google'`
- Updated `SitesSearchFooter` to use the shared `SEARCH_ENGINE_URLS` map
so the "Search for ... on {engine}" label and URL correctly reflect the
selected engine (previously hardcoded to Google/DuckDuckGo only)
- Fallback for unknown search engine values now uses
`AppConstants.DEFAULT_SEARCH_ENGINE` (Brave) instead of hardcoded Google
## **Changelog**
CHANGELOG entry: Changed the default search engine to Brave Search for a
privacy-focused, ad-free browsing experience
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: Brave Search as default search engine
Scenario: New user searches in the in-app browser
Given the user has freshly installed the app
When user types a search keyword in the browser URL bar
Then the search results are served by Brave Search (search.brave.com)
Scenario: Existing user is migrated to Brave Search
Given the user previously had Google or DuckDuckGo as their search engine
When the user updates the app and launches it
Then the search engine setting is automatically changed to Brave
And searches in the in-app browser use Brave Search
Scenario: Search footer label reflects selected engine
Given the user is typing a keyword in the browser URL bar
When the autocomplete dropdown appears
Then the footer shows "Search for {keyword} on Brave" (not Google)
And tapping it navigates to search.brave.com
Scenario: User can still select other search engines
Given the user is on Settings > General
When user opens the Search Engine picker
Then Google, DuckDuckGo, and Brave Search are all available options
And the user can switch between them
And the search footer label updates to match the selected engine
```
## **Screenshots/Recordings**
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes core browser URL processing and the default search engine,
plus a state migration that mutates persisted user settings; mistakes
could send users to wrong destinations or override preferences
unexpectedly.
>
> **Overview**
> **Switches the in-app browser default search engine from Google to
Brave.** This updates `AppConstants.DEFAULT_SEARCH_ENGINE`, adds Brave
to the General Settings search engine picker, and centralizes engine
base URLs in `SEARCH_ENGINE_URLS`.
>
> Search URL generation is refactored to use the shared lookup (with
fallback to the default) in both `processUrlForBrowser` and
`SitesSearchFooter`, and the footer testID/text are renamed from
Google-specific to a generic `trending-search-footer-search-link`.
>
> Adds migration `126` to move persisted `settings.searchEngine` from
`Google` to `Brave` for existing users, and updates unit/integration/e2e
tests and selectors to match the new engine + testIDs.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
471a8dd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
0 commit comments