brave-core
brave-core copied to clipboard
[PoC]: GeoClue LocationProvider on Linux
Resolves https://github.com/brave/brave-browser/issues/29715
Submitter Checklist:
- [ ] I confirm that no security/privacy review is needed, or that I have requested one
- [ ] There is a ticket for my issue
- [ ] Used Github auto-closing keywords in the PR description above
- [ ] Wrote a good PR/commit description
- [ ] Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
- [ ] Added appropriate labels (
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issue - [ ] Checked the PR locally:
- [ ] Ran
git rebase master
(if needed)
Reviewer Checklist:
- [ ] A security review is not needed, or a link to one is included in the PR description
- [ ] New files have MPL-2.0 license header
- [ ] Adequate test coverage exists to prevent regressions
- [ ] Major classes, functions and non-trivial code blocks are well-commented
- [ ] Changes in component dependencies are properly reflected in
gn
- [ ] Code follows the style guide
- [ ] Test plan is specified in PR before merging
After-merge Checklist:
- [ ] The associated issue milestone is set to the smallest version that the changes has landed on
- [ ] All relevant documentation has been updated, for instance:
- [ ] https://github.com/brave/brave-browser/wiki/Deviations-from-Chromium-(features-we-disable-or-remove)
- [ ] https://github.com/brave/brave-browser/wiki/Proxy-redirected-URLs
- [ ] https://github.com/brave/brave-browser/wiki/Fingerprinting-Protections
- [ ] https://github.com/brave/brave-browser/wiki/Brave%E2%80%99s-Use-of-Referral-Codes
- [ ] https://github.com/brave/brave-browser/wiki/Custom-Headers
- [ ] https://github.com/brave/brave-browser/wiki/Web-Compatibility-Exceptions-in-Brave
- [ ] https://github.com/brave/brave-browser/wiki/QA-Guide
- [ ] https://github.com/brave/brave-browser/wiki/P3A
Test Plan:
Does it continue to fall back to https://location.brave.com if it fails to get a location using GeoClue2 for any reason?
Does it continue to fall back to https://location.brave.com/ if it fails to get a location using GeoClue2 for any reason?
Interestingly it looks like it doesn't - I'll try and get that set up.
We should add:
Ooh interesting - I'll do that
@fmarier I've added the additional_deps
and now we should fallback to our default location services if GeoClue isn't available. @simonhong would you mind taking a look too?
Also, I think I can rewrite the LocationProvider to use the dbus
blocking calls, because the location services run on a background thread. Do you reckon it's worth doing?
now we should fallback to our default location services if GeoClue isn't available
Is the fallback service used in all of these cases?
-
LinuxGeoClueLocationBackend
is false - geoclue2 is not installed on the machine
- geoclue fails to initialize for some reason
- geoclue get location times out
Nope, we only use the fallback when:
-
LinuxGeoClueLocationBackend
is false - The geoclue2 service is not available
This is comparable to what Chromium does on Windows/Mac - if something goes wrong with the SystemLocationProvider
once it's been instantiated we don't fallback to the NetworkLocationProvider
, the location just errors.
This is comparable to what Chromium does on Windows/Mac
Ok, that sounds good then. No need to make it more robust than Windows/Mac.
Several suggested reviewers were missing from the list. Please be sure to always add all suggested reviewers and double-check after changing any new files
please rebase to cr114. some Geolocation types have changed there.
@bridiver did you have anything else?
@bridiver did you have a chance to take another look?
I'm curious why the work has stopped here? This looked fine and was fine to be merged and enabled the last time I looked at it.
@fallaciousreasoning can you please rebase the PR and resume the work here?
we're clearly lacking good geolocation support on Linux rn. see https://github.com/brave/brave-browser/issues/16897
Rebased - sorry it's been a while but I think @bridiver had some reservations about the approach?
@fallaciousreasoning looks like the PR needs some updates, tests are failing.
Yup, I've got a few things to clean up still but I'm working on some other stuff at the moment.
Just working out what's changed with the permission model which is causing the tests to fail.
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
Looks like this is still active - needs a rebase though cc: @fallaciousreasoning
Yup, the main blocker is I'm struggling to get the environment in the tests working right
[puLL-Merge] - brave/brave-core@18063
Here's my review of the pull request:
Description
This PR adds support for using the GeoClue2 location provider on Linux systems. It implements a new GeoClueLocationProvider
class that interacts with the GeoClue2 D-Bus service to obtain location information. The feature is controlled by a new feature flag kLinuxGeoClueLocationBackend
, which is disabled by default.
Changes
Changes
-
browser/DEPS
:- Added include rule for
brave/services/device/geolocation
.
- Added include rule for
-
browser/about_flags.cc
:- Added a new feature flag for the GeoClue location backend.
-
browser/brave_content_browser_client.cc
andbrowser/brave_content_browser_client.h
:- Added
OverrideSystemLocationProvider
method to potentially use the GeoClue provider.
- Added
-
browser/sources.gni
:- Added dependency on the new geolocation component for Linux builds.
-
chromium_src/services/device/public/cpp/device_features.cc
anddevice_features.h
:- Added the new feature flag definition.
-
patches/chrome-installer-linux-debian-additional_deps.patch
andpatches/chrome-installer-linux-rpm-additional_deps.patch
:- Added GeoClue2 as a dependency for Linux installations.
-
services/device/geolocation/
:- Added new files implementing the GeoClue location provider:
-
geoclue_client_object.cc
and.h
-
geoclue_location_provider.cc
and.h
-
geoclue_location_provider_unittest.cc
-
- Added new files implementing the GeoClue location provider:
-
test/BUILD.gn
:- Added dependency on the new geolocation unit tests for Linux builds.
Possible Issues
- The feature is disabled by default, which means it won't be immediately available to users unless explicitly enabled.
- The implementation assumes the availability of the GeoClue2 service on the Linux system, which may not always be the case.
Security Hotspots
- The GeoClue2 service interaction involves handling sensitive location data. Ensure that proper permissions and user consent mechanisms are in place before accessing location information.
- The D-Bus communication with the GeoClue2 service should be secured to prevent potential man-in-the-middle attacks or unauthorized access to location data.
Overall, this PR adds a valuable feature for Linux users, providing a native location service integration. The implementation seems well-structured and includes unit tests. However, careful consideration should be given to privacy and security aspects of handling location data.
A Storybook has been deployed to preview UI for the latest push