From 10f218c6c9b29d8a163c87a7b6a725a39bf2d07f Mon Sep 17 00:00:00 2001 From: Dominick Ng Date: Tue, 20 Mar 2018 09:50:24 +0000 Subject: [PATCH] Reset event bindings in AppBannerManager::OnInstall. This addresses a bug where sites using the beforeinstallpromptevent to implement an install button could have users trigger a do-nothing install prompt if the user first used the menu item "Add to Shelf" to install, and then pressed the beforeinstallprompt-connected button. Resetting the event binding when the OnInstall() method is triggered means that when an install is started, all outstanding beforeinstallpromptevents are voided, fixing the bug. BUG=823602 Change-Id: Ib2c747c74f7083a7663580ed37da7a319d9a9c60 Reviewed-on: https://chromium-review.googlesource.com/970050 Reviewed-by: Matt Giuca Commit-Queue: Dominick Ng Cr-Commit-Position: refs/heads/master@{#544317} --- chrome/browser/banners/app_banner_manager.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chrome/browser/banners/app_banner_manager.cc b/chrome/browser/banners/app_banner_manager.cc index afd566175cf699..230b2ad8e4d230 100644 --- a/chrome/browser/banners/app_banner_manager.cc +++ b/chrome/browser/banners/app_banner_manager.cc @@ -191,6 +191,10 @@ void AppBannerManager::OnInstall(bool is_native, mojo::MakeRequest(&installation_service)); DCHECK(installation_service); installation_service->OnInstall(); + + // We've triggered an installation, so reset bindings to ensure that any + // existing beforeinstallprompt events cannot trigger add to home screen. + ResetBindings(); } void AppBannerManager::SendBannerAccepted() {