OLD | NEW |
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.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.net.Uri; | 9 import android.net.Uri; |
10 import android.os.Build; | 10 import android.os.Build; |
11 import android.os.Bundle; | 11 import android.os.Bundle; |
12 import android.text.TextUtils; | 12 import android.text.TextUtils; |
13 import android.util.Base64; | 13 import android.util.Base64; |
14 | 14 |
15 import org.chromium.base.ApiCompatibilityUtils; | 15 import org.chromium.base.ApiCompatibilityUtils; |
16 import org.chromium.base.ApplicationStatus; | 16 import org.chromium.base.ApplicationStatus; |
17 import org.chromium.base.Log; | 17 import org.chromium.base.Log; |
18 import org.chromium.chrome.browser.IntentHandler; | 18 import org.chromium.chrome.browser.IntentHandler; |
19 import org.chromium.chrome.browser.ShortcutHelper; | 19 import org.chromium.chrome.browser.ShortcutHelper; |
20 import org.chromium.chrome.browser.ShortcutSource; | 20 import org.chromium.chrome.browser.ShortcutSource; |
21 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 21 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
22 import org.chromium.chrome.browser.metrics.LaunchMetrics; | 22 import org.chromium.chrome.browser.metrics.LaunchMetrics; |
23 import org.chromium.chrome.browser.tab.Tab; | 23 import org.chromium.chrome.browser.tab.Tab; |
24 import org.chromium.chrome.browser.util.IntentUtils; | 24 import org.chromium.chrome.browser.util.IntentUtils; |
25 import org.chromium.webapk.lib.client.WebApkValidator; | 25 import org.chromium.webapk.lib.client.WebApkValidator; |
| 26 import org.chromium.webapk.lib.common.WebApkConstants; |
26 | 27 |
27 import java.lang.ref.WeakReference; | 28 import java.lang.ref.WeakReference; |
28 | 29 |
29 /** | 30 /** |
30 * Launches web apps. This was separated from the ChromeLauncherActivity becaus
e the | 31 * Launches web apps. This was separated from the ChromeLauncherActivity becaus
e the |
31 * ChromeLauncherActivity is not allowed to be excluded from Android's Recents:
crbug.com/517426. | 32 * ChromeLauncherActivity is not allowed to be excluded from Android's Recents:
crbug.com/517426. |
32 */ | 33 */ |
33 public class WebappLauncherActivity extends Activity { | 34 public class WebappLauncherActivity extends Activity { |
34 /** | 35 /** |
35 * Action fired when an Intent is trying to launch a WebappActivity. | 36 * Action fired when an Intent is trying to launch a WebappActivity. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 /** | 197 /** |
197 * Checks whether the WebAPK package specified in the intent is a valid WebA
PK and whether the | 198 * Checks whether the WebAPK package specified in the intent is a valid WebA
PK and whether the |
198 * url specified in the intent can be fulfilled by the WebAPK. | 199 * url specified in the intent can be fulfilled by the WebAPK. |
199 * | 200 * |
200 * @param intent The intent | 201 * @param intent The intent |
201 * @return true iff all validation criteria are met. | 202 * @return true iff all validation criteria are met. |
202 */ | 203 */ |
203 private boolean isValidWebApk(Intent intent) { | 204 private boolean isValidWebApk(Intent intent) { |
204 if (!ChromeWebApkHost.isEnabled()) return false; | 205 if (!ChromeWebApkHost.isEnabled()) return false; |
205 | 206 |
206 String webApkPackage = IntentUtils.safeGetStringExtra(intent, | 207 String webApkPackage = |
207 ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME); | 208 IntentUtils.safeGetStringExtra(intent, WebApkConstants.EXTRA_WEB
APK_PACKAGE_NAME); |
208 if (TextUtils.isEmpty(webApkPackage)) return false; | 209 if (TextUtils.isEmpty(webApkPackage)) return false; |
209 | 210 |
210 String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA
_URL); | 211 String url = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA
_URL); |
211 if (TextUtils.isEmpty(url)) return false; | 212 if (TextUtils.isEmpty(url)) return false; |
212 | 213 |
213 if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url))
) { | 214 if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url))
) { |
214 Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage
); | 215 Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage
); |
215 return false; | 216 return false; |
216 } | 217 } |
217 return true; | 218 return true; |
218 } | 219 } |
219 } | 220 } |
OLD | NEW |