| 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_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 Loading... |
| 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 Loading... |
| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 454 |
| 457 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); | 455 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); |
| 458 return true; | 456 return true; |
| 459 } | 457 } |
| 460 | 458 |
| 461 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { | 459 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { |
| 462 return RegisterNativesImpl(env); | 460 return RegisterNativesImpl(env); |
| 463 } | 461 } |
| 464 | 462 |
| 465 } // namespace banners | 463 } // namespace banners |
| OLD | NEW |