• Tommy Li's avatar
    [search_engines] Stop OpenSearch from deleting Default Search Engine · abcfd145
    Tommy Li authored
    Currently, when Chrome adds a new engine from the OpenSearch
    description file, it can delete the Default Search Engine if it is
    is safe_for_autoreplace() and not prepopulated.
    
    This is an edge case, but there are crash reports of this triggering
    our CHECK. From what I can tell, this issue has existed for a long time,
    but was never caught because we had a DCHECK instead of a CHECK.
    
    This CL does two things:
    
     1. Prevents that happening by no longer returning an |existing_engine|
        from the CanAddAutogeneratedKeyword() method.
    
        Since Add() can now automatically do ranking and deduplication,
        there's no need for the caller to manually Remove() engines like
        before.
    
     2. Makes OpenSearch outrank form-search autogenerated engines
        in TemplateURL::IsBetterThanEngineWithConflictingKeyword().
    
        We always treated it this way, but this formalizes it in our
        sorting function, which helps us build our total ordering of
        TemplateURLs.
    
    In summary: This CL makes the auto-generated engine adding logic
    reuse our existing deduplication logic, rather than relying on its own
    custom logic, which didn't respect the default search provider.
    
    This is meant to be merged into M89.
    
    Bug: 1166372
    Change-Id: I410a0f8870f65cd16001f5ebd120ccbf04aadd93
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644936Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
    Reviewed-by: default avatarOrin Jaworski <orinj@chromium.org>
    Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
    Commit-Queue: Tommy Li <tommycli@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#846299}
    abcfd145
template_url_fetcher.cc 9.71 KB