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; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 String webApkPackageName = webappInfo.webApkPackageName(); | 57 String webApkPackageName = webappInfo.webApkPackageName(); |
58 int webappSource = webappInfo.source(); | 58 int webappSource = webappInfo.source(); |
59 | 59 |
60 if (webappId != null && webappUrl != null) { | 60 if (webappId != null && webappUrl != null) { |
61 Intent launchIntent = null; | 61 Intent launchIntent = null; |
62 | 62 |
63 // Permit the launch to a standalone web app frame if any of the fol
lowing are true: | 63 // Permit the launch to a standalone web app frame if any of the fol
lowing are true: |
64 // - the request was for a WebAPK that is valid; | 64 // - the request was for a WebAPK that is valid; |
65 // - the MAC is present and valid for the homescreen shortcut to be
opened; | 65 // - the MAC is present and valid for the homescreen shortcut to be
opened; |
66 // - the intent was sent by Chrome. | 66 // - the intent was sent by Chrome. |
| 67 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK
)) { |
| 68 ChromeWebApkHost.init(); |
| 69 } |
67 boolean isValidWebApk = isValidWebApk(webApkPackageName, webappUrl); | 70 boolean isValidWebApk = isValidWebApk(webApkPackageName, webappUrl); |
68 | 71 |
69 if (isValidWebApk | 72 if (isValidWebApk |
70 || isValidMacForUrl(webappUrl, IntentUtils.safeGetStringExtr
a( | 73 || isValidMacForUrl(webappUrl, IntentUtils.safeGetStringExtr
a( |
71 intent, ShortcutHelper.EXTRA_MAC)) | 74 intent, ShortcutHelper.EXTRA_MAC)) |
72 || wasIntentFromChrome(intent)) { | 75 || wasIntentFromChrome(intent)) { |
73 LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webap
pUrl, webappSource); | 76 LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webap
pUrl, webappSource); |
74 launchIntent = createWebappLaunchIntent(webappInfo, isValidWebAp
k); | 77 launchIntent = createWebappLaunchIntent(webappInfo, isValidWebAp
k); |
75 } else { | 78 } else { |
76 Log.e(TAG, "Shortcut (%s) opened in Chrome.", webappUrl); | 79 Log.e(TAG, "Shortcut (%s) opened in Chrome.", webappUrl); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 Log.d(TAG, "%s is not valid WebAPK", webApkPackage); | 188 Log.d(TAG, "%s is not valid WebAPK", webApkPackage); |
186 return false; | 189 return false; |
187 } | 190 } |
188 if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url))
) { | 191 if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url))
) { |
189 Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage
); | 192 Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage
); |
190 return false; | 193 return false; |
191 } | 194 } |
192 return true; | 195 return true; |
193 } | 196 } |
194 } | 197 } |
OLD | NEW |