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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java

Issue 2373823002: Add support for NEW_TASK in CCTs.
Patch Set: Created 4 years, 3 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/ChromeTabbedActivity.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/document/ChromeLauncherActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
index 799ba6adf2cec0c199dddc718c3fecc40c0002f7..d9595ec1ea2b04e0f84b3cddf688ec423d991c52 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
@@ -356,38 +356,7 @@ public class ChromeLauncherActivity extends Activity
/**
* Adds extras to the Intent that are needed by Herb.
*/
- public static void updateHerbIntent(Context context, Intent newIntent, Uri uri) {
- // For Elderberry flavored Herbs that are to be launched in a separate task, add a random
- // UUID to try and prevent Android from refocusing/clobbering items that share the same
- // base intent. If we do support refocusing of existing Herbs, we need to do it on the
- // current URL and not the URL that it was triggered with.
- if (TextUtils.equals(
- FeatureUtilities.getHerbFlavor(), ChromeSwitches.HERB_FLAVOR_ELDERBERRY)
- && ((newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0
- || (newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0)) {
- String uuid = UUID.randomUUID().toString();
- newIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- newIntent.setFlags(
- newIntent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- // Force a new document L+ to ensure the proper task/stack creation.
- newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
- newIntent.setClassName(context, SeparateTaskCustomTabActivity.class.getName());
- } else {
- int activityIndex =
- ActivityAssigner.instance(ActivityAssigner.SEPARATE_TASK_CCT_NAMESPACE)
- .assign(uuid);
- String className = SeparateTaskCustomTabActivity.class.getName() + activityIndex;
- newIntent.setClassName(context, className);
- }
-
- String url = IntentHandler.getUrlFromIntent(newIntent);
- assert url != null;
- newIntent.setData(new Uri.Builder().scheme(UrlConstants.CUSTOM_TAB_SCHEME)
- .authority(uuid).query(url).build());
- }
-
+ public static void updateHerbIntent(Context context, Intent newIntent) {
newIntent.putExtra(CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM, true);
newIntent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, true);
@@ -425,10 +394,30 @@ public class ChromeLauncherActivity extends Activity
// so explicitly remove it to ensure the CCT does not get lost in recents.
if ((newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0
|| (newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
+ String uuid = UUID.randomUUID().toString();
newIntent.setFlags(
newIntent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ // Force a new document L+ to ensure the proper task/stack creation.
+ newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+ newIntent.setClassName(context, SeparateTaskCustomTabActivity.class.getName());
+ } else {
+ newIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+ int activityIndex =
+ ActivityAssigner.instance(ActivityAssigner.SEPARATE_TASK_CCT_NAMESPACE)
+ .assign(uuid);
+ String className = SeparateTaskCustomTabActivity.class.getName() + activityIndex;
+ newIntent.setClassName(context, className);
+ }
+
+ String url = IntentHandler.getUrlFromIntent(newIntent);
+ assert url != null;
+ newIntent.setData(new Uri.Builder().scheme(UrlConstants.CUSTOM_TAB_SCHEME)
+ .authority(uuid).query(url).build());
}
- if (addHerbExtras) updateHerbIntent(context, newIntent, uri);
+
+ if (addHerbExtras) updateHerbIntent(context, newIntent);
return newIntent;
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698