cef icon indicating copy to clipboard operation
cef copied to clipboard

chrome: Support configuration as default system browser

Open magreenblatt opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. Chrome/Chromium has an option here to configure itself as the default system browser.

Describe the solution you'd like This functionality should be disabled by default for CEF-based applications, with an option to enable via CefSettings or similar.

Additional context We will disable this functionality in M120.

magreenblatt avatar Nov 28 '23 17:11 magreenblatt

Comment on shell_integration::SetAsDefaultBrowser:

// Sets Chrome as the default browser (only for the current user).
//
// Don't use this, because:
//   - This does not work on Windows version 8 or higher.
//   - This cannot provide feedback as to success because setting a default
//     browser is asynchronous.
//
// Use `DefaultBrowserWorker` instead.
// TODO(https://crbug.com/1393452): Extend `DefaultBrowserWorker` to work better
// on the Mac and remove this function.

Code using DefaultBrowserWorker in BrowserProcessImpl::ApplyDefaultBrowserPolicy. This should not be triggering currently because prefs::kDefaultBrowserSettingEnabled is false by default.

magreenblatt avatar Nov 28 '23 18:11 magreenblatt

I have confirmed in my testing that even though prefs::kDefaultBrowserSettingEnabled is false, this simply determines whether to check that it's default, and re-default it if it is.

The call stack for actively setting the default, essentially boils down to the following for Chromium:

https://github.com/chromium/chromium/blob/94885c7b3d3/chrome/install_static/chromium_install_modes.cc#L70-L71

The actual code that runs to show "Set as Default" is the following:

https://github.com/chromium/chromium/blob/e4b8843c718a515f3c55ee0a96440fe0bf56d6ac/chrome/browser/custom_handlers/chrome_protocol_handler_registry_delegate.cc#L70-L81

This eventually boils down to

https://github.com/chromium/chromium/blob/e4b8843c718a515f3c55ee0a96440fe0bf56d6ac/chrome/browser/shell_integration.cc#L89-L96

And per-platform behaviours:

https://github.com/chromium/chromium/blob/e4b8843c718a515f3c55ee0a96440fe0bf56d6ac/chrome/browser/shell_integration_win.cc#L747-L751

which points back to that install mode in the first snippet.

https://github.com/chromium/chromium/blob/e4b8843c718a515f3c55ee0a96440fe0bf56d6ac/chrome/install_static/install_util.cc#L402-L404

So theoretically, either calling shell_integration::DefaultBrowserWorker::DisableSetAsDefaultForTesting();, or overriding the supports_set_as_default_browser value could do it so that it can't be accidentally enabled by users (either by chrome://settings or a launch flag). Chromium's code in general doesn't have a direct way to just disable the ability to set as default, so it may require patching.

WizardCM avatar Aug 06 '24 09:08 WizardCM