| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.content.pm.PackageManager; | 9 import android.content.pm.PackageManager; |
| 10 import android.net.Uri; | 10 import android.net.Uri; |
| 11 import android.os.Build; | 11 import android.os.Build; |
| 12 import android.os.Looper; | 12 import android.os.Looper; |
| 13 | 13 |
| 14 import org.chromium.base.ApplicationState; | 14 import org.chromium.base.ApplicationState; |
| 15 import org.chromium.base.ApplicationStatus; | 15 import org.chromium.base.ApplicationStatus; |
| 16 import org.chromium.base.Callback; | 16 import org.chromium.base.Callback; |
| 17 import org.chromium.base.ContentUriUtils; | 17 import org.chromium.base.ContentUriUtils; |
| 18 import org.chromium.base.ContextUtils; | 18 import org.chromium.base.ContextUtils; |
| 19 import org.chromium.base.annotations.CalledByNative; | 19 import org.chromium.base.annotations.CalledByNative; |
| 20 import org.chromium.chrome.browser.ChromeApplication; | 20 import org.chromium.chrome.browser.ChromeApplication; |
| 21 import org.chromium.chrome.browser.ShortcutHelper; | 21 import org.chromium.chrome.browser.ShortcutHelper; |
| 22 import org.chromium.chrome.browser.banners.InstallerDelegate; | 22 import org.chromium.chrome.browser.banners.InstallerDelegate; |
| 23 import org.chromium.chrome.browser.externalauth.ExternalAuthUtils; |
| 24 import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler; |
| 23 import org.chromium.chrome.browser.util.IntentUtils; | 25 import org.chromium.chrome.browser.util.IntentUtils; |
| 24 | 26 |
| 25 import java.io.File; | 27 import java.io.File; |
| 26 | 28 |
| 27 /** | 29 /** |
| 28 * Java counterpart to webapk_installer.h | 30 * Java counterpart to webapk_installer.h |
| 29 * Contains functionality to install / update WebAPKs. | 31 * Contains functionality to install / update WebAPKs. |
| 30 * This Java object is created by and owned by the native WebApkInstaller. | 32 * This Java object is created by and owned by the native WebApkInstaller. |
| 31 */ | 33 */ |
| 32 public class WebApkInstaller { | 34 public class WebApkInstaller { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 55 ChromeApplication application = (ChromeApplication) ContextUtils.getAppl
icationContext(); | 57 ChromeApplication application = (ChromeApplication) ContextUtils.getAppl
icationContext(); |
| 56 mGooglePlayWebApkInstallDelegate = application.getGooglePlayWebApkInstal
lDelegate(); | 58 mGooglePlayWebApkInstallDelegate = application.getGooglePlayWebApkInstal
lDelegate(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 @CalledByNative | 61 @CalledByNative |
| 60 private static WebApkInstaller create(long nativePtr) { | 62 private static WebApkInstaller create(long nativePtr) { |
| 61 return new WebApkInstaller(nativePtr); | 63 return new WebApkInstaller(nativePtr); |
| 62 } | 64 } |
| 63 | 65 |
| 64 @CalledByNative | 66 @CalledByNative |
| 65 private boolean hasGooglePlayWebApkInstallDelegate() { | 67 private boolean canUseGooglePlayInstallService() { |
| 66 return mGooglePlayWebApkInstallDelegate != null; | 68 return mGooglePlayWebApkInstallDelegate != null |
| 69 && ExternalAuthUtils.getInstance().canUseGooglePlayServices( |
| 70 ContextUtils.getApplicationContext(), |
| 71 new UserRecoverableErrorHandler.Silent()); |
| 67 } | 72 } |
| 68 | 73 |
| 69 @CalledByNative | 74 @CalledByNative |
| 70 private void destroy() { | 75 private void destroy() { |
| 71 if (mListener != null) { | 76 if (mListener != null) { |
| 72 ApplicationStatus.unregisterApplicationStateListener(mListener); | 77 ApplicationStatus.unregisterApplicationStateListener(mListener); |
| 73 } | 78 } |
| 74 mListener = null; | 79 mListener = null; |
| 75 mNativePointer = 0; | 80 mNativePointer = 0; |
| 76 } | 81 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 }; | 233 }; |
| 229 } | 234 } |
| 230 | 235 |
| 231 private boolean isWebApkInstalled(String packageName) { | 236 private boolean isWebApkInstalled(String packageName) { |
| 232 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); | 237 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); |
| 233 return InstallerDelegate.isInstalled(packageManager, packageName); | 238 return InstallerDelegate.isInstalled(packageManager, packageName); |
| 234 } | 239 } |
| 235 | 240 |
| 236 private native void nativeOnInstallFinished(long nativeWebApkInstaller, bool
ean success); | 241 private native void nativeOnInstallFinished(long nativeWebApkInstaller, bool
ean success); |
| 237 } | 242 } |
| OLD | NEW |