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 8f65f963a0fff3a6728583c434fb23cfdb755488..ab67fedc868a91680fb435926a0e5b0256ce9b5a 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 |
@@ -32,6 +32,7 @@ import org.chromium.base.CommandLineInitUtil; |
import org.chromium.base.Log; |
import org.chromium.base.TraceEvent; |
import org.chromium.chrome.browser.ChromeApplication; |
+import org.chromium.chrome.browser.ChromeSwitches; |
import org.chromium.chrome.browser.ChromeTabbedActivity; |
import org.chromium.chrome.browser.IntentHandler; |
import org.chromium.chrome.browser.IntentHandler.TabOpenType; |
@@ -279,7 +280,32 @@ public class ChromeLauncherActivity extends Activity |
* @return Whether the intent sent is for launching a Custom Tab. |
*/ |
private boolean isCustomTabIntent() { |
- if (getIntent() == null || !getIntent().hasExtra(CustomTabsIntent.EXTRA_SESSION)) { |
+ // HERB: Determine whether or not a CCT will be used for the incoming Intent. |
+ String flavor = ChromePreferenceManager.getInstance(this).getHerbFlavor(); |
+ boolean isHerbyIntent = !TextUtils.isEmpty(flavor); |
+ if (isHerbyIntent) { |
+ Log.d(TAG, "Herb flavor: " + flavor); |
+ isHerbyIntent &= TextUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW); |
+ |
+ if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ANISE) |
+ || TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_BASIL)) { |
+ // Only View Intents without NEW_TASK and NEW_DOCUMENT will trigger a CCT. |
+ boolean isSameTask = (getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == 0; |
+ boolean isSameDocument = |
+ (getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) == 0; |
+ isHerbyIntent &= isSameTask && isSameDocument; |
+ Log.d(TAG, "Herb Intent proprties -- SAME TASK: " |
+ + isSameTask + ", SAME DOCUMENT: " + isSameDocument); |
+ } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_CHIVE)) { |
+ // Chive sends all View Intents to the main browser. |
+ isHerbyIntent = false; |
+ } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_DILL)) { |
+ // Dill always opens View Intents in CCTs -- even home screen shortcuts. |
+ } |
+ } |
+ |
+ if (getIntent() == null || (!getIntent().hasExtra(CustomTabsIntent.EXTRA_SESSION) |
+ && !isHerbyIntent)) { |
return false; |
} |