| 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 return shortcut_info; | 52 return shortcut_info; |
| 51 } | 53 } |
| 52 | 54 |
| 53 } // anonymous namespace | 55 } // anonymous namespace |
| 54 | 56 |
| 55 namespace banners { | 57 namespace banners { |
| 56 | 58 |
| 57 AppBannerManagerAndroid::AppBannerManagerAndroid( | 59 AppBannerManagerAndroid::AppBannerManagerAndroid( |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 AppBannerManager::ResetCurrentPageData(); | 233 AppBannerManager::ResetCurrentPageData(); |
| 232 native_app_data_.Reset(); | 234 native_app_data_.Reset(); |
| 233 native_app_package_ = ""; | 235 native_app_package_ = ""; |
| 234 } | 236 } |
| 235 | 237 |
| 236 void AppBannerManagerAndroid::ShowBanner() { | 238 void AppBannerManagerAndroid::ShowBanner() { |
| 237 content::WebContents* contents = web_contents(); | 239 content::WebContents* contents = web_contents(); |
| 238 DCHECK(contents); | 240 DCHECK(contents); |
| 239 | 241 |
| 240 if (native_app_data_.is_null()) { | 242 if (native_app_data_.is_null()) { |
| 241 // TODO(zpeng): Add badge to WebAPK installation flow. | |
| 242 if (AppBannerInfoBarDelegateAndroid::Create( | 243 if (AppBannerInfoBarDelegateAndroid::Create( |
| 243 contents, GetWeakPtr(), app_title_, | 244 contents, GetWeakPtr(), app_title_, |
| 244 CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_), | 245 CreateShortcutInfo(manifest_url_, manifest_, primary_icon_url_, |
| 245 std::move(primary_icon_), event_request_id(), | 246 badge_icon_url_), |
| 246 webapk::INSTALL_SOURCE_BANNER)) { | 247 std::move(primary_icon_), std::move(badge_icon_), |
| 248 event_request_id(), webapk::INSTALL_SOURCE_BANNER)) { |
| 247 RecordDidShowBanner("AppBanner.WebApp.Shown"); | 249 RecordDidShowBanner("AppBanner.WebApp.Shown"); |
| 248 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); | 250 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); |
| 249 ReportStatus(contents, SHOWING_WEB_APP_BANNER); | 251 ReportStatus(contents, SHOWING_WEB_APP_BANNER); |
| 250 } else { | 252 } else { |
| 251 ReportStatus(contents, FAILED_TO_CREATE_BANNER); | 253 ReportStatus(contents, FAILED_TO_CREATE_BANNER); |
| 252 } | 254 } |
| 253 } else { | 255 } else { |
| 254 if (AppBannerInfoBarDelegateAndroid::Create( | 256 if (AppBannerInfoBarDelegateAndroid::Create( |
| 255 contents, app_title_, native_app_data_, std::move(primary_icon_), | 257 contents, app_title_, native_app_data_, std::move(primary_icon_), |
| 256 native_app_package_, referrer_, event_request_id())) { | 258 native_app_package_, referrer_, event_request_id())) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 367 } |
| 366 | 368 |
| 367 // static | 369 // static |
| 368 void SetTotalEngagementToTrigger(JNIEnv* env, | 370 void SetTotalEngagementToTrigger(JNIEnv* env, |
| 369 const JavaParamRef<jclass>& clazz, | 371 const JavaParamRef<jclass>& clazz, |
| 370 jdouble engagement) { | 372 jdouble engagement) { |
| 371 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement); | 373 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement); |
| 372 } | 374 } |
| 373 | 375 |
| 374 } // namespace banners | 376 } // namespace banners |
| OLD | NEW |