Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Informs to users about system location service #19529

Closed
wants to merge 1 commit into from

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Aug 2, 2023

fix brave/brave-browser#16897

If system location service is enabled, browser can get more accurate geolocation data.
Launch dialog about this when site asks geolocation permission if system location service is not yet enabled.

image

NOTE: focus ring color should be handled separately.

Resolves

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • 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:

Test Plan:

GeolocationAccuracyBrowserTest.DialogLaunchTest

  1. Disable Location services from Privacy & security settings
  2. Load https://browserleaks.com/geo
  3. Check permission bubble and above dialog are launched
  4. When click Ok, Privacy & Secury > Location setting page is opened
  5. Load https://browserleaks.com/geo and check Don't show again checkbox
  6. Hide dialog and load again
  7. Check dialog is not shown

@simonhong simonhong self-assigned this Aug 2, 2023
@github-actions github-actions bot added the potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false label Aug 2, 2023
@simonhong simonhong added the CI/skip Do not run CI builds (except noplatform) label Aug 2, 2023
@simonhong simonhong force-pushed the geolocation_accuracy branch 3 times, most recently from 2173a24 to 7ed867a Compare August 2, 2023 09:08
@simonhong simonhong removed the CI/skip Do not run CI builds (except noplatform) label Aug 3, 2023
@simonhong simonhong added CI/skip Do not run CI builds (except noplatform) and removed CI/skip Do not run CI builds (except noplatform) labels Aug 4, 2023
@simonhong simonhong force-pushed the geolocation_accuracy branch 3 times, most recently from 6bcab7e to 738e19e Compare August 4, 2023 06:40
@bsclifton
Copy link
Member

I know it's a WIP - but just pulled the code 🙂 This is looking nice!

@simonhong
Copy link
Member Author

I know it's a WIP - but just pulled the code 🙂 This is looking nice!

@bsclifton Thanks for testing! I'm updating dialog UI (https://www.figma.com/file/tU9zrk9Ite8B06JSjHAHhn/General-dialogs-and-popups?type=design&node-id=113-17205&mode=design&t=ReAGaEUCCkOSD3OC-0)

@simonhong simonhong force-pushed the geolocation_accuracy branch 2 times, most recently from 187bbdb to 778df10 Compare August 16, 2023 08:49
@simonhong
Copy link
Member Author

simonhong commented Aug 16, 2023

Updating UI like below. Ok button has proper color in normal state(blue) but shows orange color on hovered.
Checking which part affects hover color. GetButtonThemes() in our md_text_button.cc defines proper hover color
for kPrimary kind. but that color is not applied. => Fixed.
Screenshot 2023-08-16 174710
Screenshot 2023-08-16 174818

@simonhong simonhong force-pushed the geolocation_accuracy branch 2 times, most recently from 7c23e41 to 44e28c6 Compare August 17, 2023 02:59
@simonhong
Copy link
Member Author

Found another issue with current PR. After closing helper dialog, permission request bubble is shown.
When allowing from permission bubble,
original behavior - page renders map
changed behavior - page shows Off - Allow location access instead of renders map. Proper map is shown after reloading.

@simonhong
Copy link
Member Author

simonhong commented Aug 17, 2023

@goodov it's not ready yet to ask review as this PR introduced regression . but can you give early reivew about this PR's approach for launching another dialog before showing geolocation permission bubble? I used nested loop to block permission bubble launching.

@goodov
Copy link
Member

goodov commented Aug 17, 2023

@goodov it's not ready yet to ask review as this PR introduced regression . but can you give early reivew about this PR's approach for launching another dialog before showing geolocation permission bubble? I used nested loop to block permission bubble launching.

having RunLoop::QuitClosure() in production code is wrong, I don't think we should do that.

do we really want to add a separate nagging window before the permission popup? This doesn't look as a great UX tbh. cc @pes10k ?

@simonhong simonhong added the CI/skip Do not run CI builds (except noplatform) label Aug 18, 2023
@simonhong
Copy link
Member Author

simonhong commented Aug 18, 2023

@goodov it's not ready yet to ask review as this PR introduced regression . but can you give early reivew about this PR's approach for launching another dialog before showing geolocation permission bubble? I used nested loop to block permission bubble launching.

having RunLoop::QuitClosure() in production code is wrong, I don't think we should do that.

Yup, I think this causes some regressions. Trying to find another way to avoid it.

@simonhong simonhong removed the CI/skip Do not run CI builds (except noplatform) label Aug 21, 2023
@simonhong simonhong force-pushed the geolocation_accuracy branch 3 times, most recently from adf4401 to a2dce0c Compare August 21, 2023 08:07
@simonhong simonhong marked this pull request as ready for review August 21, 2023 09:21
@simonhong simonhong requested review from goodov and a team as code owners August 21, 2023 09:21
fix brave/brave-browser#16897

If system location service is enabled, browser can get more accurate
geolocation data. Launch dialog about this when site asks geolocation
permission if system location service is not yet enabled.
Copy link
Contributor

@sangwoo108 sangwoo108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Comment on lines +59 to +64
dialog_asked_in_current_navigation_ = true;
is_dialog_running_ = true;
brave::ShowGeolocationAccuracyHelperDialog(
web_contents(),
base::BindOnce(&GeolocationAccuracyTabHelper::OnDialogClosed,
weak_ptr_factory_.GetWeakPtr()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it better to move this into IS_WIN guard together? I know this tab helper won't be populated on other platforms but just in case.

Comment on lines +10 to +11
bool IsSystemLocationSettingEnabled();
void LaunchLocationServiceSettings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need namespace here as these plain functions are global namespace.

Comment on lines +9 to +10
constexpr char kShowGeolocationAccuracyHelperDialog[] =
"brave.show_geolocation_accuracy_helper_dialog";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

class Checkbox;
} // namespace views

class GeolocationAccuracyHelperDialogView : public views::DialogDelegateView {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: From my experience, when having modal window, using constrained_window could be a good choice as it provides more functionality to make it sure that the modal dialog is visible to users, such as restoring window when it's minimized.

Comment on lines +551 to +559
<message name="IDS_GEOLOCATION_ACCURACY_HELPER_DLG_CONTENTS_LABEL" desc="The text for content part in the dialog">
The Brave browser is attempting to access your location. You may not get accurate results unless you enable your operating system's <ph name="PART_ONE">$1<ex>Location services</ex></ph> setting and also enable <ph name="PART_TWO">$2<ex>Let apps access your location</ex></ph>.
</message>
<message name="IDS_GEOLOCATION_ACCURACY_HELPER_DLG_CONTENTS_PART_ONE_LABEL" desc="The text for content part one in the dialog">
Location services
</message>
<message name="IDS_GEOLOCATION_ACCURACY_HELPER_DLG_CONTENTS_PART_TWO_LABEL" desc="The text for content part two in the dialog">
Let apps access your location
</message>
Copy link
Collaborator

@mkarolin mkarolin Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this is not great for localization. Not sure if this is doable, but would it be possible to use two placeholders for each fragment just to get offsets? For example:

<message name="IDS_GEOLOCATION_ACCURACY_HELPER_DLG_CONTENTS_LABEL"
    desc="The text for content part in the dialog">
The Brave browser is attempting to access your location. You may not get accurate results
 unless you enable your operating system's 
<ph name="STYLE_ONE_BEGIN">$1</ph>Location services<ph name="STYLE_ONE_END">$2</ph> 
setting and also enable 
<ph name="STYLE_TWO_BEING">$3</ph>Let apps access your location<ph name="STYLE_TWO_END">$4</ph>.


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Extra line breaks for visibility in GitHub

Then use l10n_util::GetStringFUTF16 to get all the offsets and apply styling to ranges in between _BEGIN and _END offsets. I guess we can replace placeholders themselves with empty strings, if necessary. WDYT?

@simonhong
Copy link
Member Author

Changed to draft as we could change UI. cc @rebron

@simonhong simonhong marked this pull request as draft September 1, 2023 09:11
@simonhong
Copy link
Member Author

Closed as we'll add more information to geolocation permission bubble instead of another dialog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add permission for location service to help improve geolocation accuracy
5 participants