Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Prevent loss of default browser on Windows during upgrade/reinstall/etc #8060

Merged
merged 2 commits into from
Apr 4, 2017
Merged

Prevent loss of default browser on Windows during upgrade/reinstall/etc #8060

merged 2 commits into from
Apr 4, 2017

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Apr 4, 2017

Test plan

Prevent loss of default browser on Windows during upgrade/reinstall/etc

This should be attempted on Windows 7 and 10

  1. Install the official release of Brave 0.14.2 (at the time of writing, not available)
  2. Set Brave as the default for all applications
  • Start menu
  • search "Default Programs" and press enter
    • Click "Set defaults by app" (Windows 10) or "Set your default programs" (Windows 7)
    • On the left, pick Brave
    • choose "Choose defaults for this program"
    • Pick the "select all" checkbox at the top and hit OK
  • Windows 10 demo:
    default-win10
  • Windows 7 demo:
    default-win7
  1. Now that default browser is set, you can test it
  • Open a link from email
  • Open link from Slack
  • etc
  1. Once default browser as Brave is confirmed, let's re-install the same version of Brave on top of itself. Before, this would break the setting. Basically repeat step 1
  2. Wait at least 30 seconds; if the default browser is reset, it doesn't happen immediately
  3. Go into the "Default Programs" UI and verify that NONE of the settings (specifically http and https changed for Brave

Update name shown in Windows to Brave Software (was Brave Inc)

While doing the test plan for Windows default browser, make sure all places in the UI say Brave Software and not Brave Inc. See below screenshots for expected before/after.

Description

Prevent loss of default browser on Windows during upgrade/reinstall/etc

Fixes #5246

  • Brave registers a handler called BraveHTML
  • Using Default Programs, users can associate an extension or protocol with a handler (which in our case is BraveHTML.

Each upgrade was breaking default browser because the install or upgrade updates the path which is not allowed. For example, it would set:
"C:\Users\brian\AppData\Local\brave\app-0.13.4\Brave.exe" -- "%1"
to
"C:\Users\brian\AppData\Local\brave\app-0.13.5\Brave.exe" -- "%1"

Changing the value of keys associated with the BraveHTML handler would trigger the reset of the handler for http and https (but not extensions, email, or FTP). Specifically these keys:

  • HKEY_CURRENT_USER\SOFTWARE\Classes\BraveHTML\DefaultIcon
  • HKEY_CURRENT_USER\SOFTWARE\Classes\BraveHTML\shell\open\command

This PR fixes the issue by linking to the stub executable. Using the above example, this would look like:
"C:\Users\brian\AppData\Local\brave\Brave.exe" -- "%1"

This stub executable was something introduced (I believe) with Squirrel 1.5.0. We already use it for the shortcut which gets installed on the desktop (in fact, this change was something @aekeus
and I had to resolve because it broke the params being passed).

The stub executable has an absolute path which does not change, meaning:

  • the path never gets updated in the registry
  • default browser not modified (because registry wasn't updated)

Update name shown in Windows to Brave Software (was Brave Inc)

Fixes #2061

BEFORE change
screen shot 2017-04-04 at 1 08 12 am


AFTER change
screen shot 2017-04-04 at 1 44 31 am


  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

This prevents default browser from being reset on upgrade / reinstall.

Fixes #5246

Auditors: @bbondy, @jonathansampson
This value ends up getting stored in the MUICache so existing installs doing
an upgrade may not show the new name immediately. You can verify by either
deleting the MUICache registry key or installing on a machine which has never
had Brave installed before.

Fixes #2061

Auditors: @bbondy, @bridiver
@bsclifton bsclifton added this to the 0.14.2 milestone Apr 4, 2017
@bsclifton bsclifton self-assigned this Apr 4, 2017
@bsclifton bsclifton added impact/high parity Features which should be supported in Brave since they're supported in other major browsers. QA/test-plan-required release-notes/include labels Apr 4, 2017

Push $EXEDIR
Call GetParent
Call GetParent
Copy link
Member Author

@bsclifton bsclifton Apr 4, 2017

Choose a reason for hiding this comment

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

Sorry for the confusing diff; This is the fix here (calling GetParent a second time)

I messed around with my .gitconfig for about 20 minutes trying it to only recognize this one line change before giving up and just checking it in like this. I believe this file in particular was checked in with CRLF (and I'm not about to change my config to do that). Good news: future updates won't have this conflict

@darkdh darkdh self-requested a review April 4, 2017 12:54
Copy link
Member

@darkdh darkdh left a comment

Choose a reason for hiding this comment

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

++

Copy link
Collaborator

@jonathansampson jonathansampson left a comment

Choose a reason for hiding this comment

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

I had to look into GetParent to understand the fix, but I think I get it now. Nice work!

@luixxiul
Copy link
Contributor

luixxiul commented Apr 9, 2017

@bsclifton do you think QA work on this needs to be postponed until 0.14.2?

@luixxiul luixxiul added the needs-info Another team member needs information from the PR/issue opener. label Apr 9, 2017
@bsclifton
Copy link
Member Author

@luixxiul do you mean postponed until 0.14.3? (the version after this?)

I believe a valid test is to install the same version on top of what you already have. For example, with 0.14.1 (which does not have the fix), you can do these steps:

  • Install 0.14.1
  • Set default browser
  • Install 0.14.1 again, even though it's already installed
  • Default browser is reset

The same steps should not repro for 0.14.2 (because it will properly handle the path)

@luixxiul
Copy link
Contributor

do you mean postponed until 0.14.3?

Yes, I just misunderstood the current version number.

@srirambv
Copy link
Collaborator

srirambv commented Apr 13, 2017

Still see Brave Inc. in preview 3.
image

@bsclifton
Copy link
Member Author

@srirambv OK - let me see if I can find a way that you can reset the cache. There is something called the MUI cache which is holding onto that value

@bsclifton
Copy link
Member Author

bsclifton commented Apr 19, 2017

@srirambv here are some steps you can take to force the MUI cache to reload:

  • Close default programs UI completely
  • Open regedit.exe
    • Expand HKEY_CURRENT_ROOT from the root of the tree in the left pane.
    • Expand Local Settings.
    • Expand Software.
    • Expand Microsoft.
    • Expand Windows.
    • Expand Shell.
    • Right-click MuiCache
    • you might choose to back up the values (export). Just in case
    • when ready, Choose Delete from the context menu.
    • Click Yes.
  • Reopen default programs UI
  • name should now be correct

@srirambv
Copy link
Collaborator

@bsclifton Works perfect after deleting reg values 👍 (verified on 0.14.2 RC2)
image

@luixxiul luixxiul removed the needs-info Another team member needs information from the PR/issue opener. label Apr 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
OS/Windows parity Features which should be supported in Brave since they're supported in other major browsers. QA/test-plan-specified release-notes/include
Projects
None yet
5 participants