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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java

Issue 2386383002: Remove redundant check for whether WebappInfo#id or WebappInfo#uri are null (Closed)
Patch Set: Merge branch 'master' into security00 Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698