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

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

Issue 2145833003: Open the notification URL (not the web app start_url) when deep-linking into standalone mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add flag to clear existing task Created 4 years, 5 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 | « chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java ('k') | 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 e8d3b18515d30157d7f4f6b20ebd238ebd3e6bc9..1f74905ebf285ede97bbf238f5cf80ae9cd4e6ed 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
@@ -19,6 +19,7 @@ import org.chromium.base.Log;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.ShortcutHelper;
+import org.chromium.chrome.browser.ShortcutSource;
import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.metrics.LaunchMetrics;
import org.chromium.chrome.browser.tab.Tab;
@@ -74,7 +75,7 @@ public class WebappLauncherActivity extends Activity {
intent, ShortcutHelper.EXTRA_MAC))
|| wasIntentFromChrome(intent)) {
LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(webappUrl, webappSource);
- launchIntent = createWebappLaunchIntent(webappInfo, isValidWebApk);
+ launchIntent = createWebappLaunchIntent(webappInfo, webappSource, isValidWebApk);
} else {
Log.e(TAG, "Shortcut (%s) opened in Chrome.", webappUrl);
@@ -119,7 +120,7 @@ public class WebappLauncherActivity extends Activity {
* @param isWebApk If true, launch the app as a WebApkActivity. If false, launch the app as
* a WebappActivity.
*/
- private Intent createWebappLaunchIntent(WebappInfo info, boolean isWebApk) {
+ private Intent createWebappLaunchIntent(WebappInfo info, int source, boolean isWebApk) {
String activityName = isWebApk ? WebApkActivity.class.getName()
: WebappActivity.class.getName();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
@@ -145,6 +146,17 @@ public class WebappLauncherActivity extends Activity {
// of the WebAPK's main activity and in the same task.
launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| ApiCompatibilityUtils.getActivityNewDocumentFlag());
+
+ // 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);
+ }
}
return launchIntent;
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698