• Devlin Cronin's avatar
    [Extensions] (More) Gracefully handle previously-installed policy extensions · ae9baf56
    Devlin Cronin authored
    Consider the following circumstance:
    - User installs extension Alpha normally (e.g., through the webstore).
      Alpha has Manifest::Location INTERNAL.
    - Corp policy pushes out an update that lists Alpha as a required
      extension.
    
    Currently, this behaves fantastically poorly. We validate that the user
    is allowed to load an extension on each run of Chrome when loading
    installed extensions, and UserMayLoad() will return false if the
    extension is required by corporate policy (in order to prevent users
    from installing "over" a policy-required extension). This means that
    the policy-required extension gets disabled with reason
    DISABLE_BLOCKED_BY_POLICY.
    
    Make this slightly less bad by introducing a new policy provider method,
    UserMayInstall(). This checks whether the user is allowed to install a
    given extension, rather than whether the user is allowed to load it. For
    default implementations, UserMayInstall() forwards to UserMayLoad()
    (since they should be treated equivalently). However, we can now move
    the check for if a Manifest::INTERNAL extension is required policy to
    the UserMayInstall() check rather than UserMayLoad(). The effect of this
    is to allow the user to load an already-installed extension that's
    required by policy, but not policy-installed itself, while still
    preventing the user from installing a new copy of that extension.
    
    This is not a perfect solution, since the installed version of the
    extension will still be the Manifest::INTERNAL one. This has a number of
    implications, including that the extension won't show most policy-
    installed indications and won't have access to policy-only APIs. In
    extreme cases, the extensions can also be different versions. In the
    future, we will need to think about how to handle this scenario more
    gracefully.
    
    Bug: 894184
    
    Change-Id: I83c9c305b56f90ea211e4a9b0120b22d601b4fb4
    Reviewed-on: https://chromium-review.googlesource.com/c/1327616
    Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
    Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#608538}
    ae9baf56
extension_service_unittest.cc 289 KB