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

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: dominickn@'s comments. 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 * Installs a WebAPK from Google Play and monitors the installation. 101 * Installs a WebAPK from Google Play and monitors the installation.
101 * @param packageName The package name of the WebAPK to install. 102 * @param packageName The package name of the WebAPK to install.
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 notify(WebApkInstallResult.FAILURE);
112 return;
113 }
114
115 // Check whether the WebAPK package is already installed. The WebAPK may have been installed 111 // 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 112 // 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. 113 // install API fails silently if the package is already installed.
118 if (isWebApkInstalled(packageName)) { 114 if (isWebApkInstalled(packageName)) {
119 notify(WebApkInstallResult.SUCCESS); 115 notify(WebApkInstallResult.SUCCESS);
120 return; 116 return;
121 } 117 }
122 118
119 if (mGooglePlayWebApkInstallDelegate == null) {
120 notify(WebApkInstallResult.FAILURE);
121 WebApkUma.recordGooglePlayInstallResult(
122 WebApkUma.GOOGLE_PLAY_INSTALL_FAILED_NO_DELEGATE);
123 return;
124 }
125
123 Callback<Integer> callback = new Callback<Integer>() { 126 Callback<Integer> callback = new Callback<Integer>() {
124 @Override 127 @Override
125 public void onResult(Integer result) { 128 public void onResult(Integer result) {
126 WebApkInstaller.this.notify(result); 129 WebApkInstaller.this.notify(result);
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
(...skipping 112 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/metrics/WebApkUma.java ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698