Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java |
index 8c89984ececd97088056a9e5b540e06501a4c690..78077861cdff18986b2bcf1b6d2a1d264e486639 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java |
@@ -32,6 +32,7 @@ import org.chromium.base.metrics.RecordHistogram; |
import org.chromium.base.metrics.RecordUserAction; |
import org.chromium.chrome.R; |
import org.chromium.chrome.browser.ChromeActivity; |
+import org.chromium.chrome.browser.ChromeFeatureList; |
import org.chromium.chrome.browser.ChromeSwitches; |
import org.chromium.chrome.browser.ChromeTabbedActivity; |
import org.chromium.chrome.browser.IntentHandler; |
@@ -597,7 +598,7 @@ public class CustomTabActivity extends ChromeActivity { |
&& TextUtils.equals(getPackageName(), creatorPackage)) { |
RecordUserAction.record( |
"TaskManagement.OpenInChromeActionButtonClicked"); |
- if (openCurrentUrlInBrowser(false)) finishAndClose(); |
+ if (openCurrentUrlInBrowser(false, true)) finishAndClose(); |
} else { |
mIntentDataProvider.sendButtonPendingIntentWithUrl( |
getApplicationContext(), getActivityTab().getUrl()); |
@@ -658,9 +659,13 @@ public class CustomTabActivity extends ChromeActivity { |
&& !mIntentDataProvider.shouldShowBookmarkMenuItem()) { |
return true; |
} else if (id == R.id.open_in_browser_id) { |
- openCurrentUrlInBrowser(false); |
+ openCurrentUrlInBrowser(false, true); |
RecordUserAction.record("CustomTabsMenuOpenInChrome"); |
return true; |
+ } else if (id == R.id.read_it_later_id) { |
+ openCurrentUrlInBrowser(false, false); |
+ RecordUserAction.record("CustomTabsMenuReadItLater"); |
+ return true; |
} else if (id == R.id.find_in_page_id) { |
mFindToolbarManager.showToolbar(); |
if (getContextualSearchManager() != null) { |
@@ -713,10 +718,10 @@ public class CustomTabActivity extends ChromeActivity { |
/** |
* Opens the URL currently being displayed in the Custom Tab in the regular browser. |
* @param forceReparenting Whether tab reparenting should be forced for testing. |
- * |
+ * @param stayInChrome Whether the user stays in Chrome after the tab is reparented. |
* @return Whether or not the tab was sent over successfully. |
*/ |
- boolean openCurrentUrlInBrowser(boolean forceReparenting) { |
+ boolean openCurrentUrlInBrowser(boolean forceReparenting, boolean stayInChrome) { |
Tab tab = getActivityTab(); |
if (tab == null) return false; |
@@ -728,6 +733,10 @@ public class CustomTabActivity extends ChromeActivity { |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
intent.putExtra(ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, false); |
+ if (ChromeFeatureList.isEnabled("ReadItLaterInMenu")) { |
+ // In this trial both "open in chrome" and "read it later" should target Chrome. |
+ intent.setPackage(getPackageName()); |
+ } |
boolean willChromeHandleIntent = getIntentDataProvider().isOpenedByChrome(); |
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
@@ -750,7 +759,8 @@ public class CustomTabActivity extends ChromeActivity { |
}; |
mMainTab = null; |
- tab.detachAndStartReparenting(intent, startActivityOptions, finalizeCallback); |
+ tab.detachAndStartReparenting(intent, startActivityOptions, finalizeCallback, |
+ stayInChrome); |
} else { |
// Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860 |
StrictMode.allowThreadDiskReads(); |