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

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

Issue 2829943002: Redirecting off-origin navigations in PWAs to CCT. (Closed)
Patch Set: Relaxed the WebApkIntegrationTest Created 3 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 side-by-side diff with in-line comments
Download patch
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 a232f04b66ad689b7d37309dd32e758ad99464f6..2faec72fc74a674bbcf5c0896bfd3677adbdc6eb 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
@@ -196,19 +196,17 @@ public class WebappLauncherActivity extends Activity {
launchIntent.setData(Uri.parse(WebappActivity.WEBAPP_SCHEME + "://" + info.id()));
launchIntent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivityNewDocumentFlag());
-
- if (!isWebApk) {
- // If this is launching from a notification, we want to ensure that the URL being
- // launched is the URL in the intent. If a paused WebappActivity exists for this id,
- // then by default it will be focused and we have no way of sending the desired URL to
- // it (the intent is swallowed). As a workaround, set the CLEAR_TOP flag to ensure that
- // the existing Activity is cleared and relaunched with this intent.
- // TODO(dominickn): ideally, we want be able to route an intent to
- // WebappActivity.onNewIntent instead of restarting the Activity.
- if (source == ShortcutSource.NOTIFICATION) {
- launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- }
- }
+ // Setting FLAG_ACTIVITY_CLEAR_TOP handles 2 edge cases:
+ // - If a legacy PWA is launching from a notification, we want to ensure that the URL being
+ // launched is the URL in the intent. If a paused WebappActivity exists for this id,
+ // then by default it will be focused and we have no way of sending the desired URL to
+ // it (the intent is swallowed). As a workaround, set the CLEAR_TOP flag to ensure that
+ // the existing Activity handles an update via onNewIntent().
+ // - If a WebAPK is having a CustomTabActivity on top of it in the same Task, and user
+ // clicks a link to takes them back to the scope of a WebAPK, we want to destroy the
+ // CustomTabActivity activity and go back to the WebAPK activity. It is intentional that
+ // Custom Tab will not be reachable with a back button.
+ launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return launchIntent;
}

Powered by Google App Engine
This is Rietveld 408576698