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; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 Context context = ContextUtils.getApplicationContext(); | 198 Context context = ContextUtils.getApplicationContext(); |
199 Intent intent; | 199 Intent intent; |
200 File pathToInstall = new File(filePath); | 200 File pathToInstall = new File(filePath); |
201 | 201 |
202 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | 202 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
203 intent = new Intent(Intent.ACTION_VIEW); | 203 intent = new Intent(Intent.ACTION_VIEW); |
204 Uri fileUri = Uri.fromFile(pathToInstall); | 204 Uri fileUri = Uri.fromFile(pathToInstall); |
205 intent.setDataAndType(fileUri, "application/vnd.android.package-arch
ive"); | 205 intent.setDataAndType(fileUri, "application/vnd.android.package-arch
ive"); |
206 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 206 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
207 } else { | 207 } else { |
208 Uri source = ContentUriUtils.getContentUriFromFile(context, pathToIn
stall); | 208 Uri source = ContentUriUtils.getContentUriFromFile(pathToInstall); |
209 intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); | 209 intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); |
210 intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | 210 intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
211 intent.setData(source); | 211 intent.setData(source); |
212 } | 212 } |
213 return IntentUtils.safeStartActivity(context, intent); | 213 return IntentUtils.safeStartActivity(context, intent); |
214 } | 214 } |
215 | 215 |
216 private InstallerDelegate.Observer createInstallerDelegateObserver() { | 216 private InstallerDelegate.Observer createInstallerDelegateObserver() { |
217 return new InstallerDelegate.Observer() { | 217 return new InstallerDelegate.Observer() { |
218 @Override | 218 @Override |
(...skipping 29 matching lines...) Expand all Loading... |
248 } | 248 } |
249 | 249 |
250 private boolean isWebApkInstalled(String packageName) { | 250 private boolean isWebApkInstalled(String packageName) { |
251 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); | 251 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); |
252 return InstallerDelegate.isInstalled(packageManager, packageName); | 252 return InstallerDelegate.isInstalled(packageManager, packageName); |
253 } | 253 } |
254 | 254 |
255 private native void nativeOnInstallFinished( | 255 private native void nativeOnInstallFinished( |
256 long nativeWebApkInstaller, @WebApkInstallResult.WebApkInstallResult
Enum int result); | 256 long nativeWebApkInstaller, @WebApkInstallResult.WebApkInstallResult
Enum int result); |
257 } | 257 } |
OLD | NEW |