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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java

Issue 2733543002: [Android:WebAPK] Don't add webapp to homescreen if WebAPK install times out part 1/3 (Closed)
Patch Set: Merge branch 'refactor_shortcut_helper29' into refactor_shortcut_helper3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java
index c157c6aeba67ef45cf8ccc87372055cec810ec27..e708ab86fa90d440faaf29401b27a91b8ed168c8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java
@@ -111,23 +111,26 @@ public class WebApkInstaller {
private void installWebApkFromGooglePlayAsync(
String packageName, int version, String title, String token, String url) {
if (mGooglePlayWebApkInstallDelegate == null) {
- notify(false);
+ notify(WebApkInstallResult.INSTALL_FAILED);
return;
}
Callback<Boolean> callback = new Callback<Boolean>() {
@Override
public void onResult(Boolean success) {
- WebApkInstaller.this.notify(success);
+ // TODO(pkotwicz): Send WebApkInstallResult.INSTALL_PROBABLY_FAILED result if
+ // install timed out.
+ WebApkInstaller.this.notify(success ? WebApkInstallResult.INSTALLED
+ : WebApkInstallResult.INSTALL_FAILED);
}
};
mGooglePlayWebApkInstallDelegate.installAsync(
packageName, version, title, token, url, callback);
}
- private void notify(boolean success) {
+ private void notify(int result) {
dominickn 2017/03/05 23:52:39 Can you call this variable webApkInstallResult, or
pkotwicz 2017/03/12 21:11:48 The java_cpp_enum.py script does not seem to suppo
dominickn 2017/03/13 03:22:23 Hmm, I've definitely seen this supported. Did you
pkotwicz 2017/03/14 22:38:57 Thank you for the pointer! I switched the code to
if (mNativePointer != 0) {
- nativeOnInstallFinished(mNativePointer, success);
+ nativeOnInstallFinished(mNativePointer, result);
}
}
@@ -190,18 +193,19 @@ public class WebApkInstaller {
@Override
public void onInstallFinished(InstallerDelegate task, boolean success) {
if (mInstallTask != task) return;
- onInstallFinishedInternal(success);
+ // TODO(pkotwicz): Return WebApkInstallResult.INSTALL_PROBABLY_FAILED if the install
+ // timed out.
+ onInstallFinishedInternal(success ? WebApkInstallResult.INSTALLED
+ : WebApkInstallResult.INSTALL_FAILED);
}
};
}
- private void onInstallFinishedInternal(boolean success) {
+ private void onInstallFinishedInternal(int result) {
ApplicationStatus.unregisterApplicationStateListener(mListener);
mInstallTask = null;
- if (mNativePointer != 0) {
- nativeOnInstallFinished(mNativePointer, success);
- }
- if (success && mIsInstall) {
+ notify(result);
+ if (result == WebApkInstallResult.INSTALLED && mIsInstall) {
ShortcutHelper.addWebApkShortcut(ContextUtils.getApplicationContext(),
mWebApkPackageName);
}
@@ -221,7 +225,7 @@ public class WebApkInstaller {
*/
if (newState == ApplicationState.HAS_RUNNING_ACTIVITIES
&& !isWebApkInstalled(mWebApkPackageName)) {
- onInstallFinishedInternal(false);
+ onInstallFinishedInternal(WebApkInstallResult.INSTALL_PROBABLY_FAILED);
return;
}
}
@@ -233,5 +237,5 @@ public class WebApkInstaller {
return InstallerDelegate.isInstalled(packageManager, packageName);
}
- private native void nativeOnInstallFinished(long nativeWebApkInstaller, boolean success);
+ private native void nativeOnInstallFinished(long nativeWebApkInstaller, int result);
}

Powered by Google App Engine
This is Rietveld 408576698