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

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

Issue 2751913003: Add metrics to track Google Play install WebAPK failures. (Closed)
Patch Set: Nits. 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
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;
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.AppHooks; 20 import org.chromium.chrome.browser.AppHooks;
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.metrics.WebApkUma;
23 import org.chromium.chrome.browser.util.IntentUtils; 24 import org.chromium.chrome.browser.util.IntentUtils;
24 25
25 import java.io.File; 26 import java.io.File;
26 27
27 /** 28 /**
28 * Java counterpart to webapk_installer.h 29 * Java counterpart to webapk_installer.h
29 * Contains functionality to install / update WebAPKs. 30 * Contains functionality to install / update WebAPKs.
30 * This Java object is created by and owned by the native WebApkInstaller. 31 * This Java object is created by and owned by the native WebApkInstaller.
31 */ 32 */
32 public class WebApkInstaller { 33 public class WebApkInstaller {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 * @param version The version of WebAPK to install. 103 * @param version The version of WebAPK to install.
103 * @param title The title of the WebAPK to display during installation. 104 * @param title The title of the WebAPK to display during installation.
104 * @param token The token from WebAPK Server. 105 * @param token The token from WebAPK Server.
105 * @param url The start URL of the WebAPK to install. 106 * @param url The start URL of the WebAPK to install.
106 */ 107 */
107 @CalledByNative 108 @CalledByNative
108 private void installWebApkFromGooglePlayAsync( 109 private void installWebApkFromGooglePlayAsync(
109 String packageName, int version, String title, String token, String url) { 110 String packageName, int version, String title, String token, String url) {
110 if (mGooglePlayWebApkInstallDelegate == null) { 111 if (mGooglePlayWebApkInstallDelegate == null) {
111 notify(WebApkInstallResult.FAILURE); 112 notify(WebApkInstallResult.FAILURE);
113 WebApkUma.recordGooglePlayIntallResult(
dominickn 2017/03/22 00:15:22 Should this conditional be moved after the isWebAp
Xi Han 2017/03/22 17:32:36 It makes sense to me. Yes, we shouldn't records an
114 WebApkUma.GOOGLE_PLAY_INSTALL_FAILED_NO_DELEGATE);
112 return; 115 return;
113 } 116 }
114 117
115 // Check whether the WebAPK package is already installed. The WebAPK may have been installed 118 // 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 119 // 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. 120 // install API fails silently if the package is already installed.
118 if (isWebApkInstalled(packageName)) { 121 if (isWebApkInstalled(packageName)) {
119 notify(WebApkInstallResult.SUCCESS); 122 notify(WebApkInstallResult.SUCCESS);
120 return; 123 return;
121 } 124 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 248 }
246 249
247 private boolean isWebApkInstalled(String packageName) { 250 private boolean isWebApkInstalled(String packageName) {
248 PackageManager packageManager = ContextUtils.getApplicationContext().get PackageManager(); 251 PackageManager packageManager = ContextUtils.getApplicationContext().get PackageManager();
249 return InstallerDelegate.isInstalled(packageManager, packageName); 252 return InstallerDelegate.isInstalled(packageManager, packageName);
250 } 253 }
251 254
252 private native void nativeOnInstallFinished( 255 private native void nativeOnInstallFinished(
253 long nativeWebApkInstaller, @WebApkInstallResult.WebApkInstallResult Enum int result); 256 long nativeWebApkInstaller, @WebApkInstallResult.WebApkInstallResult Enum int result);
254 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698