Files
brave-core/components
Brian R. Bondy 754872677b Open origin settings on first purchase (#35460)
* Open Origin settings page on first purchase detection

- Add Delegate interface to BraveOriginService for browser-layer actions
- Watch skus::prefs::kSkusState changes to re-check purchase state
  when credentials update (e.g. after purchasing on account.brave.com)
- On first purchase detection, open brave://settings/origin via the
  delegate so the user can configure Origin policies
- Add BraveOriginNavigationDelegate (browser layer) implementing the
  delegate using chrome::ShowSettingsSubPageForProfile
- Move navigation impl to its own source_set to avoid adding sources
  directly to browser/ui/BUILD.gn
- Add unit tests for delegate, one-shot behavior, and pref-triggered
  recheck

* Address review feedback on PR #35460

- Move Delegate from SetDelegate() setter to constructor parameter
  per ARCH-025 (constructor injection over setter methods)
- Add //chrome/browser/ui dep in browser/ui/brave_origin/BUILD.gn
  for chrome_pages.h include per BS-012
- Move //brave/components/brave_origin to public_deps in
  browser/brave_origin/BUILD.gn since the header exposes it per BS-024

* Guard brave_origin UI dep on !is_android

chrome::ShowSettingsSubPageForProfile is only compiled for desktop
(chrome_pages.cc is in the !is_android sources block). Move the
//brave/browser/ui/brave_origin dep and its allow_circular_includes_from
entry behind !is_android to fix the Android linker error.

* Address remaining review feedback on PR #35460

- Move SkusServiceGetter into Delegate::GetSkusService() so the
  component layer no longer depends on the browser-layer SKU factory
- Track first-purchase settings open with a boolean instead of
  resetting the delegate; delegate is only dropped in Shutdown()
- Change BraveOriginNavigationDelegate to use raw_ref<Profile>
- Add TODO comment in config.gni for the circular dependency
- Add //brave/browser/skus dep to browser/ui/brave_origin BUILD.gn

* Fix Android linker error for ShowSettingsSubPageForProfile

chrome::ShowSettingsSubPageForProfile is not available on Android.
Guard the call and its include with #if !BUILDFLAG(IS_ANDROID),
matching the pattern used in ai_chat and other Brave features.

* Register kOriginFreeTierAccepted pref in settings handler unit tests on Linux

The three test fixtures in this file manually register prefs but were
missing kOriginFreeTierAccepted, which is registered in production code
via RegisterLocalStatePrefs and read during BraveOriginService
construction on Linux. This caused a CHECK failure on Linux:
"Trying to access an unregistered pref: brave.origin.free_tier_accepted"

* Fix linker errors for BraveOriginNavigationDelegate on Android/tests and iOS constructor mismatch

The brave_origin_navigation.cc implementation was only compiled for
desktop (!is_android) but the factory references it on all platforms.
Move the dep outside the platform guard so it links on Android too, and
add it to the unit_tests target. For iOS, create a BraveOriginDelegateIOS
that wraps the SKU service getter to match the new Delegate-based
constructor signature.
2026-04-14 18:09:51 -04:00
..