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

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

Issue 2757563002: Revert of [Android:WebAPK] Don't add webapp to homescreen if WebAPK install times out part 2/3 (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/webapps/GooglePlayWebApkInstallDelegate.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 // Check whether the WebAPK package is already installed. The WebAPK may have been installed 115 // Check whether the WebAPK package is already installed. The WebAPK may have been installed
116 // by another Chrome version (e.g. Chrome Dev). We have to do this check because the Play 116 // by another Chrome version (e.g. Chrome Dev). We have to do this check because the Play
117 // install API fails silently if the package is already installed. 117 // install API fails silently if the package is already installed.
118 if (isWebApkInstalled(packageName)) { 118 if (isWebApkInstalled(packageName)) {
119 notify(WebApkInstallResult.SUCCESS); 119 notify(WebApkInstallResult.SUCCESS);
120 return; 120 return;
121 } 121 }
122 122
123 Callback<Integer> callback = new Callback<Integer>() { 123 Callback<Boolean> callback = new Callback<Boolean>() {
124 @Override 124 @Override
125 public void onResult(Integer result) { 125 public void onResult(Boolean success) {
126 WebApkInstaller.this.notify(result); 126 // TODO(pkotwicz): Send WebApkInstallResult.PROBABLE_FAILURE res ult if
127 // install timed out.
128 WebApkInstaller.this.notify(
129 success ? WebApkInstallResult.SUCCESS : WebApkInstallRes ult.FAILURE);
127 } 130 }
128 }; 131 };
129 mGooglePlayWebApkInstallDelegate.installAsync( 132 mGooglePlayWebApkInstallDelegate.installAsync(
130 packageName, version, title, token, url, callback); 133 packageName, version, title, token, url, callback);
131 } 134 }
132 135
133 private void notify(@WebApkInstallResult.WebApkInstallResultEnum int result) { 136 private void notify(@WebApkInstallResult.WebApkInstallResultEnum int result) {
134 if (mListener != null) { 137 if (mListener != null) {
135 ApplicationStatus.unregisterApplicationStateListener(mListener); 138 ApplicationStatus.unregisterApplicationStateListener(mListener);
136 mListener = null; 139 mListener = null;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 * @param url The start URL of the WebAPK to install. 173 * @param url The start URL of the WebAPK to install.
171 */ 174 */
172 @CalledByNative 175 @CalledByNative
173 private void updateAsyncFromGooglePlay( 176 private void updateAsyncFromGooglePlay(
174 String packageName, int version, String title, String token, String url) { 177 String packageName, int version, String title, String token, String url) {
175 if (mGooglePlayWebApkInstallDelegate == null) { 178 if (mGooglePlayWebApkInstallDelegate == null) {
176 notify(WebApkInstallResult.FAILURE); 179 notify(WebApkInstallResult.FAILURE);
177 return; 180 return;
178 } 181 }
179 182
180 Callback<Integer> callback = new Callback<Integer>() { 183 Callback<Boolean> callback = new Callback<Boolean>() {
181 @Override 184 @Override
182 public void onResult(Integer result) { 185 public void onResult(Boolean success) {
183 WebApkInstaller.this.notify(result); 186 // TODO(pkotwicz): Send WebApkInstallResult.PROBABLE_FAILURE res ult if
187 // update timed out.
188 WebApkInstaller.this.notify(
189 success ? WebApkInstallResult.SUCCESS : WebApkInstallRes ult.FAILURE);
184 } 190 }
185 }; 191 };
186 mGooglePlayWebApkInstallDelegate.installAsync( 192 mGooglePlayWebApkInstallDelegate.installAsync(
187 packageName, version, title, token, url, callback); 193 packageName, version, title, token, url, callback);
188 } 194 }
189 195
190 /** 196 /**
191 * Sends intent to Android to show prompt to install or update downloaded We bAPK. 197 * Sends intent to Android to show prompt to install or update downloaded We bAPK.
192 * @param filePath File to install. 198 * @param filePath File to install.
193 */ 199 */
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 251 }
246 252
247 private boolean isWebApkInstalled(String packageName) { 253 private boolean isWebApkInstalled(String packageName) {
248 PackageManager packageManager = ContextUtils.getApplicationContext().get PackageManager(); 254 PackageManager packageManager = ContextUtils.getApplicationContext().get PackageManager();
249 return InstallerDelegate.isInstalled(packageManager, packageName); 255 return InstallerDelegate.isInstalled(packageManager, packageName);
250 } 256 }
251 257
252 private native void nativeOnInstallFinished( 258 private native void nativeOnInstallFinished(
253 long nativeWebApkInstaller, @WebApkInstallResult.WebApkInstallResult Enum int result); 259 long nativeWebApkInstaller, @WebApkInstallResult.WebApkInstallResult Enum int result);
254 } 260 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/webapps/GooglePlayWebApkInstallDelegate.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698