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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java

Issue 1683533002: Herb: Show an icon allowing the user to open a tab in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ripping out back behavior yet again because people can't decide things Created 4 years, 10 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
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 ab1fe0c71f3d759022bf313cb774bf24f96f6e9b..daf091174cb28d63ff86c235225004d4455f563d 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
@@ -39,6 +39,7 @@ import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChangeReason;
import org.chromium.chrome.browser.compositor.layouts.LayoutManagerDocument;
import org.chromium.chrome.browser.datausage.DataUseTabUIManager;
+import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.rappor.RapporServiceBridge;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabIdManager;
@@ -66,6 +67,7 @@ import java.util.List;
*/
public class CustomTabActivity extends ChromeActivity {
private static final String TAG = "CustomTabActivity";
+
private static CustomTabContentHandler sActiveContentHandler;
private FindToolbarManager mFindToolbarManager;
@@ -172,7 +174,6 @@ public class CustomTabActivity extends ChromeActivity {
@Override
public void preInflationStartup() {
super.preInflationStartup();
-
mIntentDataProvider = new CustomTabIntentDataProvider(getIntent(), this);
supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
}
@@ -444,7 +445,7 @@ public class CustomTabActivity extends ChromeActivity {
* Configures the custom button on toolbar. Does nothing if invalid data is provided by clients.
*/
private void showCustomButtonOnToolbar() {
- CustomButtonParams params = mIntentDataProvider.getCustomButtonOnToolbar();
+ final CustomButtonParams params = mIntentDataProvider.getCustomButtonOnToolbar();
if (params == null) return;
getToolbarManager().setCustomActionButton(
params.getIcon(getResources()),
@@ -452,9 +453,17 @@ public class CustomTabActivity extends ChromeActivity {
new OnClickListener() {
@Override
public void onClick(View v) {
- mIntentDataProvider.sendButtonPendingIntentWithUrl(
- getApplicationContext(), getActivityTab().getUrl());
- RecordUserAction.record("CustomTabsCustomActionButtonClick");
+ String creatorPackage =
+ ApiCompatibilityUtils.getCreatorPackage(params.getPendingIntent());
+ if (mIntentDataProvider.finishAfterOpeningInBrowser()
+ && TextUtils.equals(getPackageName(), creatorPackage)) {
+ openCurrentUrlInBrowser();
+ finish();
+ } else {
+ mIntentDataProvider.sendButtonPendingIntentWithUrl(
+ getApplicationContext(), getActivityTab().getUrl());
+ RecordUserAction.record("CustomTabsCustomActionButtonClick");
+ }
}
});
}
@@ -561,22 +570,7 @@ public class CustomTabActivity extends ChromeActivity {
|| id == R.id.new_tab_menu_id || id == R.id.open_history_menu_id) {
return true;
} else if (id == R.id.open_in_browser_id) {
- String url = getTabModelSelector().getCurrentTab().getUrl();
- if (DomDistillerUrlUtils.isDistilledPage(url)) {
- url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
- }
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- // Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860
- StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
- StrictMode.allowThreadDiskWrites();
- try {
- startActivity(intent);
- } finally {
- StrictMode.setThreadPolicy(oldPolicy);
- }
-
+ openCurrentUrlInBrowser();
RecordUserAction.record("CustomTabsMenuOpenInChrome");
return true;
} else if (id == R.id.find_in_page_id) {
@@ -621,4 +615,26 @@ public class CustomTabActivity extends ChromeActivity {
CustomTabIntentDataProvider getIntentDataProvider() {
return mIntentDataProvider;
}
+
+ /**
+ * Opens the URL currently being displayed in the Custom Tab in the regular browser.
+ */
+ void openCurrentUrlInBrowser() {
+ String url = getTabModelSelector().getCurrentTab().getUrl();
+ if (DomDistillerUrlUtils.isDistilledPage(url)) {
+ url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
+ }
+ 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);
+
+ // Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ StrictMode.allowThreadDiskWrites();
+ try {
+ startActivity(intent);
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698