Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.cc

Issue 2641973003: Implement server-suggested update check backoff (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/android/shortcut_helper.h" 12 #include "chrome/browser/android/shortcut_helper.h"
13 #include "chrome/browser/android/shortcut_info.h" 13 #include "chrome/browser/android/shortcut_info.h"
14 #include "chrome/browser/android/tab_android.h" 14 #include "chrome/browser/android/tab_android.h"
15 #include "chrome/browser/android/webapk/chrome_webapk_host.h" 15 #include "chrome/browser/android/webapk/chrome_webapk_host.h"
16 #include "chrome/browser/android/webapk/webapk_installer.h"
17 #include "chrome/browser/banners/app_banner_manager.h" 16 #include "chrome/browser/banners/app_banner_manager.h"
18 #include "chrome/browser/banners/app_banner_metrics.h" 17 #include "chrome/browser/banners/app_banner_metrics.h"
19 #include "chrome/browser/banners/app_banner_settings_helper.h" 18 #include "chrome/browser/banners/app_banner_settings_helper.h"
20 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
22 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" 21 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h"
23 #include "components/rappor/public/rappor_utils.h" 22 #include "components/rappor/public/rappor_utils.h"
24 #include "components/rappor/rappor_service_impl.h" 23 #include "components/rappor/rappor_service_impl.h"
25 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/manifest.h" 25 #include "content/public/common/manifest.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 AppBannerSettingsHelper::RecordBannerEvent( 343 AppBannerSettingsHelper::RecordBannerEvent(
345 web_contents, web_contents->GetLastCommittedURL(), 344 web_contents, web_contents->GetLastCommittedURL(),
346 shortcut_info_->url.spec(), 345 shortcut_info_->url.spec(),
347 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 346 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
348 AppBannerManager::GetCurrentTime()); 347 AppBannerManager::GetCurrentTime());
349 } 348 }
350 349
351 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( 350 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState(
352 env, java_delegate_, true); 351 env, java_delegate_, true);
353 UpdateInstallState(env, nullptr); 352 UpdateInstallState(env, nullptr);
354 WebApkInstaller::FinishCallback callback = 353 WebApkInstallService::FinishCallback callback =
355 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, 354 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished,
356 weak_ptr_factory_.GetWeakPtr()); 355 weak_ptr_factory_.GetWeakPtr());
357 ShortcutHelper::InstallWebApkWithSkBitmap(web_contents->GetBrowserContext(), 356 ShortcutHelper::InstallWebApkWithSkBitmap(web_contents->GetBrowserContext(),
358 *shortcut_info_, 357 *shortcut_info_,
359 *icon_.get(), callback); 358 *icon_.get(), callback);
360 SendBannerAccepted(); 359 SendBannerAccepted();
361 360
362 // Prevent the infobar from disappearing, because the infobar will show 361 // Prevent the infobar from disappearing, because the infobar will show
363 // "Adding" during the installation process. 362 // "Adding" during the installation process.
364 return false; 363 return false;
365 } 364 }
366 365
367 bool AppBannerInfoBarDelegateAndroid::TriggeredFromBanner() const { 366 bool AppBannerInfoBarDelegateAndroid::TriggeredFromBanner() const {
368 return !is_webapk_ || webapk_install_source_ == webapk::INSTALL_SOURCE_BANNER; 367 return !is_webapk_ || webapk_install_source_ == webapk::INSTALL_SOURCE_BANNER;
369 } 368 }
370 369
371 void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() { 370 void AppBannerInfoBarDelegateAndroid::SendBannerAccepted() {
372 if (weak_manager_ && TriggeredFromBanner()) { 371 if (weak_manager_ && TriggeredFromBanner()) {
373 weak_manager_->SendBannerAccepted(event_request_id_); 372 weak_manager_->SendBannerAccepted(event_request_id_);
374 // TODO(mgiuca): Send the appinstalled event for WebAPKs (but just removing 373 // TODO(mgiuca): Send the appinstalled event for WebAPKs (but just removing
375 // this check won't be sufficient). 374 // this check won't be sufficient).
376 if (!is_webapk_) 375 if (!is_webapk_)
377 weak_manager_->OnInstall(); 376 weak_manager_->OnInstall();
378 } 377 }
379 } 378 }
380 379
381 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished( 380 void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
382 bool success, 381 bool success,
383 const std::string& webapk_package_name) { 382 const WebApkInstallService::FinishCallbackData& data) {
384 JNIEnv* env = base::android::AttachCurrentThread(); 383 JNIEnv* env = base::android::AttachCurrentThread();
385 if (!success) { 384 if (!success) {
386 DVLOG(1) << "The WebAPK installation failed."; 385 DVLOG(1) << "The WebAPK installation failed.";
387 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env); 386 Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
388 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); 387 webapk::TrackInstallEvent(webapk::INSTALL_FAILED);
389 if (infobar()) 388 if (infobar())
390 infobar()->RemoveSelf(); 389 infobar()->RemoveSelf();
391 return; 390 return;
392 } 391 }
393 392
394 UpdateStateForInstalledWebAPK(webapk_package_name); 393 UpdateStateForInstalledWebAPK(data.webapk_package_name);
395 webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED); 394 webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED);
396 } 395 }
397 396
398 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( 397 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
399 InstallState install_state) { 398 InstallState install_state) {
400 if (install_state == INSTALL_NOT_STARTED) { 399 if (install_state == INSTALL_NOT_STARTED) {
401 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); 400 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION);
402 } else if (install_state == INSTALLING) { 401 } else if (install_state == INSTALLING) {
403 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION); 402 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION);
404 } else if (install_state == INSTALLED) { 403 } else if (install_state == INSTALLED) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 470
472 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 471 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
473 return true; 472 return true;
474 } 473 }
475 474
476 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 475 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
477 return RegisterNativesImpl(env); 476 return RegisterNativesImpl(env);
478 } 477 }
479 478
480 } // namespace banners 479 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698