| Index: chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java b/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java
|
| index ecffb299f387abd224728293bb631e33901d39e4..bd2b66db6e8ab7b1b4891b3b74a78017a93e460f 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/banners/AppBannerManager.java
|
| @@ -4,12 +4,6 @@
|
|
|
| package org.chromium.chrome.browser.banners;
|
|
|
| -import android.app.Activity;
|
| -import android.content.ContentResolver;
|
| -import android.content.Context;
|
| -import android.content.Intent;
|
| -import android.content.pm.PackageManager;
|
| -import android.os.Looper;
|
| import android.text.TextUtils;
|
|
|
| import org.chromium.base.ApplicationStatus;
|
| @@ -18,9 +12,7 @@ import org.chromium.base.JNINamespace;
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.EmptyTabObserver;
|
| import org.chromium.chrome.browser.Tab;
|
| -import org.chromium.chrome.browser.infobar.AppBannerInfoBar;
|
| import org.chromium.content_public.browser.WebContents;
|
| -import org.chromium.ui.base.WindowAndroid;
|
|
|
| /**
|
| * Manages an AppBannerInfoBar for a Tab.
|
| @@ -46,12 +38,6 @@ public class AppBannerManager extends EmptyTabObserver {
|
| /** Tab that the AppBannerView/AppBannerManager is owned by. */
|
| private final Tab mTab;
|
|
|
| - /** Monitors an installation in progress. */
|
| - private InstallerDelegate mInstallTask;
|
| -
|
| - /** Monitors for application state changes. */
|
| - private final ApplicationStatus.ApplicationStateListener mListener;
|
| -
|
| /**
|
| * Checks if app banners are enabled.
|
| * @return True if banners are enabled, false otherwise.
|
| @@ -77,18 +63,6 @@ public class AppBannerManager extends EmptyTabObserver {
|
| mNativePointer = nativeInit();
|
| mTab = tab;
|
| updatePointers();
|
| - mListener = createApplicationStateListener();
|
| - ApplicationStatus.registerApplicationStateListener(mListener);
|
| - }
|
| -
|
| - private ApplicationStatus.ApplicationStateListener createApplicationStateListener() {
|
| - return new ApplicationStatus.ApplicationStateListener() {
|
| - @Override
|
| - public void onApplicationStateChange(int newState) {
|
| - if (!ApplicationStatus.hasVisibleActivities()) return;
|
| - nativeUpdateInstallState(mNativePointer);
|
| - }
|
| - };
|
| }
|
|
|
| @Override
|
| @@ -106,11 +80,6 @@ public class AppBannerManager extends EmptyTabObserver {
|
| * Destroys the native AppBannerManager.
|
| */
|
| public void destroy() {
|
| - if (mInstallTask != null) {
|
| - mInstallTask.cancel();
|
| - mInstallTask = null;
|
| - }
|
| - ApplicationStatus.unregisterApplicationStateListener(mListener);
|
| nativeDestroy(mNativePointer);
|
| }
|
|
|
| @@ -160,73 +129,6 @@ public class AppBannerManager extends EmptyTabObserver {
|
| };
|
| }
|
|
|
| - @CalledByNative
|
| - private boolean installOrOpenNativeApp(AppData appData) {
|
| - Context context = ApplicationStatus.getApplicationContext();
|
| - String packageName = appData.packageName();
|
| - PackageManager packageManager = context.getPackageManager();
|
| -
|
| - if (InstallerDelegate.isInstalled(packageManager, packageName)) {
|
| - // Open the app.
|
| - Intent launchIntent = packageManager.getLaunchIntentForPackage(packageName);
|
| - if (launchIntent == null) return true;
|
| - context.startActivity(launchIntent);
|
| - return true;
|
| - } else {
|
| - // Try installing the app. If the installation was kicked off, return false to prevent
|
| - // the infobar from disappearing.
|
| - return !mTab.getWindowAndroid().showIntent(
|
| - appData.installIntent(), createIntentCallback(appData), null);
|
| - }
|
| - }
|
| -
|
| - private WindowAndroid.IntentCallback createIntentCallback(final AppData appData) {
|
| - return new WindowAndroid.IntentCallback() {
|
| - @Override
|
| - public void onIntentCompleted(WindowAndroid window, int resultCode,
|
| - ContentResolver contentResolver, Intent data) {
|
| - boolean isInstalling = resultCode == Activity.RESULT_OK;
|
| - if (isInstalling) {
|
| - // Start monitoring the install.
|
| - PackageManager pm =
|
| - ApplicationStatus.getApplicationContext().getPackageManager();
|
| - mInstallTask = new InstallerDelegate(
|
| - Looper.getMainLooper(), pm, createInstallerDelegateObserver(),
|
| - appData.packageName());
|
| - mInstallTask.start();
|
| - }
|
| -
|
| - nativeOnInstallIntentReturned(mNativePointer, isInstalling);
|
| - }
|
| - };
|
| - }
|
| -
|
| - private InstallerDelegate.Observer createInstallerDelegateObserver() {
|
| - return new InstallerDelegate.Observer() {
|
| - @Override
|
| - public void onInstallFinished(InstallerDelegate task, boolean success) {
|
| - if (mInstallTask != task) return;
|
| - mInstallTask = null;
|
| - nativeOnInstallFinished(mNativePointer, success);
|
| - }
|
| - };
|
| - }
|
| -
|
| - @CalledByNative
|
| - private void showAppDetails(AppData appData) {
|
| - mTab.getWindowAndroid().showIntent(appData.detailsIntent(), null, null);
|
| - }
|
| -
|
| - @CalledByNative
|
| - private int determineInstallState(AppData data) {
|
| - if (mInstallTask != null) return AppBannerInfoBar.INSTALL_STATE_INSTALLING;
|
| -
|
| - PackageManager pm = ApplicationStatus.getApplicationContext().getPackageManager();
|
| - boolean isInstalled = InstallerDelegate.isInstalled(pm, data.packageName());
|
| - return isInstalled ? AppBannerInfoBar.INSTALL_STATE_INSTALLED
|
| - : AppBannerInfoBar.INSTALL_STATE_NOT_INSTALLED;
|
| - }
|
| -
|
| private static native boolean nativeIsEnabled();
|
| private native long nativeInit();
|
| private native void nativeDestroy(long nativeAppBannerManager);
|
| @@ -234,10 +136,6 @@ public class AppBannerManager extends EmptyTabObserver {
|
| WebContents webContents);
|
| private native boolean nativeOnAppDetailsRetrieved(long nativeAppBannerManager, AppData data,
|
| String title, String packageName, String imageUrl);
|
| - private native void nativeOnInstallIntentReturned(
|
| - long nativeAppBannerManager, boolean isInstalling);
|
| - private native void nativeOnInstallFinished(long nativeAppBannerManager, boolean success);
|
| - private native void nativeUpdateInstallState(long nativeAppBannerManager);
|
|
|
| // UMA tracking.
|
| private static native void nativeRecordDismissEvent(int metric);
|
|
|