• Charlie Harrison's avatar
    ContentSettingBubbleModel: ensure destruction on WebContentsDestroyed · e3da3b00
    Charlie Harrison authored
    ContentSettingBubbleContents owns the underlying bubble model. It is
    also a WebContentsObserver. This CL destroys the bubble model in
    WebContentsDestroyed, which allows the model to avoid paranoid
    null checking throughout the code.
    
    In the process, we also remove:
    1. Notification observation about profile / web contents destruction.
       The profile should be alive as long as the web contents.
    
    2. Storing the profile directly and accessing the raw ptr. Instead,
       just pull it off the web contents.
    
    One subtle thing about this patch. On WebContentsDestroyed, we do not
    synchronously destroy the underlying ContentSettingBubbleContents,
    instead, we synchronously hide it and post a task which actually
    deletes it. This means we need to be careful about properly null
    checking the content_setting_bubble_model_. Thankfully, we can assume
    that event listeners are not invoked on hidden widgets.
    
    Bug: None
    Change-Id: I0a1ff38a705ace8a9898a4c89f81d51d8474b4da
    Reviewed-on: https://chromium-review.googlesource.com/c/1334097
    Commit-Queue: Charlie Harrison <csharrison@chromium.org>
    Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
    Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
    Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#610852}
    e3da3b00
content_setting_bubble_contents.cc 24.5 KB