Skip to content

Fix OnRegisterCustomPreferences timing and add SetDefaultPreference #4281

Description

@magreenblatt

CefBrowserProcessHandler::OnRegisterCustomPreferences for CEF_PREFERENCES_TYPE_REQUEST_CONTEXT is currently called after Chromium's general profile preferences are registered in RegisterUserProfilePrefs, but before service-specific preferences are registered in RegisterProfilePrefs. This timing is incorrect for values like prefs::kSigninAllowedOnNextStartup, which can only be configured after the service-specific registration is complete (see issue #4276). The current timing also introduces the possibility of CEF apps registering preference names that conflict with Chromium service-specific preferences.

The proposal here is to move OnRegisterCustomPreferences timing after all Chromium preferences are registered (end of RegisterProfilePrefs in pref_service_builder_utils.cc), and add a new CefPreferenceRegistrar::SetDefaultPreference method that can be used to override defaults for all Chromium preferences. Persisted user settings and higher-priority settings (set via CefPreferenceManager::SetPreference, managed settings or command-line) would still take precedence over these default values (standard Chromium behavior for defaults).

In summary:

  • Remove the CEF registration call from Chromium’s RegisterUserProfilePrefs().
  • Add it at the end of RegisterProfilePrefs() in pref_service_builder_utils.cc (chrome/browser/profiles/pref_service_builder_utils.cc:66), after both dependency managers register their preferences.
  • Add a new CefPreferenceRegistrar::SetDefaultPreference method that calls PrefRegistry::SetDefaultPrefValue()
    virtual bool SetDefaultPreference(const CefString& name,
                                     CefRefPtr<CefValue> value,
                                     CefString& error) = 0;
    

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions