| 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 const GURL url = shortcut_info->url; | 50 const GURL url = shortcut_info->url; |
| 52 if (url.is_empty()) | 51 if (url.is_empty()) |
| 53 return false; | 52 return false; |
| 54 | 53 |
| 55 auto infobar_delegate = | 54 auto infobar_delegate = |
| 56 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( | 55 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( |
| 57 weak_manager, app_title, std::move(shortcut_info), primary_icon, | 56 weak_manager, std::move(shortcut_info), primary_icon, badge_icon, |
| 58 badge_icon, event_request_id, is_webapk, webapk_install_source)); | 57 event_request_id, is_webapk, webapk_install_source)); |
| 59 auto* raw_delegate = infobar_delegate.get(); | 58 auto* raw_delegate = infobar_delegate.get(); |
| 60 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( | 59 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( |
| 61 std::move(infobar_delegate), url, is_webapk); | 60 std::move(infobar_delegate), url, is_webapk); |
| 62 if (!InfoBarService::FromWebContents(web_contents) | 61 if (!InfoBarService::FromWebContents(web_contents) |
| 63 ->AddInfoBar(std::move(infobar))) | 62 ->AddInfoBar(std::move(infobar))) |
| 64 return false; | 63 return false; |
| 65 | 64 |
| 66 if (is_webapk) { | 65 if (is_webapk) { |
| 67 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) { | 66 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) { |
| 68 webapk::TrackInstallInfoBarShown( | 67 webapk::TrackInstallInfoBarShown( |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( | 194 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( |
| 196 env, java_delegate_, false); | 195 env, java_delegate_, false); |
| 197 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName( | 196 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName( |
| 198 env, java_delegate_, java_webapk_package_name); | 197 env, java_delegate_, java_webapk_package_name); |
| 199 UpdateInstallState(env, nullptr); | 198 UpdateInstallState(env, nullptr); |
| 200 install_state_ = INSTALLED; | 199 install_state_ = INSTALLED; |
| 201 } | 200 } |
| 202 | 201 |
| 203 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( | 202 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( |
| 204 base::WeakPtr<AppBannerManager> weak_manager, | 203 base::WeakPtr<AppBannerManager> weak_manager, |
| 205 const base::string16& app_title, | |
| 206 std::unique_ptr<ShortcutInfo> shortcut_info, | 204 std::unique_ptr<ShortcutInfo> shortcut_info, |
| 207 const SkBitmap& primary_icon, | 205 const SkBitmap& primary_icon, |
| 208 const SkBitmap& badge_icon, | 206 const SkBitmap& badge_icon, |
| 209 int event_request_id, | 207 int event_request_id, |
| 210 bool is_webapk, | 208 bool is_webapk, |
| 211 webapk::InstallSource webapk_install_source) | 209 webapk::InstallSource webapk_install_source) |
| 212 : weak_manager_(weak_manager), | 210 : weak_manager_(weak_manager), |
| 213 app_title_(app_title), | 211 app_title_(shortcut_info->name), |
| 214 shortcut_info_(std::move(shortcut_info)), | 212 shortcut_info_(std::move(shortcut_info)), |
| 215 primary_icon_(primary_icon), | 213 primary_icon_(primary_icon), |
| 216 badge_icon_(badge_icon), | 214 badge_icon_(badge_icon), |
| 217 event_request_id_(event_request_id), | 215 event_request_id_(event_request_id), |
| 218 has_user_interaction_(false), | 216 has_user_interaction_(false), |
| 219 is_webapk_(is_webapk), | 217 is_webapk_(is_webapk), |
| 220 install_state_(INSTALL_NOT_STARTED), | 218 install_state_(INSTALL_NOT_STARTED), |
| 221 webapk_install_source_(webapk_install_source), | 219 webapk_install_source_(webapk_install_source), |
| 222 weak_ptr_factory_(this) { | 220 weak_ptr_factory_(this) { |
| 223 CreateJavaDelegate(); | 221 CreateJavaDelegate(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 453 |
| 456 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); | 454 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); |
| 457 return true; | 455 return true; |
| 458 } | 456 } |
| 459 | 457 |
| 460 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { | 458 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { |
| 461 return RegisterNativesImpl(env); | 459 return RegisterNativesImpl(env); |
| 462 } | 460 } |
| 463 | 461 |
| 464 } // namespace banners | 462 } // namespace banners |
| OLD | NEW |