Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PwaRestore]: Link up the startup promo with the feature flag.
This sets up a promo for startup to the PWA Restore feature. At the moment, the flag for it is disabled, so this won't be a material change. Also, the flag needed to be moved to account for where it is being used (the location wasn't known beforehand). Bug: 1481570 Low-Coverage-Reason: An integration test is planned in the near future, but at the moment the dialog shows only dummy data, so further tests are a bit premature. Change-Id: I3a45776802bbc6f197ef19dabb7f293249a8daca Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5002592 Reviewed-by: Glenn Hartmann <hartmanng@chromium.org> Reviewed-by: David Trainor <dtrainor@chromium.org> Commit-Queue: Finnur Thorarinsson <finnur@chromium.org> Cr-Commit-Position: refs/heads/main@{#1219905}
- Loading branch information
Finnur Thorarinsson
authored and
Chromium LUCI CQ
committed
Nov 4, 2023
1 parent
2821846
commit 7e70e2a
Showing
10 changed files
with
73 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...er/webapps/android/java/src/org/chromium/chrome/browser/webapps/PwaRestorePromoUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.chromium.chrome.browser.webapps; | ||
|
||
import android.app.Activity; | ||
|
||
import org.chromium.chrome.browser.flags.ChromeFeatureList; | ||
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; | ||
import org.chromium.components.browser_ui.bottomsheet.BottomSheetControllerProvider; | ||
import org.chromium.components.webapps.pwa_restore_ui.PwaRestoreBottomSheetCoordinator; | ||
import org.chromium.ui.base.WindowAndroid; | ||
|
||
/** | ||
* This class is responsible for coordinating the showing of the PWA Restore promo (which aims to | ||
* remind users that they had PWAs installed on their old device, and can restore them on their new | ||
* device. | ||
*/ | ||
public class PwaRestorePromoUtils { | ||
/** | ||
* Launch the PWA Restore promotion, if we've determined that this launch meets the criteria for | ||
* for showing it. | ||
* | ||
* @param activity The current {@link Activity} to use for this promo. | ||
* @param windowAndroid The current {@link WindowAndroid} to use for this promo. | ||
* @param arrowResourceId The resource id for the Back arrow to use. | ||
* @return Whether the PWA Restore promo was shown. | ||
*/ | ||
public static boolean launchPromoIfNeeded( | ||
Activity activity, WindowAndroid windowAndroid, int arrowResourceId) { | ||
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.PWA_RESTORE_UI)) { | ||
return false; | ||
} | ||
|
||
// TODO(finnur): The criteria for this needs to be fleshed out, but the flag above is | ||
// disabled by default, so we can just attempt to show the dialog for now (which also helps | ||
// during development). | ||
return launchPromo(activity, windowAndroid, arrowResourceId); | ||
} | ||
|
||
private static boolean launchPromo( | ||
Activity activity, WindowAndroid windowAndroid, int arrowResourceId) { | ||
BottomSheetController controller = BottomSheetControllerProvider.from(windowAndroid); | ||
if (controller == null) return false; | ||
PwaRestoreBottomSheetCoordinator pwaRestoreBottomSheetCoordinator = | ||
new PwaRestoreBottomSheetCoordinator(activity, controller, arrowResourceId); | ||
return pwaRestoreBottomSheetCoordinator != null && pwaRestoreBottomSheetCoordinator.show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters