OLD | NEW |
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_manager_android.h" | 5 #include "chrome/browser/android/banners/app_banner_manager_android.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
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 20 matching lines...) Expand all Loading... |
31 using base::android::ScopedJavaLocalRef; | 31 using base::android::ScopedJavaLocalRef; |
32 | 32 |
33 DEFINE_WEB_CONTENTS_USER_DATA_KEY(banners::AppBannerManagerAndroid); | 33 DEFINE_WEB_CONTENTS_USER_DATA_KEY(banners::AppBannerManagerAndroid); |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 std::unique_ptr<ShortcutInfo> CreateShortcutInfo( | 37 std::unique_ptr<ShortcutInfo> CreateShortcutInfo( |
38 const GURL& manifest_url, | 38 const GURL& manifest_url, |
39 const content::Manifest& manifest, | 39 const content::Manifest& manifest, |
40 const GURL& primary_icon_url, | 40 const GURL& primary_icon_url, |
41 const GURL& badge_icon_url) { | 41 const GURL& badge_icon_url, |
| 42 bool is_webapk) { |
42 auto shortcut_info = base::MakeUnique<ShortcutInfo>(GURL()); | 43 auto shortcut_info = base::MakeUnique<ShortcutInfo>(GURL()); |
43 if (!manifest.IsEmpty()) { | 44 if (!manifest.IsEmpty()) { |
44 shortcut_info->UpdateFromManifest(manifest); | 45 shortcut_info->UpdateFromManifest(manifest); |
45 shortcut_info->manifest_url = manifest_url; | 46 shortcut_info->manifest_url = manifest_url; |
46 shortcut_info->best_primary_icon_url = primary_icon_url; | 47 shortcut_info->best_primary_icon_url = primary_icon_url; |
47 shortcut_info->best_badge_icon_url = badge_icon_url; | 48 shortcut_info->best_badge_icon_url = badge_icon_url; |
48 shortcut_info->UpdateSource(ShortcutInfo::SOURCE_APP_BANNER); | 49 if (is_webapk) |
| 50 shortcut_info->UpdateSource(ShortcutInfo::SOURCE_APP_BANNER_WEBAPK); |
| 51 else |
| 52 shortcut_info->UpdateSource(ShortcutInfo::SOURCE_APP_BANNER); |
49 } | 53 } |
50 | 54 |
51 shortcut_info->ideal_splash_image_size_in_px = | 55 shortcut_info->ideal_splash_image_size_in_px = |
52 ShortcutHelper::GetIdealSplashImageSizeInPx(); | 56 ShortcutHelper::GetIdealSplashImageSizeInPx(); |
53 shortcut_info->minimum_splash_image_size_in_px = | 57 shortcut_info->minimum_splash_image_size_in_px = |
54 ShortcutHelper::GetMinimumSplashImageSizeInPx(); | 58 ShortcutHelper::GetMinimumSplashImageSizeInPx(); |
55 shortcut_info->splash_image_url = ManifestIconSelector::FindBestMatchingIcon( | 59 shortcut_info->splash_image_url = ManifestIconSelector::FindBestMatchingIcon( |
56 manifest.icons, shortcut_info->ideal_splash_image_size_in_px, | 60 manifest.icons, shortcut_info->ideal_splash_image_size_in_px, |
57 shortcut_info->minimum_splash_image_size_in_px, | 61 shortcut_info->minimum_splash_image_size_in_px, |
58 content::Manifest::Icon::IconPurpose::ANY); | 62 content::Manifest::Icon::IconPurpose::ANY); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 240 } |
237 | 241 |
238 void AppBannerManagerAndroid::ShowBanner() { | 242 void AppBannerManagerAndroid::ShowBanner() { |
239 content::WebContents* contents = web_contents(); | 243 content::WebContents* contents = web_contents(); |
240 DCHECK(contents); | 244 DCHECK(contents); |
241 | 245 |
242 if (native_app_data_.is_null()) { | 246 if (native_app_data_.is_null()) { |
243 if (AppBannerInfoBarDelegateAndroid::Create( | 247 if (AppBannerInfoBarDelegateAndroid::Create( |
244 contents, GetWeakPtr(), app_title_, | 248 contents, GetWeakPtr(), app_title_, |
245 CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_, | 249 CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_, |
246 badge_icon_url_), | 250 badge_icon_url_, can_install_webapk_), |
247 primary_icon_, badge_icon_, event_request_id(), | 251 primary_icon_, badge_icon_, event_request_id(), can_install_webapk_, |
248 webapk::INSTALL_SOURCE_BANNER)) { | 252 webapk::INSTALL_SOURCE_BANNER)) { |
249 RecordDidShowBanner("AppBanner.WebApp.Shown"); | 253 RecordDidShowBanner("AppBanner.WebApp.Shown"); |
250 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); | 254 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); |
251 ReportStatus(contents, SHOWING_WEB_APP_BANNER); | 255 ReportStatus(contents, SHOWING_WEB_APP_BANNER); |
252 } else { | 256 } else { |
253 ReportStatus(contents, FAILED_TO_CREATE_BANNER); | 257 ReportStatus(contents, FAILED_TO_CREATE_BANNER); |
254 } | 258 } |
255 } else { | 259 } else { |
256 if (AppBannerInfoBarDelegateAndroid::Create( | 260 if (AppBannerInfoBarDelegateAndroid::Create( |
257 contents, app_title_, native_app_data_, primary_icon_, | 261 contents, app_title_, native_app_data_, primary_icon_, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 371 } |
368 | 372 |
369 // static | 373 // static |
370 void SetTotalEngagementToTrigger(JNIEnv* env, | 374 void SetTotalEngagementToTrigger(JNIEnv* env, |
371 const JavaParamRef<jclass>& clazz, | 375 const JavaParamRef<jclass>& clazz, |
372 jdouble engagement) { | 376 jdouble engagement) { |
373 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement); | 377 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement); |
374 } | 378 } |
375 | 379 |
376 } // namespace banners | 380 } // namespace banners |
OLD | NEW |