Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java |
index 958835bffce6d6a4cbd3f465328a2df9b0974d27..d0b5fcd25db808f1edc512afcc43dcec53593cf5 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java |
@@ -26,6 +26,7 @@ import org.chromium.base.Log; |
import org.chromium.base.VisibleForTesting; |
import org.chromium.chrome.R; |
import org.chromium.chrome.browser.ChromeActivity; |
+import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
import org.chromium.chrome.browser.util.IntentUtils; |
import org.chromium.chrome.browser.widget.TintedDrawable; |
@@ -44,6 +45,13 @@ public class CustomTabIntentDataProvider { |
*/ |
public static final String EXTRA_KEEP_ALIVE = "android.support.customtabs.extra.KEEP_ALIVE"; |
+ /** |
+ * Extra used by Chrome to tell the CustomTabActivity to finish itself. |
+ * Guarded explicitly for use only by PendingIntents with the Chrome package. |
+ */ |
+ public static final String EXTRA_FINISH_ACTIVITY_ON_ACTION = |
+ "org.chromium.chrome.browser.customtabs.FINISH_ACTIVITY_ON_ACTION"; |
+ |
private static final int MAX_CUSTOM_MENU_ITEMS = 5; |
private static final String ANIMATION_BUNDLE_PREFIX = |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? "android:activity." : "android:"; |
@@ -52,9 +60,12 @@ public class CustomTabIntentDataProvider { |
ANIMATION_BUNDLE_PREFIX + "animEnterRes"; |
private static final String BUNDLE_EXIT_ANIMATION_RESOURCE = |
ANIMATION_BUNDLE_PREFIX + "animExitRes"; |
+ |
private final IBinder mSession; |
private final Intent mKeepAliveServiceIntent; |
private final int mTitleVisibilityState; |
+ private final boolean mFinishActivityOnAction; |
+ |
private int mToolbarColor; |
private int mBottomBarColor; |
private boolean mEnableUrlBarHiding; |
@@ -74,6 +85,9 @@ public class CustomTabIntentDataProvider { |
public CustomTabIntentDataProvider(Intent intent, Context context) { |
if (intent == null) assert false; |
mSession = IntentUtils.safeGetBinderExtra(intent, CustomTabsIntent.EXTRA_SESSION); |
+ mFinishActivityOnAction = |
+ IntentUtils.safeGetBooleanExtra(intent, EXTRA_FINISH_ACTIVITY_ON_ACTION, false); |
+ |
retrieveCustomButtons(intent, context); |
retrieveToolbarColor(intent, context); |
retrieveBottomBarColor(intent); |
@@ -334,12 +348,20 @@ public class CustomTabIntentDataProvider { |
* @param context The context to use for sending the {@link PendingIntent}. |
* @param url The url to attach as additional data to the {@link PendingIntent}. |
*/ |
- public void sendButtonPendingIntentWithUrl(Context context, String url) { |
+ public void sendButtonPendingIntentWithUrl(Activity activity, String url) { |
Intent addedIntent = new Intent(); |
addedIntent.setData(Uri.parse(url)); |
try { |
- getCustomButtonOnToolbar().getPendingIntent().send(context, 0, addedIntent, mOnFinished, |
- null); |
+ getCustomButtonOnToolbar().getPendingIntent().send(activity, 0, addedIntent, |
+ mOnFinished, null); |
+ |
+ if (!TextUtils.isEmpty(ChromePreferenceManager.getHerbFlavor()) |
+ && mFinishActivityOnAction |
+ && TextUtils.equals(activity.getPackageName(), |
+ getCustomButtonOnToolbar().getPendingIntent().getCreatorPackage())) { |
Ian Wen
2016/02/09 20:30:49
Maybe we should move the package comparison to the
gone
2016/02/09 21:09:59
Are you sure about this? This means that any Inte
|
+ Log.e(TAG, "PendingIntent was created by Chrome. Finishing Activity."); |
+ activity.finish(); |
+ } |
} catch (CanceledException e) { |
Log.e(TAG, "CanceledException while sending pending intent in custom tab"); |
} |