• Christopher Cameron's avatar
    MacPWAs: Close shims when it is uninstalled for all profiles · 3257ebfa
    Christopher Cameron authored
    Change AppShimManager::AppState::ShouldDeleteAppState to return true
    if the app is not installed for any profiles. Previously, the app
    would continue running even after it had been deleted, resulting in
    all sorts of cool behaviors. This winds up being hit in two paths.
    
    First path is the AppShimManager::OnAppDeactivated call that is made
    when a profile closes its last app window. This fixes crbug.com/1139254
    where an app kept running even after it was uninstalled.
    
    Second path is AppShimManager::OnProfileMarkedForPermanentDeletion,
    for when a profile is deleted. This is for crbug.com/1132223 and is
    a bit more involved.
    * Listening for chrome::NOTIFICATION_PROFILE_CREATED/DESTROYED has
      been deprecated for a half-decade, so change AppShimManager to be
      a ProfileManagerObserver instead.
    * Inline AppShimManager::CloseShimsForProfile to be a lambda inside
      of OnProfileMarkedForPermanentDeletion.
    * Of note about ProfileManagerObserver is that closing app shims
      inside OnProfileMarkedForPermanentDeletion can cause crashes
      because it is not expected that Browser instances will be closed
      inside that call. For that reason, post a task to do the work.
    
    Update tests (because now they're affected by the AppShimRegistry)
    and add tests for both paths (shim installed vs uninstalled).
    
    Since AppShimManager is now a ProfileManagerObserver we have to
    make sure that the AppShimManager stops observing the ProfileManager
    before the ProfileManager is destroyed. To do this, a new call,
    BrowserProcessPlatformPart::BeginStartTearDown, which happens at
    the beginning of BrowserProcessPlatformPart::StartTearDown.
    
    Bug: 1139254,1132223
    Change-Id: I19990f6ae5ff8d8727e1fb0ecf46d1142b543764
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2481790Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
    Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
    Commit-Queue: ccameron <ccameron@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#818594}
    3257ebfa
browser_process_impl.cc 53.1 KB