Chromium Code Reviews| 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/android/shortcut_helper.h" | 14 #include "chrome/browser/android/shortcut_helper.h" |
| 15 #include "chrome/browser/android/shortcut_info.h" | 15 #include "chrome/browser/android/shortcut_info.h" |
| 16 #include "chrome/browser/android/tab_android.h" | 16 #include "chrome/browser/android/tab_android.h" |
| 17 #include "chrome/browser/android/webapk/webapk_installer.h" | 17 #include "chrome/browser/android/webapk/webapk_installer.h" |
| 18 #include "chrome/browser/android/webapk/webapk_metrics.h" | |
| 18 #include "chrome/browser/banners/app_banner_manager.h" | 19 #include "chrome/browser/banners/app_banner_manager.h" |
| 19 #include "chrome/browser/banners/app_banner_metrics.h" | 20 #include "chrome/browser/banners/app_banner_metrics.h" |
| 20 #include "chrome/browser/banners/app_banner_settings_helper.h" | 21 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/infobars/infobar_service.h" | 23 #include "chrome/browser/infobars/infobar_service.h" |
| 23 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" | 24 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" |
| 24 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
| 25 #include "components/rappor/rappor_utils.h" | 26 #include "components/rappor/rappor_utils.h" |
| 26 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/manifest.h" | 29 #include "content/public/common/manifest.h" |
| 29 #include "jni/AppBannerInfoBarDelegateAndroid_jni.h" | 30 #include "jni/AppBannerInfoBarDelegateAndroid_jni.h" |
| 30 #include "ui/gfx/android/java_bitmap.h" | 31 #include "ui/gfx/android/java_bitmap.h" |
| 31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 32 | 33 |
| 33 using base::android::ConvertJavaStringToUTF8; | 34 using base::android::ConvertJavaStringToUTF8; |
| 34 using base::android::ConvertJavaStringToUTF16; | 35 using base::android::ConvertJavaStringToUTF16; |
| 35 using base::android::ConvertUTF8ToJavaString; | 36 using base::android::ConvertUTF8ToJavaString; |
| 36 using base::android::ConvertUTF16ToJavaString; | 37 using base::android::ConvertUTF16ToJavaString; |
| 37 using base::android::JavaParamRef; | 38 using base::android::JavaParamRef; |
| 38 using base::android::ScopedJavaLocalRef; | 39 using base::android::ScopedJavaLocalRef; |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 bool IsInfoEmpty(const ShortcutInfo* info) { | 43 bool IsInfoEmpty(const ShortcutInfo* info) { |
| 43 return !info || info->url.is_empty(); | 44 return !info || info->url.is_empty(); |
| 44 } | 45 } |
| 45 | 46 |
| 47 void TrackWebApkInstallationDismissEvents(banners::InstallState install_state) { | |
|
dominickn
2016/09/19 01:38:39
As per comment in the .h file, consider making thi
Xi Han
2016/09/20 18:25:18
Done.
| |
| 48 if (install_state == banners::WAIT_FOR_START) | |
| 49 webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADD_TO_HOME_SCREEN_DISMISS); | |
|
dominickn
2016/09/19 01:38:39
Won't you be in the WAIT_FOR_START state if you tr
Xi Han
2016/09/20 18:25:18
Rename it to DISMISS_BEFORE_INSTALLATION.
| |
| 50 else if (install_state == banners::INSTALLING) | |
| 51 webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADDING_DISMISS); | |
| 52 else if (install_state == banners::INSTALLED) | |
| 53 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS); | |
| 46 } | 54 } |
| 47 | 55 |
| 56 } // namespace | |
| 57 | |
| 48 namespace banners { | 58 namespace banners { |
| 49 | 59 |
| 50 // static | 60 // static |
| 51 bool AppBannerInfoBarDelegateAndroid::Create( | 61 bool AppBannerInfoBarDelegateAndroid::Create( |
| 52 content::WebContents* web_contents, | 62 content::WebContents* web_contents, |
| 53 base::WeakPtr<AppBannerManager> weak_manager, | 63 base::WeakPtr<AppBannerManager> weak_manager, |
| 54 const base::string16& app_title, | 64 const base::string16& app_title, |
| 55 std::unique_ptr<ShortcutInfo> shortcut_info, | 65 std::unique_ptr<ShortcutInfo> shortcut_info, |
| 56 std::unique_ptr<SkBitmap> icon, | 66 std::unique_ptr<SkBitmap> icon, |
| 57 int event_request_id, | 67 int event_request_id, |
| 58 bool is_webapk, | 68 bool is_webapk, |
| 59 bool start_install_webapk) { | 69 bool start_install_webapk) { |
| 60 const GURL& url = shortcut_info->url; | 70 const GURL& url = shortcut_info->url; |
| 61 auto infobar_delegate = | 71 auto infobar_delegate = |
| 62 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( | 72 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( |
| 63 weak_manager, app_title, std::move(shortcut_info), std::move(icon), | 73 weak_manager, app_title, std::move(shortcut_info), std::move(icon), |
| 64 event_request_id, is_webapk)); | 74 event_request_id, is_webapk)); |
| 65 auto raw_delegate = infobar_delegate.get(); | 75 auto raw_delegate = infobar_delegate.get(); |
| 66 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( | 76 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( |
| 67 std::move(infobar_delegate), url, is_webapk); | 77 std::move(infobar_delegate), url, is_webapk); |
| 68 if (!InfoBarService::FromWebContents(web_contents) | 78 if (!InfoBarService::FromWebContents(web_contents) |
| 69 ->AddInfoBar(std::move(infobar))) | 79 ->AddInfoBar(std::move(infobar))) |
| 70 return false; | 80 return false; |
| 71 | 81 |
| 72 if (is_webapk && start_install_webapk) | 82 if (is_webapk) { |
| 73 raw_delegate->AcceptWebApk(web_contents); | 83 if (start_install_webapk) { |
| 84 raw_delegate->AcceptWebApk(web_contents); | |
| 85 webapk::TrackStartType(webapk::STARTED_FROM_ADD_TO_HOME_SCREEN_MENU); | |
| 86 } else { | |
| 87 webapk::TrackStartType(webapk::TRIGGERED_FROM_BANNER); | |
|
dominickn
2016/09/19 01:38:39
See comment in webapk_metrics.h
Xi Han
2016/09/20 18:25:18
Done.
| |
| 88 } | |
| 89 } | |
| 74 | 90 |
| 75 return true; | 91 return true; |
| 76 } | 92 } |
| 77 | 93 |
| 78 // static | 94 // static |
| 79 bool AppBannerInfoBarDelegateAndroid::Create( | 95 bool AppBannerInfoBarDelegateAndroid::Create( |
| 80 content::WebContents* web_contents, | 96 content::WebContents* web_contents, |
| 81 const base::string16& app_title, | 97 const base::string16& app_title, |
| 82 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 98 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 83 std::unique_ptr<SkBitmap> icon, | 99 std::unique_ptr<SkBitmap> icon, |
| 84 const std::string& native_app_package, | 100 const std::string& native_app_package, |
| 85 const std::string& referrer, | 101 const std::string& referrer, |
| 86 int event_request_id) { | 102 int event_request_id) { |
| 87 auto infobar_delegate = base::WrapUnique(new AppBannerInfoBarDelegateAndroid( | 103 auto infobar_delegate = base::WrapUnique(new AppBannerInfoBarDelegateAndroid( |
| 88 app_title, native_app_data, std::move(icon), native_app_package, referrer, | 104 app_title, native_app_data, std::move(icon), native_app_package, referrer, |
| 89 event_request_id)); | 105 event_request_id)); |
| 90 return InfoBarService::FromWebContents(web_contents) | 106 return InfoBarService::FromWebContents(web_contents) |
| 91 ->AddInfoBar(base::MakeUnique<AppBannerInfoBarAndroid>( | 107 ->AddInfoBar(base::MakeUnique<AppBannerInfoBarAndroid>( |
| 92 std::move(infobar_delegate), native_app_data)); | 108 std::move(infobar_delegate), native_app_data)); |
| 93 } | 109 } |
| 94 | 110 |
| 95 AppBannerInfoBarDelegateAndroid::~AppBannerInfoBarDelegateAndroid() { | 111 AppBannerInfoBarDelegateAndroid::~AppBannerInfoBarDelegateAndroid() { |
| 96 weak_ptr_factory_.InvalidateWeakPtrs(); | 112 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 97 | 113 |
| 98 if (!has_user_interaction_) { | 114 if (!has_user_interaction_) { |
| 99 if (!native_app_data_.is_null()) | 115 if (!native_app_data_.is_null()) { |
| 100 TrackUserResponse(USER_RESPONSE_NATIVE_APP_IGNORED); | 116 TrackUserResponse(USER_RESPONSE_NATIVE_APP_IGNORED); |
| 101 else if (!IsInfoEmpty(shortcut_info_.get())) | 117 } else if (!IsInfoEmpty(shortcut_info_.get())) { |
| 102 TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED); | 118 TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED); |
| 119 if (is_webapk_) | |
| 120 webapk::TrackInstallEvent(webapk::INSTALL_EVENT_BANNER_IGNORED); | |
| 121 } | |
| 103 } | 122 } |
| 104 | 123 |
| 105 TrackDismissEvent(DISMISS_EVENT_DISMISSED); | 124 TrackDismissEvent(DISMISS_EVENT_DISMISSED); |
| 106 JNIEnv* env = base::android::AttachCurrentThread(); | 125 JNIEnv* env = base::android::AttachCurrentThread(); |
| 107 Java_AppBannerInfoBarDelegateAndroid_destroy(env, java_delegate_); | 126 Java_AppBannerInfoBarDelegateAndroid_destroy(env, java_delegate_); |
| 108 java_delegate_.Reset(); | 127 java_delegate_.Reset(); |
| 109 } | 128 } |
| 110 | 129 |
| 111 void AppBannerInfoBarDelegateAndroid::UpdateInstallState( | 130 void AppBannerInfoBarDelegateAndroid::UpdateInstallState( |
| 112 JNIEnv* env, | 131 JNIEnv* env, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 // |webapk_package_name_| is set when the WebAPK has finished installing. | 188 // |webapk_package_name_| is set when the WebAPK has finished installing. |
| 170 // If the |webapk_package_name_| is empty, it means the "Add to Homescreen" | 189 // If the |webapk_package_name_| is empty, it means the "Add to Homescreen" |
| 171 // button is pressed, so request WebAPK installation. Otherwise, it means | 190 // button is pressed, so request WebAPK installation. Otherwise, it means |
| 172 // the "Open" button is pressed, so open the installed WebAPK. | 191 // the "Open" button is pressed, so open the installed WebAPK. |
| 173 if (!webapk_package_name_.empty()) { | 192 if (!webapk_package_name_.empty()) { |
| 174 // Open the WebAPK. | 193 // Open the WebAPK. |
| 175 ScopedJavaLocalRef<jstring> java_webapk_package_name = | 194 ScopedJavaLocalRef<jstring> java_webapk_package_name = |
| 176 base::android::ConvertUTF8ToJavaString(env, webapk_package_name_); | 195 base::android::ConvertUTF8ToJavaString(env, webapk_package_name_); |
| 177 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_, | 196 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_, |
| 178 java_webapk_package_name); | 197 java_webapk_package_name); |
| 179 | 198 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN); |
| 180 SendBannerAccepted(web_contents, "web"); | 199 SendBannerAccepted(web_contents, "web"); |
| 181 return true; | 200 return true; |
|
dominickn
2016/09/19 01:38:39
If a user already has the WebAPK installed, it see
Xi Han
2016/09/20 18:25:18
This is a good point. I add "has_user_interaction_
dominickn
2016/09/21 06:54:27
This seems reasonable to me.
| |
| 182 } | 201 } |
| 183 | 202 |
| 184 // Request install the WebAPK. | 203 // Request install the WebAPK. |
| 204 install_state_ = INSTALLING; | |
| 185 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); | 205 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); |
| 186 AppBannerSettingsHelper::RecordBannerInstallEvent( | 206 AppBannerSettingsHelper::RecordBannerInstallEvent( |
| 187 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); | 207 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); |
| 188 | 208 |
| 189 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( | 209 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( |
| 190 env, java_delegate_, true); | 210 env, java_delegate_, true); |
| 191 UpdateInstallState(env, nullptr); | 211 UpdateInstallState(env, nullptr); |
| 192 WebApkInstaller::FinishCallback callback = | 212 WebApkInstaller::FinishCallback callback = |
| 193 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, | 213 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, |
| 194 weak_ptr_factory_.GetWeakPtr()); | 214 weak_ptr_factory_.GetWeakPtr()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 209 std::unique_ptr<SkBitmap> icon, | 229 std::unique_ptr<SkBitmap> icon, |
| 210 int event_request_id, | 230 int event_request_id, |
| 211 bool is_webapk) | 231 bool is_webapk) |
| 212 : weak_manager_(weak_manager), | 232 : weak_manager_(weak_manager), |
| 213 app_title_(app_title), | 233 app_title_(app_title), |
| 214 shortcut_info_(std::move(shortcut_info)), | 234 shortcut_info_(std::move(shortcut_info)), |
| 215 icon_(std::move(icon)), | 235 icon_(std::move(icon)), |
| 216 event_request_id_(event_request_id), | 236 event_request_id_(event_request_id), |
| 217 has_user_interaction_(false), | 237 has_user_interaction_(false), |
| 218 is_webapk_(is_webapk), | 238 is_webapk_(is_webapk), |
| 239 install_state_(WAIT_FOR_START), | |
| 219 weak_ptr_factory_(this) { | 240 weak_ptr_factory_(this) { |
| 220 DCHECK(!IsInfoEmpty(shortcut_info_.get())); | 241 DCHECK(!IsInfoEmpty(shortcut_info_.get())); |
| 221 CreateJavaDelegate(); | 242 CreateJavaDelegate(); |
| 222 } | 243 } |
| 223 | 244 |
| 224 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( | 245 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( |
| 225 const base::string16& app_title, | 246 const base::string16& app_title, |
| 226 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 247 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 227 std::unique_ptr<SkBitmap> icon, | 248 std::unique_ptr<SkBitmap> icon, |
| 228 const std::string& native_app_package, | 249 const std::string& native_app_package, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 web_contents->GetMainFrame()->Send( | 295 web_contents->GetMainFrame()->Send( |
| 275 new ChromeViewMsg_AppBannerDismissed( | 296 new ChromeViewMsg_AppBannerDismissed( |
| 276 web_contents->GetMainFrame()->GetRoutingID(), | 297 web_contents->GetMainFrame()->GetRoutingID(), |
| 277 event_request_id_)); | 298 event_request_id_)); |
| 278 | 299 |
| 279 if (!native_app_data_.is_null()) { | 300 if (!native_app_data_.is_null()) { |
| 280 TrackUserResponse(USER_RESPONSE_NATIVE_APP_DISMISSED); | 301 TrackUserResponse(USER_RESPONSE_NATIVE_APP_DISMISSED); |
| 281 AppBannerSettingsHelper::RecordBannerDismissEvent( | 302 AppBannerSettingsHelper::RecordBannerDismissEvent( |
| 282 web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE); | 303 web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE); |
| 283 } else { | 304 } else { |
| 305 if (is_webapk_) | |
| 306 TrackWebApkInstallationDismissEvents(install_state_); | |
| 284 TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED); | 307 TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED); |
| 285 AppBannerSettingsHelper::RecordBannerDismissEvent( | 308 AppBannerSettingsHelper::RecordBannerDismissEvent( |
| 286 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); | 309 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); |
| 287 } | 310 } |
| 288 } | 311 } |
| 289 | 312 |
| 290 base::string16 AppBannerInfoBarDelegateAndroid::GetMessageText() const { | 313 base::string16 AppBannerInfoBarDelegateAndroid::GetMessageText() const { |
| 291 return app_title_; | 314 return app_title_; |
| 292 } | 315 } |
| 293 | 316 |
| 294 int AppBannerInfoBarDelegateAndroid::GetButtons() const { | 317 int AppBannerInfoBarDelegateAndroid::GetButtons() const { |
| 295 return BUTTON_OK; | 318 return BUTTON_OK; |
| 296 } | 319 } |
| 297 | 320 |
| 298 bool AppBannerInfoBarDelegateAndroid::Accept() { | 321 bool AppBannerInfoBarDelegateAndroid::Accept() { |
| 299 has_user_interaction_ = true; | 322 has_user_interaction_ = true; |
| 300 | 323 |
| 301 content::WebContents* web_contents = | 324 content::WebContents* web_contents = |
| 302 InfoBarService::WebContentsFromInfoBar(infobar()); | 325 InfoBarService::WebContentsFromInfoBar(infobar()); |
| 303 if (!web_contents) { | 326 if (!web_contents) { |
| 304 TrackDismissEvent(DISMISS_EVENT_ERROR); | 327 TrackDismissEvent(DISMISS_EVENT_ERROR); |
| 305 return true; | 328 return true; |
| 306 } | 329 } |
| 307 | 330 |
| 308 if (!native_app_data_.is_null()) | 331 if (!native_app_data_.is_null()) |
| 309 return AcceptNativeApp(web_contents); | 332 return AcceptNativeApp(web_contents); |
| 310 | 333 |
| 311 if (is_webapk_) | 334 if (is_webapk_) { |
| 335 webapk::TrackStartType(webapk::STARTED_FROM_BANNER); | |
| 312 return AcceptWebApk(web_contents); | 336 return AcceptWebApk(web_contents); |
| 337 } | |
| 313 | 338 |
| 314 return AcceptWebApp(web_contents); | 339 return AcceptWebApp(web_contents); |
| 315 } | 340 } |
| 316 | 341 |
| 317 bool AppBannerInfoBarDelegateAndroid::AcceptNativeApp( | 342 bool AppBannerInfoBarDelegateAndroid::AcceptNativeApp( |
| 318 content::WebContents* web_contents) { | 343 content::WebContents* web_contents) { |
| 319 TrackUserResponse(USER_RESPONSE_NATIVE_APP_ACCEPTED); | 344 TrackUserResponse(USER_RESPONSE_NATIVE_APP_ACCEPTED); |
| 320 JNIEnv* env = base::android::AttachCurrentThread(); | 345 JNIEnv* env = base::android::AttachCurrentThread(); |
| 321 | 346 |
| 322 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 347 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( | 386 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( |
| 362 bool success, | 387 bool success, |
| 363 const std::string& webapk_package_name) { | 388 const std::string& webapk_package_name) { |
| 364 JNIEnv* env = base::android::AttachCurrentThread(); | 389 JNIEnv* env = base::android::AttachCurrentThread(); |
| 365 if (!success) { | 390 if (!success) { |
| 366 // The installation failed. | 391 // The installation failed. |
| 367 if (infobar()) | 392 if (infobar()) |
| 368 infobar()->RemoveSelf(); | 393 infobar()->RemoveSelf(); |
| 369 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); | 394 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); |
| 370 DVLOG(1) << "The WebAPK installation failed."; | 395 DVLOG(1) << "The WebAPK installation failed."; |
| 396 webapk::TrackInstallEvent(webapk::INSTALL_EVENT_FAILED); | |
| 371 return; | 397 return; |
| 372 } | 398 } |
| 373 | 399 |
| 374 webapk_package_name_ = webapk_package_name; | 400 webapk_package_name_ = webapk_package_name; |
| 375 ScopedJavaLocalRef<jstring> java_webapk_package_name = | 401 ScopedJavaLocalRef<jstring> java_webapk_package_name = |
| 376 base::android::ConvertUTF8ToJavaString(env, webapk_package_name); | 402 base::android::ConvertUTF8ToJavaString(env, webapk_package_name); |
| 377 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( | 403 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( |
| 378 env, java_delegate_, false); | 404 env, java_delegate_, false); |
| 379 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName( | 405 Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName( |
| 380 env, java_delegate_, java_webapk_package_name); | 406 env, java_delegate_, java_webapk_package_name); |
| 381 UpdateInstallState(env, nullptr); | 407 UpdateInstallState(env, nullptr); |
| 408 install_state_ = INSTALLED; | |
| 409 webapk::TrackInstallEvent(webapk::INSTALL_EVENT_COMPLETED); | |
| 382 } | 410 } |
| 383 | 411 |
| 384 bool AppBannerInfoBarDelegateAndroid::LinkClicked( | 412 bool AppBannerInfoBarDelegateAndroid::LinkClicked( |
| 385 WindowOpenDisposition disposition) { | 413 WindowOpenDisposition disposition) { |
| 386 if (native_app_data_.is_null()) | 414 if (native_app_data_.is_null()) |
| 387 return false; | 415 return false; |
| 388 | 416 |
| 389 // Try to show the details for the native app. | 417 // Try to show the details for the native app. |
| 390 JNIEnv* env = base::android::AttachCurrentThread(); | 418 JNIEnv* env = base::android::AttachCurrentThread(); |
| 391 | 419 |
| 392 content::WebContents* web_contents = | 420 content::WebContents* web_contents = |
| 393 InfoBarService::WebContentsFromInfoBar(infobar()); | 421 InfoBarService::WebContentsFromInfoBar(infobar()); |
| 394 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 422 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
| 395 DCHECK(tab); | 423 DCHECK(tab); |
| 396 | 424 |
| 397 Java_AppBannerInfoBarDelegateAndroid_showAppDetails( | 425 Java_AppBannerInfoBarDelegateAndroid_showAppDetails( |
| 398 env, java_delegate_, tab->GetJavaObject(), native_app_data_); | 426 env, java_delegate_, tab->GetJavaObject(), native_app_data_); |
| 399 | 427 |
| 400 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); | 428 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); |
| 401 return true; | 429 return true; |
| 402 } | 430 } |
| 403 | 431 |
| 404 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { | 432 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { |
| 405 return RegisterNativesImpl(env); | 433 return RegisterNativesImpl(env); |
| 406 } | 434 } |
| 407 | 435 |
| 408 } // namespace banners | 436 } // namespace banners |
| OLD | NEW |