| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 using base::android::JavaParamRef; | 32 using base::android::JavaParamRef; |
| 33 using base::android::ScopedJavaLocalRef; | 33 using base::android::ScopedJavaLocalRef; |
| 34 | 34 |
| 35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(banners::AppBannerManagerAndroid); | 35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(banners::AppBannerManagerAndroid); |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 std::unique_ptr<ShortcutInfo> CreateShortcutInfo( | 39 std::unique_ptr<ShortcutInfo> CreateShortcutInfo( |
| 40 const GURL& manifest_url, | 40 const GURL& manifest_url, |
| 41 const content::Manifest& manifest, | 41 const content::Manifest& manifest, |
| 42 const GURL& icon_url) { | 42 const GURL& primary_icon_url, |
| 43 const GURL& badge_icon_url) { |
| 43 auto shortcut_info = base::MakeUnique<ShortcutInfo>(GURL()); | 44 auto shortcut_info = base::MakeUnique<ShortcutInfo>(GURL()); |
| 44 if (!manifest.IsEmpty()) { | 45 if (!manifest.IsEmpty()) { |
| 45 shortcut_info->UpdateFromManifest(manifest); | 46 shortcut_info->UpdateFromManifest(manifest); |
| 46 shortcut_info->manifest_url = manifest_url; | 47 shortcut_info->manifest_url = manifest_url; |
| 47 shortcut_info->best_primary_icon_url = icon_url; | 48 shortcut_info->best_primary_icon_url = primary_icon_url; |
| 49 shortcut_info->best_badge_icon_url = badge_icon_url; |
| 48 shortcut_info->UpdateSource(ShortcutInfo::SOURCE_APP_BANNER); | 50 shortcut_info->UpdateSource(ShortcutInfo::SOURCE_APP_BANNER); |
| 49 } | 51 } |
| 50 | 52 |
| 51 shortcut_info->ideal_splash_image_size_in_px = | 53 shortcut_info->ideal_splash_image_size_in_px = |
| 52 ShortcutHelper::GetIdealSplashImageSizeInPx(); | 54 ShortcutHelper::GetIdealSplashImageSizeInPx(); |
| 53 shortcut_info->minimum_splash_image_size_in_px = | 55 shortcut_info->minimum_splash_image_size_in_px = |
| 54 ShortcutHelper::GetMinimumSplashImageSizeInPx(); | 56 ShortcutHelper::GetMinimumSplashImageSizeInPx(); |
| 55 shortcut_info->splash_image_url = ManifestIconSelector::FindBestMatchingIcon( | 57 shortcut_info->splash_image_url = ManifestIconSelector::FindBestMatchingIcon( |
| 56 manifest.icons, shortcut_info->ideal_splash_image_size_in_px, | 58 manifest.icons, shortcut_info->ideal_splash_image_size_in_px, |
| 57 shortcut_info->minimum_splash_image_size_in_px, | 59 shortcut_info->minimum_splash_image_size_in_px, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 AppBannerManager::ResetCurrentPageData(); | 224 AppBannerManager::ResetCurrentPageData(); |
| 223 native_app_data_.Reset(); | 225 native_app_data_.Reset(); |
| 224 native_app_package_ = ""; | 226 native_app_package_ = ""; |
| 225 } | 227 } |
| 226 | 228 |
| 227 void AppBannerManagerAndroid::ShowBanner() { | 229 void AppBannerManagerAndroid::ShowBanner() { |
| 228 content::WebContents* contents = web_contents(); | 230 content::WebContents* contents = web_contents(); |
| 229 DCHECK(contents); | 231 DCHECK(contents); |
| 230 | 232 |
| 231 if (native_app_data_.is_null()) { | 233 if (native_app_data_.is_null()) { |
| 232 // TODO(zpeng): Add badge to WebAPK installation flow. | |
| 233 if (AppBannerInfoBarDelegateAndroid::Create( | 234 if (AppBannerInfoBarDelegateAndroid::Create( |
| 234 contents, GetWeakPtr(), app_title_, | 235 contents, GetWeakPtr(), app_title_, |
| 235 CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_), | 236 CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_, |
| 236 std::move(primary_icon_), event_request_id(), | 237 badge_icon_url_), |
| 237 webapk::INSTALL_SOURCE_BANNER)) { | 238 std::move(primary_icon_), std::move(badge_icon_), |
| 239 event_request_id(), webapk::INSTALL_SOURCE_BANNER)) { |
| 238 RecordDidShowBanner("AppBanner.WebApp.Shown"); | 240 RecordDidShowBanner("AppBanner.WebApp.Shown"); |
| 239 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); | 241 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); |
| 240 ReportStatus(contents, SHOWING_WEB_APP_BANNER); | 242 ReportStatus(contents, SHOWING_WEB_APP_BANNER); |
| 241 } else { | 243 } else { |
| 242 ReportStatus(contents, FAILED_TO_CREATE_BANNER); | 244 ReportStatus(contents, FAILED_TO_CREATE_BANNER); |
| 243 } | 245 } |
| 244 } else { | 246 } else { |
| 245 if (AppBannerInfoBarDelegateAndroid::Create( | 247 if (AppBannerInfoBarDelegateAndroid::Create( |
| 246 contents, app_title_, native_app_data_, std::move(primary_icon_), | 248 contents, app_title_, native_app_data_, std::move(primary_icon_), |
| 247 native_app_package_, referrer_, event_request_id())) { | 249 native_app_package_, referrer_, event_request_id())) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 358 } |
| 357 | 359 |
| 358 // static | 360 // static |
| 359 void SetTotalEngagementToTrigger(JNIEnv* env, | 361 void SetTotalEngagementToTrigger(JNIEnv* env, |
| 360 const JavaParamRef<jclass>& clazz, | 362 const JavaParamRef<jclass>& clazz, |
| 361 jdouble engagement) { | 363 jdouble engagement) { |
| 362 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement); | 364 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement); |
| 363 } | 365 } |
| 364 | 366 |
| 365 } // namespace banners | 367 } // namespace banners |
| OLD | NEW |