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

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

Issue 2290603005: Trigger app banner when add to homescreen is pressed and WebAPKs are enabled. (Closed)
Patch Set: Try to fix test failures Created 4 years, 3 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_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 d7e5929cce20b287d60081bf160abd4bde2a3244..b7b8a6b200265feb45a3c1eaea8a5f054f09e6ac 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_manager.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_manager.cc
@@ -8,8 +8,10 @@
#include "base/android/jni_string.h"
#include "base/guid.h"
#include "base/location.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
#include "chrome/browser/android/shortcut_helper.h"
#include "chrome/browser/android/webapk/chrome_webapk_host.h"
#include "chrome/browser/banners/app_banner_settings_helper.h"
@@ -33,7 +35,8 @@ jlong InitializeAndStart(JNIEnv* env,
}
AddToHomescreenManager::AddToHomescreenManager(JNIEnv* env, jobject obj)
- : add_shortcut_pending_(false) {
+ : add_shortcut_pending_(false),
+ is_webapk_compatible_(false) {
java_ref_.Reset(env, obj);
}
@@ -129,13 +132,15 @@ void AddToHomescreenManager::RecordAddToHomescreen() {
void AddToHomescreenManager::OnDidDetermineWebApkCompatibility(
bool is_webapk_compatible) {
- // TODO(pkotwicz): Select whether to use dialog or not based on
- // |is_webapk_compatible|.
- ShowDialog();
+ is_webapk_compatible_ = is_webapk_compatible;
+ if (!is_webapk_compatible)
+ ShowDialog();
}
void AddToHomescreenManager::OnUserTitleAvailable(
const base::string16& user_title) {
+ if (is_webapk_compatible_)
+ return;
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jstring> j_user_title =
base::android::ConvertUTF16ToJavaString(env, user_title);
@@ -146,6 +151,11 @@ void AddToHomescreenManager::OnUserTitleAvailable(
void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info,
const SkBitmap& icon) {
+ if (is_webapk_compatible_) {
+ CreateInfoBarForWebAPK(info, icon);
+ return;
+ }
+
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> java_bitmap;
if (icon.getSize())
@@ -157,6 +167,15 @@ void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info,
AddShortcut(info, icon);
}
+void AddToHomescreenManager::CreateInfoBarForWebAPK(const ShortcutInfo& info,
+ const SkBitmap& icon) {
+ banners::AppBannerInfoBarDelegateAndroid::Create(
+ data_fetcher_->web_contents(), nullptr, info.user_title,
+ base::MakeUnique<ShortcutInfo>(info), base::MakeUnique<SkBitmap>(icon),
+ -1 /* event_request_id */, true /* is_webapk */,
+ true /* start_install_webapk*/);
Peter Kasting 2016/09/08 04:56:58 Nit: Space before */, or remove these
Xi Han 2016/09/08 15:49:10 Done.
+}
+
SkBitmap AddToHomescreenManager::FinalizeLauncherIconInBackground(
const SkBitmap& bitmap,
const GURL& url,

Powered by Google App Engine
This is Rietveld 408576698