Convert cloud_policy_manager_browsertest.cc to use GetSafeWeakWrapper.

GetSafeWeakWrapper takes care of calling Detach(), so tests don't have
to.

This change also fixes some memory safety issues in this test where
stack-allocated variables were being captured reference [&], for
callbacks that may be invoked after the stack-allocated variables have
been deallocated.

Capturing stack-allocated variables by reference appears to have worked
before this change only because the Detach() call on line 197 prevented
callbacks from being run a second time.

Bug: 924960
Change-Id: I89e4a217ad4793104c560c7a61a34b3171765ec6
Reviewed-on: https://chromium-review.googlesource.com/c/1454358
Reviewed-by: Julian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: Lowell Manners <lowell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630753}
1 file changed