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

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

Issue 2236033003: Make downloaded WebAPK world readable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_builder_impl2_directory Created 4 years, 4 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 | « no previous file | chrome/browser/android/webapk/webapk_installer.h » ('j') | 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.ActivityNotFoundException; 7 import android.content.ActivityNotFoundException;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.net.Uri; 10 import android.net.Uri;
(...skipping 19 matching lines...) Expand all
30 * @return True if the install was started. A "true" return value does not g uarantee that the 30 * @return True if the install was started. A "true" return value does not g uarantee that the
31 * install succeeds. 31 * install succeeds.
32 */ 32 */
33 @CalledByNative 33 @CalledByNative
34 static boolean installAsyncFromNative(String filePath, String packageName) { 34 static boolean installAsyncFromNative(String filePath, String packageName) {
35 if (!installingFromUnknownSourcesAllowed()) { 35 if (!installingFromUnknownSourcesAllowed()) {
36 Log.e(TAG, 36 Log.e(TAG,
37 "WebAPK install failed because installation from unknown sou rces is disabled."); 37 "WebAPK install failed because installation from unknown sou rces is disabled.");
38 return false; 38 return false;
39 } 39 }
40 if (!new File(filePath).exists()) {
41 return false;
42 }
43 Intent intent = new Intent(Intent.ACTION_VIEW); 40 Intent intent = new Intent(Intent.ACTION_VIEW);
44 Uri fileUri = Uri.fromFile(new File(filePath)); 41 Uri fileUri = Uri.fromFile(new File(filePath));
45 intent.setDataAndType(fileUri, "application/vnd.android.package-archive" ); 42 intent.setDataAndType(fileUri, "application/vnd.android.package-archive" );
46 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 43 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
47 try { 44 try {
48 ContextUtils.getApplicationContext().startActivity(intent); 45 ContextUtils.getApplicationContext().startActivity(intent);
49 } catch (ActivityNotFoundException e) { 46 } catch (ActivityNotFoundException e) {
50 return false; 47 return false;
51 } 48 }
52 return true; 49 return true;
53 } 50 }
54 51
55 /** 52 /**
56 * Returns whether the user has enabled installing apps from sources other t han the Google Play 53 * Returns whether the user has enabled installing apps from sources other t han the Google Play
57 * Store. 54 * Store.
58 */ 55 */
59 private static boolean installingFromUnknownSourcesAllowed() { 56 private static boolean installingFromUnknownSourcesAllowed() {
60 Context context = ContextUtils.getApplicationContext(); 57 Context context = ContextUtils.getApplicationContext();
61 try { 58 try {
62 return Settings.Secure.getInt( 59 return Settings.Secure.getInt(
63 context.getContentResolver(), Settings.Secure.INSTALL _NON_MARKET_APPS) 60 context.getContentResolver(), Settings.Secure.INSTALL _NON_MARKET_APPS)
64 == 1; 61 == 1;
65 } catch (Settings.SettingNotFoundException e) { 62 } catch (Settings.SettingNotFoundException e) {
66 return false; 63 return false;
67 } 64 }
68 } 65 }
69 } 66 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/webapk/webapk_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698