• Timothy Loh's avatar
    Scope PermissionPrompt lifetime to UI visibility · 0a992857
    Timothy Loh authored
    This patch make the lifetime of PermissionPrompt objects more sensible
    and match what we occasionally think it actually is. Currently these
    objects exist when a tab is active, or on Android all the time. This
    patch changes it so that, as the name might suggest, it corresponds to
    when a prompt is actually visible. We retain the distinction between
    desktop/Android where desktop hides the UI (now deletes the object) on
    tab switching, while Android retains the UI (keeps the object alive)
    as the InfoBar system manages hiding the prompt.
    
    Since we don't explicitly manage lifetimes of the actual UI surface on
    Android (infobars in particular, as it's clearer for modals when the UI
    is actually destroyed) from the PermissionPrompt, we change the pointer
    to a WeakPtr for safety. When the PermissionPrompt is destroyed due to
    navigation, if an infobar happens to still persist due to a bug it
    won't be able to be resolve different permission requests.
    
    Bug: 606138, 737102
    Change-Id: I26a8843b9b446e91282a9b0ce67c4b442bf440e9
    Reviewed-on: https://chromium-review.googlesource.com/567940
    Commit-Queue: Timothy Loh <timloh@chromium.org>
    Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#487029}
    0a992857
permission_request_manager_unittest.cc 21.1 KB