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

Side by Side Diff: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java

Issue 1968353002: Upstream: Add URL intent filter to WebAPK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/webapk/shell_apk/BUILD.gn ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.webapk.shell_apk; 5 package org.chromium.webapk.shell_apk;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.ComponentName; 8 import android.content.ComponentName;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.pm.ApplicationInfo; 10 import android.content.pm.ApplicationInfo;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 String name = null; 47 String name = null;
48 String url = null; 48 String url = null;
49 String scope = null; 49 String scope = null;
50 String encodedIcon = null; 50 String encodedIcon = null;
51 String runtimeHost = null; 51 String runtimeHost = null;
52 try { 52 try {
53 ApplicationInfo appInfo = getPackageManager().getApplicationInfo( 53 ApplicationInfo appInfo = getPackageManager().getApplicationInfo(
54 packageName, PackageManager.GET_META_DATA); 54 packageName, PackageManager.GET_META_DATA);
55 Bundle bundle = appInfo.metaData; 55 Bundle bundle = appInfo.metaData;
56 url = bundle.getString(META_DATA_HOST_URL); 56 url = bundle.getString(META_DATA_HOST_URL);
57
58 String overrideUrl = getIntent().getDataString();
59 // TODO(pkotwicz): Use same logic as {@code IntentHandler#shouldIgno reIntent()}
60 if (overrideUrl != null && overrideUrl.startsWith("https:")) {
61 url = overrideUrl;
62 }
63
57 scope = bundle.getString(META_DATA_SCOPE); 64 scope = bundle.getString(META_DATA_SCOPE);
58 webappId = WebApkConstants.WEBAPK_ID_PREFIX + packageName; 65 webappId = WebApkConstants.WEBAPK_ID_PREFIX + packageName;
59 mac = bundle.getString(META_DATA_MAC); 66 mac = bundle.getString(META_DATA_MAC);
60 runtimeHost = bundle.getString(META_DATA_RUNTIME_HOST); 67 runtimeHost = bundle.getString(META_DATA_RUNTIME_HOST);
61 name = (String) getPackageManager().getApplicationLabel(appInfo); 68 name = (String) getPackageManager().getApplicationLabel(appInfo);
62 // TODO(hanxi): find a neat solution to avoid encode/decode each tim e launch the 69 // TODO(hanxi): find a neat solution to avoid encode/decode each tim e launch the
63 // activity. 70 // activity.
64 Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawabl e.app_icon); 71 Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawabl e.app_icon);
65 encodedIcon = encodeBitmapAsString(icon); 72 encodedIcon = encodeBitmapAsString(icon);
66 Log.w(TAG, "Url of the WebAPK: " + url); 73 Log.w(TAG, "Url of the WebAPK: " + url);
(...skipping 21 matching lines...) Expand all
88 * The encoded string can be decoded using {@link decodeBitmapFromString(Str ing)}. 95 * The encoded string can be decoded using {@link decodeBitmapFromString(Str ing)}.
89 * @param bitmap The Bitmap to compress and encode. 96 * @param bitmap The Bitmap to compress and encode.
90 * @return the String encoding the Bitmap. 97 * @return the String encoding the Bitmap.
91 */ 98 */
92 private static String encodeBitmapAsString(Bitmap bitmap) { 99 private static String encodeBitmapAsString(Bitmap bitmap) {
93 if (bitmap == null) return ""; 100 if (bitmap == null) return "";
94 ByteArrayOutputStream output = new ByteArrayOutputStream(); 101 ByteArrayOutputStream output = new ByteArrayOutputStream();
95 bitmap.compress(Bitmap.CompressFormat.PNG, 100, output); 102 bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
96 return Base64.encodeToString(output.toByteArray(), Base64.DEFAULT); 103 return Base64.encodeToString(output.toByteArray(), Base64.DEFAULT);
97 } 104 }
105
106 /**
107 * Returns whether a url is valid.
108 * @param url The url to check.
109 * @return Whether the url is valid.
110 */
111 private static boolean isUrlValid(String url) {
Yaron 2016/05/12 13:45:12 nit: remove
112 return url != null && url.startsWith("https:");
113 }
98 } 114 }
OLDNEW
« no previous file with comments | « chrome/android/webapk/shell_apk/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698