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

Side by Side Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.cc

Issue 2915913002: [WebAPKs] Display same text for menu & engagement banner (Closed)
Patch Set: Merge branch 'master' into same_infobar_title Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 23 matching lines...) Expand all
34 using base::android::ConvertUTF16ToJavaString; 34 using base::android::ConvertUTF16ToJavaString;
35 using base::android::JavaParamRef; 35 using base::android::JavaParamRef;
36 using base::android::ScopedJavaLocalRef; 36 using base::android::ScopedJavaLocalRef;
37 37
38 namespace banners { 38 namespace banners {
39 39
40 // static 40 // static
41 bool AppBannerInfoBarDelegateAndroid::Create( 41 bool AppBannerInfoBarDelegateAndroid::Create(
42 content::WebContents* web_contents, 42 content::WebContents* web_contents,
43 base::WeakPtr<AppBannerManager> weak_manager, 43 base::WeakPtr<AppBannerManager> weak_manager,
44 const base::string16& app_title,
45 std::unique_ptr<ShortcutInfo> shortcut_info, 44 std::unique_ptr<ShortcutInfo> shortcut_info,
46 const SkBitmap& primary_icon, 45 const SkBitmap& primary_icon,
47 const SkBitmap& badge_icon, 46 const SkBitmap& badge_icon,
48 int event_request_id, 47 int event_request_id,
49 bool is_webapk, 48 bool is_webapk,
50 webapk::InstallSource webapk_install_source) { 49 webapk::InstallSource webapk_install_source) {
51 DCHECK(shortcut_info); 50 DCHECK(shortcut_info);
52 const GURL url = shortcut_info->url; 51 const GURL url = shortcut_info->url;
53 if (url.is_empty()) 52 if (url.is_empty())
54 return false; 53 return false;
55 54
56 auto infobar_delegate = 55 auto infobar_delegate =
57 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( 56 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid(
58 weak_manager, app_title, std::move(shortcut_info), primary_icon, 57 weak_manager, std::move(shortcut_info), primary_icon, badge_icon,
59 badge_icon, event_request_id, is_webapk, webapk_install_source)); 58 event_request_id, is_webapk, webapk_install_source));
60 auto* raw_delegate = infobar_delegate.get(); 59 auto* raw_delegate = infobar_delegate.get();
61 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( 60 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>(
62 std::move(infobar_delegate), url, is_webapk); 61 std::move(infobar_delegate), url, is_webapk);
63 if (!InfoBarService::FromWebContents(web_contents) 62 if (!InfoBarService::FromWebContents(web_contents)
64 ->AddInfoBar(std::move(infobar))) 63 ->AddInfoBar(std::move(infobar)))
65 return false; 64 return false;
66 65
67 if (is_webapk) { 66 if (is_webapk) {
68 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) { 67 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) {
69 webapk::TrackInstallInfoBarShown( 68 webapk::TrackInstallInfoBarShown(
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( 195 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState(
197 env, java_delegate_, false); 196 env, java_delegate_, false);
198 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName( 197 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName(
199 env, java_delegate_, java_webapk_package_name); 198 env, java_delegate_, java_webapk_package_name);
200 UpdateInstallState(env, nullptr); 199 UpdateInstallState(env, nullptr);
201 install_state_ = INSTALLED; 200 install_state_ = INSTALLED;
202 } 201 }
203 202
204 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( 203 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
205 base::WeakPtr<AppBannerManager> weak_manager, 204 base::WeakPtr<AppBannerManager> weak_manager,
206 const base::string16& app_title,
207 std::unique_ptr<ShortcutInfo> shortcut_info, 205 std::unique_ptr<ShortcutInfo> shortcut_info,
208 const SkBitmap& primary_icon, 206 const SkBitmap& primary_icon,
209 const SkBitmap& badge_icon, 207 const SkBitmap& badge_icon,
210 int event_request_id, 208 int event_request_id,
211 bool is_webapk, 209 bool is_webapk,
212 webapk::InstallSource webapk_install_source) 210 webapk::InstallSource webapk_install_source)
213 : weak_manager_(weak_manager), 211 : weak_manager_(weak_manager),
214 app_title_(app_title), 212 app_title_(shortcut_info->name),
215 shortcut_info_(std::move(shortcut_info)), 213 shortcut_info_(std::move(shortcut_info)),
216 primary_icon_(primary_icon), 214 primary_icon_(primary_icon),
217 badge_icon_(badge_icon), 215 badge_icon_(badge_icon),
218 event_request_id_(event_request_id), 216 event_request_id_(event_request_id),
219 has_user_interaction_(false), 217 has_user_interaction_(false),
220 is_webapk_(is_webapk), 218 is_webapk_(is_webapk),
221 install_state_(INSTALL_NOT_STARTED), 219 install_state_(INSTALL_NOT_STARTED),
222 webapk_install_source_(webapk_install_source), 220 webapk_install_source_(webapk_install_source),
223 weak_ptr_factory_(this) { 221 weak_ptr_factory_(this) {
224 CreateJavaDelegate(); 222 CreateJavaDelegate();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return was_opened; 271 return was_opened;
274 } 272 }
275 273
276 bool AppBannerInfoBarDelegateAndroid::AcceptWebApp( 274 bool AppBannerInfoBarDelegateAndroid::AcceptWebApp(
277 content::WebContents* web_contents) { 275 content::WebContents* web_contents) {
278 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); 276 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
279 277
280 AppBannerSettingsHelper::RecordBannerInstallEvent( 278 AppBannerSettingsHelper::RecordBannerInstallEvent(
281 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); 279 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
282 280
283 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, 281 ShortcutHelper::AddToLauncherWithSkBitmap(
284 primary_icon_); 282 web_contents, *shortcut_info_, shortcut_info_->short_name, primary_icon_);
285 283
286 SendBannerAccepted(); 284 SendBannerAccepted();
287 return true; 285 return true;
288 } 286 }
289 287
290 bool AppBannerInfoBarDelegateAndroid::AcceptWebApk( 288 bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
291 content::WebContents* web_contents) { 289 content::WebContents* web_contents) {
292 JNIEnv* env = base::android::AttachCurrentThread(); 290 JNIEnv* env = base::android::AttachCurrentThread();
293 291
294 // If the WebAPK is installed and the "Open" button is clicked, open the 292 // If the WebAPK is installed and the "Open" button is clicked, open the
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return; 368 return;
371 369
372 // If the install didn't definitely fail, we don't add a shortcut. This could 370 // If the install didn't definitely fail, we don't add a shortcut. This could
373 // happen if Play was busy with another install and this one is still queued 371 // happen if Play was busy with another install and this one is still queued
374 // (and hence might succeed in the future). 372 // (and hence might succeed in the future).
375 if (result == WebApkInstallResult::FAILURE) { 373 if (result == WebApkInstallResult::FAILURE) {
376 content::WebContents* web_contents = 374 content::WebContents* web_contents =
377 InfoBarService::WebContentsFromInfoBar(infobar()); 375 InfoBarService::WebContentsFromInfoBar(infobar());
378 // Add webapp shortcut to the homescreen. 376 // Add webapp shortcut to the homescreen.
379 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_, 377 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
378 shortcut_info_->short_name,
dominickn 2017/06/16 01:32:32 This is a behaviour change for app banners. Previo
pkotwicz 2017/06/17 00:17:23 Thank you for your question. This is actually inc
dominickn 2017/06/17 01:05:44 Yes, we should still use the |short_name| for the
380 primary_icon_); 379 primary_icon_);
381 } 380 }
382 381
383 infobar()->RemoveSelf(); 382 infobar()->RemoveSelf();
384 } 383 }
385 384
386 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( 385 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
387 InstallState install_state) { 386 InstallState install_state) {
388 if (install_state == INSTALL_NOT_STARTED) { 387 if (install_state == INSTALL_NOT_STARTED) {
389 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); 388 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 455
457 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 456 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
458 return true; 457 return true;
459 } 458 }
460 459
461 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 460 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
462 return RegisterNativesImpl(env); 461 return RegisterNativesImpl(env);
463 } 462 }
464 463
465 } // namespace banners 464 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698