• Ali Juma's avatar
    [iOS] Ensure PolicyDecisionStateTracker's callback is called · f25888e8
    Ali Juma authored
    This changes PolicyDecisionStateTracker's destructor to invoke
    the state tracker's callback if it hasn't already been invoked.
    Destroying the callback without ever invoking it can result in
    a WKWebView-provided callback never getting invoked, which
    triggers an NSException causing a crash.
    
    In the linked bug, the PolicyDecisionStateTracker is destroyed
    as a result of MainFrameUrlQuery::operator= implicitly
    releasing its old response_callback, which owns the state
    tracker. An alternative fix would be to change that method
    to invoke the old response_callback. However, the change made
    by this CL is a more general fix for the problem, and should
    prevent similar issues in the future.
    
    Bug: 1079471
    Change-Id: Ib8782b2278cace0f24692dbe951d498792111095
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2229201
    Commit-Queue: Ali Juma <ajuma@chromium.org>
    Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#774772}
    f25888e8
policy_decision_state_tracker.mm 1.72 KB