| Index: chrome/browser/android/webapps/add_to_homescreen_manager.cc
|
| diff --git a/chrome/browser/android/webapps/add_to_homescreen_manager.cc b/chrome/browser/android/webapps/add_to_homescreen_manager.cc
|
| index 3608e943e34200d435da7aae84e1ee3567502880..25be3a55bd4d91f3831187a85153c5935cbae4f1 100644
|
| --- a/chrome/browser/android/webapps/add_to_homescreen_manager.cc
|
| +++ b/chrome/browser/android/webapps/add_to_homescreen_manager.cc
|
| @@ -79,17 +79,35 @@ void AddToHomescreenManager::Start(content::WebContents* web_contents) {
|
| if (ChromeWebApkHost::AreWebApkEnabled() &&
|
| InstallableManager::IsContentSecure(web_contents)) {
|
| check_webapk_compatible = true;
|
| - } else {
|
| - ShowDialog();
|
| + if (ChromeWebApkHost::CanUseGooglePlayToInstallWebApk()) {
|
| + // It is possible that the Google Play Install API isn't available when
|
| + // Google Play install is enabled. In that case, we fallback to classic
|
| + // add-to-homescreen shortcut flow.
|
| + ChromeWebApkHost::CanUseGooglePlayInstallApiCallback callback
|
| + = base::Bind(&AddToHomescreenManager::OnCanUseGooglePlayInstallApi,
|
| + base::Unretained(this),
|
| + web_contents, check_webapk_compatible);
|
| + ChromeWebApkHost::CanUseGooglePlayInstallApi(callback);
|
| + return;
|
| + }
|
| }
|
|
|
| + StartImpl(web_contents, check_webapk_compatible, true);
|
| +}
|
| +
|
| +void AddToHomescreenManager::StartImpl(content::WebContents* web_contents,
|
| + bool check_webapk_compatible,
|
| + bool can_use_webapk_install_flow) {
|
| + if (!check_webapk_compatible)
|
| + ShowDialog();
|
| +
|
| data_fetcher_ = new AddToHomescreenDataFetcher(
|
| web_contents, ShortcutHelper::GetIdealHomescreenIconSizeInPx(),
|
| ShortcutHelper::GetMinimumHomescreenIconSizeInPx(),
|
| ShortcutHelper::GetIdealSplashImageSizeInPx(),
|
| ShortcutHelper::GetMinimumSplashImageSizeInPx(),
|
| ShortcutHelper::GetIdealBadgeIconSizeInPx(),
|
| - check_webapk_compatible, this);
|
| + check_webapk_compatible, can_use_webapk_install_flow, this);
|
| }
|
|
|
| AddToHomescreenManager::~AddToHomescreenManager() {
|
| @@ -99,6 +117,13 @@ AddToHomescreenManager::~AddToHomescreenManager() {
|
| }
|
| }
|
|
|
| +void AddToHomescreenManager::OnCanUseGooglePlayInstallApi(
|
| + content::WebContents* web_contents,
|
| + bool check_webapk_compatible,
|
| + bool isAvailable) {
|
| + StartImpl(web_contents, check_webapk_compatible, isAvailable);
|
| +}
|
| +
|
| void AddToHomescreenManager::ShowDialog() {
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| Java_AddToHomescreenManager_showDialog(env, java_ref_);
|
| @@ -194,7 +219,8 @@ void AddToHomescreenManager::CreateInfoBarForWebApk(const ShortcutInfo& info,
|
| banners::AppBannerInfoBarDelegateAndroid::Create(
|
| data_fetcher_->web_contents(), nullptr, info.user_title,
|
| base::MakeUnique<ShortcutInfo>(info), base::MakeUnique<SkBitmap>(icon),
|
| - -1 /* event_request_id */, webapk::INSTALL_SOURCE_MENU);
|
| + -1 /* event_request_id */, true /* can_use_webapk_install_flow */,
|
| + webapk::INSTALL_SOURCE_MENU);
|
| }
|
|
|
| SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground(
|
|
|