brave-core icon indicating copy to clipboard operation
brave-core copied to clipboard

[PoC]: GeoClue LocationProvider on Linux

Open fallaciousreasoning opened this issue 1 year ago • 22 comments

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 or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • [ ] Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • [ ] 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:

fallaciousreasoning avatar Apr 14 '23 04:04 fallaciousreasoning

Does it continue to fall back to https://location.brave.com if it fails to get a location using GeoClue2 for any reason?

fmarier avatar May 02 '23 05:05 fmarier

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

fallaciousreasoning avatar May 03 '23 02:05 fallaciousreasoning

@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?

fallaciousreasoning avatar May 09 '23 01:05 fallaciousreasoning

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

fmarier avatar May 09 '23 21:05 fmarier

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.

fallaciousreasoning avatar May 09 '23 21:05 fallaciousreasoning

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.

fmarier avatar May 10 '23 22:05 fmarier

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

bridiver avatar May 11 '23 00:05 bridiver

please rebase to cr114. some Geolocation types have changed there.

goodov avatar May 17 '23 13:05 goodov

@bridiver did you have anything else?

fallaciousreasoning avatar Jun 15 '23 00:06 fallaciousreasoning

@bridiver did you have a chance to take another look?

fallaciousreasoning avatar Jul 24 '23 20:07 fallaciousreasoning

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

goodov avatar Apr 16 '24 07:04 goodov

Rebased - sorry it's been a while but I think @bridiver had some reservations about the approach?

fallaciousreasoning avatar Apr 17 '24 04:04 fallaciousreasoning

@fallaciousreasoning looks like the PR needs some updates, tests are failing.

goodov avatar Apr 18 '24 10:04 goodov

Yup, I've got a few things to clean up still but I'm working on some other stuff at the moment.

fallaciousreasoning avatar Apr 18 '24 23:04 fallaciousreasoning

Just working out what's changed with the permission model which is causing the tests to fail.

fallaciousreasoning avatar May 03 '24 03:05 fallaciousreasoning

A Storybook has been deployed to preview UI for the latest push

brave-builds avatar May 07 '24 22:05 brave-builds

A Storybook has been deployed to preview UI for the latest push

brave-builds avatar Jun 17 '24 05:06 brave-builds

A Storybook has been deployed to preview UI for the latest push

brave-builds avatar Jun 17 '24 23:06 brave-builds

Looks like this is still active - needs a rebase though cc: @fallaciousreasoning

bsclifton avatar Aug 13 '24 22:08 bsclifton

Yup, the main blocker is I'm struggling to get the environment in the tests working right

fallaciousreasoning avatar Aug 13 '24 23:08 fallaciousreasoning

[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

  1. browser/DEPS:

    • Added include rule for brave/services/device/geolocation.
  2. browser/about_flags.cc:

    • Added a new feature flag for the GeoClue location backend.
  3. browser/brave_content_browser_client.cc and browser/brave_content_browser_client.h:

    • Added OverrideSystemLocationProvider method to potentially use the GeoClue provider.
  4. browser/sources.gni:

    • Added dependency on the new geolocation component for Linux builds.
  5. chromium_src/services/device/public/cpp/device_features.cc and device_features.h:

    • Added the new feature flag definition.
  6. patches/chrome-installer-linux-debian-additional_deps.patch and patches/chrome-installer-linux-rpm-additional_deps.patch:

    • Added GeoClue2 as a dependency for Linux installations.
  7. 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
  8. test/BUILD.gn:

    • Added dependency on the new geolocation unit tests for Linux builds.

Possible Issues

  1. The feature is disabled by default, which means it won't be immediately available to users unless explicitly enabled.
  2. The implementation assumes the availability of the GeoClue2 service on the Linux system, which may not always be the case.

Security Hotspots

  1. The GeoClue2 service interaction involves handling sensitive location data. Ensure that proper permissions and user consent mechanisms are in place before accessing location information.
  2. 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.

github-actions[bot] avatar Oct 03 '24 03:10 github-actions[bot]

A Storybook has been deployed to preview UI for the latest push

brave-builds avatar Oct 03 '24 04:10 brave-builds