• Devlin Cronin's avatar
    [Extensions] Fix a crash in ExtensionPrefValueMap · efe0c886
    Devlin Cronin authored
    When extensions are disabled with --disable-extensions, ExtensionPrefs
    would completely skip initializing the Extension-controlled preferences
    (which encompasses the content settings overrides, preferences API, and
    chrome settings overrides). This would result in no entry being added
    to the ExtensionPrefValueMap for extensions if --disable-extensions was
    used. This is generally desirable, since otherwise the settings may
    still take effect, even though the extensions were not enabled.
    
    However, some extensions are still loaded with --disable-extensions.
    Obviously, this includes component extensions, but this also
    (surprisingly) includes external extensions, such as those added by
    the windows registry.
    
    The result of this is that if an external extension used an API that
    relied on the ExtensionPrefValueMap, such as the chrome settings
    overrides, while --disable-extensions was used, there would be no
    entry in the value map. Chrome would then crash.
    
    Fix this by having ExtensionPrefs check if the extension will still be
    loaded, even if extensions are disabled. If it will, always load the
    corresponding extension-controlled preferences.
    
    Add two tests to cover this case: one general unit test to ensure the
    extension-controlled prefs are initialized for external extensions
    (which will always be loaded), and one end-to-end test with adding an
    external extension using the chrome settings overrides API.
    
    Bug: 828295
    Change-Id: I0b01f6ed2fd41874f8fa47378f111c0692cb1ea5
    Reviewed-on: https://chromium-review.googlesource.com/1013305Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
    Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#552209}
    efe0c886
extension_prefs_unittest.cc 36.6 KB