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

Added ms-edge protocol handler option #10879

Merged
merged 7 commits into from
Nov 16, 2021
Merged

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Nov 4, 2021

fix brave/brave-browser#17558

Applied below FF's implementation to set default handler w/o using windows system ui.
It calculated hash value by using some properties such as user sid, protocol or timestamp.
If this method is not available, system ui will be launched instead.
https://github.com/mozilla/gecko-dev/blob/master/toolkit/mozapps/defaultagent/SetDefaultBrowser.cpp

Resolves

Option state when brave is not yet set for ms-edge protocol handler
Screenshot 2021-11-04 212457

Option state when brave is ms-edge protocol handler
Screenshot 2021-11-04 212648

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
  • 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, npm run lint, 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:

npm run test brave_unit_tests -- --filter=DefaultProtocolHandlerUtilsWinTest

Test 1

  1. Check this browser is not a default ms-edge protocol handler from control panel
  2. Launch browser and load brave://settings/system/
  3. Check Make default button is visible and click
  4. Check button is disappeared
  5. Search any keyword from windows taskbar and bing url is loaded in this browser
  6. Change default handler to another browser like edge from control panel
  7. Check brave://settings/system/ is updated properly

Test 2

  1. Check this browser is not a default ms-edge protocol handler from control panel
  2. Launch browser with --use-system-ui-for-ms-edge cmd line switch
  3. load brave://settings/system/ and click button
  4. Check system ui is launched for setting default apps for protocol

NOTE: With Older than Windows 10 RS2, system ui will be launched.

@simonhong
Copy link
Member Author

@rebron Needs above options's all texts.

@simonhong simonhong force-pushed the ms_edge_protocol_setting branch 2 times, most recently from 10e64f3 to 3a352f9 Compare November 5, 2021 02:49
@simonhong simonhong changed the title WIP: Added ms-edge protion setting WIP: Added ms-edge protocol handler option setting Nov 5, 2021
@simonhong simonhong changed the title WIP: Added ms-edge protocol handler option setting WIP: Added ms-edge protocol handler option Nov 5, 2021
@simonhong simonhong force-pushed the ms_edge_protocol_setting branch 9 times, most recently from 0988b4d to 261efb9 Compare November 10, 2021 07:18
@simonhong simonhong marked this pull request as ready for review November 10, 2021 12:18
@simonhong simonhong requested review from a team as code owners November 10, 2021 12:18
@simonhong simonhong changed the title WIP: Added ms-edge protocol handler option Added ms-edge protocol handler option Nov 10, 2021
@simonhong simonhong force-pushed the ms_edge_protocol_setting branch from c92206d to 9f379a1 Compare November 10, 2021 12:32
@goodov
Copy link
Member

goodov commented Nov 10, 2021

this is crazy! (I love it) 😀

@simonhong simonhong added the CI/skip Do not run CI builds (except noplatform) label Nov 11, 2021
@simonhong simonhong force-pushed the ms_edge_protocol_setting branch from 9f379a1 to d45f6ea Compare November 11, 2021 05:53
@simonhong simonhong removed the CI/skip Do not run CI builds (except noplatform) label Nov 11, 2021
@simonhong simonhong requested a review from rebron November 11, 2021 06:10
@simonhong simonhong force-pushed the ms_edge_protocol_setting branch 3 times, most recently from 9c5de9f to b6a61ff Compare November 15, 2021 05:53
Copy link
Member Author

@simonhong simonhong left a comment

Choose a reason for hiding this comment

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

@goodov @bsclifton Comments are all addressed. PTAL again!

@simonhong simonhong requested a review from goodov November 15, 2021 05:57
@simonhong simonhong force-pushed the ms_edge_protocol_setting branch from b6a61ff to 30eea76 Compare November 15, 2021 06:27
@simonhong simonhong requested a review from rmcfadden3 November 15, 2021 06:28
As ms will not allow setting 3p applications as a default
ms-edge protocol handler, this option should not be visible
from that version (Win11, 22494 build).
See https://www.ctrl.blog/entry/microsoft-edge-protocol-competition.html
@simonhong simonhong force-pushed the ms_edge_protocol_setting branch from 30eea76 to 346a6f6 Compare November 15, 2021 06:47
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Code looks great and works perfectly. After setting to default, it hides the button. When default is changed away from Brave, button re-appears. Thanks for putting in the Windows 11 version check for 22494 😄

@rmcfadden3
Copy link

@simonhong & @rebron — text lgtm. No changes.

@simonhong
Copy link
Member Author

Merged as only upload step was failed in CI.

@simonhong simonhong merged commit a866388 into master Nov 16, 2021
@simonhong simonhong deleted the ms_edge_protocol_setting branch November 16, 2021 22:49
@simonhong simonhong added this to the 1.34.x - Nightly milestone Nov 16, 2021
simonhong added a commit that referenced this pull request Nov 23, 2021
Added ms-edge protocol handler option
simonhong added a commit that referenced this pull request Nov 23, 2021
@kjozwiak
Copy link
Member

kjozwiak commented Nov 23, 2021

Verification PASSED on Win 11 x64 using the following build:

Brave | 1.34.31 Chromium: 96.0.4664.45 (Official Build) nightly (64-bit)
-- | --
Revision | 76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}
OS | Windows 11 Version 21H2 (Build 22000.318)

Test Case #1

  • ensured that Default microsoft-edge protocol handler under brave://settings/system displays a Make default when the MICROSOFT-EDGE protocol is set to another browser
  • ensured that selecting Make default changes MICROSOFT-EDGE to Brave under Apps -> Default apps -> Brave Nightly
  • ensured that the Make default isn't visible under brave://settings/system when Brave is set as the default application for the MICROSOFT-EDGE protocol
  • ensured that opening links within the task manager correctly opens Brave when it's not running
  • ensured that opening links within the task manager correctly opens a new tab within Brave when it's already running
Brave not ms-edge default Button visible when not default After clicking button Brave as default
msEdgeNotDefault protocolvisibleIcon defaultButtonClicked braveSetasDefaultProtocol

Test Case #2

brave.exe --enable-logging=stderr --use-system-ui-for-ms-edge
  • ensured that clicking on Make Default under brave://settings/system launched the Default app system UI

systemUIcommand


Verification PASSED on Win 10 x64 using the following build:

Test Case #1

  • ensured that Default microsoft-edge protocol handler under brave://settings/system displays a Make default when the MICROSOFT-EDGE protocol is set to another browser
  • ensured that selecting Make default changes MICROSOFT-EDGE to Brave under Apps -> Default apps -> Brave Nightly
  • ensured that the Make default isn't visible under brave://settings/system when Brave is set as the default application for the MICROSOFT-EDGE protocol
  • ensured that opening links within the task manager correctly opens Brave when it's not running
  • ensured that opening links within the task manager correctly opens a new tab within Brave when it's already running
Brave not ms-edge default Button visible when not default After clicking button Brave as default
ms-edge-default-handler brave-default-reverted default-handler nightly-default-handler

Test Case #2

brave.exe --enable-logging=stderr --use-system-ui-for-ms-edge
  • ensured that clicking on Make Default under brave://settings/system launched the Default app system UI

apps-by-protocol

@kjozwiak
Copy link
Member

While running through the verifications via #10879 (comment), I did run into the following:

keepUsing

However, this is a Windows limitation and much we can do. Once you click on OK, I never received the screen again. Even after switching the ms-edge protocol to Edge <-> Brave a few times.


void MSEdgeProtocolMessageHandler::OnRegValChanged() {
CheckMSEdgeProtocolDefaultHandlerState();
StartWatching();
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesn't seem right, aren't we already watching it? What happens if you call StartWatching more than once on the same key?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess RegistryMonitor does this, but why aren't we using that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Calling StartWatching from callback doesn't make any issue because it's onetime watching.

  // To stop watching, delete this RegKey object. To continue watching the
  // object after the callback is invoked, call StartWatching again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, RegistryMonitor seems installer specific (it inherits InstalledVersionMonitor interface).
And the logic for monitoring is quite simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add entry in settings webui for configuring Brave as a default app for microsoft-edge protocol
8 participants