Use WeakPtr to prevent using the ptr out of scope

When switching to AnimationBuilder, we passed
a callback instead of using the old
ImplicitAnimationObserver pattern.
ImplicitAnimationObserver removes itself on its
dtor. Meanwhile AnimationBuilder has a dangling
ptr.

Using a WeakPtr should fix this crash (but I
cannot repro it, so this fix is technically
speculative).

Bug: 1265741
Change-Id: I234621cfd780c93b47c1a11aa67945075f2e9632
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3260120
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#938078}
diff --git a/ui/views/animation/slide_out_controller.cc b/ui/views/animation/slide_out_controller.cc
index 0d941907..11d5d390 100644
--- a/ui/views/animation/slide_out_controller.cc
+++ b/ui/views/animation/slide_out_controller.cc
@@ -186,7 +186,7 @@
     // after the animation finishes.
     AnimationBuilder()
         .OnEnded(base::BindOnce(&SlideOutController::OnAnimationsCompleted,
-                                base::Unretained(this)))
+                                weak_ptr_factory_.GetWeakPtr()))
         .Once()
         .SetDuration(animation_duration)
         .SetTransform(layer, transform, kSwipeTweenType);