Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java |
index 7136bc655808489419e81983ee58672b6240f64f..f2f38a715fc5eb87ea72d75add2c80c9b1f1dc38 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java |
@@ -44,6 +44,8 @@ public class WebappLauncherActivity extends Activity { |
public void onCreate(Bundle savedInstanceState) { |
WebappInfo webappInfo = WebappInfo.create(getIntent()); |
if (webappInfo == null) { |
+ // {@link WebappInfo#create()} returns null if the intent does not specify the id or the |
+ // uri. |
super.onCreate(null); |
ApiCompatibilityUtils.finishAndRemoveTask(this); |
return; |
@@ -51,43 +53,40 @@ public class WebappLauncherActivity extends Activity { |
super.onCreate(savedInstanceState); |
Intent intent = getIntent(); |
- String webappId = webappInfo.id(); |
String webappUrl = webappInfo.uri().toString(); |
String webApkPackageName = webappInfo.webApkPackageName(); |
int webappSource = webappInfo.source(); |
- if (webappId != null && webappUrl != null) { |
- Intent launchIntent = null; |
- |
- // Permit the launch to a standalone web app frame if any of the following are true: |
- // - the request was for a WebAPK that is valid; |
- // - the MAC is present and valid for the homescreen shortcut to be opened; |
- // - the intent was sent by Chrome. |
- ChromeWebApkHost.init(); |
- boolean isValidWebApk = isValidWebApk(webApkPackageName, webappUrl); |
- |
- if (isValidWebApk |
- || isValidMacForUrl(webappUrl, IntentUtils.safeGetStringExtra( |
- intent, ShortcutHelper.EXTRA_MAC)) |
- || wasIntentFromChrome(intent)) { |
- LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webappUrl, webappSource); |
- launchIntent = createWebappLaunchIntent(webappInfo, webappSource, isValidWebApk); |
- } else { |
- Log.e(TAG, "Shortcut (%s) opened in Chrome.", webappUrl); |
- |
- // The shortcut data doesn't match the current encoding. Change the intent action |
- // launch the URL with a VIEW Intent in the regular browser. |
- launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webappUrl)); |
- launchIntent.setClassName(getPackageName(), ChromeLauncherActivity.class.getName()); |
- launchIntent.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); |
- launchIntent.putExtra(ShortcutHelper.EXTRA_SOURCE, webappSource); |
- launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
- | ApiCompatibilityUtils.getActivityNewDocumentFlag()); |
- } |
- |
- startActivity(launchIntent); |
+ Intent launchIntent = null; |
+ |
+ // Permit the launch to a standalone web app frame if any of the following are true: |
+ // - the request was for a WebAPK that is valid; |
+ // - the MAC is present and valid for the homescreen shortcut to be opened; |
+ // - the intent was sent by Chrome. |
+ ChromeWebApkHost.init(); |
+ boolean isValidWebApk = isValidWebApk(webApkPackageName, webappUrl); |
+ |
+ if (isValidWebApk |
+ || isValidMacForUrl(webappUrl, IntentUtils.safeGetStringExtra( |
+ intent, ShortcutHelper.EXTRA_MAC)) |
+ || wasIntentFromChrome(intent)) { |
+ LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webappUrl, webappSource); |
+ launchIntent = createWebappLaunchIntent(webappInfo, webappSource, isValidWebApk); |
+ } else { |
+ Log.e(TAG, "Shortcut (%s) opened in Chrome.", webappUrl); |
+ |
+ // The shortcut data doesn't match the current encoding. Change the intent action |
+ // launch the URL with a VIEW Intent in the regular browser. |
+ launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webappUrl)); |
+ launchIntent.setClassName(getPackageName(), ChromeLauncherActivity.class.getName()); |
+ launchIntent.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); |
+ launchIntent.putExtra(ShortcutHelper.EXTRA_SOURCE, webappSource); |
+ launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
+ | ApiCompatibilityUtils.getActivityNewDocumentFlag()); |
} |
+ startActivity(launchIntent); |
+ |
ApiCompatibilityUtils.finishAndRemoveTask(this); |
} |