Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2846)

Unified Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc

Issue 2675803004: Fall back to shortcut A2HS when Phonesky is out of date or unavailable. (Closed)
Patch Set: Update add_to_homescreen_data_fetcher_unittest.cc. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
index 4ad906bb684d8a6198f5660f005199b28a49928e..d93b9fc11645a9ab7b0b6b7ad83366ebbde1b927 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
@@ -71,6 +71,7 @@ AddToHomescreenDataFetcher::AddToHomescreenDataFetcher(
int minimum_splash_image_size_in_px,
int badge_size_in_px,
bool check_webapk_compatibility,
+ bool can_use_webapk_install_flow,
Observer* observer)
: WebContentsObserver(web_contents),
weak_observer_(observer),
@@ -86,7 +87,8 @@ AddToHomescreenDataFetcher::AddToHomescreenDataFetcher(
is_waiting_for_web_application_info_(true),
is_installable_check_complete_(false),
is_icon_saved_(false),
- is_ready_(false) {
+ is_ready_(false),
+ can_use_webapk_install_flow_(can_use_webapk_install_flow) {
DCHECK(minimum_icon_size_in_px <= ideal_icon_size_in_px);
DCHECK(minimum_splash_image_size_in_px <= ideal_splash_image_size_in_px);
@@ -206,10 +208,23 @@ void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck(
is_installable_check_complete_ = true;
+ bool webapk_compatible = false;
if (check_webapk_compatibility_) {
- bool webapk_compatible =
+ webapk_compatible =
(data.error_code == NO_ERROR_DETECTED &&
AreWebManifestUrlsWebApkCompatible(data.manifest));
+
+ if (webapk_compatible) {
+ std::string webapk_package_name = ShortcutHelper::QueryWebApkPackage(
+ data.manifest.start_url);
+ // We will continue the WebAPK install flow if:
+ // The WebAPK has been installed, or
+ // The WebAPK install flow can be used.
+ // Otherwises, we will continue the classic add-to-homescreen shortcut
+ // flow.
+ if (webapk_package_name.empty() && !can_use_webapk_install_flow_)
+ webapk_compatible = false;
+ }
weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible);
if (webapk_compatible) {

Powered by Google App Engine
This is Rietveld 408576698