[merge-m73] Do not bind a raw pointer in AppShortcutManager callbacks.

UpdateShortcutsForAllApps() spawns disk IO tasks to update shortcuts,
then executes a callback on the calling thread when they're all complete.
It's possible for a browser shutdown or profile deletion to occur in
the meantime, in which case we can no longer write to the profile
preferences. Updates will happen again on the next browser startup
if the profile still exists then.

The initial call to UpdateShortcutsForAllApps() is also delayed.

To fix, call these via the WeakPtr that already exists.
AppShortcutManager is a [Profile]KeyedService so will always be
destroyed before the Profile* it's keyed to, nerfing callbacks that have
bound the WeakPtr.

Note UpdateShortcutsForAllApps() writes to user home folders, so can't
be tested on the bots directly. (Things it calls are tested via mocks
bound to WebAppShortcutCreator).


(cherry picked from commit 0fce8e3240f217c0ff3cd446878a6d2525b31dd1)

Bug: 925194
Change-Id: If05c45178cda5e7b0322d30c155b79feecddf478
Reviewed-on: https://chromium-review.googlesource.com/c/1442035
Reviewed-by: ccameron <ccameron@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#627672}
Reviewed-on: https://chromium-review.googlesource.com/c/1451476
Reviewed-by: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/branch-heads/3683@{#150}
Cr-Branched-From: e51029943e0a38dd794b73caaf6373d5496ae783-refs/heads/master@{#625896}
2 files changed