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

Unified Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.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/banners/app_banner_infobar_delegate_android.cc
diff --git a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
index 090e1f260a452ca9e831cda9ca0cc8cafcef5086..0c190b72a484ed1fdcd030072a2d368406b272e5 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -53,18 +53,23 @@ bool AppBannerInfoBarDelegateAndroid::Create(
std::unique_ptr<ShortcutInfo> shortcut_info,
std::unique_ptr<SkBitmap> icon,
int event_request_id,
+ bool can_use_webapk_install_flow,
webapk::InstallSource webapk_install_source) {
- bool is_webapk = ChromeWebApkHost::AreWebApkEnabled();
+ bool is_webapk_enabled = ChromeWebApkHost::AreWebApkEnabled();
std::string webapk_package_name = "";
const GURL& url = shortcut_info->url;
- if (is_webapk)
+ if (is_webapk_enabled)
pkotwicz 2017/02/03 18:56:32 For the sake of simplicity, I am ok with creating
Xi Han 2017/02/03 22:16:20 Yes it is complex, but I try to make it less diffi
pkotwicz 2017/02/03 23:05:05 Can we instead have the simpler behavior: "Only ch
webapk_package_name = ShortcutHelper::QueryWebApkPackage(url);
bool is_webapk_already_installed = !webapk_package_name.empty();
+ // We continue the WebAPK flow if there is an associated WebAPK has been
+ // installed or WebAPKs are enabled and the install flow is available.
+ bool is_webapk = is_webapk_already_installed ? true
+ : is_webapk_enabled & can_use_webapk_install_flow;
auto infobar_delegate =
base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid(
weak_manager, app_title, std::move(shortcut_info), std::move(icon),
event_request_id, is_webapk, is_webapk_already_installed,
- webapk_install_source));
+ webapk_package_name, webapk_install_source));
auto raw_delegate = infobar_delegate.get();
auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>(
std::move(infobar_delegate), url, is_webapk);
@@ -220,6 +225,7 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
int event_request_id,
bool is_webapk,
bool is_webapk_already_installed,
+ const std::string& webapk_package_name,
webapk::InstallSource webapk_install_source)
: weak_manager_(weak_manager),
app_title_(app_title),
@@ -229,6 +235,7 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
has_user_interaction_(false),
is_webapk_(is_webapk),
is_webapk_already_installed_(is_webapk_already_installed),
+ webapk_package_name_(webapk_package_name),
install_state_(INSTALL_NOT_STARTED),
webapk_install_source_(webapk_install_source),
weak_ptr_factory_(this) {
@@ -322,6 +329,12 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN);
SendBannerAccepted();
return true;
+ } else if (is_webapk_already_installed_) {
+ // If a WebAPK has installed, but the |install_state_| hasn't changed
+ // yet, we updates the text of button on the banner, and return false to
+ // prevent the banner from disappear.
+ UpdateStateForInstalledWebAPK(webapk_package_name_);
+ return false;
}
// If the WebAPK is not installed and the "Add to Home Screen" button is

Powered by Google App Engine
This is Rietveld 408576698